0

I want to input this string:

"pow(y,2) = 4 - pow(x,2)" (in other words, y^2=4-x^2)

and make "x" = 1, then have it evaluate and give me the value of y. How do I do this?

1 Answers1

1

So you want to solve the equation for y given a number x? That means that 'y' is a function of x, so:

var y = new Expression("sqrt(4 - pow(x, 2))"); // y = SQRT(4 - X^2)
e.Parameters["x"] = 1;

var x = y.Evaluate();

Wouldn't that solve your problem? (other than that the square root of anything is always plus/minus something, so you'd hav to add that logic)

Pedro G. Dias
  • 3,162
  • 1
  • 18
  • 30