[Scilab-users] Can't understand different answer's on sqrt(x^2+1)

Adrien Vogt-Schilb vogt at centre-cired.fr
Sun May 26 22:57:11 CEST 2013


On 26/05/2013 22:12, Modestas Bunokas wrote:
> Trying to work with vectors, and getting weird results. Example:
>
> m=[9 16];
> sqrt(m^2+1)
> ans = 9.0553851    16.03122
>
> I will get same values if I will use input as vector, or will put values
> manually. But if I use negative numbers like:
>
> m=[-10 -3];
> sqrt(m^2+1)
> ans =10.049876    3.1622777
> ------------------------------
> sqrt(-10^2+1)
> ans =  9.9498744i
> sqrt(-2^2+1)
> ans = 2.8284271i

Hi
m=-2
m^2

computes (-2)^2

while -2^2 computes -(2^2)

if you type sqrt((-2)^2+1) you may get what you expect









> Questions would be - why do I getting complex number as a result by
> inputting m by hand and different result by giving it as vector? Is scilab
> irc channel active for some more arithmetic questions, as I stuck a bit on
> such things with scilab, if not maybe exist any other places to look for
> real time help? I fully understand that it's all because of lack of my
> expierence
>
> p.s. Scilab version 5.4.1, on octave and wolframalpha for sqrt(-2^2+1)
> getting 1.73205i.
>
> Regards
>
>
>
>
>
> --
> View this message in context: http://mailinglists.scilab.org/Can-t-understand-different-answer-s-on-sqrt-x-2-1-tp4026728.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users


-- 
Adrien Vogt-Schilb (Cired)
+33 (0) 1 43 94 73 83




More information about the users mailing list