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 4 2890
In <ee**************************@posting.google.com > la************@orange.fr (Laurent) writes: 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: Da*****@ifh.de la************@orange.fr (Laurent) wrote in message news:<ee**************************@posting.google. com>... 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
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
<Da****@aol.com>
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" <ja***@jacob.remcomp.fr> wrote in message news:<cb**********@news-reader1.wanadoo.fr>... 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 <Da****@aol.com> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Blair |
last post by:
could someone PLEASE tell me why this doesn't work...
-----------------------------------------
#include <complex>
using namespace std;
typedef complex<long double> cld;
void main()
{
cld...
|
by: Pmb |
last post by:
I've been working on creating a Complex class for my own learning purpose
(learn through doing etc.). I'm once again puzzled about something. I can't
figure out how to overload the assignment...
|
by: Laurent |
last post by:
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
|
by: |
last post by:
I have a collectiond derived from NameObjectCollectionBase. FxCop is
complaining that I need to implement a strongly typed CopyTo(MyObjectType,
int)
How do I do this? I can't seem to find any...
|
by: Russ |
last post by:
I tried the following:
>>> x = complex(4)
>>> y = x
>>> y *= 2
>>> print x, y
(4+0j) (8+0j)
But when I tried the same thing with my own class in place of
"complex" above, I found that both...
|
by: Jason Doucette |
last post by:
I am converting a C-style unit into a C++ class. I have an
implementation function that was defined in the .cpp file (so it was
hidden from the interface that exists in the .h file). It uses a...
|
by: perroe |
last post by:
Hi
I have a array of complex numbers that are stored in a simple double
array. This is done since the array is part of an wrapper for an
external C library, and the imaginary part of the first...
|
by: jacob navia |
last post by:
hi
I am trying to use the complex data type.
Consider this code, taken from the cclib library:
struct complex csqrt(Cpx z)
{ double r;
r=sqrt(z.re*z.re+z.im*z.im);...
|
by: magicman |
last post by:
can anyone point me out to its implementation in C before I roll my
own.
thx
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |