Error, (in ...) numeric exception: division by zero
Description
Examples
In Maple, dividing by zero produces a division by zero error. However, sometimes the division by zero is not apparent.
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.
NumericEventHandler⁡division_by_zero=procoperator,operands,defValifoperator=lnthenreturn−∞elsereturndefValend ifend proc;division⁢_by_zero=procoperator,operands,defValdefValend proc
division_by_zero=default
division⁢_by_zero=procoperator,operands,defValdefValend proc
ln⁡0
−∞
∞+∞⁢I
Example 2
f≔sin⁡a2+cos⁡a2−1⁢x
intsinf,x;
−cos⁡sin⁡a2+cos⁡a2−1⁢xsin⁡a2+cos⁡a2−1
simplify;
Error, (in simplify/trig) numeric exception: division by zero
The weakness is in int, which does not identify sin⁡a2+cos⁡a2−1 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.
intsimplifysinf,x;
0
Solution 2: For numerous expressions, control zero-testing using Normalizer.
Normalizer≔`simplify`
Normalizer≔simplify
Normalizer≔`normal`:
See Also
int
ln
Normalizer
NumericEventHandler
simplify
tan
Download Help Document