# Difference between revisions of "Error Messages/40506"

m (history) |
|||

Line 1: | Line 1: | ||

− | + | [[Category: Error messages]] | |

− | :<code>Variable Va3 computes the product INF*0, resulting in NaN (an indeterminant number).</code> | + | == Example warning text == |

+ | |||

+ | :<code>''Variable Va3 computes the product INF*0, resulting in NaN (an indeterminant number).''</code> | ||

== Description == | == Description == | ||

Line 7: | Line 9: | ||

You probably know that any number multiplied by zero is zero, and that any positive number multiplied by infinity is infinity. But when you consider multiplying 0 times infinity, both of these cannot be true. In mathematics, the product of zero times infinity is ''indeterminant'', or not defined. In Analytica (as well as in most software programs), the special numeric value [[NaN]] denotes an indeterminant number. | You probably know that any number multiplied by zero is zero, and that any positive number multiplied by infinity is infinity. But when you consider multiplying 0 times infinity, both of these cannot be true. In mathematics, the product of zero times infinity is ''indeterminant'', or not defined. In Analytica (as well as in most software programs), the special numeric value [[NaN]] denotes an indeterminant number. | ||

− | By employing limits, it is possible to construct theoretical mathematical constructions that imply a finite result for INF * 0. For example, consider the function | + | By employing limits, it is possible to construct theoretical mathematical constructions that imply a finite result for <code>INF*0</code>. For example, consider the function |

:<math>f(x) = tan(x) * x</math> | :<math>f(x) = tan(x) * x</math> | ||

+ | |||

(Note: ''x'' here is in radians, whereas the [[Tan]](x) function in Analytica expects ''x'' to be in degrees). At <math>x=\pi/2</math>, INF*0 occurs, so that <math>f(\pi/2)</math> is not defined; however, | (Note: ''x'' here is in radians, whereas the [[Tan]](x) function in Analytica expects ''x'' to be in degrees). At <math>x=\pi/2</math>, INF*0 occurs, so that <math>f(\pi/2)</math> is not defined; however, | ||

:<math>\lim_{x\rightarrow \pi/2} f(x) = -1</math> | :<math>\lim_{x\rightarrow \pi/2} f(x) = -1</math> | ||

− | |||

− | The IEEE 754 standard is a widely accepted standard for how floating point numbers should represented in a computer's memory, and how arithmetic operations should be carried out. Analytica follows the IEEE 754 standard, which stipulates that the special value INF multiplied by zero should be the special value NaN. | + | implying that the correct value here for <code>INF*0</code> should be <code>-1</code>. But if you apply the same logic to <math>g(x)=2*f(x)</math>, you would conclude that the correct value for <code>INF*0</code> ought to be <code>-2</code>. You can see that with different mathematical constructions, you can create a valid argument that any value you desire is the ''natural'' result of <code>INF*0</code>. Because the multiplication operator can't possibly know which theoretical mathematical construction should apply, it cannot possibly know what the "correct" result should be, and hence, this is why an indeterminate number is returned. |

+ | |||

+ | The IEEE 754 standard is a widely accepted standard for how floating point numbers should represented in a computer's memory, and how arithmetic operations should be carried out. Analytica follows the IEEE 754 standard, which stipulates that the special value [[INF]] multiplied by zero should be the special value [[NaN]]. | ||

In some cases, you might use multiplication to zero out certain values, as in this example | In some cases, you might use multiplication to zero out certain values, as in this example | ||

− | :<code>( direction = 'East' Or direction = 'West' ) * distance</code> | + | |

− | This is a valid and concise way of doing this, but only provided that <code>distance</code> is guaranteed to be finite. If there is any chance that <code>distance</code> could validly be INF, then you would need to use | + | :<code>(direction = 'East' Or direction = 'West')*distance</code> |

− | :<code> | + | |

− | Zeroing by multiplication does have the advantage that it will trigger this warning if an INF is encountered. This is an advantage in that you might catch an error in your model logic when a non-finite value would never occur. | + | This is a valid and concise way of doing this, but only provided that <code>distance</code> is guaranteed to be finite. If there is any chance that <code>distance</code> could validly be [[INF]], then you would need to use |

+ | |||

+ | :<code>If direction = 'East' Or direction = 'West' Then distance Else 0</code> | ||

+ | |||

+ | Zeroing by multiplication does have the advantage that it will trigger this warning if an [[INF]] is encountered. This is an advantage in that you might catch an error in your model logic when a non-finite value would never occur. | ||

== History == | == History == | ||

− | In Analytica 3.x and earlier, Analytica returned 0 for NaN*0. This was changed in [[Analytica 4.0]] to comply with the IEEE 754 standard. | + | In Analytica 3.x and earlier, Analytica returned 0 for <code>NaN*0</code>. This was changed in [[What's new in Analytica 4.0?|Analytica 4.0]] to comply with the IEEE 754 standard. |

== See Also == | == See Also == | ||

− | + | * [[Numbers]] | |

− | * [[NaN]] | + | * [[NaN|NaN -- Not a Number]] |

+ | * [[INF]] | ||

+ | * [[If-Then-Else]] |

## Revision as of 20:31, 27 April 2016

## Example warning text

*Variable Va3 computes the product INF*0, resulting in NaN (an indeterminant number).*

## Description

You probably know that any number multiplied by zero is zero, and that any positive number multiplied by infinity is infinity. But when you consider multiplying 0 times infinity, both of these cannot be true. In mathematics, the product of zero times infinity is *indeterminant*, or not defined. In Analytica (as well as in most software programs), the special numeric value NaN denotes an indeterminant number.

By employing limits, it is possible to construct theoretical mathematical constructions that imply a finite result for `INF*0`

. For example, consider the function

- $ f(x) = tan(x) * x $

(Note: *x* here is in radians, whereas the Tan(x) function in Analytica expects *x* to be in degrees). At $ x=\pi/2 $, INF*0 occurs, so that $ f(\pi/2) $ is not defined; however,

- $ \lim_{x\rightarrow \pi/2} f(x) = -1 $

implying that the correct value here for `INF*0`

should be `-1`

. But if you apply the same logic to $ g(x)=2*f(x) $, you would conclude that the correct value for `INF*0`

ought to be `-2`

. You can see that with different mathematical constructions, you can create a valid argument that any value you desire is the *natural* result of `INF*0`

. Because the multiplication operator can't possibly know which theoretical mathematical construction should apply, it cannot possibly know what the "correct" result should be, and hence, this is why an indeterminate number is returned.

The IEEE 754 standard is a widely accepted standard for how floating point numbers should represented in a computer's memory, and how arithmetic operations should be carried out. Analytica follows the IEEE 754 standard, which stipulates that the special value INF multiplied by zero should be the special value NaN.

In some cases, you might use multiplication to zero out certain values, as in this example

`(direction = 'East' Or direction = 'West')*distance`

This is a valid and concise way of doing this, but only provided that `distance`

is guaranteed to be finite. If there is any chance that `distance`

could validly be INF, then you would need to use

`If direction = 'East' Or direction = 'West' Then distance Else 0`

Zeroing by multiplication does have the advantage that it will trigger this warning if an INF is encountered. This is an advantage in that you might catch an error in your model logic when a non-finite value would never occur.

## History

In Analytica 3.x and earlier, Analytica returned 0 for `NaN*0`

. This was changed in Analytica 4.0 to comply with the IEEE 754 standard.

Enable comment auto-refresher