how can I fix this error??can you help me??

1 view (last 30 days)
tinkerbell
tinkerbell on 5 Jan 2014
Answered: Walter Roberson on 5 Jan 2014
>> syms x;
>> f1=log(x+2);
>> f2=2*log(x);
>> S=int(abs(f1-f2),1/exp(1),2)
S =
(6627126856707895*log(6627126856707895/18014398509481984))/9007199254740992 - (42655923875671863*log(42655923875671863/18014398509481984))/18014398509481984 - (4*log(4) - 4*log(2) + 2)/sign(2*log(2) - log(4)) - 6627126856707895/18014398509481984
>> double(S)
??? Error using ==> mupadmex
Error in MuPAD command: Division by zero [_power];
during evaluation of 'mllib::double'
Error in ==> sym.sym>sym.double at 927
Xstr = mupadmex('mllib::double', S.s, 0);
>>

Answers (1)

Walter Roberson
Walter Roberson on 5 Jan 2014
sign(2*log(2) - log(4)) is sign(0) which is 0 in MATLAB. As that expression is being divided by, this becomes a division by 0.
I do not know why sign(2*log(2) - log(4)) is being generated.
What I would suggest you try is
S=int(abs(f1-f2),1/exp(sym(1)),2)
That way the exp(1) will become a symbolic parameter instead of an approximate floating point parameter.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!