Mathematica source code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
ClearAll["Global`*"] yN = c1*(1 - x^2) + c2*x^2*(1 - x^2) D[yN[x], x] D[yN[x], {x, 2}] Clear[yN] yN[x_] := c1*(1 - x^2) + c2*x^2*(1 - x^2) yNp = yN'[x]; (*first derivative*) yNpp = yN''[x]; (*second derivative*) Simplify /@ {yN[x], yNp, yNpp} L[x_] := yNpp + (1 + x^2)*yN[x] + 1 // Simplify L1 = L[x = 0] L2 = L[x = 1/2] sol = Solve[{L1 == 0, L2 == 0}, {c1, c2}][[1]]; {c1, c2} /. sol {c1, c2} /. sol // N yNsub[x_] := yN[x] /. sol plt = Plot[yNsub[x], {x, -1, 1}, PlotRange -> All, AxesLabel -> {"x", "y_N(x)"}, PlotLabel -> "Collocation solution y_N(x)"] SetDirectory[$HomeDirectory] Export[FileNameJoin[{NotebookDirectory[], "ex467.png"}], plt, ImageResolution -> 150] |
Last Updated on 2026-01-10 by gantovnik

Recent Comments