C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

implementation of the complex airy function

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Laurent
Guest





PostPosted: Fri Jun 25, 2004 9:52 am    Post subject: implementation of the complex airy function Reply with quote



I am looking for an implementation of the complex airy function
in C/C++/C#. Can anybody help me find a piece of code for this
function ?

Thanks in advance

Laurent
Back to top
Dan Pop
Guest





PostPosted: Fri Jun 25, 2004 12:03 pm    Post subject: Re: implementation of the complex airy function Reply with quote



In <ee6d6e5c.0406250152.6cc14cee (AT) posting (DOT) google.com> [email]laurent.faivre (AT) orange (DOT) fr[/email] (Laurent) writes:

Quote:
I am looking for an implementation of the complex airy function
in C/C++/C#. Can anybody help me find a piece of code for this
function ?

What was your C *and* C++ language question?

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: [email]Dan.Pop (AT) ifh (DOT) de[/email]

Back to top
puppet_sock@hotmail.com
Guest





PostPosted: Fri Jun 25, 2004 6:02 pm    Post subject: Re: implementation of the complex airy function Reply with quote



[email]laurent.faivre (AT) orange (DOT) fr[/email] (Laurent) wrote in message news:<ee6d6e5c.0406250152.6cc14cee (AT) posting (DOT) google.com>...
Quote:
I am looking for an implementation of the complex airy function
in C/C++/C#. Can anybody help me find a piece of code for this
function ?

It's kind of off topic in c.l.c++. But the Airy function can
be implemented in terms of a Bessel function. Bessel fcns
should be in any numerical package.
Socks

Back to top
jacob navia
Guest





PostPosted: Sat Jun 26, 2004 2:32 pm    Post subject: Re: implementation of the complex airy function Reply with quote

Salut Laurent!

/* airy.c CCMATH mathematics library source code.
*
* Copyright (C) 2000 Daniel A. Atkinson All rights reserved.
* This code may be redistributed under the terms of the GNU library
* public license (LGPL). ( See the lgpl.license file for details.)
* ------------------------------------------------------------------------
*/
#include <math.h>
double airy(double x,int df)
{
double f,y,a,b,s;
int p;
double u=.258819403792807,v=.355028053887817;
if(x<=1.7 && x>= -6.9){
y=x*x*x/9.;
if(df){
b= -(a=2./3.);
v*=x*x/2.;
u= -u;
}
else{
a= -(b=1./3.);
u*= -x;
}
for(p=1,f=u+v;;++p){
v*=y/(p*(a+=1.));
u*=y/(p*(b+=1.));
f+=(s=u+v);
if(fabs(s)<1.e-14) break;
}
}
else{
s=1./sqrt(v=3.14159265358979);
y=fabs(x);
if(df) s*=pow(y,.25);
else s/=pow(y,.25);
y*=2.*sqrt(y)/3.;
if(x>0.){
a=12./pow(y,.333);
p=a*a;
if(df) a= -7./36.;
else a=5./36.;
b=2.*(p+y);
f=1.;
u=x=0.;
s*=exp(-y)/2.;
for(; p>0 ;--p,b-=2.){
y=(b*f-(p+1)*x)/(p-1+a/p);
x=f;
u+=(f=y);
}
if(df) f*= -s/u;
else f*=s/u;
}
else{
x=y-v/4.;
y*=2.;
b=.5;
f=s;
v=0.;
if(df) a=2./3.;
else a=1./3.;
for(p=1; (u=fabs(s))>1.e-14 ;++p,b+=1.){
s*=(a+b)*(a-b)/(p*y);
if(fabs(s)>=u) break;
if(!(p&1)){
s= -s;
f+=s;
}
else v+=s;
}
if(df) f=f*sin(x)+v*cos(x);
else f=f*cos(x)-v*sin(x);
}
}
return f;
}
----------------------------------------------------------------------------
------------------
CCMATH: A Mathematics Library
-----------------------------
Version 2.2.0

developed and maintained by
Daniel A. Atkinson
<DanAtk (AT) aol (DOT) com>


Back to top
Laurent
Guest





PostPosted: Mon Jun 28, 2004 6:47 am    Post subject: Re: implementation of the complex airy function Reply with quote

Hi Jacob

Thanks a lot for replying with a piece of code. Unfortunatly what I am looking
for is this function with a complex number in argument and not a real number.

Feel free if you have any ideas.

Laurent

"jacob navia" <jacob (AT) jacob (DOT) remcomp.fr> wrote

Quote:
Salut Laurent!

/* airy.c CCMATH mathematics library source code.
*
* Copyright (C) 2000 Daniel A. Atkinson All rights reserved.
* This code may be redistributed under the terms of the GNU library
* public license (LGPL). ( See the lgpl.license file for details.)
* ------------------------------------------------------------------------
*/
#include <math.h
double airy(double x,int df)
{
double f,y,a,b,s;
int p;
double u=.258819403792807,v=.355028053887817;
if(x<=1.7 && x>= -6.9){
y=x*x*x/9.;
if(df){
b= -(a=2./3.);
v*=x*x/2.;
u= -u;
}
else{
a= -(b=1./3.);
u*= -x;
}
for(p=1,f=u+v;;++p){
v*=y/(p*(a+=1.));
u*=y/(p*(b+=1.));
f+=(s=u+v);
if(fabs(s)<1.e-14) break;
}
}
else{
s=1./sqrt(v=3.14159265358979);
y=fabs(x);
if(df) s*=pow(y,.25);
else s/=pow(y,.25);
y*=2.*sqrt(y)/3.;
if(x>0.){
a=12./pow(y,.333);
p=a*a;
if(df) a= -7./36.;
else a=5./36.;
b=2.*(p+y);
f=1.;
u=x=0.;
s*=exp(-y)/2.;
for(; p>0 ;--p,b-=2.){
y=(b*f-(p+1)*x)/(p-1+a/p);
x=f;
u+=(f=y);
}
if(df) f*= -s/u;
else f*=s/u;
}
else{
x=y-v/4.;
y*=2.;
b=.5;
f=s;
v=0.;
if(df) a=2./3.;
else a=1./3.;
for(p=1; (u=fabs(s))>1.e-14 ;++p,b+=1.){
s*=(a+b)*(a-b)/(p*y);
if(fabs(s)>=u) break;
if(!(p&1)){
s= -s;
f+=s;
}
else v+=s;
}
if(df) f=f*sin(x)+v*cos(x);
else f=f*cos(x)-v*sin(x);
}
}
return f;
}
----------------------------------------------------------------------------
------------------
CCMATH: A Mathematics Library
-----------------------------
Version 2.2.0

developed and maintained by
Daniel A. Atkinson
[email]DanAtk (AT) aol (DOT) com[/email]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.