Post Reply 
newRPL - build 1255 released! [updated to 1299]
08-09-2018, 07:34 PM (This post was last modified: 08-09-2018 07:36 PM by Claudio L..)
Post: #256
RE: newRPL - build 1089 released! [update:build 1099]
(08-09-2018 03:57 PM)rprosperi Wrote:  Claudio - Suggest you provide 2 examples, one trivial and one non-trivial, to illustrate the exact syntax of the arguments; this avoids time wasted figuring out what your explanations do/don't mean. I'm not suggesting the wording is poor, simply that for such use, interpretation can vary. For example is the list with variable names like { A B C } or {'A' 'B' 'C'}, etc.

Fair enough. Here's the trivial one: get the roots of x^2=4

Code:

{ 'X^2=4' }  @ List of equations
{ 'X' } @ List of variables (quoted/unquoted doesn't matter)
{ 1 } @ Initial guess range: left point
{ 10 } @ Initial guess range: right point (can be anything as long as all variables are different from the left point)
0.0001 @ TOLERANCE

MSOLVE

It will return:
Code:

{ -2.000022888184 } @ List of values for each of the variables
{ 0.000091553258. } @ List of residuals for each expression (same as storing the result and ->NUM on the equations)

In this case it converged to the negative. If we want the positive there's 2 options:
a) Try a different initial guess range, for example { 0 } { 1 } does the trick.
b) Coerce the system with a constraint: change the list of equations to:
Code:
{ 'X^2=4' 'X>0' }
And sure enough, you'll get the positive root.

A less trivial example:

To test the Beale function from here:

Code:

{ '1.5-X+X*Y' '2.25-X+X*Y^2' '2.625-X+X*Y^3' } @ We input them as 3 separate expressions
{ 'X' 'Y' }    @ 2 Variables
{ -4.5 -4.5 }  @ Same range as in Wikipedia
{ 4.5 4.5 }    @ Same range as in Wikipedia
0.0001    @ Tolerance

The results are this:
Code:

{ -317914.438741247053. 1.000003117366. } @Values
{ 0.508944245104. 0.267885400724. -0.348176533149. } @ Residues
And from the residues we can see the algorithm didn't find a root, the value of X diverged to the negative side while Y converged to 1. Not what we expected, let's try inverting the range:

Code:

{ '1.5-X+X*Y' '2.25-X+X*Y^2' '2.625-X+X*Y^3' } @ We input them as 3 separate expressions
{ 'X' 'Y' }    @ 2 Variables
{ 4.5 4.5 }  @ Same range as in Wikipedia
{ -4.5 -4.5 }    @ Same range as in Wikipedia
0.0001    @ Tolerance

And now we get:
Code:

{ 2.99999918766. 0.50000000274. }
{ 0.000000414389. 0.000000617475. 0.000000716962. }

And now the algorithm went the other way (towards the positive side of X), converging to the proper root.

EDIT: By the way, you could also force a constraint by adding 'X>-4.5' to the list of equations.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL - build 1001 released! - pier4r - 12-16-2017, 08:03 AM
newRPL - on Hp 39gs - Martin Hepperle - 06-05-2019, 06:51 AM
RE: newRPL - build 1001 released! - pier4r - 12-23-2017, 10:16 AM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 09:42 AM
t - Claudio L. - 01-01-2018, 03:06 PM
RE: newRPL - build 1001 released! - pier4r - 01-01-2018, 03:41 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 04:54 PM
RE: newRPL - build 1001 released! - pier4r - 01-02-2018, 06:58 PM
RE: newRPL - build 1089 released! [update:build 1099] - Claudio L. - 08-09-2018 07:34 PM
newRPL - brickviking - 10-05-2018, 06:01 AM
How to participate? - erazor - 12-13-2019, 07:12 AM



User(s) browsing this thread: 28 Guest(s)