S
S
slupoke2018-04-18 22:52:09
C++ / C#
slupoke, 2018-04-18 22:52:09

How to convert string expression?

Given variables of type string

string y1 = "34*x^2+2*x+7";
string y2 = "x^17+1";
string y3 = "2*sin(13*x)";
string y4 = "ln(2x)"
//и т.д.

Question: How can I find the value of an expression at a point?
Is there a built-in function or a specific algorithm for such tasks?
A C# solution is desirable.
UPD: I need a general solution, for example, I string ycan enter any expression in it, and from it I want to get a value at a point.
Visually, it will look like this:

>Enter expression y = [*waiting for input expression]
>Enter x = [*input x]
>Value Expression at point X = [value expression at point]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
VoidVolker, 2018-04-18
@slupoke

I need a general solution
Enter expression y = [*waiting for input expression]
Enter x = [*input x]
Value Expression at point X = [value expression at point]

  1. Get Expression
  2. Check the correctness of the expression
  3. Get more information
  4. Check the correctness of the entered data
  5. Parse expression
  6. Parse input data
  7. Calculate the expression taking into account the previously entered data
  8. Show calculation result

G
Griboks, 2018-04-18
@Griboks

Is there a built-in function or a specific algorithm for such tasks?

Here is the most "deadly" solution to the problem: Only this is not a sharp. It's a little more difficult to do it on it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question