0
$\begingroup$

I am solving a heat equation in following example:

heqn = D[u[x, t], t] == D[u[x, t], {x, 2}];
ic = u[x, 0] == Exp[-x^2];
sol = DSolveValue[{heqn, ic}, u[x, t], {x, t}]

I'd like to manipulate the solution by plotting it in space for a given time. However a naive way of implementing it gives an empty plot:

Manipulate[
 Plot[sol, {x, -2, 2}, PlotRange -> All],
 {t, 0, 1}
]

What is a proper way of using Manipulate in such a case?

$\endgroup$
1

1 Answer 1

1
$\begingroup$

This is a classic pitfall in localization by Manipulate. I'll try to find a similar Q&A.

heqn = D[u[x, t], t] == D[u[x, t], {x, 2}];
ic = u[x, 0] == Exp[-x^2];
sol[x_, t_] = DSolveValue[{heqn, ic}, u[x, t], {x, t}]

Manipulate[
 Plot[sol[x, t], {x, -2, 2}, PlotRange -> All],
 {t, 0, 1}
]
$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.