Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,30 +0,0 @@
|
|||
with ada.text_io; use ada.text_io;
|
||||
|
||||
procedure golden_ratio_convergence is
|
||||
|
||||
-- This is a fixed-point type. I typed a bunch of "0"
|
||||
-- without counting them.
|
||||
type number is delta 0.000000000000001 range -10.0 .. 10.0;
|
||||
|
||||
one : constant number := number (1.0);
|
||||
phi : constant number := number (1.61803398874989484820458683436563811772030917980576286213544862270526046281890244970720720418939113748475); -- OEIS A001622
|
||||
phi0, phi1 : number;
|
||||
count : integer;
|
||||
|
||||
begin
|
||||
count := 1;
|
||||
phi0 := 1.0;
|
||||
phi1 := (one + (one / phi0));
|
||||
while abs (phi1 - phi0) > number (1.0e-5) loop
|
||||
count := count + 1;
|
||||
phi0 := phi1;
|
||||
phi1 := (one + (one / phi0));
|
||||
end loop;
|
||||
put ("Result:");
|
||||
put (phi1'image);
|
||||
put (" after");
|
||||
put (count'image);
|
||||
put_line (" iterations");
|
||||
put ("The error is approximately ");
|
||||
put_line (number'image (phi1 - phi));
|
||||
end golden_ratio_convergence;
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
*> -*- mode: cobol -*-
|
||||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. GOLDEN_RATIO_CONVERGENCE.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 PHI0 PIC 9(1)V9(12).
|
||||
01 PHI1 PIC 9(1)V9(12).
|
||||
01 DIFF PIC S9(1)V9(12).
|
||||
01 ERR PIC S9(1)V9(12).
|
||||
01 NOMINAL-VALUE PIC 9(1)V9(12).
|
||||
01 ITER PIC 9(2).
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
MOVE 0 TO ITER
|
||||
MOVE 1.0 TO PHI0.
|
||||
LOOP.
|
||||
COMPUTE PHI1 = 1.0 + (1.0 / PHI0)
|
||||
COMPUTE DIFF = FUNCTION ABS (PHI1 - PHI0)
|
||||
MOVE PHI1 TO PHI0
|
||||
ADD 1 TO ITER
|
||||
IF 100000 * DIFF > 1.0
|
||||
GO TO LOOP
|
||||
END-IF
|
||||
DISPLAY 'RESULT: ' PHI1 ' AFTER ' ITER ' ITERATIONS'
|
||||
MOVE 1.61803398874989 TO NOMINAL-VALUE
|
||||
COMPUTE ERR = PHI1 - NOMINAL-VALUE
|
||||
DISPLAY 'THE ERROR IS APPROXIMATELY ' ERR.
|
||||
|
|
@ -1,11 +1,9 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
|
||||
<span style="color: #004080;">atom</span> <span style="color: #000000;">Phi</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">iter</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span>
|
||||
<span style="color: #008080;">do</span>
|
||||
<span style="color: #004080;">atom</span> <span style="color: #000000;">Pi</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">Phi</span>
|
||||
<span style="color: #000000;">Phi</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">/</span><span style="color: #000000;">Phi</span>
|
||||
<span style="color: #000000;">iter</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">1</span>
|
||||
<span style="color: #008080;">until</span> <span style="color: #7060A8;">abs</span><span style="color: #0000FF;">(</span><span style="color: #000000;">Phi</span><span style="color: #0000FF;">-</span><span style="color: #000000;">Pi</span><span style="color: #0000FF;">)<</span><span style="color: #000000;">1e-5</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Result: %.14f after %d iterations\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">Phi</span><span style="color: #0000FF;">,</span><span style="color: #000000;">iter</span><span style="color: #0000FF;">})</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"Error: %.14f\n"</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">Phi</span><span style="color: #0000FF;">-(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">+</span><span style="color: #7060A8;">sqrt</span><span style="color: #0000FF;">(</span><span style="color: #000000;">5</span><span style="color: #0000FF;">))/</span><span style="color: #000000;">2</span><span style="color: #0000FF;">})</span>
|
||||
<!--
|
||||
with javascript_semantics
|
||||
atom Phi = 1, iter = 0
|
||||
do
|
||||
atom Pi = Phi
|
||||
Phi = 1+1/Phi
|
||||
iter += 1
|
||||
until abs(Phi-Pi)<1e-5
|
||||
printf(1,"Result: %.14f after %d iterations\n",{Phi,iter})
|
||||
printf(1,"Error: %.14f\n",{Phi-(1+sqrt(5))/2})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue