NTNUJAVA Virtual Physics Laboratory
Enjoy the fun of physics with simulations!
Backup site http://enjoy.phy.ntnu.edu.tw/ntnujava/
November 20, 2017, 09:09:54 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Everything has its beauty but not every one sees it. ...Confucius (551-479 BC)
Google Bookmarks Yahoo My Web MSN Live Netscape Del.icio.us FURL Stumble Upon Delirious Ask FaceBook

Pages: [1]   Go Down
  Print  
Author Topic: is it possible to eliminate rounding off error in this simulation calculation?  (Read 4872 times)
0 Members and 1 Guest are viewing this topic. Click to toggle author information(expand message area).
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
on: January 25, 2012, 03:45:47 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

Dear Prof Hwang!

is it possible to eliminate rounding off error in this simulation calculation?

http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=2067.msg8920#msg8920

notice the
L1 = 10.416 = 10.42
L2 = 9.393 = 9.38
delta L = 10.33 = 10.3

but 10.42-9.38 =! 10.3 but actually = 10.4


* rippletankkroundingofferrorcansolved.png (116.13 KB, 758x634 - viewed 271 times.)
Logged
Fu-Kwun Hwang
Administrator
Hero Member
*****
Offline Offline

Posts: 3080



WWW
«
Embed this message
Reply #1 on: January 26, 2012, 08:38:45 am » posted from:,,Satellite Provider

From the attached picture:
L1=10.416
L2=9.383
So L1-L2=1.033
It seems that you round of the above result to 2 significant figures.
So S1P=10.42 , S2P=9.38
and you round off |S1P-S2P} from the above |1.033| value, so you get 1.03

If you want to get 1.04 you should calculate difference from the round-off values instead.

e.g.

double dv;
public float  roundoff(double v){
 if(v>0)dv=0.5;
 else if(v<0)dv=-0.5;
 else dv=0;
 return (int)(v*100+dv)/100.;
}

roundoff(L1) will give you 10.42
roundoff(L2)will give you 9.38
roundof(L1-L2)will give you 1.03
roundoff(L1)-roundoff(L2) will give you 1.04

This is an opportunity to teach students about the meaning of significant value (the last digit might be off).

I would not change the above result, but I will ask student why it is off (provide opportunity for student to think about this problem).
It could have more education value if we take the opportunity to invite student to think/learn:
There is always error due to numerical simulation.
And the physics experiment always contain error, too! It is a nature of physics.
Logged
lookang
Hero Member
*****
Offline Offline

Posts: 1784


http://weelookang.blogspot.com


WWW
«
Embed this message
Reply #2 on: January 26, 2012, 07:36:28 pm » posted from:SINGAPORE,SINGAPORE,SINGAPORE

i agree!
i will not modify the simulation to have round-off effect.

thanks for the Ejs tip on round off and the greater learning of nature of precision in physics!
Logged
Pages: [1]   Go Up
  Print  
Everything has its beauty but not every one sees it. ...Confucius (551-479 BC)
 
Jump to:  


Related Topics
Subject Started by Replies Views Last post
Calculation of impact velocity
kinematics
HACKNEYL 1 14863 Last post June 05, 2008, 10:12:44 am
by Fu-Kwun Hwang
Capacitor Calculation
Electromagnetics
KOKI 4 15684 Last post March 27, 2009, 04:07:15 pm
by lookang
AC Power calculation from current
misc
Fu-Kwun Hwang 6 20656 Last post September 17, 2010, 04:09:36 pm
by Fu-Kwun Hwang
Image in front of a mirror with thick glass
Optics
Fu-Kwun Hwang 2 24354 Last post April 06, 2011, 10:56:40 am
by Fu-Kwun Hwang
Request : SUN to Earth Energy calculation
Request for physics Simulations
barzivb 6 5321 Last post December 18, 2013, 12:51:58 pm
by TaraLaster
Powered by MySQL Powered by PHP Powered by SMF 1.1.13 | SMF © 2006-2011, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.073 seconds with 22 queries.since 2011/06/15