@finite_math,finite_inverse,finite_divide,finite_power,finite_exp,finite_log


The global macros are created in \Core\Math.jl.


Global Macros

Description

@finite_math

The `@finite_math` macro transforms mathematical expressions in the input code to their finite versions. 

A macro that transforms the standard mathematical operations in the input expression `expr` to their finite versions.

The macro replaces division, logarithm, exponentiation, and power operations with `finite_divide`, `finite_log`, `finite_exp`, and `finite_power` functions, respectively.

In Julia, NaN stands for "Not a Number" and is a special floating-point value used to represent undefined or unrepresentable numerical results, such as the result of 0/0 or square root of -1. It is a standard feature of IEEE 754 floating-point arithmetic, designed to allow computations to continue without crashing, rather than halting execution when an indeterminate result occurs.

In other words, it handles math in which there is division by zero. Without the @finite_math macro, a division by zero is returned as "not a number" (NaN). This function will turn into zero.

It takes a single expression `expr` as input.

  # The macro traverses the input expression, and for each mathematical operation, it replaces the standard operation with its corresponding finite version.

  # Once all the operations are replaced, the transformed expression is returned.