I am trying to implement an infrastructure in C # that would allow me to create arbitrary mathematical expressions. For example, I want to have an expression, for example
asin (sqrt (z - sin (x + y) ^ 2))
and turn it into an object that will allow me to evaluate it in terms of x, y and z, get derivatives and, possibly, make some kind of symbolic algebra on it. What do people think of a good model for this in C #?
I have my own take, which, I'm afraid, is being directed to the architecture of astronautics, so I want to make sure that this is not so.
Basically, functions like sin, +, sqrt, etc., have classes based on the base class:
Function
Function<TOut> : Function
TOut Value
Function<Tin, TOut> : Function
TOut Evaluate(TIn value)
Function Derivative
Function<TOut, TIn> INverse
Function<TInA, TInB, TOut> : Function
TOut Evaluate(TInA valueA, TInB valueB)
Function PartialDerivativeA
Function PartialDerivativeB
. , . , - currying, , . , factory :
Function<TInA, TInB, TOut> ->
Function<TInA, Function<TInB, TOut>>
(Function<TInA, TInB, TOut>, Function<TInX, TInA>, null) ->
Function<TInX, Function<TInB, TOut>>
(Function<TInA, TInB, TOut>, Function<TInA>, Function<TInX, TInY, TInB>) ->
Function<TInX, Function<TInY, TInB>>
.. , ( , ), , , .
!