help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Same .m file: different results with different versions of Octave


From: perseu.as
Subject: Re: Same .m file: different results with different versions of Octave
Date: Sun, 18 Apr 2010 09:02:03 -0800 (PST)

>From GSL-ref: Chapter 5: Complex Numbers

The algorithms take care to avoid unnecessary intermediate underflows 
and overflows, allowing the functions to be evaluated over as much 
of the complex plane as possible.
For multiple-valued functions the branch cuts have been chosen to 
follow the conventions of Abramowitz and Stegun in the Handbook of 
Mathematical Functions. The functions return principal values which 
are the same as those in GNU Calc, which in turn are the same as those 
in Common Lisp, The Language (Second Edition)1 and the HP-28/48 series
of calculators.

C sample code using GSL to compute Sinh(), Cosh(), and Tanh():

#include <stdio.h>
#include <gsl/gsl_complex.h>
#include <gsl/gsl_complex_math.h>

int main(void)
{
 gsl_complex n, s, c, r, t;
 n.dat[0]=711;
 n.dat[1]=711;
 s = gsl_complex_sinh(n);
 c = gsl_complex_cosh(n);
 r = gsl_complex_div(s,c);
 t = gsl_complex_tanh(n);
 printf("GSL 1.8, march/30/2006, Windows XP 32bits\n");
 printf("Complex number n = %-e %-e*i\n", GSL_REAL(n),GSL_IMAG(n));
 printf("Sinh(n) = %-e %-e*i\n", GSL_REAL(s),GSL_IMAG(s));
 printf("Cosh(n) = %-e %-e*i\n", GSL_REAL(c),GSL_IMAG(c));
 printf("Sinh(n)/Cosh(n) = %-e %-e*i\n", GSL_REAL(r),GSL_IMAG(r));
 printf("Tanh(n) = %-e %-e*i\n", GSL_REAL(t),GSL_IMAG(t));
 return 0;
}

Output:

GSL 1.8, march/30/2006, Windows XP 32bits
Complex number n = 7.110000e+002 7.110000e+002*i
Sinh(n) = 1.#INF00e+000 1.#INF00e+000*i
Cosh(n) = 1.#INF00e+000 1.#INF00e+000*i
Sinh(n)/Cosh(n) = -1.#IND00e+000 -1.#IND00e+000*i
Tanh(n) = 1.000000e+000 0.000000e+000*i

The limit is near n = 710 + 710i: 

GSL 1.8, march/30/2006, Windows XP 32bits
Complex number n = 7.100000e+002 7.100000e+002*i
Sinh(n) = 1.116997e+308 6.734233e+303*i
Cosh(n) = 1.116997e+308 6.734233e+303*i
Sinh(n)/Cosh(n) = 1.000000e+000 5.325051e-024*i
Tanh(n) = 1.000000e+000 0.000000e+000*i

I think that GSL is more robust than Octave in this case.
-- 
View this message in context: 
http://n4.nabble.com/Same-m-file-different-results-with-different-versions-of-Octave-tp2013296p2014958.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]