parsing of mathematical expressions

Posted by gcc on Stack Overflow See other posts from Stack Overflow or by gcc
Published on 2010-05-28T19:48:43Z Indexed on 2010/05/29 0:42 UTC
Read the original article Hit count: 187

Filed under:
|
|
|
|

(in c90) (linux)

input:

sqrt(2 - sin(3*A/B)^2.5) + 0.5*(C*~(D) + 3.11 +B)
a
b   /*there are values for a,b,c,d */
c
d

input:

cos(2 - asin(3*A/B)^2.5) +cos(0.5*(C*~(D)) + 3.11 +B)
a
b   /*there are values for a,b,c,d */
c
d

input:

sqrt(2 - sin(3*A/B)^2.5)/(0.5*(C*~(D)) + sin(3.11) +ln(B))
 /*max lenght of formula is 250 characters*/
a
b   /*there are values for a,b,c,d */
c   /*each variable with set of floating numbers*/
d

As you can see infix formula in the input depends on user. My program will take a formula and n-tuples value. Then it calculate the results for each value of a,b,c and d. If you wonder I am saying ;outcome of program is graph. /sometimes,I think i will take input and store in string. then another idea is arise " I should store formula in the struct" but i don't know how I can construct the code on the base of structure./

really, I don't know way how to store the formula in program code so that I can do my job. can you show me?

/* a,b,c,d is letters
 cos,sin,sqrt,ln is function*/

© Stack Overflow or respective owner

Related posts about c

    Related posts about algorithm