Post Reply 
Can you calculate Pi using a Solver?
12-12-2019, 05:49 PM
Post: #21
RE: Can you calculate Pi using a Solver?
.
Hi again, EdS2:

(12-12-2019 03:02 PM)EdS2 Wrote:  Merely evaluating an expression doesn't feel like it's making proper use of a solver.)

Frankly, I don't understand why you're so fixed in solving something (as in finding the root of some equation, say) and think evaluating expressions isn't "proper use of a solver".

Matter of fact, what distinguishes the best solvers is their capability to do much more than finding roots, and being in fact able to essentially do some kind of programming with them increases their power and usefulness an order of magnitude. That is making proper use of a solver, the same way that doing synthetic programming was a proper use of RPN in the HP-41C.

Anyway, I'll indulge you. You want to use the Solver to compute a 10 or 12 digit approximation to Pi by "using the Solver to Solve Some Equation" ? Try this one:

Find the root between 3 and 4 of:      e\(^{\frac{x\sqrt{163}}{3}}\) - 640320 = 0.

If the Solver works as it should it will find the root:

      x = 3.141592653589793... which agrees with Pi to all 16 digits shown.

Regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
12-12-2019, 06:03 PM (This post was last modified: 12-12-2019 06:05 PM by EdS2.)
Post: #22
RE: Can you calculate Pi using a Solver?
That's a very nice one, thanks Valentin!
Find all posts by this user
Quote this message in a reply
12-12-2019, 09:40 PM
Post: #23
RE: Can you calculate Pi using a Solver?
Excerpt from Π Unleashed, Springer, ISBN 3-540-66572-2, © 2000

Chapter 16
[attachment=7920]

154 algorithms.

BEST!
SlideRule
Find all posts by this user
Quote this message in a reply
12-12-2019, 10:07 PM (This post was last modified: 12-12-2019 10:12 PM by EdS2.)
Post: #24
RE: Can you calculate Pi using a Solver?
Here's a nice one by Ramanujan:
22x^4-2143=0
x≈3.14159265258...

and another from the same page
x^4+x^5-e^6=0
x≈3.14159268...

(Although it has to be said, the answers here are not pi but something rather close to pi. And so, not exactly what I was hoping for.)
Find all posts by this user
Quote this message in a reply
12-13-2019, 06:35 PM (This post was last modified: 12-13-2019 06:35 PM by EdS2.)
Post: #25
RE: Can you calculate Pi using a Solver?
(12-12-2019 05:49 PM)Valentin Albillo Wrote:  
(12-12-2019 03:02 PM)EdS2 Wrote:  Merely evaluating an expression doesn't feel like it's making proper use of a solver.)
Frankly, I don't understand why you're so fixed in solving something (as in finding the root of some equation, say) and think evaluating expressions isn't "proper use of a solver".

It's a good question, and I haven't managed to be clear, for which I apologise. I wonder if I can do better...

For me, this challenge, like many, is about constrained programming of a kind. If I had a programmable calculator, I might want a challenge which was to write a program. If it was not programmable, but had an Integrate command, I might want an interesting challenge which involved integration. But if it was programmable, I might still be interested in a challenge to use the Integrate command in an interesting way. Or indeed, I might be interested in a challenge to write a program for numerical integration, which doesn't use the Integrate command.

So it is with this challenge. I'm thinking of a solver as a complex feature which finds roots to an equation - preferably not an easy equation like x^2-3=0 or 1/x-4=0 but an equation which we couldn't readily solve ourselves, like x^4+x^5-e^6=0. But I want the root found to be pi, not a specific number that's close to pi but not equal to pi. And I think, as yet, I haven't seen such an equation - maybe there isn't one.

(Of course, an equation like sin(x)=0 could suffice, but it's trivial, which is why I wanted to avoid use of trig functions.)

It's always interesting to see various ways to compute pi: sums, products, nested surds, iterative algorithms, even spigots. And this, I'd hoped, is another possible way.

Hope this makes things a bit clearer. (And I'm still glad to see all the various contributions and references!)
Find all posts by this user
Quote this message in a reply
12-13-2019, 11:30 PM
Post: #26
RE: Can you calculate Pi using a Solver?
.
G'night, EdS2 (Dec 14th 0:30 am here):

(12-13-2019 06:35 PM)EdS2 Wrote:  It's a good question, and I haven't managed to be clear, for which I apologise. I wonder if I can do better...

Thanks but no need to apologize, it's just that I think that if a Solver somehow manages to return an answer to some problem, it doesn't matter if it does it finding a root of some equation or adding up terms of a series or anything, it's still "solving" the problem.

Remember, it isn't called a "root finder" but a "solver".

Quote:But I want the root found to be pi, not a specific number that's close to pi but not equal to pi. And I think, as yet, I haven't seen such an equation - maybe there isn't one.

Unless the Solver can work with complex numbers I don't think there's such an equation using just real numbers and no trigs. Equations whose roots are arbitrarily accurate approximations to Pi (say 34 digits) can be produced but ones returning exactly Pi (in theory, limited to 10-12 digits in practice) is a no-go IMHO.

Quote:It's always interesting to see various ways to compute pi: sums, products, nested surds, iterative algorithms, even spigots.

The comprehensive list given in a previous post doesn't include Monte-Carlo methods to compute Pi if I'm not mistaken (cursory read), and there are some really pretty, though very slow-converging (typically like the square root, i.e.: 100 tries give 2 digits, 10,000 tries give 4, a million tries give 6, and so on.)

As for "spigots", have a look at this 6-line program o'mine for an HP calc which produces an arbitrary number of digits of Pi one at a time using a spigot algorithm. The sample run in the PDF document produces 1,000 digits.

Producing Digits of Pi one at a time

Thanks for your comments and have a nice weekend.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
12-14-2019, 12:34 AM
Post: #27
RE: Can you calculate Pi using a Solver?
(12-13-2019 11:30 PM)Valentin Albillo Wrote:  The comprehensive list given in a previous post doesn't include Monte-Carlo methods to compute Pi if I'm not mistaken (cursory read), and there are some really pretty, though very slow-converging (typically like the square root, i.e.: 100 tries give 2 digits, 10,000 tries give 4, a million tries give 6, and so on.)

Π Unleashed, Springer, © 2000, ISBN 3-540-66572-2, page 39

3.4 Π and chance (Monte Carlo methods)

The needle problem of the Comte de Buffon

During the American Civil War, Captain C.0. Fox was recovering from
a wound in a military hospital. To pass the time, he threw a number
of identical needles in random fashion onto a board on which he had
previously drawn a series of parallel lines each a needle's length apart.
He counted the number of throws and the number of hits, i.e. instances
in which a needle touched or intersected a line.
After 1100 throws, the Captain had determined Π to two decimal
places. How come?
First of all it seems to have been the Comte de Buffon (1707-1788),
who examined this kind of experiment and in whose honour it is now
known as the Buffon needle problem. In 1777, Buffon showed that the
ratio of hits to throws was 2:Π, or, stated otherwise, that the probability
of a needle thrown at random onto the area coming to rest across one
of the lines was, ²/Π ≈ 63.7%. With this knowledge, Fox was able to
calculate Π by doubling the number of throws and dividing by the
number of hits.
The interesting thing about the needle problem is that it forges a
link between the "geometric" Π and the quite different area of probabilities.
There are other similar relationships between Π and chance,
from which other methods of calculating Π are derived. They are informatively
called Monte Carlo methods.

emphasis mine

BEST!
SlideRule
Find all posts by this user
Quote this message in a reply
12-14-2019, 12:56 AM
Post: #28
RE: Can you calculate Pi using a Solver?
.
Self-quoting a little:

(12-13-2019 11:30 PM)Valentin Albillo Wrote:  Unless the Solver can work with complex numbers I don't think there's such an equation using just real numbers and no trigs. Equations whose roots are arbitrarily accurate approximations to Pi (say 34 digits) can be produced but ones returning exactly Pi (in theory, limited to 10-12 digits in practice) is a no-go IMHO.

Well, to make myself clearer, the previous quotation refers to polynomials or rational functions, which indeed can't produce Pi as an exact root because Pi is transcendental.

But if we involve other functions but polynomials, rational functions and trigs, there are many ways to concoct an equation whose root is exactly Pi. For instance, if your Solver admits nesting and can use the Gamma function, then this will do:

Code for the HP-71B, where FNROOT (Find Root) is the "official" HP-71B's "Solver":

     1   DEF FNF(X) = FNROOT(1, 1, GAMMA(FVAR) - X)
     2   DISP FNROOT(3, 4, FNF(SQR(FVAR)) - 1/2)

>RUN

          3.14159265359

This produces as a root the theoretically exact (not an approximation) value of Pi.

V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
12-14-2019, 10:51 AM
Post: #29
RE: Can you calculate Pi using a Solver?
(I'm sometimes surprised that I don't already own Pi Unleashed and indeed Pi a source book. Oh, and I see a reviewer mentions Beckman's A History of Pi and Blatner's The Joy of Pi)

Yes, the Gamma function is a nice way in!

I had hopes that Euler's equation would serve - if we could take the magnitude, or the real value, of e^(ix)+1, then we have a (complex) function which takes a real to a real, and the job would be done. But the HP-35s lacks the capability. Can the 15c manage it??
Find all posts by this user
Quote this message in a reply
12-14-2019, 09:03 PM
Post: #30
RE: Can you calculate Pi using a Solver?
(12-14-2019 10:51 AM)EdS2 Wrote:  I had hopes that Euler's equation would serve - if we could take the magnitude, or the real value, of e^(ix)+1, then we have a (complex) function which takes a real to a real, and the job would be done. But the HP-35s lacks the capability. Can the 15c manage it??

You're kidding, right ? Wink

... and two question marks, no less ...

Regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
12-15-2019, 10:39 AM
Post: #31
RE: Can you calculate Pi using a Solver?
(12-14-2019 10:51 AM)EdS2 Wrote:  I had hopes that Euler's equation would serve - if we could take the magnitude, or the real value, of e^(ix)+1, then we have a (complex) function which takes a real to a real, and the job would be done. But the HP-35s lacks the capability.

Following your suggestion, here is a solution of Euler's equation on the HP32S (I like this little machine:-):

LBL E
INPUT X
RCL X
0
CMPLXe^X
1
+
x^2
x<>y
x^2
+
RTN

Then:
FN= E
SOLVE X

The 32S displays "NO ROOT FND" but the best guess 3.14159265359 is in X.

Anyhow, for me it's a complicated way to just solve COS(X)=-1.

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
12-15-2019, 11:28 AM
Post: #32
RE: Can you calculate Pi using a Solver?
Very nice - well done!
Find all posts by this user
Quote this message in a reply
12-16-2019, 11:44 AM (This post was last modified: 12-16-2019 11:51 AM by EdS2.)
Post: #33
RE: Can you calculate Pi using a Solver?
So, indeed, I got my trusty Limited Edition HP15C out, set flag 8 (surprised to see it not documented on the back plate) and indeed it does a very solid job of being a complex-number calculator, and is willing to have a go at solving Euler's identity for a value of pi.

It doesn't do terribly well, but it is willing.

Using the Real() method:
Solver input 1,4: result is 3.141591597
Solver input 2,3: result is 3.141583326

Using the ABS() method:
Solver input 1,4: result is Error 8, aka 3.139172931
Solver input 2,3: result is Error 8, aka 3.141225122

(Edit: I see now that using Re<>Im or the I function puts the calculator into complex mode without any flag manipulation. I wonder if the unaware user might then be stuck in complex mode forever? I must read more manual.)
Find all posts by this user
Quote this message in a reply
12-16-2019, 12:31 PM
Post: #34
RE: Can you calculate Pi using a Solver?
(12-14-2019 12:56 AM)Valentin Albillo Wrote:  Code for the HP-71B, where FNROOT (Find Root) is the "official" HP-71B's "Solver":

     1   DEF FNF(X) = FNROOT(1, 1, GAMMA(FVAR) - X)
     2   DISP FNROOT(3, 4, FNF(SQR(FVAR)) - 1/2)

>RUN

          3.14159265359

This produces as a root the theoretically exact (not an approximation) value of Pi.

V.

Hi, Valentin!
Why not just use GAMMA(0.5) - SQRT(X) = 0 as the generating equation?
I don't own a 71, but then it ought to be something like
DISP FNROOT(3, 4, GAMMA(1/2) - SQR(FVAR) )

Cheers, Werner

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
12-16-2019, 09:54 PM
Post: #35
RE: Can you calculate Pi using a Solver?
I tried this method on the 32S and worked perfectly. However when I tried it on the 32SII the result is way off. Is the programming that different on both machines?

(12-15-2019 10:39 AM)J-F Garnier Wrote:  
(12-14-2019 10:51 AM)EdS2 Wrote:  I had hopes that Euler's equation would serve - if we could take the magnitude, or the real value, of e^(ix)+1, then we have a (complex) function which takes a real to a real, and the job would be done. But the HP-35s lacks the capability.

Following your suggestion, here is a solution of Euler's equation on the HP32S (I like this little machine:-):

LBL E
INPUT X
RCL X
0
CMPLXe^X
1
+
x^2
x<>y
x^2
+
RTN

Then:
FN= E
SOLVE X

The 32S displays "NO ROOT FND" but the best guess 3.14159265359 is in X.

Anyhow, for me it's a complicated way to just solve COS(X)=-1.

J-F


11C 12C 15C 17BII 18C 19BII 21 25 27S 28S 32E 32S 32SII 33C 33S 34S 35S 38C 39gs 39GII 40gs 41C 41CV 41CX 42S 45 48G+ 48GII 49G 49G+ 50 67 71B 97
Find all posts by this user
Quote this message in a reply
12-17-2019, 01:22 AM
Post: #36
RE: Can you calculate Pi using a Solver?
.
Hi, Werner:

(12-16-2019 12:31 PM)Werner Wrote:  
(12-14-2019 12:56 AM)Valentin Albillo Wrote:  Code for the HP-71B, where FNROOT (Find Root) is the "official" HP-71B's "Solver":

     1   DEF FNF(X) = FNROOT(1, 1, GAMMA(FVAR) - X)
     2   DISP FNROOT(3, 4, FNF(SQR(FVAR)) - 1/2)

>RUN

          3.14159265359

This produces as a root the theoretically exact (not an approximation) value of Pi.

V.

Hi, Valentin!
Why not just use GAMMA(0.5) - SQRT(X) = 0 as the generating equation?
I don't own a 71, but then it ought to be something like
DISP FNROOT(3, 4, GAMMA(1/2) - SQR(FVAR) )


Because that's not much use of a Solver as the OP intended it, i.e.: to solve some equation which isn't explicitly solvable (i.e: the variable can't be isolated, e.g.: cos(x)-x=0), doesn't involve trigs, and of course doesn't feature Pi explicitly in the equation.

Your proposed equation fails in those regards. For starters, Gamma(1/2) is a *constant*, namely √Pi. You can call it "Gamma(1/2)" or you can call it "Pepe" but it's still just √Pi.

So, your equation becomes:

          √Pi - SQRT(X) = 0    →   √x = √Pi   →    x = Pi

and not only does it have the variable x isolated and Pi included in the equation but it's also as utterly trivial as it gets, and probably this is not what the OP was asking for.

Anyway, thanks for your question and most of all, for your interest.

And if you don't own an HP-71B but would like to, there are at least two excellent, free Emu71 out there (running in MS-DOS, DOS console in Win/16/32, or full-GUI Win/16/32/64 or under DOSEMU in any operating system, Android included and even some electronic-ink eBook readers) which you can download. For free.

Best regards.
V.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
12-17-2019, 07:42 AM (This post was last modified: 12-17-2019 08:12 AM by Stevetuc.)
Post: #37
RE: Can you calculate Pi using a Solver?
(12-14-2019 12:56 AM)Valentin Albillo Wrote:  .
Self-quoting a little:

(12-13-2019 11:30 PM)Valentin Albillo Wrote:  Unless the Solver can work with complex numbers I don't think there's such an equation using just real numbers and no trigs. Equations whose roots are arbitrarily accurate approximations to Pi (say 34 digits) can be produced but ones returning exactly Pi (in theory, limited to 10-12 digits in practice) is a no-go IMHO.

Well, to make myself clearer, the previous quotation refers to polynomials or rational functions, which indeed can't produce Pi as an exact root because Pi is transcendental.

But if we involve other functions but polynomials, rational functions and trigs, there are many ways to concoct an equation whose root is exactly Pi. For instance, if your Solver admits nesting and can use the Gamma function, then this will do:

Code for the HP-71B, where FNROOT (Find Root) is the "official" HP-71B's "Solver":

     1   DEF FNF(X) = FNROOT(1, 1, GAMMA(FVAR) - X)
     2   DISP FNROOT(3, 4, FNF(SQR(FVAR)) - 1/2)

>RUN

          3.14159265359

This produces as a root the theoretically exact (not an approximation) value of Pi.

V.

Tried this on the prime but it appears that the solver doesnt support recursion.
I created a thread on prime forum to followup on this https://www.hpmuseum.org/forum/thread-14184.html
Find all posts by this user
Quote this message in a reply
12-17-2019, 08:01 AM (This post was last modified: 12-17-2019 08:15 AM by J-F Garnier.)
Post: #38
RE: Can you calculate Pi using a Solver?
(12-16-2019 09:54 PM)Moggul Wrote:  I tried this method on the 32S and worked perfectly. However when I tried it on the 32SII the result is way off. Is the programming that different on both machines?

The solver will find one of the many solutions pi+(2*pi)*n, depending on the initial guess. Try setting the X variable (and x register) to zero first.

I'm pretty sure that there is no difference in the 32S and 32SII solvers, if there are I'm very interested to know them!

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
12-17-2019, 09:36 AM (This post was last modified: 12-17-2019 10:19 AM by EdS2.)
Post: #39
RE: Can you calculate Pi using a Solver?
Interesting - my 15C did a lot better finding 3pi given a starting range of 9 to 12. (Edit: compared to finding pi)
Find all posts by this user
Quote this message in a reply
01-07-2020, 06:37 PM (This post was last modified: 01-07-2020 06:40 PM by EdS2.)
Post: #40
RE: Can you calculate Pi using a Solver?
(12-16-2019 11:44 AM)EdS2 Wrote:  ... Euler's identity...
As a slight digression, in related explorations on the web I landed on a marvellous article by Alon Amit explaining nicely the nature of and the linkage between pi and e:

“So here, again, is the exponential function, stemming from its unique property as the fixed point of the operator d/dx. And here, again, is our friend pi, always accompanying its master of which it is the period (times 2i). And this, finally, is where pi comes from, and what it is, and there are no circles to be found.”

What is pi? also available here and in archived form here.
Find all posts by this user
Quote this message in a reply
Post Reply 




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