newRPL - build 1255 released! [updated to 1299]
08-09-2018, 03:47 PM
Post: #254
 Claudio L. Senior Member Posts: 1,880 Joined: Dec 2013
RE: newRPL - build 1089 released! [update:build 1089]
All unofficial ROMs updated to 1099.

The main change is the addition of the multiple non-linear equation solver (command MSOLVE).

It works like this:
Arguments:
* List with equations in the stack (any number of equations, at least one of course)
* List with variable names (the variables that will be used as variables in the search)
* Initial guess range: List with minimum values for each of the names
* Initial guess range: List with maximum values for each of the names
* A real number with the desired tolerance

The main difference with ROOT is that equations don't need to be in the form 'F(X)=expression'. Since this is a more general solver, expressions can be of any type, mainly:
'expression' which will be interpreted as 'expression=0' when searching for roots
'expression<expression' All kinds of inequalities accepted (>, <, <=, >=)

The list of variable names can have any number of variables. Any other variables in the equations need to be defined elsewhere (as globals or locals) and will remain constant during the analysis.

The initial guess is a range of values where the algorithm will begin the search. This is not a bracketed method, so it may converge to roots outside this range, this is only an initial guess.
The range of variables can be constrained by adding inequalities like 'X>-5' to the list of equations.

Finally, the tolerance is up to your own patience. Always start with 2 or 3 digits (0.001), and if it finds a root, then run it again with tighter tolerance.

The solver uses an optimization method, so it actually minimizes the sum of the squares of the equations (*). This means it may find local minimums instead of actual roots.
Also, the method only works properly with real numbers, so don't even try it in the complex plane. Make sure all equations return real values. Division by zero or any kind of infinity needs flag -22 to be set so your equations don't error but return +/-Inf, which the solver can handle, no problem.
Also, the solver is derivative-free, so functions don't need to be continuous.

To distinguish between them, MSOLVE returns:
* A list of values for each of the variables in the list
* A list of the value of each equation after replacing the solution found, so the user can see whether the equations are satisfied by this solution or not.

(*) For inequalities, when an inequality is True, it adds no value to the sum. When it is false, it turns the result of the sum into +Inf, making it the worst choice of solution, hence the algorithm will turn away from areas that don't satisfy inequalities. In other words, regular equations are "minimized", while inequalities are "enforced".

This needs HEAVY testing. Please help test it thoroughly and report any anomalies (like looping forever, crashing, etc.).
 « Next Oldest | Next Newest »