<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hello Farimani,<br>
      <br>
      Le 19/02/2019 à 10:47, farimani a écrit :<br>
    </div>
    <blockquote cite="mid:1550569662980-0.post@n3.nabble.com"
      type="cite">
      <pre wrap="">As I have originally explained in  this post
<a class="moz-txt-link-rfc2396E" href="https://stackoverflow.com/questions/54756985/expression-block-in-xcos-gives-answer-given-for-scilab-expression-is-wrong-err"><https://stackoverflow.com/questions/54756985/expression-block-in-xcos-gives-answer-given-for-scilab-expression-is-wrong-err></a>  
I'm trying to put the SciLab expression:

sign(u2 – u1) * (2 * ((Fm + M) * abs(u2 – u1) + k * (u2^2 – u1^2) / 2) /
m)^0.5

but I get this error message:

<a class="moz-txt-link-rfc2396E" href="http://mailinglists.scilab.org/file/t497909/7ivdz.png"><http://mailinglists.scilab.org/file/t497909/7ivdz.png></a> 

answer given for scilab expression is incorrect...

I would appreciate if you could help me know what is the problem and how I
can solve it. Maybe I should use a different block?</pre>
    </blockquote>
    <br>
    Copy/pasting your formula in the console:<br>
    <pre style="font-family:Monospaced;font-style:normal;font-size:12.0;"><span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">Fm</span><span style="color:rgb(0,0,0);">,</span> <span style="color:rgb(0,0,0);">M</span><span style="color:rgb(0,0,0);">,</span> <span style="color:rgb(0,0,0);">m</span><span style="color:rgb(0,0,0);">,</span> <span style="color:rgb(0,0,0);">k</span><span style="color:rgb(74,85,219);">]</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(0,0,0);">,</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(0,0,0);">,</span><span style="color:rgb(188,143,143);">1</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(74,85,219);">[</span><span style="color:rgb(0,0,0);">u1</span><span style="color:rgb(0,0,0);">,</span> <span style="color:rgb(0,0,0);">u2</span><span style="color:rgb(74,85,219);">]</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(0,0,0);">,</span><span style="color:rgb(188,143,143);">2</span><span style="color:rgb(74,85,219);">)</span><span style="color:rgb(0,0,0);">;</span>
<span style="color:rgb(0,0,0);">r</span> <span style="color:rgb(92,92,92);">=</span> <span style="color:rgb(50,185,185);">sign</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">u2</span> <span style="color:rgb(0,0,0);">–</span> <span style="color:rgb(0,0,0);">u1</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">*</span> <span style="color:rgb(74,85,219);">(</span><span style="color:rgb(188,143,143);">2</span> <span style="color:rgb(92,92,92);">*</span> <span style="color:rgb(74,85,219);">(</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">Fm</span> <span style="color:rgb(92,92,92);">+</span> <span style="color:rgb(0,0,0);">M</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">*</span> <span style="color:rgb(50,185,185);">abs</span><span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">u2</span> <span style="color:rgb(0,0,0);">–</span> <span style="color:rgb(0,0,0);">u1</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">+</span> <span style="color:rgb(0,0,0);">k</span> <span style="color:rgb(92,92,92);">*</span> <span style="color:rgb(74,85,219);">(</span><span style="color:rgb(0,0,0);">u2</span><span style="color:rgb(92,92,92);">^</span><span style="color:rgb(188,143,143);">2</span> <span style="color:rgb(0,0,0);">–</span> <span style="color:rgb(0,0,0);">u1</span><span style="color:rgb(92,92,92);">^</span><span style="color:rgb(188,143,143);">2</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">/</span> <span style="color:rgb(188,143,143);">2</span><span style="color:rgb(74,85,219);">)</span> <span style="color:rgb(92,92,92);">/</span><span style="color:rgb(0,0,0);">m</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.5</span><span style="color:rgb(0,0,0);">;

<tt>--> r = sign(u2 – u1) * (2 * ((Fm + M) * abs(u2 – u1) + k * (u2^2 – u1^2) / 2) /m)^0.5;</tt><tt>
</tt><tt>r = sign(u2 – u1) * (2 * ((Fm + M) * abs(u2 – u1) + k * (u2^2 – u1^2) / 2) /m)^0.5;</tt><tt>
</tt><tt>            ^~~^</tt><tt>
</tt><tt>Error: syntax error, unexpected identifier, expecting "," or )</tt><tt>
</tt>
</span></pre>
    Puzzling... Hard to find why, but finally:<br>
    <br>
    You have likely copy/pasted this formula from a "formatted"
    document, maybe a web site, etc.<br>
    Then, the included <tt>"–"</tt> character is not the mathematical
    minus, that is <tt>"-"</tt>.<br>
    This puzzles the Scilab's parser.<br>
    <br>
    If you input the same formula, just replacing the hyphens with the
    true minus, it works,<br>
    in the console as well as in Xcos.<br>
    <br>
    <font size="-1"><tt>--> r = sign(u2 - u1) * (2 * ((Fm + M) *
        abs(u2 - u1) + k * (u2^2 - u1^2) / 2) /m)^0.5</tt><tt><br>
      </tt><tt> r  = </tt><tt><br>
      </tt><tt>   2.6457513</tt><tt><br>
      </tt></font><br>
    HTH<br>
    Samuel<br>
    <br>
  </body>
</html>