Post Reply 
Re-entrant SOLVE and INTEG
12-15-2021, 06:39 PM
Post: #1
Re-entrant SOLVE and INTEG
I'm working on re-entrant versions of SOLVE and INTEG for Plus42. Initial tests on RINTEG look OK, but I don't really have any good test cases for RSOLVE. Could someone help me out with an example or two, that you'd actually want to use solve-within-solve for?
Visit this user's website Find all posts by this user
Quote this message in a reply
12-16-2021, 07:14 AM (This post was last modified: 12-18-2021 04:42 AM by Paul Dale.)
Post: #2
RE: Re-entrant SOLVE and INTEG
Any two dimensional problem would benefit from nested solve.

For the sake of argument: solve ?(x) = sin(y), where y <> x.


Pauli
Find all posts by this user
Quote this message in a reply
12-17-2021, 11:01 PM
Post: #3
RE: Re-entrant SOLVE and INTEG
I don't see it. With f(x, y) = 0, you typically have a set of zeroes. You pick an x and solve for y, or vice versa. If there's a unique (x, y) for which f = 0, a univariate solver isn't going to find it, even if you can run two instances at the same time...
Visit this user's website Find all posts by this user
Quote this message in a reply
12-18-2021, 12:16 AM (This post was last modified: 12-18-2021 12:39 AM by Albert Chan.)
Post: #4
RE: Re-entrant SOLVE and INTEG
(12-17-2021 11:01 PM)Thomas Okken Wrote:  I don't see it. With f(x, y) = 0, you typically have a set of zeroes. You pick an x and solve for y, or vice versa. If there's a unique (x, y) for which f = 0, a univariate solver isn't going to find it, even if you can run two instances at the same time...

With 2 guess x1, x2, we solved for y, minimizing |f(x,y)|

Now, we have 2 points, (x1, f1), (x2, f2).
Get the root of the secant line, we have (x3, f3)

Rinse, and repeat.
Hopefully, final |f(x,y)| converged close to 0.0

---

Example, HP17B code, to predict Matt's Catenoid soap bubble radius.
(A = radius, B=half height, both with unit of meter)

10 R1=.508 @ R2=.56 @ L=.5 @ B0=L/2 @ B=B0
20 DEF FNF(A,B)=ABS((A*COSH(B/A)-R1,A*COSH((L-B)/A)-R2))
30 DEF FNB(A)
40 B=FNROOT(B0,B,FNF(A,FVAR))
50 B0=FGUESS @ FNB=FVALUE @ DISP A,B,FVALUE
60 END DEF
70 A=FNROOT(R1,R2,FNB(FVAR))
80 DISP A,B,"FINAL"

>RUN
Code:
 .508           .211662534193   5.50327323373E-2
 .56            .218220987486   .119490920995
 .463603746535  .204546580254   1.76185927841E-3
 .46213540283   .204287302616   3.38495601751E-5
 .462106639804  .204282215772   2.38285383522E-8
 .462106619542  .204282212316   2.82842712475E-12
 .46210661954   .204282212312   .000000000001
 .462106619539  .204282212312   2.2360679775E-12
 .462106619541  .204282212311   .000000000001
 .462106619542  .20428221231    3.60555127546E-12
 .462106619541  .20428221231    FINAL
Find all posts by this user
Quote this message in a reply
12-19-2021, 05:25 PM
Post: #5
RE: Re-entrant SOLVE and INTEG
That's not finding a root of a function defined using a root; that's finding a minimum of a function defined using a minimum.

The Free42 solver wasn't really designed for finding minima. It will report them if it gets stuck on them, but there's no guarantee of finding minima like there is of finding zeroes, given good starting guesses.
Visit this user's website Find all posts by this user
Quote this message in a reply
12-19-2021, 06:57 PM
Post: #6
RE: Re-entrant SOLVE and INTEG
Hi, Thomas Okken

Is this what you are looking for ?




This is code for getting jacobian matrix numerically.
https://github.com/fredrik-johansson/mpm...on.py#L579
Find all posts by this user
Quote this message in a reply
12-20-2021, 01:10 PM (This post was last modified: 12-20-2021 07:19 PM by Albert Chan.)
Post: #7
RE: Re-entrant SOLVE and INTEG
(12-19-2021 05:25 PM)Thomas Okken Wrote:  That's not finding a root of a function defined using a root; that's finding a minimum of a function defined using a minimum.

If we can ensure "inner" solver always find a root, we can avoid minimum search.
With R2 ≥ R1 ≥ A, and COSH(X) ≥ 1, FNB(A) always find a root.

10 R1=.508 @ R2=.56 @ L=.5 @ B=0
20 DEF FNB(A) @ B=FNROOT(B,L,COSH((L-FVAR)/A)-R2/A) @ FNB=B
30 DISP A,B,FVALUE @ END DEF
40 A=FNROOT(R1,R2,COSH(FNB(FVAR)/FVAR)-R1/FVAR)
50 DISP A,B,FVALUE

>RUN
Code:
 .508                 .272064726623        0
 .56                  .5                   0
 .48745686541         .237253771483        0
 .463767426087        .206176310534        0
 .462131139668        .204309934281        0
 .462106627543        .204282221362        0
 .462106619541        .204282212316        0
 .462106619541        .204282212316        0
Find all posts by this user
Quote this message in a reply
Post Reply 




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