The old round off problem?
sam
samschul at pacbell.net
Sat Mar 4 14:00:26 EST 2006
Hello all, I am taking a class in scientific programming at the local
college. My problem is that the following difference produces round off
errors as the value of x increases. For x >= 19 the diference goes to
zero.I understand the problem, but am curious as to whether their
exists a solution. I have tried various graphing programs,and they all
exihibit this problem.
thanks in advance Sam Schulenburg
f(x) = cosh^2(x) - sinh^2(x) = 1
>>> from math import *
>>> for x in range(20):
print "x= %2d Sinh^2(x) = %20.3f f(x) = %2.10f
"%(x,pow(cosh(x),2),pow(cosh(x),2)- pow(sinh(x),2))
x= 0 Sinh^2(x) = 1.000 f(x) = 1.0000000000
x= 1 Sinh^2(x) = 2.381 f(x) = 1.0000000000
x= 2 Sinh^2(x) = 14.154 f(x) = 1.0000000000
x= 3 Sinh^2(x) = 101.358 f(x) = 1.0000000000
x= 4 Sinh^2(x) = 745.740 f(x) = 1.0000000000
x= 5 Sinh^2(x) = 5507.116 f(x) = 1.0000000000
x= 6 Sinh^2(x) = 40689.198 f(x) = 1.0000000000
x= 7 Sinh^2(x) = 300651.571 f(x) = 0.9999999999
x= 8 Sinh^2(x) = 2221528.130 f(x) = 1.0000000000
x= 9 Sinh^2(x) = 16414992.784 f(x) = 1.0000000037
x= 10 Sinh^2(x) = 121291299.352 f(x) = 1.0000000298
x= 11 Sinh^2(x) = 896228212.033 f(x) = 0.9999998808
x= 12 Sinh^2(x) = 6622280532.961 f(x) = 1.0000019073
x= 13 Sinh^2(x) = 48932402357.710 f(x) = 0.9999923706
x= 14 Sinh^2(x) = 361564266073.369 f(x) = 0.9999389648
x= 15 Sinh^2(x) = 2671618645381.616 f(x) = 1.0000000000
x= 16 Sinh^2(x) = 19740740045670.668 f(x) = 0.9921875000
x= 17 Sinh^2(x) = 145865435631864.219 f(x) = 1.0000000000
x= 18 Sinh^2(x) = 1077807886778799.250 f(x) = 1.0000000000
x= 19 Sinh^2(x) = 7963982939278438.000 f(x) = 0.0000000000
>>>
More information about the Python-list
mailing list