MagicPlot Manual

Plotting and nonlinear fitting software

User Tools

Site Tools


nan

This is an old revision of the document!


Missing Values (NaN) in Tables and Calculations

In computing, NaN, which stands for Not a Number, is a value or symbol that is usually produced as a result of an operation on invalid input operands. For example, most floating-point units are unable to explicitly calculate the square root of negative numbers, and will instead indicate that the operation was invalid and return a NaN result.

An invalid operation is not the same as an arithmetic overflow (which returns a positive or negative infinity). Arithmetic operations involving NaN always produce NaN, allowing the value to propagate through a calculation so that errors can be detected at the end without extensive testing during intermediate stages. A NaN does not compare equal to any number or NaN.

How does a NaN appear?

There are three kinds of operations which return NaN:

  1. Operations with a NaN as at least one operand, e.g. 1+NaN
  2. Indeterminate forms
    • Divisions 0/0, ∞/∞, ∞/-∞, -∞/∞, -∞/-∞
    • Multiplications 0*∞, 0*(-∞)
    • Power 1^∞
    • Additions ∞+(-∞), (-∞)+∞ and equivalent subtractions.
  3. Real operations with complex results
    • Square root of a negative number
    • Logarithm of a negative number
    • Tangent of an odd multiple of 90 degrees (or π/2 radians)
    • Inverse sine or cosine of a number which is less than -1 or greater than +1.

Examples

Expression Result
0^0 1
0/0 NaN
sqrt(-1) NaN
1/0 Infinity
-1/0 -Infinity

NaN in MagicPlot Tables

In MagicPlot NaN is also used to represent empty cells in Tables.

Statistical functions ignore NaN values in Tables.

NaN in Expressions

You can use predefined constants NaN, nan or NAN in expressions to specify NaN value.

Example

  • If you set a Column Formula if(col(B) >= 0, col(B), NaN), it will return only positive values from column B. Negative values are replaced with NaN value. You can use this expression to filter negative values if you do not want to use them in future calculations. Note that ”Not-a-Number returned at row #” warning can be shown for such expressions.
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
nan.1446974484.txt.gz · Last modified: Sun Nov 8 12:21:24 2015 by 127.0.0.1