1

I would like to know how to procedure to parse an equation like:

y = e^x+sin(x)+cos(x)-x^2

My prodcedure would be as follows: Make two arrays of same length and fill the first array which stores the xValues from like -10 to 10. Then insert these values in the the above equation and create thereby an array of yValues. Next I would plot the x over the yValues of the two arrays.

My question now is how can I parse the above Input ( e^x+sin(x)+cos(x)-x^2) step by Step to calculate the yValues.

Does anyone of you know if there is a d3 or javascript library for things like that? I mean is the only way to extract the above Input in e, sin, x, etc. parameters and then formulate a Equation in javascript like: Math.exp(x)+Math.sin(x)+Math.cos(x)-Math.pow(2,x)

I would like to parse such an arugment with javascript.

sqp_125
  • 538
  • 6
  • 21
  • It is probably a duplicate of [this](http://stackoverflow.com/questions/1052470/javascript-parser-for-simple-expression) question. – Aᴍɪʀ Nov 25 '16 at 20:29

0 Answers0