Can you calculate Pi using a Solver (on the prime)?

12172019, 08:08 AM
(This post was last modified: 12172019 09:25 AM by Stevetuc.)
Post: #1




Can you calculate Pi using a Solver (on the prime)?
In this thread post #26
https://www.hpmuseum.org/forum/thread14...#pid125210 Valentin gives a recursive method to solve for Pi using fnroot solver. Valentin Albillo ' Wrote: [...]For instance, if your Solver admits nesting and can use the Gamma function, then this will do:Code for the HP71B, where FNROOT (Find Root) is the "official" HP71B's "Solver": Tried this on the prime but it appears that the solver doesnt support recursion Code: EXPORT FVAR:=0; And then at Home screen: Code: FNROOT(FNF(√(FVAR))(1/2),FVAR,3,4) produces the error Error: Bad Guess(es) I also tried defining FNF as a user function using Define key, changing and omitting initial guesses, but same error. ROOT instead of FNROOT gives Error:No solution found. 

12172019, 03:54 PM
Post: #2




RE: Can you calculate Pi using a Solver (on the prime)?
.
Hi, Stevetuc: (12172019 08:08 AM)Stevetuc Wrote: Valentin gives a recursive method to solve for Pi using fnroot solver. Just a terminology issue: it's not recursion, as you say, it's nesting. The Solver (FNROOT) instance isn't calling itself (recursion), it's the function being solved the one who's calling another instance of the solver applied to a different equation (nesting). Think of integration. A double or triple integral isn't recursive integration, it's just nested integration. Regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection 

12172019, 04:16 PM
Post: #3




RE: Can you calculate Pi using a Solver (on the prime)?
(12172019 03:54 PM)Valentin Albillo Wrote: . Thanks for the interesting clarification! 

12182019, 03:02 AM
(This post was last modified: 12182019 03:11 AM by Valentin Albillo.)
Post: #4




RE: Can you calculate Pi using a Solver (on the prime)?
(12172019 04:16 PM)Stevetuc Wrote: Thanks for the interesting clarification You're welcome. Getting a Solver to be nestable isn't easy, that's why many aren't. If you're interested to know how the HP71B's FNROOT does it, have a look at this enlightening explanation in the HP Journal July 1984 issue, beginning at page 30 (nesting is explained at page 32; up to 4 additional levels of nesting are possible, for a total of 5 levels, which allows for solving systems of up to 5 nonlinear equations.) Regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection 

12182019, 05:51 AM
(This post was last modified: 12182019 06:10 AM by Stevetuc.)
Post: #5




RE: Can you calculate Pi using a Solver (on the prime)?
(12182019 03:02 AM)Valentin Albillo Wrote:(12172019 04:16 PM)Stevetuc Wrote: Thanks for the interesting clarification Very informative article, thanks. I'm wondering if some of this functionality might be achieved on the prime by sending the arguments unevaluated using Quote() would this allow nesting? (I tried..unsuccessfully). I'm sure there are many subtleties! The issue on the HP71B was that stack passing could not be used so the arguments needed to be passed unevaluated to the function. Also passing and keeping track of FVAR. Much of this is native to the prime. Maybe Cyrille or Tim could answer  was nesting FNROOT a design consideration on the prime ? 

12182019, 01:24 PM
Post: #6




RE: Can you calculate Pi using a Solver (on the prime)?
This shows (on XCas) that FNROOT can not be nested
XCas>FNF(v):={local FVAR; purge(FVAR); print(v); FNROOT(Gamma(FVAR)=v,FVAR=0..1)[0]} XCas>m := makelist(FNF, 1.75, 1.8, 0.01) v:1.75 v:1.76 v:1.77 v:1.78 v:1.79 v:1.8 → [0.506546500849,0.503607372216,0.500706197505,0.497842178366,0.495014540318,0.492222531811] XCas>map(m, Gamma) // confirm FNF = Gamma^{1}, at least for domain [1.75,1.8] → [1.75,1.76,1.77,1.78,1.79,1.8] XCas>FNROOT(FNF(sqrt(x))=0.5, x=3) // unable to get value of sqrt(x) into FNF v:sqrt(x) "Error: Invalid dimension" 

« Next Oldest  Next Newest »

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