Why do I get the message NaN?
Show older comments
Hello,
I would like to calculate the expression below. But I always get: NaN. I can´t find my mistake.
Can somebody help me?
I4=5.718534314;
I5=-0.001546715453;
Cov__B_C_direct =1125899906842624*exp(I4^(4831891999187463/1125899906842624))*exp(8187485477687969/1715238139330560)*((230090095199403*...
exp(-I4^(4831891999187463/1125899906842624))*exp(-8187485477687969/1715238139330560)*I4^...
(3705992092344839/1125899906842624))/1233348233694652400 - (2558136220007576158378628793351*...
exp(-I4^(4831891999187463/1125899906842624))*exp(-8187485477687969/1715238139330560)*I5*I4^(2580092185502215/1125899906842624))/10681743549394799937933824491520 + ...
(3335311470258831134378888053767*exp(-I4^(4831891999187463/1125899906842624))*exp(-8187485477687969/1715238139330560)*...
I5* I4^(3705992092344839/562949953421312))/10681743549394799937933824491520)
1 Comment
Star Strider
on 30 Jan 2016
When I converted it into a symbolic by putting:
syms I4 I5
between the assignments to those and your equation, I got:
Error using mupadengine/feval (line 163)
Exponent overflow.
I suspect you’re dividing Inf/Inf, which will evaluate to NaN.
This is an observation, not an Answer, so I’m not posting it as one.
Accepted Answer
More Answers (1)
Abhisek Roy
on 3 Feb 2016
0 votes
Hi Max,
It looks like some part of the expression reaches the maximum representable value for a double precision floating point number (which you can find using the function 'realmax'), it overflows, so it is represented as 'inf'. At this point, the numerical result no longer correctly represents the value of the function.
As a workaround for this type of issue try to re-express the function in a different form which does not contain quantities that overflow. In this case, simplify it if possible.
Categories
Find more on Conversion Between Symbolic and Numeric in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!