Difference between revisions of "Sqrt"

 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status C]] <!-- For Lumina use, do not change -->
 
   
 
   
<code>Sqrt(x)</code> returns the square root of x.  Unless you are using complex numbers, x should be positive or zero.
 
  
= Square root of negative numbers =
+
==Sqrt(x)==
 
+
Returns the square root of «x».  Unless you are using complex numbers, «x» should be positive or zero.
''new to [[Analytica 4.5]]''
 
  
 +
== Square root of negative numbers ==
 
When you evaluate [[Sqrt]] of a negative real number, the behavior of [[Sqrt]] depends on whether you have [[EnableComplexNumbers|enabled complex numbers]].   
 
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 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.
+
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 =
 
  
 +
== 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]].
 
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 =
+
== Examples ==
 
+
:<code>Sqrt(0) &rarr; 0</code>
:<code>[[Sqrt]](0)</code> &rarr; 0
+
:<code>Sqrt(1) &rarr; 1</code>
:<code>[[Sqrt]](1)</code> &rarr; 1
+
:<code>Sqrt(25) &rarr; 5</code>
:<code>[[Sqrt]](25)</code> &rarr; 5
+
:<code>Sqrt(3^2 + 4^2) &rarr; 5</code>
:<code>[[Sqrt]](3^2 + 4^2)</code> &rarr; 5
+
:<code>Sqrt(0..10) &rarr; [0, 1, 1.414, 1.732, 2, 2.236, 2.449, 2.646, 2.828, 3, 3.162]</code>
:<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(1j) &rarr; 0.707 + 0.707j</code>
:<code>[[Sqrt]](2j)</code> &rarr; 1+1j
+
:<code>Sqrt(2j) &rarr; 1+1j</code>
:<code>[[Sqrt]](-3-2j)</code> &rarr; .5502-1.817j
+
:<code>Sqrt(-3-2j) &rarr; .5502-1.817j</code>
  
 
With complex numbers not enabled:
 
With complex numbers not enabled:
:<code>[[Sqrt]](-1)</code> &rarr; [[NaN]]   ''{ with a warning }''
+
:<code>Sqrt(-1) &rarr; NaN    { with a warning }</code>
  
 
With complex numbers enabled:
 
With complex numbers enabled:
:<code>[[Sqrt]](-1)</code> &rarr; 1j
+
:<code>Sqrt(-1) &rarr; 1j</code>
 
 
  
= See Also =
+
==History==
 +
This function was introduced in [[Analytica 4.5]].
  
 +
== See Also ==
 +
* [[Ln]]
 +
* [[Exp]]
 +
* [[Exponentiation of negative numbers]]
 
* [[Complex Numbers]]
 
* [[Complex Numbers]]
* [[Sqrt]]
+
* [[Error_Messages/4294941821]]

Latest revision as of 22:08, 21 January 2016


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

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

History

This function was introduced in Analytica 4.5.

See Also

Comments


You are not allowed to post comments.