<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <font face="Courier New, Courier, monospace">Stephane,<br>
    </font><br>
    <blockquote cite="mid:916859f7-6573-cf33-a2ee-452c30f08120@utc.fr"
      type="cite">
      <blockquote type="cite"
        cite="mid:5C50AE20.1000004@fceia.unr.edu.ar">However, I must say
        that acos(1-%eps) gives on my Scilab 6.0.1 (Windows 7, i7
        processor) a result of <br>
      </blockquote>
      Federico, you have to try 1+%eps or -1-%eps !<br>
    </blockquote>
    <br>
    acos(x) with x > 1 is indeed imaginary, so there is no unexpected
    result.<br>
    <br>
    However, I see now that it hadn't been said that in-domain arguments
    yielded complex results but -1 - %eps was the culprit.<br>
    <br>
    But, for instance, <br>
    <br>
    min([-1-%eps, -1-%eps*2/3, -1, -1+ %eps, -0.9]) >= -1   <br>
    <br>
    is false (on my system), so the test performed by Paul Carrico would
    not succeed if there were a -1-%eps among the values of the vector.<br>
    <br>
    Only when alpha*%eps  with alpha < 0.5 is the minimum the test is
    successful, but in such case acos() yields a value close to %pi, not
    a complex value<br>
    <br>
    --> acos(-1 - 0.499*%eps)<br>
     ans  =<br>
    <br>
       3.141592653589793100000<br>
    <br>
    When alpha > 0.5 the test is not successful nor is the acos()
    real:<br>
    <br>
    --> acos(-1 - 0.50000001*%eps)<br>
     ans  =<br>
    <br>
       3.141592653589793100000 - 0.000000021073424255447i<br>
    <br>
    (this is a binary rounding situation since %eps is 2^-52)<br>
    <br>
    I think the original question is not completely solved. Why a number
    that is not smaller to -1 (asuming the min test is successful)
    yields a complex acos?<br>
    <br>
    An why it does in some systems and not in others? (Assuming Paul's
    report is accurate) <br>
    <br>
    There is another situation where this happens, when an fft is
    performed on a real signal, then filtered in the frequency domain
    and then the ifft is applied. The result should be real, but
    sometimes there are small imaginary parts. <br>
    <br>
    In this case there is a reason, complex exponentials are used in the
    algorithm so arithmetioc errors may not completely cancel out
    because of arithmetic and precision issues.<br>
    <br>
    Federico Miyara<br>
  <div id="DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2">
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
        <tr>
                <td style='border:none;padding:0px 15px 0px 8px'>
                        <a href="https://www.avast.com/antivirus">
                                <img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" alt="Avast logo" />
                        </a>
                </td>
                <td>
                        <p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
                                El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
                                <br><a href="https://www.avast.com/antivirus">www.avast.com</a>
                        </p>
                </td>
        </tr>
</table>
<br />
<a href="#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2" width="1" height="1"> </a></div></body>
</html>