Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. passing a math function as input of a program

passing a math function as input of a program

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    marouane miftah el kheir
    wrote on last edited by
    #1

    Hi i'm trying to write a program that compute integrals of functions of single variable f(x), the program will ask the user to enter the function for which he needs te compute the integral. my question is : once the user enter the function formula (for exemple: f(x)=log(x)+cos(1/x)), how can pass this formula to the program. thanks

    C L 2 Replies Last reply
    0
    • M marouane miftah el kheir

      Hi i'm trying to write a program that compute integrals of functions of single variable f(x), the program will ask the user to enter the function for which he needs te compute the integral. my question is : once the user enter the function formula (for exemple: f(x)=log(x)+cos(1/x)), how can pass this formula to the program. thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You can only pass that as a string, you'll obviously need to parse it from there. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff.

      M 1 Reply Last reply
      0
      • C Christian Graus

        You can only pass that as a string, you'll obviously need to parse it from there. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff.

        M Offline
        M Offline
        marouane miftah el kheir
        wrote on last edited by
        #3

        do you have an idea on how to parse it from string to math function. thanks

        C 1 Reply Last reply
        0
        • M marouane miftah el kheir

          do you have an idea on how to parse it from string to math function. thanks

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          You're going to have to search the string for brackets, work out the order of operations, and then check for maths functions, and call them. The problem is quite simply that you're going to have to write code for each math function you want to support. Basically, it's not a pretty job. You may be able to do it easier by writing a macro. Christian I have come to clean zee pooollll. - Michael Martin Dec 30, 2001 Picture the daffodil. And while you do that, I'll be over here going through your stuff.

          1 Reply Last reply
          0
          • M marouane miftah el kheir

            Hi i'm trying to write a program that compute integrals of functions of single variable f(x), the program will ask the user to enter the function for which he needs te compute the integral. my question is : once the user enter the function formula (for exemple: f(x)=log(x)+cos(1/x)), how can pass this formula to the program. thanks

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Check out This parser not only answers your question but it also solves the ugly work for you...

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups