Error, (in ...) numeric exception: division by zero - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Error Message Guide : divisionbyzero

Error,  (in ...) numeric exception: division by zero

Description

In Maple, dividing by zero produces a division by zero error. However, sometimes the division by zero is not apparent.

Examples

Example 1

restart

ln(0)

Error, (in ln) numeric exception: division by zero

tanπ2

Error, (in tan) numeric exception: division by zero

Solution: Replace the NumericEventHandler for division by zero.

NumericEventHandlerdivision_by_zero=procoperator,operands,defVal     if operator=ln then return else return defVal end if   end proc; division_by_zero=procoperator,operands,defVal defVal end proc;

division_by_zero=default

division_by_zero=procoperator,operands,defValdefValend proc

(2.1)

ln0

∞

(2.2)

tanπ2

∞+∞I

(2.3)

restart

Example 2

f:=sina2+cosa21x

f:=sina2+cosa21x

(2.4)

intsinf,x;

cossina2+cosa21xsina2+cosa21

(2.5)

simplify;

Error, (in simplify/trig) numeric exception: division by zero

The weakness is in int, which does not identify sina2+cosa21 as equal to 0.  Simplifying the expanded output from int then leads to division by zero. A stronger zero-testing routine is required earlier in the process. However, using the strongest possible zero-testing routine by default is inefficient.

Solution 1: For a single expression, simplify before taking the integral.

restart

f:=sina2+cosa21x

f:=sina2+cosa21x

(2.6)

intsimplifysinf,x;

0

(2.7)

Solution 2: For numerous expressions, control zero-testing using Normalizer.

restart

Normalizer:=simplify;

Normalizer:=simplify

(2.8)

f:=sina2+cosa21x

f:=sina2+cosa21x

(2.9)

intsinf,x;

0

(2.10)

See Also

int, ln, Normalizer, NumericEventHandler, simplify, tan


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam