Mathematica Asked by Gabrielle on April 14, 2021
I was able to solve the heat equation, but am unsure of how to graph the partial sums of the solution.
The problem:
a.) Solve the heat equation subject to
u(0, t) = 0, u(100, t)=0, t>0
u(x, 0) = 0.8x, 0 ≤ x ≤ 50
u(x, 0)=0.8(100-x), 50 < x ≤ 100
b.) Use the 3D plot application to graph the partial sums consisting of the first five nonzero terms of the solution in art a for 0 ≤ x ≤ 100, 0 ≤ t ≤ 200. Assume that k=1.6352. Experiment with various three-dimensional viewing perspectives of the surface.
I was able to get part a, but am unsure of how to code part b in Mathematica.
ClearAll[x, t];
L = 100;
k = 16352/10000;
pde = D[u[x, t], t] == k*D[u[x, t], {x, 2}];
ic = u[x, 0] == Piecewise[{{8/10*x, 0 <= x < L/2}, {8/10*(L - x), L/2 < x <= 100}}];
bc = {u[0, t] == 0, u[L, t] == 0}
sol = DSolve[{pde, ic, bc}, u[x, t], {x, t}]
plotit[n_] := Module[{sol0},
sol0 = Activate[u[x, t] /. First@sol /. Infinity -> n];
Plot3D[sol0, {x, 0, L}, {t, 0, 200},
PlotLabel -> Row[{"Using ", n, " terms"}],
AxesLabel -> {"x", "time", "u(x,t)"}, BaseStyle -> 14,
ImageSize -> 300]
]
Grid[Partition[plotit[#] & /@ Range[1, 6], 2], Frame -> All]
Answered by Nasser on April 14, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP