Linked Questions

81
votes
3answers
11k views

Why should I avoid the For loop in Mathematica?

Some people advise against the use of For loops in Mathematica. Why? Should I heed this advice? What is wrong with For? What ...
37
votes
6answers
4k views

How to splice together several instances of InterpolatingFunction?

I have a set of InterpolatingFunction returned by NDSolve which are valid over different (but overall continuous) domains. How ...
12
votes
2answers
1k views

Boundary condition with spatial derivative is ignored by NDSolve

Consider the following differential equation: $$\begin{align*}&\rho C_p\left(\frac{\partial T}{\partial t}\right)=k\left[\frac{\partial^2 T}{\partial x^2}\right]+\dot{q}\\ &\text{at }x=0,\;\...
11
votes
2answers
2k views

What's behind Method -> {“EquationSimplification” -> “Residual”}

In order to solve a quite large system of differential equations, I have the habit to use the NDSolve command without changing any options. As I wanted more ...
5
votes
1answer
364 views

Variation of heat equation with guessed initial condition

Hi I am trying to solve a variation of the heat equation with interaction terms and external source -- actually it's the Schrödinger-Newton equation if that's more familiar to you. \begin{align} i \...
8
votes
1answer
329 views

Solve PDEs with finite difference scheme by modifying NDSolve-based solver

Motivation As discussed here, NDSolve uses different difference orders for various spatial derivatives and the implicit design could cause trouble in certain cases....
10
votes
0answers
232 views

Solving Maxwell's Equations in Mathematica

For the sake of demonstration (for my students) and practice, I wanted to numerically calculate the electric and magnetic field (3D) for a sphere of uniform density moving slightly to the right and ...
3
votes
1answer
170 views
3
votes
2answers
82 views

Need more equations in PDEs by NDSolve? Bug of mma?

I am trying to solve set of pdes as below ...
0
votes
0answers
273 views

PDE combined with ODE 1D

I try to solve the following system of PDE coupled with ODE: $$\theta_t - a\theta_{xx} + b\kappa_a(\theta^4-\varphi)=0,$$ $$-\alpha\varphi_{xx} + \kappa_a(\varphi - \theta^4) = 0,$$ $$-a\theta_x + \...
1
vote
1answer
58 views

Solve coupled PDEs: boundary conditions problem

I need to solve 4 coupled PDEs. Thanks to @xzczd's help, a few days ago I can obtain the solution of the first 2 equations with some proper boundary conditions, see this post. Now, these two equations ...
1
vote
0answers
56 views

Solving an algebraic-differential equation

I cannot find the relevant part in the documentation. Maybe you have a quick solution to my problem. Background Sometimes you want to propagate in time some system of ODEs, but not all the variables ...