precision

precision - Messaggi

#1 Pubblicato: 24/04/2011 06:44:57
kilele

kilele

134 apprezzamenti in 397 post.

Gruppo: User

What am I doing wrong ?
Shouldn't the last two values be equal ?
Besides, r^65 gives different values depending on decimal places configured in option menu
r^65=64.992 (3 decimal places)
r^65=64.9994 (4 deccimal places)
third decimal isn't the same!!

[LIVE width=386 height=543]http://smath.info/live/?file=2675[/LIVE]
#2 Pubblicato: 25/04/2011 12:19:30
maweilian

maweilian

5 apprezzamenti in 103 post.

Gruppo: User

I agree, there does appear to be a problem with the way SMath is calculating powers.

Here is the same calculation performed with the number of decimal places set to the maximum:



and performed with the number of decimal places set to 3:



Thus, when the 5th power of the results are calculated, the answer should be equal out to the 10th decimal place. The remaining difference would be roundoff error between the different numerical algorithms used in the polyroots and solve functions.

I would think that Smath should pass results to all subsequent calculations with the maximum possible precision and the round only the DISPLAYED results to the number of decimal places specified in the "options" dialog.
Will Massie Mechanical Engineer Oregon, USA
#3 Pubblicato: 26/04/2011 03:23:12
Radovan Omorjan

Radovan Omorjan

325 apprezzamenti e 1 disapprezzamenti in 2.052 post.

Gruppo: Moderator

Hello,

Will is right. The results of solve() function depend on the number of displayed decimals. In general, SMath does not have the option for setting the calculating precision with the applied numerical functions. I think that Will is using 0.89 version. Here is the same example with 0.89.8 version
[MATH=eng]r←solve(65-x^5,x)[/MATH]
[MATH=eng]r=2.304[/MATH]
[MATH=eng]r^5=64.917[/MATH]
and
[MATH=eng]r=2.30453161980214[/MATH]
[MATH=eng]r^5=64.9999999999999[/MATH]
It seems that something has been changed in between. My advice is to use the four argument solve() function, whenever posible. Here it is:
[MATH=eng]r←solve(65-x^5,x,2,3)[/MATH]
[MATH=eng]r=2.305[/MATH]
[MATH=eng]r^5=65[/MATH]
Pay attention that solve() will sometimes fail in spite of quite good searching range given. Some playing with the range (third and fourth argument) might be needed.
Regarding the nonlinear equations, one can use roots() as well. Here is the same example solved with roots():
[MATH=eng]r←roots(65-x^5,x)[/MATH]
Three decimal places:
[MATH=eng]r=2.305[/MATH]
[MATH=eng]r^5=65[/MATH]
Fifteen decimal places:
[MATH=eng]r=2.30453161980214[/MATH]
[MATH=eng]r^5=64.9999999999999[/MATH]
Sometimes a three argument roots() version might be more appropriate (if the two argument roots() fails)
[MATH=eng]r←roots(65-x^5,x,2)[/MATH]
[MATH=eng]r=2.305[/MATH]
[MATH=eng]r^5=65[/MATH]

Regards,
Radovan
When Sisyphus climbed to the top of a hill, they said: "Wrong boulder!"
  • Nuovi post
  • Nessun nuovo post