Mathematica: 2nd order PDE, variable coefficients

Click For Summary

Discussion Overview

The discussion revolves around solving a second-order ordinary differential equation (ODE) with variable coefficients using Mathematica's NDSolve function. Participants explore issues related to the implementation of the code and the behavior of the solution under specific conditions.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant presents an ODE with variable coefficients and seeks assistance in solving it using NDSolve.
  • Another participant suggests that if the functions A and B are defined, NDSolve should work and requests the original code for further assistance.
  • A third participant corrects the initial mislabeling of the equation as a PDE, clarifying it is an ODE.
  • A participant shares their code for defining coefficients A and B, detailing their attempts to solve the ODE using NDSolve.
  • Another participant points out a potential issue with the syntax in the NDSolve command and requests additional information, including error messages and the forms of the solutions.
  • A new user expresses difficulty in understanding the discussion and requests help.
  • A participant later identifies the source of their problem as related to the calculations for R[t] and the maximum number of steps in NDSolve, indicating they found a solution by adjusting parameters.
  • Another participant expresses satisfaction that the issue was resolved.

Areas of Agreement / Disagreement

Participants generally agree on the use of NDSolve for the problem at hand, but there are varying opinions on the specific issues encountered and how to resolve them. The discussion includes both technical challenges and clarifications without reaching a consensus on all aspects.

Contextual Notes

Some limitations include the dependency on the definitions of A and B, the need for numerical values for certain parameters, and potential issues with the interpolation of functions used in the ODE.

Who May Find This Useful

This discussion may be useful for users of Mathematica dealing with ordinary differential equations, particularly those involving variable coefficients, as well as those seeking to understand the use of NDSolve in complex scenarios.

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 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
5
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 3 ·
Replies
3
Views
8K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K