[Scilab-users] Numerical precision
Claus Futtrup
cfuttrup at gmail.com
Sun Aug 21 16:11:42 CEST 2016
Dear Scilab Users
I have a script, which imitates a Fortran script. I can see there's a
difference in calculation of about 1%, which is very strange to me.
Input parameters (dz1 and dz2 vectors, length 1200) to the equation seem
to agree within 0,1% ... so right now my theory is that the precision
slips away when I do the following calculation:
Scilab: zm_star = (1-mu)* dz1 .* dz2 ./ (dz2-mu*dz1); // model free
mech. impedance
Fortran: zm_star = (1-mu)*dz1*dz2/(dz2-mu*dz1)
Do you see anything in the Scilab formulation, which should worry me /
which would give me such a high error?
P.S. mu is a mass-ratio = 1.9970156677443420... and it's exactly the
same value in both Scilab and Fortran.
Most of the calculations in the output vector are OK, but in particular
around the resonance frequency, I can list the following three
datapoints (zm_star(47:49)), to show what is worrying me:
In Fortran, data no. 47-48-49 (near fs):
( 66.547108467527437 , -58.427426595183157 )
( 105.67638116311093 ,-0.84432029182632362 )
( 66.018415098214774 , 47.279402998470466 )
Whereas in Scilab I get:
67.58254632254881 - 57.549843258298814*%i
104.56362768103634 + 0.9610187273575014*%i
64.84646498264745 + 47.01680213507681*%i
In particular the imaginary part is different at the middle data point
(near fs) where from Fortran the value is negative, whereas in Scilab
the value is positive. It seems that the calculation of zm_star involves
some math operations that could be critical to the precision.
If you study the impedance magnitude (pythagoras...), the results from
Fortran are about 1% higher in value - IMHO that's non-negligible.
Studying the Nyquist circle plot of the data, it seems to me that in
general the Fortran calculation is more correct.
What is going wrong with the Scilab equation? Please let me know if you
have any ideas how to increase the precision of the calculation. Thanks.
P.S. I'm using Scilab 5.5.0 (64 bit, Windows 10). Could it be the Intel
Math Kernel that's doing this wrong?
/Claus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20160821/f781181e/attachment.htm>
More information about the users
mailing list