parsing - Parsed symbolic differentiation in C++ -


I found these two libraries: - Mupers - Symbolic C ++

Before doing a skilled parsing Enabled mathematical expression, so that by wrapping the minimum I can create a parser object so that

  parser my_parar ("1/2 * x ^ 2"); The court's & lt; & Lt; Myparser (2) & lt; & Lt; Endl;  

The result will be printed 2.0. It's amazing, but it works only with doubles, okay?

The second one implements the symbolic object so that I can do something like this:

  Symbolic x ("X"); Symbolic x2 = x ^ 2; Cout & lt; & Lt; Df (x2, x) & lt; & Lt; Endl; Results in  

2.0 * x. So it is able to differentiate the expressions, which is fine.

What I have to do, is a mixture of two! I need a function and it can be isolated, so that I can do something like this:

  cout & lt; & Lt; Df ("1/2 * x ^ 2", "x") & lt; & Lt; Endl;  

And I would also like to print it 2.0 * x

Is it possible to do something like this? In principle, if a mugassar working on any object can work, then I can just run an expression on signal objects, and then separate them. But I could not do anything like this work.

So is there any other alternative solution? I have something that takes an input string with an expression and returns the output string with the derivative of that expression.

Thank you!

This is not an full answer, as they say. However, to be able to use symbolic ++ you need program-level access ..., you can not actually write and compile

 < Code> symbolic x ("x"); Symbolic x2 = x ^ 2;  

but you need something on the order of (but waaaayay )

  if (there_is_x_symbol) {expr = Symbolic x ("x"); } If (raise_to_the_2nd_power) {expr = expr ^ 2; }  

To do this in an organic way you need a parser and a parser which will not export only evaluation () Method, but something that will allow you to reach the expression tree, for example

  (multiplied) / \ (2) (square) \ (x)  

You can evaluate the recursion by:

left = my avatetate (node ​​left) right = my avatite (node. Right) if (node.p == properties A) {left right * right; } If (node.op == class) {right ^ 2; ... ...

Happy (and mooperax) libraries do not seem to allow this.

There are many other algebraic parsers, for example it seems promising that you can use the supplier parser algorithm, and you can write an evaluator of your own, which uses symbolic ++ and A signal produces ++ expressions.

You do not need the deep knowledge of grammar to hack on such motors - most just generate a stack, and all you really need to know.

In Bocca Al Loopo : -)


Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -