Mathematica Mathematica: 2nd order PDE, variable coefficients

AI Thread Summary
The discussion focuses on solving a second-order ordinary differential equation (ODE) with variable coefficients using Mathematica's NDSolve function. The user initially struggled to obtain a solution due to issues with the functions A[t] and B[t], which are dependent on R[t], R'[t], and R''[t]. After troubleshooting, it was discovered that the problem stemmed from not obtaining real values for R functions and reaching the maximum number of steps in NDSolve. The user successfully resolved the issue by increasing the MaxSteps parameter in NDSolve, allowing them to compute a[t] effectively. The conversation highlights the importance of proper function definitions and parameter adjustments in numerical solving.
hasidim
Messages
15
Reaction score
0
a\text{''}[t]+B[t]*a'[t]-A[t]*a[t]==0

a[0] = 10^-9
a'[0] = 0
a[t] = ?

The coefficients A and B are variable over time. I HAVE solved (experimental and theoretical values) for the values of A and B over the time interval of interest!

I attempted to solve for a[t] using NDSolve as one normally would when coefficients are not variable over time. No luck.

Any help would be greatly appreciated!
 
Physics news on Phys.org
I agree that NDSolve should work for this. Just for the record, this is an ODE, not a PDE.
 
Oh geez, yeah, I meant ODE... it was a little late at night.

So, here is code. SolutionA, SolutionB and SolutionC are for R(t), R'(t), and R''(t). For coefficients A and B:
A[\text{t$\_$}] = \text{constants}*\frac{R\text{''}[t]}{R[t]}-\frac{\text{constants}}{\rho *(R[t])^3}+\frac{R'[t]}{(R[t])^3}*\left(\text{constants}*\frac{1}{1+2*\psi /R[t]}\right);
\text{AA}= \text{Evaluate}[A[t]\text{/.}\text{SolutionA}\text{/.}\text{SolutionB}\text{/.}\text{SolutionC}]B[\text{t$\_$}] =3 \frac{R'[t]}{R[t]}+\frac{\text{constants}}{(R[t])^2}*\left(\frac{\text{constants}}{\text{constants}*R[t]}\right);
BB = Evaluate[B[t] /. SolutionA /. SolutionB /. SolutionC];
Attempt at using NDSolve (for SolutionD):

SolutionD = <br /> NDSolve[{a&#039;&#039;[t] + BB*a&#039;[t] - AA*a[t] == 0, a[0] == 10^-9, <br /> a&#039;[0] == 0}, a[t], {t, 0, tmax}];I've tried making AA and BB into tables, I've tried using DSolve, and so on.

Thanks a million for the help.
 
Last edited:
Although that's a lot of detail (and it's probably best to use a code block, rather than latex) it's still hard to tell what could be causing the problem.
One small thing (which is probably a problem with you're copy/pasting) is that the you should bracket {t,0,tmax}.
Can you:
1) Supply the error message that NDSolve is giving
2) Give the form of Solution* (and are \psi and \rho numerical?)
3) Provide a copy of the notebook (preferably with any extraneous stuff removed)

I'm guessing that R[t] must be some numerical/interpolated function. Here's a simple example showing the use of an interpolated function and NDSolve. Note that the interpolation becomes bad at around x=4.
Code:
data=Table[{x,Cos[Exp[x]]},{x,0,5,.05}];
AA=Interpolation[data];
Code:
Plot[{Cos[Exp[x]],AA[x]},{x,0,5}]
Code:
sol1=NDSolve[{y'[x]+Cos[Exp[x]] y[x]==0,y[0]==1},y,{x,0,5}];
sol2=NDSolve[{y'[x]+AA[x] y[x]==0,y[0]==1},y,{x,0,5}];
Code:
Plot[Evaluate[Flatten[y[x]/.{sol1,sol2}]],{x,0,5}]
 
This is very difficult to me, because i am a new user here.
==================================
http://www.bestbankrates.net"
 
Last edited by a moderator:
phyzguy and Simon_Tyler, thanks for the help.

I found the issue: it wasn't with my finding a[t] directly, it was solving for R[t], R'[t], and R''[t] (I wasn't getting real values). Also, I was reaching my maximum number of steps when using NDSolve to find a[t].

Also, I am still new and learning (mathematica and forums), I didn't realize there was a code block, so for what it is worth, this worked beautifully:

Code:
SolutionD = 
  NDSolve[{a''[t] + BB*a'[t] - AA*a[t] == 0, a[0] == 10^-9, 
    a'[0] == 0}, a[t], {t, 0, tmax}, MaxSteps -> 700000000];

CC = Evaluate[a[t] /. SolutionD];
 
Glad you got it sorted!
 

Similar threads

Replies
4
Views
3K
Replies
1
Views
2K
Replies
3
Views
8K
Replies
4
Views
1K
Replies
5
Views
3K
Replies
6
Views
2K
Replies
5
Views
2K
Back
Top