-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
program hangs #3
Comments
The program was hanging in the outreal function, the input value was "inf".
A test is added in the runtime system to check
for nan and inf values.
I did not have a good look at the program, however, when I run the program
with decreasing values for alpha (starting with alpha := 0.5,
each iteration dividing alpha by 10) I get the following
[jan@hp-jan ~]$ ./prog3
0.7853981633 0.9480594489 1.002279877 1.002279877
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
1.006507522
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
1.006507522
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
Op di 26 feb. 2019 om 12:25 schreef fred5678 <[email protected]>:
… The attached program seems to hang in k-loop at line #51. I can't find an
error. If I change the value for alpha to 0.5 or 0.005 it terminates after
four numbers. With 0.0005 it hangs. The 50 years old (1968 :-) correct
output values have to be: 0.785398... 0.948059... 1.002279... 0.977048...
and so on (29 values). The last value is 1.0.
prog3.txt
<https://github.com/JvanKatwijk/algol-60-compiler/files/2905171/prog3.txt>
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#3>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AITzwNybPDeTSv63x53CFgPlYSBuoAjBks5vRRmjgaJpZM4bR9Fz>
.
--
Jan van Katwijk
|
The "inf" values occur since in
for k:=i-1 step -1 until 0 do
begin
t[k] := t[k+1] + (t[k+1]-t[k])/
(bulz[i]*bulz[i]/(bulz[k]*bulz[k])-1);
the "bulz[k]" value will be 1 (not sure that is the correct value, but it
is the value that I see), the value shows when the "k" = 3, and "i" = 4
best
jan
Op di 26 feb. 2019 om 13:09 schreef jan van katwijk <[email protected]
…:
The program was hanging in the outreal function, the input value was
"inf". A test is added in the runtime system to check
for nan and inf values.
I did not have a good look at the program, however, when I run the program
with decreasing values for alpha (starting with alpha := 0.5,
each iteration dividing alpha by 10) I get the following
***@***.*** ~]$ ./prog3
0.7853981633 0.9480594489 1.002279877 1.002279877
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
1.006507522
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
1.006507522
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
0.7853981633 0.9480594489 1.002279877 0.9770486166 1.006037784 1.006507522
0.9871158009 inf inf inf inf
Op di 26 feb. 2019 om 12:25 schreef fred5678 ***@***.***>:
> The attached program seems to hang in k-loop at line #51. I can't find an
> error. If I change the value for alpha to 0.5 or 0.005 it terminates after
> four numbers. With 0.0005 it hangs. The 50 years old (1968 :-) correct
> output values have to be: 0.785398... 0.948059... 1.002279... 0.977048...
> and so on (29 values). The last value is 1.0.
>
> prog3.txt
> <https://github.com/JvanKatwijk/algol-60-compiler/files/2905171/prog3.txt>
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <#3>, or mute the
> thread
> <https://github.com/notifications/unsubscribe-auth/AITzwNybPDeTSv63x53CFgPlYSBuoAjBks5vRRmjgaJpZM4bR9Fz>
> .
>
--
Jan van Katwijk
--
Jan van Katwijk
|
At the moment I can't verify the correctness of the algorithm, but 0.7853981633 0.9480594489 1.002279877 The program hangs at ...e-3 > ...e-13? |
There is no test on division by zero, the resulting value will be inf,
Looking at the code, one sees that the contents of the array bulz is 1 2 3
4 6 8 12
and the code here reads
for k:=i-1 step -1 until 0 do
begin
t[k] := t[k+1] + (t[k+1]-t[k])/
(bulz[i]*bulz[i]/(bulz[k]*bulz[k])-1);
outreal(1,t[k]);
So, when k reaches 0, bulz [k] = 1, and
(bulz[i]*bulz[i]/(bulz[k]*bulz[k])-1) will be undefined (i.e. inf),
I do not know the underlying algorithm, but k becoming 0 kills the program,
Op di 26 feb. 2019 om 14:46 schreef fred5678 <[email protected]>:
… At the moment I can't verify the correctness of the algorithm, but
a. Is there no test on zero division?
b. The control print at the <= test gives
the following output:
0.7853981633 0.9480594489 1.002279877
0.2168817140 5.011399387e-13
le > ri 0.9770486166 1.006037784 1.006507522
4.227645209e-3 5.032537613e-13
The program hangs at ...e-3 > ...e-13?
prog3b.txt
<https://github.com/JvanKatwijk/algol-60-compiler/files/2905727/prog3b.txt>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AITzwDT3YVl5kFM5cpvEysDNo1_kp-CIks5vRTrEgaJpZM4bR9Fz>
.
--
Jan van Katwijk
|
I see it is a problem of very small numbers. How can I increase the accuracy of the runtime system? |
are you sure? the array "bulz" is declared integer, so (bulz [k] * bulz
[k]) - 1 becoming zero is just a tough integer 0,
are the parenteses correct?
Btw, the algol "real" is mapped upon a C double, so a straight 64 bit float
Op di 26 feb. 2019 om 15:19 schreef fred5678 <[email protected]>:
… I see it is a problem of very small numbers. How can I increase the
accuracy of the runtime system?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AITzwE8WvqH4gETdPli7ak4xKct4onzmks5vRUJXgaJpZM4bR9Fz>
.
--
Jan van Katwijk
|
(bulz[i]*bulz[i]/(bulz[k]*bulz[k])-1) = bi^2 / bk^2 -1 bk = 1 and bi >1 => bi^2 / bk^2 > 1 |
I got it. I have to declare the bulz-array as real! Thank you very much. |
you are always welcome, I really enjoy fighting with this kind of programs
I was blinded by the parenthesis and my last computation would give
for the offended loop, there you see that indeed the denominator becomes
zero
begin loop 1 0 numerator 1.110720734 denomimator 3.000000000
1.002279877
0.2168817140 5.011399387e-13
le > ri 0.9770486166
begin loop 2 1 numerator 1.006037784 denomimator 1.000000000
1.006037784
begin loop 2 0 numerator 1.009795691 denomimator 8.000000000
1.006507522
4.227645209e-3 5.032537613e-13
le > ri 0.9871158009
begin loop 3 2 numerator 0.9971829852 denomimator 0.0
inf
begin loop 3 1 numerator inf denomimator 3.000000000
inf
begin loop 3 0 numerator inf denomimator 15.00000000
inf
inf inf
\
Good luck
best
jan
Op di 26 feb. 2019 om 16:12 schreef fred5678 <[email protected]>:
… I got it. I have to declare the bulz-array as real! Thank you very much.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AITzwEp5hHQE32GV0kylnd_fyxl7r7PYks5vRU6_gaJpZM4bR9Fz>
.
--
Jan van Katwijk
|
The attached program seems to hang in k-loop at line #51. I can't find an error. If I change the value for alpha to 0.5 or 0.005 it terminates after four numbers. With 0.0005 it hangs. The 50 years old (1968 :-) correct output values have to be: 0.785398... 0.948059... 1.002279... 0.977048... and so on (29 values). The last value is 1.0.
prog3.txt
The text was updated successfully, but these errors were encountered: