From: Michael <comtech.usa@gmail.com>
To: gsl-discuss@sources.redhat.com
Subject: Help! Questions for the developers of GSL ODE: Complex-valued ODEs and the "jac" function in GSL ODE solver?
Date: Sun, 03 Jun 2007 08:18:00 -0000 [thread overview]
Message-ID: <b1f16d9d0706030118r3037f56ci70f69e9d1a1f3350@mail.gmail.com> (raw)
Help! Complex-valued ODEs and the "jac" function in GSL ODE solver?
Hi all,
I am new to GSL ode, I started looking it because I really need to
speed my current Matlab program, which runs ODE solvers repeatedly for
thousands to millions of times. I found the GSL example ode program
difficult to understand, and here are my questions:
(1)
I have to solve the following complex-valued non-linear ODE numerically,
using GSL's ode solver. But it seems that GSL's ode solver only supports
real-valued ODE...
My ODEs are:
y' = c1 * y + c2 + c3*exp(c4* y + c5*i)
x' = c6 * y
here c1, c2, c3, c4, c5 and c6 are real numbers , and "i" is the unit of
imaginary numbers.
I am planning to decompose y into yr and yi, x into xr and xi, the real
parts and the imaginary parts. And solve separately:
yr' = c1 * yr + c2 + c3*exp(c4* yr)*cos(c4* yi + c5)
yi' = c1 * yi + c2 + c3*exp(c4* yr)*sin(c4* yi + c5)
xr' = c6 * yr
xi' = c6 * yi
--------------------
Am I right? Is this the best approach to handle the ODEs with a solver only
supports real values?
My original solutions were already too slow, now by having to solve 4
equations, it is even slower, and double the computing time...
Any better approaches?
(2)
In the sample GSL ode code, there is a function called "jac", how do I
define the "jac" function for my ODE equations, as shown above?
int
jac (double t, const double y[], double *dfdy,
double dfdt[], void *params)
{
double mu = *(double *)params;
gsl_matrix_view dfdy_mat
= gsl_matrix_view_array (dfdy, 2, 2);
gsl_matrix * m = &dfdy_mat.matrix;
gsl_matrix_set (m, 0, 0, 0.0);
gsl_matrix_set (m, 0, 1, 1.0);
gsl_matrix_set (m, 1, 0, -2.0*mu*y[0]*y[1] - 1.0);
gsl_matrix_set (m, 1, 1, -mu*(y[0]*y[0] - 1.0));
dfdt[0] = 0.0;
dfdt[1] = 0.0;
return GSL_SUCCESS;
}
---------------------
There is no documentation talking about this "jac" function. I really
don't know how to define my "jac" function for my own ode equations.
Could you please help me?
Thanks a lot!
Mike
next reply other threads:[~2007-06-03 8:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-03 8:18 Michael [this message]
2007-06-03 11:50 ` Tommy Nordgren
2007-06-03 16:19 eknecronzontas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b1f16d9d0706030118r3037f56ci70f69e9d1a1f3350@mail.gmail.com \
--to=comtech.usa@gmail.com \
--cc=gsl-discuss@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).