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( | + | <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 = | ||
+ | |||
+ | ''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> → 0 | ||
+ | :<code>[[Sqrt]](1)</code> → 1 | ||
+ | :<code>[[Sqrt]](25)</code> → 5 | ||
+ | :<code>[[Sqrt]](3^2 + 4^2)</code> → 5 | ||
+ | :<code>[[Sqrt]](0..10)</code> → [0, 1, 1.414, 1.732, 2, 2.236, 2.449, 2.646, 2.828, 3, 3.162] | ||
+ | |||
+ | :<code>[[Sqrt]](1j)</code> → 0.707 + 0.707j | ||
+ | :<code>[[Sqrt]](2j)</code> → 1+1j | ||
+ | :<code>[[Sqrt]](-3-2j)</code> → .5502-1.817j | ||
+ | |||
+ | With complex numbers not enabled: | ||
+ | :<code>[[Sqrt]](-1)</code> → [[NaN]] ''{ with a warning }'' | ||
+ | |||
+ | With complex numbers enabled: | ||
+ | :<code>[[Sqrt]](-1)</code> → 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)
→ 0Sqrt(1)
→ 1Sqrt(25)
→ 5Sqrt(3^2 + 4^2)
→ 5Sqrt(0..10)
→ [0, 1, 1.414, 1.732, 2, 2.236, 2.449, 2.646, 2.828, 3, 3.162]
With complex numbers not enabled:
With complex numbers enabled:
Sqrt(-1)
→ 1j
Enable comment auto-refresher