boyfarrell
Registered
Hello everybody,
I need to calculate hyperbolic sin of large numbers, e.g. sinh(1000). However I start to get infinites after sinh(710). How can I do this?
Here is some code that calculates sinh in sinh(700) region for float, double and long double numbers. Why does long double return infinities at the same point as double does?
Here is the output:
Any ideas? Daniel.
I need to calculate hyperbolic sin of large numbers, e.g. sinh(1000). However I start to get infinites after sinh(710). How can I do this?
Here is some code that calculates sinh in sinh(700) region for float, double and long double numbers. Why does long double return infinities at the same point as double does?
Code:
#import <math.h>
#import <stdio.h>
int main(int argc, char *argv[])
{
float flo;
printf("\nfloat precision\n");
int i;
for(i=0; i < 20; i++)
{
flo = sinh(700.0+i);
printf("sinh(%f) = %g\n ",(700.0+i), flo);
}
double doub;
printf("\ndouble precision\n");
for(i=0; i < 20; i++)
{
doub = sinh(700.0+i);
printf("sinh(%lf) = %g\n ",(700.0+i), doub);
}
long double ldoub;
long double x;
printf("\nlong double precision\n");
for(x=700; x < 720; x++)
{
ldoub = sinhl(x);
printf("sinhl(%Lg) = %Lg\n", x , ldoub);
}
return 0;
}
Code:
[Session started at 2005-11-25 17:26:05 +0000.]
float precision
sinh(700.000000) = inf
sinh(701.000000) = inf
sinh(702.000000) = inf
sinh(703.000000) = inf
sinh(704.000000) = inf
sinh(705.000000) = inf
sinh(706.000000) = inf
sinh(707.000000) = inf
sinh(708.000000) = inf
sinh(709.000000) = inf
sinh(710.000000) = inf
sinh(711.000000) = inf
sinh(712.000000) = inf
sinh(713.000000) = inf
sinh(714.000000) = inf
sinh(715.000000) = inf
sinh(716.000000) = inf
sinh(717.000000) = inf
sinh(718.000000) = inf
sinh(719.000000) = inf
double precision
sinh(700.000000) = 5.07116e+303
sinh(701.000000) = 1.37848e+304
sinh(702.000000) = 3.74711e+304
sinh(703.000000) = 1.01857e+305
sinh(704.000000) = 2.76876e+305
sinh(705.000000) = 7.52627e+305
sinh(706.000000) = 2.04585e+306
sinh(707.000000) = 5.5612e+306
sinh(708.000000) = 1.51169e+307
sinh(709.000000) = 4.1092e+307
sinh(710.000000) = 1.117e+308
sinh(711.000000) = inf
sinh(712.000000) = inf
sinh(713.000000) = inf
sinh(714.000000) = inf
sinh(715.000000) = inf
sinh(716.000000) = inf
sinh(717.000000) = inf
sinh(718.000000) = inf
sinh(719.000000) = inf
long double precision
sinhl(700) = 5.07116e+303
sinhl(701) = 1.37848e+304
sinhl(702) = 3.74711e+304
sinhl(703) = 1.01857e+305
sinhl(704) = 2.76876e+305
sinhl(705) = 7.52627e+305
sinhl(706) = 2.04585e+306
sinhl(707) = 5.5612e+306
sinhl(708) = 1.51169e+307
sinhl(709) = 4.1092e+307
sinhl(710) = 1.117e+308
sinhl(711) = inf
sinhl(712) = inf
sinhl(713) = inf
sinhl(714) = inf
sinhl(715) = inf
sinhl(716) = inf
sinhl(717) = inf
sinhl(718) = inf
sinhl(719) = inf
sinh has exited with status 0.