NDSolveおよびその他の関数のオプションで,与えられた方程式の従属変数と考えられるべきすべてのオブジェクトのリストを指定する.
DependentVariables
NDSolveおよびその他の関数のオプションで,与えられた方程式の従属変数と考えられるべきすべてのオブジェクトのリストを指定する.
詳細
- DependentVariables->Automaticの場合,従属変数は方程式から決定される.
- DependentVariables->{u1,u2,…}は,たとえ解が最終的に返されないとしても,解かれるべき関数を表す従属変数 ui の完全なリストを指定する.
- DependentVariables->{uspec1,uspec2,…}を使って従属変数の範囲を指定することができる.
- uspeciの可能な形
-
u u の範囲はRealsまたはComplexesである Element[u,Reals] u の範囲はRealsである Element[u,Complexes] u の範囲はComplexesである Element[u,{v1,…}] u は離散範囲{v1,…}を持つ {u,umin,umax} u の範囲は
であるuspeciactioni uspeciが満たされなくなった場合に actioniを実行する
例題
すべて開く すべて閉じる例 (2)
xsol = NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]], x[0] == 3.1, y[0] == 0}, x, {t, 0, 20}, DependentVariables -> {x, y}]Plot[x[t] /. xsol, {t, 0, 20}]sol = NDSolve[{y'[t] == y[t], y[0] == 1}, y, {t, 0, 10}, DependentVariables -> {{y[t], 0, 3}}]Plot[y[t] /. sol, {t, 0, 1.1}]スコープ (4)
a = 1;NDSolve[{y'[t] == a y[t], y[0] == 2}, y, {t, 0, 1}, DependentVariables -> {{y, 0, 3}, {y, 1, 4}}]a = -1;NDSolve[{y'[t] == a y[t], y[0] == 2}, y, {t, 0, 1}, DependentVariables -> {{y, 0, 3}, {y, 1, 4}}]{sol, {point}} = NDSolve[{y'[t] == y[t], y[0] == 1}, y, {t, 0, 2}, DependentVariables -> {{y[t], 0, 5} :> {Print[{t, y[t]}], Sow[{t, y[t]}]}}]//Reap;Plot[y[t] /. sol, {t, 0, 2}, Epilog -> {PointSize[Medium], Point[point]}]変数が指定された範囲の外に出るたびに事象アクションを実行する:
{sol, {points}} = NDSolve[{y''[t] == -y[t], y[0] == 0, y'[0] == 1}, y, {t, 0, 20}, DependentVariables -> {{y[t], -.5, .5} :> Sow[{t, y[t]}]}]//Reap;Plot[y[t] /. sol, {t, 0, 20}, Epilog -> {PointSize[Medium], Point[points]}]変数が最初に範囲外に出た段階でメッセージを出力し積分を中止する:
NDSolve[{y''[t] == -y[t], y[0] == 0, y'[0] == 1}, y, {t, 0, 20}, DependentVariables -> {{y[t], -.5, .5} :> {Print[{ t, y[t]}], "StopIntegration"}}]アプリケーション (2)
n = 1000;
vars = Table[Subscript[x, i][t], {i, n}];
eqns = Table[j = Mod[i, n] + 1;{Subscript[x, i]'[t] == 1 / (Subscript[x, i][t] + Subscript[x, j][t])^2, Subscript[x, i][0] == 1 / i}, {i, n}];Short[eqns, 3]すべての従属変数について解くが,x1についての解のみを保存する:
sol = NDSolve[eqns, Subscript[x, 1], {t, 0, 100}, DependentVariables -> vars]Plot[Subscript[x, 1][t] /. sol, {t, 0, 100}, PlotRange -> All]こうすると,すべての解を保存するのに比べ,メモリ消費が大幅に抑えられる:
allsol = NDSolve[eqns, vars, {t, 0, 100}];{ByteCount[sol], ByteCount[allsol]}de[a_] := With[{ω = 50}, θ''[t] - (-9.8 / 10)Sin[θ[t]] == -(a / 10)ω ^ 2 Sin[ω t]Sin[θ[t]]];
ic = {θ[0] == π, θ'[0] == 0.01};sol = NDSolve[{de[5], ic}, θ, {t, 0, 2}, DependentVariables -> {{θ[t], 2, 4}}]Plot[θ[t] /. sol, {t, 0, 1.0732}, PlotRange -> {2, 4}]振幅が安定している場合,振動する台座上倒立振子は範囲の外には出ない:
sol = NDSolve[{de[2], ic}, θ, {t, 0, 2}, DependentVariables -> {{θ[t], 2, 4}}];Plot[θ[t] /. sol, {t, 0, 2}, PlotRange -> {3.139, 3.145}]特性と関係 (1)
変数範囲のチェックはWhenEventで行うこともできる:
NDSolve[{y'[t] == y[t], y[0] == 1, WhenEvent[(y[t] + 10)(y[t] - 10), "StopIntegration"]}, y, {t, 0, 10}]DependentVariablesを使った同様の範囲チェックは,これより直接的で分かりやすい:
NDSolve[{y'[t] == y[t], y[0] == 1}, y, {t, 0, 10}, DependentVariables -> {{y[t], -10, 10}}]WhenEventはより複雑な範囲チェックに役に立つ:
NDSolve[{y'[t] == y[t], y[0] == 1, WhenEvent[y[t] ^ 8 - y[t] - 2, "StopIntegration"]}, y, {t, 0, 10}]考えられる問題 (3)
NDSolve[{y'[t] == a[t]y[t], y[0] == 1, a[0] == 1}, y, {t, 0, 1}, DiscreteVariables -> {a}, DependentVariables -> {a, y}]NDSolve[{y'[t] == y[t], y[0] == 1}, y, {t, 0, 1}, DependentVariables -> {Element[y[t], {0, 1, 2, 3}]}]NDSolve[{y'[t] == y[t], y[0] == 0.5}, y[t], {t, 0, 1}, DependentVariables -> {{y[t] ^ 2, 0, 1}}]NDSolve[{y'[t] == y[t], y[0] == 0.5}, y[t], {t, 0, 1}, DependentVariables -> {{y[t], -1, 1}}]方程式中でWhenEvent式を使ってもよい:
NDSolve[{y'[t] == y[t], WhenEvent[y[t]^2 == 1, "StopIntegration"], y[0] == 0.5}, y[t], {t, 0, 1}]関連するガイド
履歴
2003 で導入 (5.0) | 2012 で更新 (9.0)
テキスト
Wolfram Research (2003), DependentVariables, Wolfram言語関数, https://reference.wolfram.com/language/ref/DependentVariables.html (2012年に更新).
CMS
Wolfram Language. 2003. "DependentVariables." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2012. https://reference.wolfram.com/language/ref/DependentVariables.html.
APA
Wolfram Language. (2003). DependentVariables. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DependentVariables.html
BibTeX
@misc{reference.wolfram_2026_dependentvariables, author="Wolfram Research", title="{DependentVariables}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/DependentVariables.html}", note=[Accessed: 12-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_dependentvariables, organization={Wolfram Research}, title={DependentVariables}, year={2012}, url={https://reference.wolfram.com/language/ref/DependentVariables.html}, note=[Accessed: 12-September-2026]}