Calculation of cosh, sinh big numbers

Hi,
let t is time. How can I calculate and plot:
for i=1:10
y=0.912*sin(314.0*t) - 3.31*cos(314.0*t) + (3.31*(cosh(1399.0*t) + 0.484*sinh(1399.0*t)))/exp(1500.0*t)
current(:,i)=(eval(y))'
end
I got NaN from cosh and sinh for time 0.51....how can I block cosh, sinh if actual value is NaN?
Thank you

 Accepted Answer

Roger Stafford
Roger Stafford on 27 Feb 2014
Edited: Roger Stafford on 27 Feb 2014
All three quantities, cosh(1399.0*t), sinh(1399.0*t), and exp(1500.0*t), will fall far beyond the realmax limit. I would suggest you refer to the definitions of sinh and cosh and modify your expression as follows. Replace cosh(1399.0*t)/exp(1500.0*t) by (exp(-101*t)+exp(-2899*t))/2 and similarly with sinh. That way you will not get NaNs even though these are equivalent expressions.

4 Comments

Hello Mr. Stafford, how can I replace sinh, cosh automatically? For example:
a=[0.794*cos(314.0*t) - 5.1*sin(314.0*t) - (0.794*(cosh(1399.0*t) + 4.06*sinh(1399.0*t)))/exp(1500.0*t);
5.1*sin(314.0*t) - 0.794*cos(314.0*t) + (0.794*(cosh(1399.0*t) + 4.06*sinh(1399.0*t)))/exp(1500.0*t);
5.1*sin(314.0*t) - 0.794*cos(314.0*t) + (0.794*(cosh(1399.0*t) + 4.06*sinh(1399.0*t)))/exp(1500.0*t);
0.912*sin(314.0*t) - 3.31*cos(314.0*t) + (3.31*(cosh(1399.0*t) + 0.484*sinh(1399.0*t)))/exp(1500.0*t);
0.912*sin(314.0*t) - 3.31*cos(314.0*t) + (3.31*(cosh(1399.0*t) + 0.484*sinh(1399.0*t)))/exp(1500.0*t);
2.52*cos(314.0*t) + 4.19*sin(314.0*t) - (2.52*(cosh(1399.0*t) - 0.644*sinh(1399.0*t)))/exp(1500.0*t)]
thank you
there exist any command to replace it? thank you
I would replace that particular expression with this equivalent one:
a=[ -5.1 0.794 -0.794 -0.794 4.06 4.06 ;
5.1 -0.794 0.794 0.794 4.06 4.06 ;
5.1 -0.794 0.794 0.794 4.06 4.06 ;
0.912 -3.31 3.31 3.31 0.484 0.484 ;
0.912 -3.31 3.31 3.31 0.484 0.484 ;
4.19 2.52 -2.52 -2.52 -0.644 -0.644 ] * ...
[ sin(314.0*t)*exp(-1500.0*t);
cos(314.0*t)*exp(-1500.0*t);
exp(-101*t)/2 ;
exp(-1899*t)/2 ;
exp(-101*t)/2 ;
-exp(-1899*t)/2 ];
I don't know any way of doing this sort of thing "automatically", but maybe the method you see here will suggest some kind of simplification for whatever you are doing. You will notice that the terms in the above never grow large with t. In fact they will essentially disappear after t takes on appreciable sizes.
Note: I would suggest that you let t = 0.001*rand several times and for each value of t compare your original 'a' with the above 'a' to ensure that they are essentially equivalent and that I didn't make some algebraic blunder.
OK, thank you.
It is not your fault, that there is no automatic function.
Thank you

Sign in to comment.

More Answers (0)

Categories

Tags

Asked:

on 27 Feb 2014

Commented:

on 9 Mar 2014

Community Treasure Hunt

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

Start Hunting!