0

I have one physical-formular set in my application and want to calculate a parameter.

Theorie:

548.1 = 27 * π / x + 73 - 2622.0 (demonstration example)

now I want to become the x value with a solve like so;

Solve(expr,vars) -> https://reference.wolfram.com/language/ref/Solve.html

The Wolfram API needs an internet connection, so nothing for me.

Is there any simple functionality to adjust the formula to get out the parameter to one side like; https://quickmath.com/#c=solve_algstepsequationsolve&v239=25%253D%25281%2F5%2529%255E%25282-x%2529&v240=x

and calculated it afterwards?

tuke307
  • 411
  • 5
  • 13
  • 2
    You can make great money if you solve that. – Jeroen van Langen Jan 15 '20 at 07:42
  • is this... a programming question? also, some formulae are irreducible; but in the general case: build a dual AST (left and right) and shuffle it, performing the same operations on both sides; not trivial, and not always possible; but not impossible to hack at for most simple cases, either – Marc Gravell Jan 15 '20 at 07:42
  • Could mXParser help? http://mathparser.org/mxparser-tutorial/solving-equation-fx-0/ – jason.kaisersmith Jan 15 '20 at 07:45
  • alternatively; use numerical estimation methods to solve the method by iteratively improving the value; many such methods exist – Marc Gravell Jan 15 '20 at 07:45
  • I tried mxparser already, but the solve function isnt what i want. The syntax there is: `solve(exp,a,b)` I need to set the a and b values and everytime i change these values, the results changes too. So nothing for me :( – tuke307 Jan 15 '20 at 07:47
  • 1
    I think I'd [math-parse](https://www.codeproject.com/articles/88435/simple-guide-to-mathematical-expression-parsing) left and right side of the equation and try to isolate the node with `x` value – Rafalon Jan 15 '20 at 07:53
  • @Rafalon Do you know any adjustment functionality to isolate the unknown parameter "x"? – tuke307 Jan 15 '20 at 07:56
  • You'd have to revert the furthest nodes to the other side of the equation (if it's a + then you convert to a - for example). Of course you have to set the rules right, and not forget edge cases (when you have `something / x` add `1 / ...` - for example) – Rafalon Jan 15 '20 at 08:24
  • But do you need to solve arbitrary equations? If you have a limited set of equations, just solve them outside of your application and then implement the solution. – Lasse V. Karlsen Jan 15 '20 at 11:42
  • @LasseV.Karlsen I have over 20 physical-formulars and dont want to solve every formular to their parameters. At the end i have over 200 formulars... so this solve fucntionality would be veerrrrrry nice. But everytime i know all parameters except one – tuke307 Jan 15 '20 at 11:55
  • How are the equations coming into your application? As strings? Or as are they code? – Lasse V. Karlsen Jan 15 '20 at 12:39
  • there are now coded like: `double result = p1 / p2 * p3...` the p1,p2,p3.. are handover parameters – tuke307 Jan 15 '20 at 12:58

1 Answers1

0

C# is a programming language. Root finding is a specific operation. There is not a built-in method for finding roots in a given equation in C#. You should either implement yourself or use third party libraries.

isidat
  • 936
  • 10
  • 18