<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Paul<br>
<br>
Yes, you're right. Sorry for disturbing the Scilab list.<br>
<br>
>it's not that surprising to me if your system is poorly
conditioned<br>
<br>
I'm surprised, but this seems to be the culprit.<br>
<br>
/Claus<br>
<br>
On 22-08-2016 09:06, Paul Bignier wrote:<br>
</div>
<blockquote
cite="mid:e8fcf8e6-7a4e-becd-5927-8e5df5381bd1@scilab-enterprises.com"
type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<p><br>
</p>
<p>Hello Claus,</p>
<p>If I get this right, after finding discrepancies between Scilab
& Fortran, you identified the origin of the problem: the
input was different.</p>
<p>So you fed Scilab the same input you had in Fortran and got
equal results, so no problem so far.</p>
<p>Have you tried feeding Fortran the Scilab input? See if it
gives the same results as Scilab.</p>
<p>As for the input/output variation, it's not that surprising to
me if your system is poorly conditioned, especially at some
points of interest (near the resonance frequency).</p>
<p>Best regards,</p>
<p>Paul<br>
</p>
<br>
<div class="moz-cite-prefix">On 08/21/2016 06:51 PM, Claus Futtrup
wrote:<br>
</div>
<blockquote
cite="mid:b90b7f68-668f-e995-d5d7-19620d56975c@gmail.com"
type="cite">
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
<div class="moz-cite-prefix">Hi there<br>
<br>
OK, so I went ahead and took some Fortran input ... yes, I do
get the same output as Fortran, so it seems there's no
calculation error per se in Scilab. It's just tiny differences
in the input which generate large differences in output. It's
scary.<br>
<br>
If you compare the input (dz1 in scilab vs. dz1 in fortran,
you get differences of around :<br>
<br>
1->dz1s./dz1f<br>
ans =<br>
<br>
0.9998331 + 0.0000339i <br>
0.9998132 + 0.0000391i <br>
0.9998197 + 0.0000391i <br>
<br>
<br>
And if you compare input for dz2, you get similar tiny
differences :<br>
<br>
-1->dz2s./dz2f<br>
ans =<br>
<br>
0.9999629 + 0.0000126i <br>
0.9999600 + 0.0000145i <br>
0.9999635 + 0.0000145i <br>
<br>
The difference in magnitude is on the scale of less than
0.02%.<br>
<br>
Here's a complete script, including comments which shows the
results and explains. I only include the three datapoints
around fs, which are of interest:<br>
<br>
<pre style="font-family:Monospaced;font-style:normal;font-size:12.0;"><span style="color:rgb(100,174,100);font-style:italic;">// dz_test.sce</span>
<span style="color:rgb(100,174,100);font-style:italic;">// Scilab input/output for zm_star:</span>
<span style="color:rgb(0,0,0);">dz1s</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.503483777422459</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.5757953650438843</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span>
<span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.5114164682962974</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.5883274915921053</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span>
<span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.5189524114871444</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.6013228498050527</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span><span style="color:rgb(74,85,219);">]</span>
<span style="color:rgb(0,0,0);">dz2s</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.9956247120533783</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.1585555511721832</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span>
<span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.019729681961281</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.1864195137402458</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span>
<span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.0436439978573127</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.2149095747738672</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span><span style="color:rgb(74,85,219);">]</span>
<span style="color:rgb(0,0,0);">mu</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(188,143,143);">1.997015667744342</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">zm_star</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(0,0,0);">mu</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">*</span> <span style="color:rgb(0,0,0);">dz1s</span> <span style="color:rgb(92,92,92);">.*</span> <span style="color:rgb(0,0,0);">dz2s</span> <span style="color:rgb(92,92,92);">./</span> <span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">dz2s</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(0,0,0);">mu</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(0,0,0);">dz1s</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(100,174,100);font-style:italic;">// =</span>
<span style="color:rgb(100,174,100);font-style:italic;">// 67.582546 - 57.549843i </span>
<span style="color:rgb(100,174,100);font-style:italic;">// 104.56363 + 0.9610187i </span>
<span style="color:rgb(100,174,100);font-style:italic;">// 64.846465 + 47.016802i</span>
<span style="color:rgb(100,174,100);font-style:italic;">// Fortran input:</span>
<span style="color:rgb(0,0,0);">dz1f</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.50358736782056468</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.57587442109900699</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span>
<span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.51153502148422891</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.58841744553307240</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span>
<span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.51906952093260994</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.60141095056474114</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span><span style="color:rgb(74,85,219);">]</span>
<span style="color:rgb(0,0,0);">dz2f</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">[</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">0.99567617243878548</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.1585859673221321</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span>
<span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.0197876382178386</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.1864521484345998</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span>
<span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.0436997434456954</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(188,143,143);">1.2149387979780446</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(218,112,214);">%i</span><span style="color:rgb(74,85,219);">]</span>
<span style="color:rgb(0,0,0);">zm_star</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(0,0,0);">mu</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(92,92,92);">*</span> <span style="color:rgb(0,0,0);">dz1f</span> <span style="color:rgb(92,92,92);">.*</span> <span style="color:rgb(0,0,0);">dz2f</span> <span style="color:rgb(92,92,92);">./</span> <span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">dz2f</span><span style="color:rgb(92,92,92);">-</span><span style="color:rgb(0,0,0);">mu</span><span style="color:rgb(92,92,92);">*</span><span style="color:rgb(0,0,0);">dz1f</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(100,174,100);font-style:italic;">// Scilab output:</span>
<span style="color:rgb(100,174,100);font-style:italic;">// =</span>
<span style="color:rgb(100,174,100);font-style:italic;">// 66.547108 - 58.427427i </span>
<span style="color:rgb(100,174,100);font-style:italic;">// 105.67638 - 0.8443203i </span>
<span style="color:rgb(100,174,100);font-style:italic;">// 66.018415 + 47.279403i </span>
<span style="color:rgb(100,174,100);font-style:italic;">// Fortran output:</span>
<span style="color:rgb(100,174,100);font-style:italic;">// ( 66.547108467527437 , -58.427426595183157 )</span>
<span style="color:rgb(100,174,100);font-style:italic;">// ( 105.67638116311093 ,-0.84432029182632362 )</span>
<span style="color:rgb(100,174,100);font-style:italic;">// ( 66.018415098214774 , 47.279402998470466 )</span></pre>
<br>
As can be seen. Scilab gives the same output as Fortran, when
the input is the same.<br>
<br>
I'm just totally surprised how such small differences in input
can generate such large differences in output.<br>
<br>
Best regards,<br>
Claus<br>
<br>
On 21-08-2016 16:11, Claus Futtrup wrote:<br>
</div>
<blockquote
cite="mid:bf13cc67-1b88-d6fc-71ae-bc3b40ea4bd1@gmail.com"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<p>Dear Scilab Users</p>
<p>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:</p>
<p>Scilab: <span style="color:rgb(0,0,0);">zm_star</span> <span
style="color:rgb(92,92,92);">=</span> <span
style="color:rgb(74,85,219);">(</span><span
style="color:rgb(188,143,143);">1</span><span
style="color:rgb(92,92,92);">-</span><span
style="color:rgb(0,0,0);">mu</span><span
style="color:rgb(74,85,219);">)</span><span
style="color:rgb(92,92,92);">*</span> <span
style="color:rgb(0,0,0);">dz1</span> <span
style="color:rgb(92,92,92);">.*</span> <span
style="color:rgb(0,0,0);">dz2</span> <span
style="color:rgb(92,92,92);">./</span> <span
style="color:rgb(74,85,219);">(</span><span
style="color:rgb(0,0,0);">dz2</span><span
style="color:rgb(92,92,92);">-</span><span
style="color:rgb(0,0,0);">mu</span><span
style="color:rgb(92,92,92);">*</span><span
style="color:rgb(0,0,0);">dz1</span><span
style="color:rgb(74,85,219);">)</span><span
style="color:rgb(0,0,0);">;</span> <span
style="color:rgb(100,174,100);font-style:italic;">// model
free mech. impedance</span></p>
<p>Fortran: zm_star = (1-mu)*dz1*dz2/(dz2-mu*dz1)<br>
</p>
<p>Do you see anything in the Scilab formulation, which should
worry me / which would give me such a high error?</p>
<p>P.S. mu is a mass-ratio = 1.9970156677443420... and it's
exactly the same value in both Scilab and Fortran.<br>
</p>
<p>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:</p>
<p>In Fortran, data no. 47-48-49 (near fs):<br>
<br>
( 66.547108467527437 , -58.427426595183157 )<br>
( 105.67638116311093 ,-0.84432029182632362 )<br>
( 66.018415098214774 , 47.279402998470466 )<br>
<br>
Whereas in Scilab I get:<br>
<br>
67.58254632254881 - 57.549843258298814*%i<br>
104.56362768103634 + 0.9610187273575014*%i<br>
64.84646498264745 + 47.01680213507681*%i</p>
<p>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.</p>
<p>If you study the impedance magnitude (pythagoras...), the
results from Fortran are about 1% higher in value - IMHO
that's non-negligible.</p>
<p>Studying the Nyquist circle plot of the data, it seems to
me that in general the Fortran calculation is more correct.</p>
<p>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>
<p>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?<br>
</p>
<p>/Claus<br>
</p>
</blockquote>
<p><br>
</p>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Paul BIGNIER
Development engineer
-----------------------------------------------------------
Scilab Enterprises
143bis rue Yves Le Coz - 78000 Versailles, France
Phone: +33.1.80.77.04.68
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.scilab-enterprises.com">http://www.scilab-enterprises.com</a></pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:users@lists.scilab.org">users@lists.scilab.org</a>
<a class="moz-txt-link-freetext" href="http://lists.scilab.org/mailman/listinfo/users">http://lists.scilab.org/mailman/listinfo/users</a>
</pre>
</blockquote>
<p><br>
</p>
</body>
</html>