[Scilab-users] {EXT} Re: [EXTERNAL] Re: acos leads to complex values
Dang Ngoc Chan, Christophe
Christophe.Dang at sidel.com
Wed Jan 30 09:13:26 CET 2019
Hello,
> De : Federico Miyara
> Envoyé : mardi 29 janvier 2019 21:36
>
> This is an improved version of the acos function with input argument check:
I would personally write it in the following way:
function y=acos1(x)
// Check if components are real
// Check if components are real and belong to [-1, 1]
absx = abs(x);
in_domain = (imag(x)==0) & (-1<=absx) & (absx<=1);
// Imaginary part of acos(x) is accepted only if
// x does not belong to [-1, 1]
y=acos(x);
y(in_domain) = real(y(in_domain));
endfunction
Regards
--
Christophe Dang Ngoc Chan
Mechanical calculation engineer
Public
This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20190130/ef8638ba/attachment.htm>
More information about the users
mailing list