# Question:Help! Maple and Matlab calculation. How to teach Matlab to calculate smartly?

## Question:Help! Maple and Matlab calculation. How to teach Matlab to calculate smartly?

Maple

Hi all,

I am helping my friend on this issue.

We have some numerical computation which involves a lot of "log(g)*g" and we have to evaluate these for g on the interval [0, 1]. The reason that 0 is included is that because the singularity at 0 is removable.

In Maple:

> x := 0; log(x)*x;
%;
0
Error, (in ln) numeric exception: division by zero

In Matlab:

>> x=0; log(x)*x

ans =

NaN

Our procedure is that we first derive very complicated symbolic expressions in Maple and then translate into Matlab to get numerical calculation.

How do handle the above "NaN" in Matlab? This is just one intermediate step using "log(x)*x" (this expression is from Maple symbolic results).

Of course we could take a limit at x=0 and handle that case in Matlab separately, let say when |x| < 1e-5, we switch to this limiting result; and when |x|>=1e-5, we still use the numerical approach.

But this creates a discontinuity at |x|=1e-5 in numerical results in Matlab.

Could anybody shed some lights on us about how to handle such a situation?

Thanks a lot!

﻿