The exact solution to a partial differential equation

11 views (last 30 days)
I know that MATLAB Has a PDE solver, but I wonder if it is possible to obtain the exact solution. For example, consider the heat equation
u_t = k u{xx}_
Is it possible to solve it with a set of initial and boundary conditions to calculate the exact equation of u
u = f(x,t)
and
u(x=0) = f(t)
I don't need numeral solution or the graph but the general equations.

Accepted Answer

Stephan
Stephan on 8 Aug 2018
Hi,
this works by using the symbolic math toolbox :
% define symbolic variables
syms u(t) k
% define equation
eqn = u == k* diff(u,2);
% Solution without initial conditions
sol = dsolve(eqn);
% Define first derivative from u(t) for initial conditions
Du = diff(u);
% Define initial conditions
conds = [u(0) == 1, Du(0) == 0];
% Get solution with initial conditions
sol_conds = dsolve(eqn, conds);
will give:
>> pretty(sol)
/ t \ / t \
C1 exp| - ------- | + C2 exp| ------- |
\ sqrt(k) / \ sqrt(k) /
>> pretty(sol_conds)
/ t \ / t \
exp| ------- | exp| - ------- |
\ sqrt(k) / \ sqrt(k) /
-------------- + ----------------
2 2
or if you use a live script it looks like this:
Best regards
Stephan
  6 Comments
Peter
Peter on 9 Jul 2025
The question was about the second derivative (u{xx}_) so I believe @Stephan's answer is correct
Torsten
Torsten on 9 Jul 2025
Edited: Torsten on 9 Jul 2025
@Stephan 's answer doesn't help to answer the original question. The requested u is a function of x and t following the partial differential equation
du/dt = k * d^2u/dx^2
The code
% define symbolic variables
syms u(t) k
% define equation
eqn = u == k* diff(u,2);
% Solution without initial conditions
sol = dsolve(eqn);
assumes that u is a function of t alone and solves k*u''(t) = u(t) which is an ordinary differential equation.

Sign in to comment.

More Answers (0)

Tags

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!