Qurak

Nd solve bvp shooting method

教學 共 5 個步驟,在同一個工作階段中依序執行。每一步都在引擎上實際執行過,下方的輸出就是它產生的結果。

步驟 1
sols = Map[First[NDSolve[{x''[t] + Sin[x[t]] == 0, x[0] == x[10] == 0}, x, t, Method -> {"Shooting", "StartingInitialConditions" -> {x[0] == 0, x'[0] == #}}]]&,
	{1.5, 1.75, 2}];
Plot[Evaluate[x[t] /. sols], {t, 0, 10}, PlotStyle -> {StandardBrown, StandardBlue, StandardGreen}]
輸出
-Graphics-
步驟 2
eqn = x'''[t] - 2λ x''[t] - λ^2x'[t] + 2λ^3x[t] == (λ^2 + π^2) (2 λ Cos[π t] + π Sin[π t]);
bcs = {x[0]  ==   1 + (1 + E^-2 λ + E^-λ/2 + E^-λ), x[1] == 0, x'[1] == (3 λ - E^-λ λ/2 + E^-λ)};
xsol[t_]  =   (E^λ (t - 1) + E^2 λ (t - 1) + E^-λ t/2 + E^-λ) + Cos[π t];

沒有輸出——這個步驟是在為下一步做準備。

步驟 3
Block[{λ = 10},
	sol = First[NDSolve[{eqn, bcs}, x, t]];
	Plot[{xsol[t], x[t] /. sol}, {t, 0, 1}]]
輸出
-Graphics-
步驟 4
Block[{λ = 10},
	sol = First[NDSolve[{eqn, bcs}, x, t,
	Method -> {"Shooting", "StartingInitialConditions" -> {x[1] == 0, x'[1] == (3 λ - E^-λ λ/2 + E^-λ), x''[1] == 0}}]];
	Plot[{xsol[t], x[t] /. sol}, {t, 0, 1}]]
輸出
-Graphics-
步驟 5
Block[{λ = 15},
	sol = First[NDSolve[{eqn, bcs}, x, t,
	Method -> {"Shooting", "StartingInitialConditions" -> {x[2 / 3] == 0, x'[2 / 3] == 0, x''[2 / 3] == 0}}]];
	Plot[{xsol[t], x[t] /. sol}, {t, 0, 1}]]
輸出
-Graphics-

使用到的函式

相關的操作範例

所有操作範例 · 函式參考 · 從 MCP 用戶端使用這個