Delphi(Object Pascal) source code


Code:

procedure TForm1.Button1Click(Sender: TObject);
var i:Longint;
    x,m:real;
begin
 i:=0;
 x:=sqrt(5+2*sqrt(5));
 m:=1;
 while (i<15) do
 begin
  x:=sqrt(2)*sqrt((-(sqrt(5)+3)*sqrt(-x*x+6*sqrt(5)+14)+6*sqrt(5)+14))/2;
  m:=m*2;
  i:=i+1;
 end;
 Memo1.Lines.Add(FloatToStr(x*m*5/(sqrt(5)+3)));
end;


PI=3.14159265321243
Verified through Mathematica:

Code:
f[0] := Sqrt[5 + 2 Sqrt[5]]
f[x_] := N[
  Sqrt[2]*Sqrt[(-(Sqrt[5] + 3)*Sqrt[-f[x - 1]^2 + 6*Sqrt[5] + 14] +
       6*Sqrt[5] + 14)]/2, 32]
Pi - f[100] 2^100*5/(Sqrt[5] + 3)

That evaluates to 0, my good friend.

I even transcribed it to TI-Basic, but it succumbed to floating-point errors, which made the process almost not worthwhile, were it not for the chance it gave me to optimize to reduce the overall number of calculations. That went something like this:

Code:
:√(5→R
:R+3→S
:6R+14→T
:√(5+2R
:For(I,0,10
:√(.5(T-S√(T-Ans²
:End
:5Ans2^I/S

The best that gets is six digits.
Weregoose wrote:
Verified through Mathematica:

Code:
f[0] := Sqrt[5 + 2 Sqrt[5]]
f[x_] := N[
  Sqrt[2]*Sqrt[(-(Sqrt[5] + 3)*Sqrt[-f[x - 1]^2 + 6*Sqrt[5] + 14] +
       6*Sqrt[5] + 14)]/2, 32]
Pi - f[100] 2^100*5/(Sqrt[5] + 3)

That evaluates to 0, my good friend.


In program Mathematica.

Try replace 32 to 100 on this line

Code:
f[x_] := N[
  Sqrt[2]*Sqrt[(-(Sqrt[5] + 3)*Sqrt[-f[x - 1]^2 + 6*Sqrt[5] + 14] +
       6*Sqrt[5] + 14)]/2, 100]


or replace 100 to 32 on this line


Code:

Pi - f[32]*2^32*5/(Sqrt[5] + 3)


now what the result returns Mathematica after changes?
First alteration: 1.28635022327396949283330999828754734230*10^-61
Second alternation: 1.12056908458*10^-20
Both combined: 1.12056908458225664852574387465500359340002453735461604462687793402623\
97648671486*10^-20
Weregoose wrote:
First alteration: 1.28635022327396949283330999828754734230*10^-61
Second alternation: 1.12056908458*10^-20
Both combined: 1.12056908458225664852574387465500359340002453735461604462687793402623\
97648671486*10^-20


After 15 iteration with presicion 32 digits, I get

(0.00010040034601319640261442801502043*5*2^15/(sqrt(5) + 3))=3.1415926533972809356186035212846

Test Mathematica again. I doubt that result in Mathematica is correct.
You understand that I'm using the difference between your result and Pi as the output. These small numbers are proof that your algorithm does work.
Weregoose wrote:
You understand that I'm using the difference between your result and Pi as the output. These small numbers are proof that your algorithm does work.


Sorry. I understood you.
Result Pi - f[100] 2^100*5/(Sqrt[5] + 3) is 0.

Does the time of calculation (Pi) and (f [100] 2 ^ 100 * 5 / (Sqrt [5] + 3)) in Mathematica?
0.016 of a second.
Weregoose wrote:
0.016 of a second.


Do I understand you that the time of calculation of pi Mathematica standard algorithm and iterative algorithms proposed by me and did not differ
equal to 0.016 seconds? That is, likely that the calculation algorithms are identical?
Oh. Calculating 2000 digits of Pi takes 2.75387*10^-17 of a second.

So says Mathematica.

This is the algorithm employed by Mathematica to compute π.
Weregoose wrote:
Oh. Calculating 2000 digits of Pi takes 2.75387*10^-17 of a second.


Do you think that these two algorithms for calculating the number pi are identical? Can not answer, because maybe it is a commercial secret of the company that created the software Mathematica. Thank you.
I edited my last post too late, so I'll drop it down here with the new info.

This is the algorithm employed by Mathematica to compute π.

To be more precise, they use:



A = 13591409
B = -1/151931373056000
C= 30285563/1651969144908540723200
Weregoose wrote:
I edited my last post too late, so I'll drop it down here with the new info.

This is the algorithm employed by Mathematica to compute π.

To be more precise, they use:



A = 13591409
B = -1/151931373056000
C= 30285563/1651969144908540723200


Ok. Thanks you.
Weregoose, your post reminds me that I've been meaning to install a plugin to render math LaTeX properly on the site. Thanks for the reminder. Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement