Exemple 5 étapes, exécutées dans l'ordre dans une même session. Chaque étape a été exécutée sur le moteur et la sortie ci-dessous est ce qu'elle a produit.
{sol1, sol2} = Map[NDSolve[{x'[t] == a[t], y'[t] == b[t], x[0] == 0, y[0] == 0, a[0] == 1, b[0] == #, WhenEvent[x[t] ^ 2 == 1, a[t] -> -a[t]], WhenEvent[y[t] ^ 2 == 1, b[t] -> -b[t]]}, {x, y}, {t, 0, 100}, DiscreteVariables -> {a, b}]&, {Rationalize[Sqrt[2], .01], Sqrt[2]}];Pas de sortie - cette étape prépare quelque chose pour la suivante.
GraphicsGrid[{Map[ParametricPlot[{x[t], y[t]} /. sol1, {t, 0, #}, Frame -> True, FrameTicks -> None, PlotRange -> 1, Axes -> False, PlotStyle -> Blue]&, {5, 20, 100}],
Map[ParametricPlot[{x[t], y[t]} /. sol2, {t, 0, #}, Frame -> True, FrameTicks -> None, PlotRange -> 1, Axes -> False, PlotStyle -> Red]&, {5, 20, 100}]}, ImageSize -> Large]-Graphics-ball3d[r1_ ? NumericQ, r2_ ? NumericQ] := NDSolve[{x'[t] == a[t], y'[t] == b[t], z'[t] == c[t], x[0] == 0, y[0] == 0, z[0] == 0, a[0] == 1, b[0] == r1, c[0] == r2, WhenEvent[x[t] ^ 2 - 1, a[t] -> -a[t]], WhenEvent[y[t] ^ 2 - 1, b[t] -> -b[t]], WhenEvent[z[t] ^ 2 - 1, c[t] -> -c[t]]}, {x[t], y[t], z[t]}, {t, 0, 200}, DiscreteVariables -> {a, b, c}];Pas de sortie - cette étape prépare quelque chose pour la suivante.
{sol3d1, sol3d2} = {ball3d[1 / 3, 2 / 3], ball3d[Sqrt[2], Sqrt[3]]};Pas de sortie - cette étape prépare quelque chose pour la suivante.
GraphicsGrid[{Map[ParametricPlot3D[{x[t], y[t], z[t]} /. sol3d1, {t, 0, #}, Axes -> False, PlotStyle -> Blue]&, {5, 20, 100}],
Map[ParametricPlot3D[{x[t], y[t], z[t]} /. sol3d2, {t, 0, #}, Axes -> False, PlotStyle -> Red]&, {1, 50, 200}]}, ImageSize -> Large]-Graphics-Toutes les recettes · Référence des fonctions · Utiliser ceci depuis un client MCP