Difference between revisions of "Sqrt"

m (adding doc status category)
Line 2: Line 2:
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
   
 
   
Sqrt(X) returns the square root of XX must be positive or zero.
+
<code>Sqrt(x)</code> returns the square root of xUnless you are using complex numbers, x should be positive or zero.
 +
 
 +
= Square root of negative numbers =
 +
 
 +
''new to [[Analytica 4.5]]''
 +
 
 +
When you evaluate [[Sqrt]] of a negative real number, the behavior of [[Sqrt]] depends on whether you have [[EnableComplexNumbers|enabled complex numbers]]. 
 +
 
 +
If you have not enabled complex numbers, a warning is issued, [[Error Messages/4294941821|Square root of a negative number]], which you won't see if you have the [[Preferences|Show Result Warnings]] preference turned off, or if the expression is inside [[IgnoreWarnings]].  If you elect to ignore warnings, the result is [[NaN]].
 +
 
 +
If you have enabled complex numbers, the result is an imaginary number.  For example, <code>[[Sqrt]](-1)</code> returns 1j.
 +
 
 +
= Square root of complex numbers =
 +
 
 +
If you evaluate [[Sqrt]] on a complex number, the result is a complex number. This does not depend on having [[EnableComplexNumbers|complex numbers enabled]].
 +
 
 +
= Examples =
 +
 
 +
:<code>[[Sqrt]](0)</code> &rarr; 0
 +
:<code>[[Sqrt]](1)</code> &rarr; 1
 +
:<code>[[Sqrt]](25)</code> &rarr; 5
 +
:<code>[[Sqrt]](3^2 + 4^2)</code> &rarr; 5
 +
:<code>[[Sqrt]](0..10)</code> &rarr; [0, 1, 1.414, 1.732, 2, 2.236, 2.449, 2.646, 2.828, 3, 3.162]
 +
 
 +
:<code>[[Sqrt]](1j)</code> &rarr; 0.707 + 0.707j
 +
:<code>[[Sqrt]](2j)</code> &rarr; 1+1j
 +
:<code>[[Sqrt]](-3-2j)</code> &rarr; .5502-1.817j
 +
 
 +
With complex numbers not enabled:
 +
:<code>[[Sqrt]](-1)</code> &rarr; [[NaN]]    ''{ with a warning }''
 +
 
 +
With complex numbers enabled:
 +
:<code>[[Sqrt]](-1)</code> &rarr; 1j
 +
 
 +
 
 +
= See Also =
 +
 
 +
* [[Complex Numbers]]
 +
* [[Sqrt]]

Revision as of 18:46, 11 April 2013


Sqrt(x) returns the square root of x. Unless you are using complex numbers, x should be positive or zero.

Square root of negative numbers

new to Analytica 4.5

When you evaluate Sqrt of a negative real number, the behavior of Sqrt depends on whether you have enabled complex numbers.

If you have not enabled complex numbers, a warning is issued, Square root of a negative number, which you won't see if you have the Show Result Warnings preference turned off, or if the expression is inside IgnoreWarnings. If you elect to ignore warnings, the result is NaN.

If you have enabled complex numbers, the result is an imaginary number. For example, Sqrt(-1) returns 1j.

Square root of complex numbers

If you evaluate Sqrt on a complex number, the result is a complex number. This does not depend on having complex numbers enabled.

Examples

Sqrt(0) → 0
Sqrt(1) → 1
Sqrt(25) → 5
Sqrt(3^2 + 4^2) → 5
Sqrt(0..10) → [0, 1, 1.414, 1.732, 2, 2.236, 2.449, 2.646, 2.828, 3, 3.162]
Sqrt(1j) → 0.707 + 0.707j
Sqrt(2j) → 1+1j
Sqrt(-3-2j) → .5502-1.817j

With complex numbers not enabled:

Sqrt(-1)NaN { with a warning }

With complex numbers enabled:

Sqrt(-1) → 1j


See Also

Comments


You are not allowed to post comments.