Trying to plot the norm of the solutions to NDsolve












2












$begingroup$



I have been tried to do two things with the solutions from NDSolveValue




  • plot the norm of the solutions of a differential equation system versus time.

  • plot one component of the solutions of a differential equation system versus time.


but I have been having difficulty it setting up the right syntax to do so.




The problem seems to be (for plotting the norms of the solutions), that Mathematica takes the norm of all the solutions, or tries to find the norm of a function rather than the value of the function at a certain time.



I have created a minimum working example from the original code. The major change is that in the original code set is a random set of $n$ points. The examples are my best guess for the correct syntax for the problems listed above. For context I have included a 3D parametric plot which works as intended.



If you have any questions please don't be afraid to ask.



Minimum Example



(*Simulation Parameters*)
Clear[i, P, B]
Clear[f]
f[P_, B_] := 1/2 P + 10 B/(1 + B);
tmax = 20;
A = {{1/20, 1/4, 1/50}, {1/4, 1/26, 1/40}};
set = {{1.1, 11.2, 0.2}, {5.6, 4.3, 7.8}, {2.3, 3.4, 3.4}};

(*ODE System*)
ODEsys = {i'[t] == f[P[t], B[t]] - i[t],
P'[t] ==
P[t] (1 - A[[1, 1]] P[t] - A[[1, 2]] B[t] - A[[1, 3]] i[t]),
B'[t] == B[t] (1 - A[[2, 2]] B[t] - A[[2, 3]] i[t])};

(* Simulation *)
With[{ttmax = tmax},
sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,
i[0] == init0}}, {P, B, i}, {t, 0, ttmax}, {init1, init2,
init0}]];

(* Plots I am having trouble with *)
(* Cannot plot the first component of multiple solutions. *)
ParametricPlot[{t,
Evaluate[Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)][[All,
1]]}, {t, 0, tmax}, PlotRange -> All]

(* Takes the norm of all solutions. Does not plot the norms of the
three different solutions. *)
ParametricPlot[{t,
Norm[Evaluate[
Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)]]}, {t, 0,
tmax}, PlotRange -> All]

(* This plot works as attended. *)
trajectoriesPlot =
ParametricPlot3D[
Evaluate[Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)], {t,
0, tmax}, PlotRange -> All]









share|improve this question









$endgroup$












  • $begingroup$
    I am looking for the default Euclidean norm e.g. $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ not $||(P_1,B_1,I_3)||=|P_1|+|B_1|+|I_3| or anything else. Abs does not give the magnitude of a vector.
    $endgroup$
    – AzJ
    9 hours ago
















2












$begingroup$



I have been tried to do two things with the solutions from NDSolveValue




  • plot the norm of the solutions of a differential equation system versus time.

  • plot one component of the solutions of a differential equation system versus time.


but I have been having difficulty it setting up the right syntax to do so.




The problem seems to be (for plotting the norms of the solutions), that Mathematica takes the norm of all the solutions, or tries to find the norm of a function rather than the value of the function at a certain time.



I have created a minimum working example from the original code. The major change is that in the original code set is a random set of $n$ points. The examples are my best guess for the correct syntax for the problems listed above. For context I have included a 3D parametric plot which works as intended.



If you have any questions please don't be afraid to ask.



Minimum Example



(*Simulation Parameters*)
Clear[i, P, B]
Clear[f]
f[P_, B_] := 1/2 P + 10 B/(1 + B);
tmax = 20;
A = {{1/20, 1/4, 1/50}, {1/4, 1/26, 1/40}};
set = {{1.1, 11.2, 0.2}, {5.6, 4.3, 7.8}, {2.3, 3.4, 3.4}};

(*ODE System*)
ODEsys = {i'[t] == f[P[t], B[t]] - i[t],
P'[t] ==
P[t] (1 - A[[1, 1]] P[t] - A[[1, 2]] B[t] - A[[1, 3]] i[t]),
B'[t] == B[t] (1 - A[[2, 2]] B[t] - A[[2, 3]] i[t])};

(* Simulation *)
With[{ttmax = tmax},
sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,
i[0] == init0}}, {P, B, i}, {t, 0, ttmax}, {init1, init2,
init0}]];

(* Plots I am having trouble with *)
(* Cannot plot the first component of multiple solutions. *)
ParametricPlot[{t,
Evaluate[Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)][[All,
1]]}, {t, 0, tmax}, PlotRange -> All]

(* Takes the norm of all solutions. Does not plot the norms of the
three different solutions. *)
ParametricPlot[{t,
Norm[Evaluate[
Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)]]}, {t, 0,
tmax}, PlotRange -> All]

(* This plot works as attended. *)
trajectoriesPlot =
ParametricPlot3D[
Evaluate[Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)], {t,
0, tmax}, PlotRange -> All]









share|improve this question









$endgroup$












  • $begingroup$
    I am looking for the default Euclidean norm e.g. $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ not $||(P_1,B_1,I_3)||=|P_1|+|B_1|+|I_3| or anything else. Abs does not give the magnitude of a vector.
    $endgroup$
    – AzJ
    9 hours ago














2












2








2





$begingroup$



I have been tried to do two things with the solutions from NDSolveValue




  • plot the norm of the solutions of a differential equation system versus time.

  • plot one component of the solutions of a differential equation system versus time.


but I have been having difficulty it setting up the right syntax to do so.




The problem seems to be (for plotting the norms of the solutions), that Mathematica takes the norm of all the solutions, or tries to find the norm of a function rather than the value of the function at a certain time.



I have created a minimum working example from the original code. The major change is that in the original code set is a random set of $n$ points. The examples are my best guess for the correct syntax for the problems listed above. For context I have included a 3D parametric plot which works as intended.



If you have any questions please don't be afraid to ask.



Minimum Example



(*Simulation Parameters*)
Clear[i, P, B]
Clear[f]
f[P_, B_] := 1/2 P + 10 B/(1 + B);
tmax = 20;
A = {{1/20, 1/4, 1/50}, {1/4, 1/26, 1/40}};
set = {{1.1, 11.2, 0.2}, {5.6, 4.3, 7.8}, {2.3, 3.4, 3.4}};

(*ODE System*)
ODEsys = {i'[t] == f[P[t], B[t]] - i[t],
P'[t] ==
P[t] (1 - A[[1, 1]] P[t] - A[[1, 2]] B[t] - A[[1, 3]] i[t]),
B'[t] == B[t] (1 - A[[2, 2]] B[t] - A[[2, 3]] i[t])};

(* Simulation *)
With[{ttmax = tmax},
sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,
i[0] == init0}}, {P, B, i}, {t, 0, ttmax}, {init1, init2,
init0}]];

(* Plots I am having trouble with *)
(* Cannot plot the first component of multiple solutions. *)
ParametricPlot[{t,
Evaluate[Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)][[All,
1]]}, {t, 0, tmax}, PlotRange -> All]

(* Takes the norm of all solutions. Does not plot the norms of the
three different solutions. *)
ParametricPlot[{t,
Norm[Evaluate[
Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)]]}, {t, 0,
tmax}, PlotRange -> All]

(* This plot works as attended. *)
trajectoriesPlot =
ParametricPlot3D[
Evaluate[Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)], {t,
0, tmax}, PlotRange -> All]









share|improve this question









$endgroup$





I have been tried to do two things with the solutions from NDSolveValue




  • plot the norm of the solutions of a differential equation system versus time.

  • plot one component of the solutions of a differential equation system versus time.


but I have been having difficulty it setting up the right syntax to do so.




The problem seems to be (for plotting the norms of the solutions), that Mathematica takes the norm of all the solutions, or tries to find the norm of a function rather than the value of the function at a certain time.



I have created a minimum working example from the original code. The major change is that in the original code set is a random set of $n$ points. The examples are my best guess for the correct syntax for the problems listed above. For context I have included a 3D parametric plot which works as intended.



If you have any questions please don't be afraid to ask.



Minimum Example



(*Simulation Parameters*)
Clear[i, P, B]
Clear[f]
f[P_, B_] := 1/2 P + 10 B/(1 + B);
tmax = 20;
A = {{1/20, 1/4, 1/50}, {1/4, 1/26, 1/40}};
set = {{1.1, 11.2, 0.2}, {5.6, 4.3, 7.8}, {2.3, 3.4, 3.4}};

(*ODE System*)
ODEsys = {i'[t] == f[P[t], B[t]] - i[t],
P'[t] ==
P[t] (1 - A[[1, 1]] P[t] - A[[1, 2]] B[t] - A[[1, 3]] i[t]),
B'[t] == B[t] (1 - A[[2, 2]] B[t] - A[[2, 3]] i[t])};

(* Simulation *)
With[{ttmax = tmax},
sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,
i[0] == init0}}, {P, B, i}, {t, 0, ttmax}, {init1, init2,
init0}]];

(* Plots I am having trouble with *)
(* Cannot plot the first component of multiple solutions. *)
ParametricPlot[{t,
Evaluate[Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)][[All,
1]]}, {t, 0, tmax}, PlotRange -> All]

(* Takes the norm of all solutions. Does not plot the norms of the
three different solutions. *)
ParametricPlot[{t,
Norm[Evaluate[
Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)]]}, {t, 0,
tmax}, PlotRange -> All]

(* This plot works as attended. *)
trajectoriesPlot =
ParametricPlot3D[
Evaluate[Through /@ (sol[#[[1]], #[[2]], #[[3]]][t] & /@ set)], {t,
0, tmax}, PlotRange -> All]






plotting differential-equations syntax






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 12 hours ago









AzJAzJ

34018




34018












  • $begingroup$
    I am looking for the default Euclidean norm e.g. $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ not $||(P_1,B_1,I_3)||=|P_1|+|B_1|+|I_3| or anything else. Abs does not give the magnitude of a vector.
    $endgroup$
    – AzJ
    9 hours ago


















  • $begingroup$
    I am looking for the default Euclidean norm e.g. $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ not $||(P_1,B_1,I_3)||=|P_1|+|B_1|+|I_3| or anything else. Abs does not give the magnitude of a vector.
    $endgroup$
    – AzJ
    9 hours ago
















$begingroup$
I am looking for the default Euclidean norm e.g. $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ not $||(P_1,B_1,I_3)||=|P_1|+|B_1|+|I_3| or anything else. Abs does not give the magnitude of a vector.
$endgroup$
– AzJ
9 hours ago




$begingroup$
I am looking for the default Euclidean norm e.g. $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ not $||(P_1,B_1,I_3)||=|P_1|+|B_1|+|I_3| or anything else. Abs does not give the magnitude of a vector.
$endgroup$
– AzJ
9 hours ago










2 Answers
2






active

oldest

votes


















3












$begingroup$



  • plot the norm of the solutions of a differential equation system versus time.




Plot[Evaluate@(Norm[Through[sol[## & @@ #][t]]] & /@ set), {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> Large,
PlotLegends -> Placed[ToString /@ set, Top],
PlotLabel -> (Norm[{P[t], B[t], i[t]}])]


enter image description here





  • plot one component of the solutions of a differential equation system versus time.






Row[ParametricPlot[Evaluate@Thread[{t, (Through[sol[## & @@ #][t]] & /@ set)[[All, #]]}], 
{t, 0, tmax}, PlotRange -> All,
PlotLegends -> Placed[set[[All, #]], Top] , AspectRatio -> 1,
ImageSize -> 300, PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1,
2, 3}, Spacer[5]]


enter image description here



Alternatively, you can use Plot:



Row[Plot[Evaluate@(Through[sol[## & @@ #][t]] & /@ set)[[All, #]], {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> 300,
PlotLegends -> Placed[set[[All, #]], Top] ,
PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1, 2, 3}, Spacer[5]]


enter image description here






share|improve this answer











$endgroup$









  • 1




    $begingroup$
    I really like this solution exactly what I was looking for and more.
    $endgroup$
    – AzJ
    9 hours ago



















2












$begingroup$

sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,i[0] == init0}}, {P[t], B[t], i[t]}, {t, 0, tmax}, {init1, init2,init0}]


plot of solutions:



Plot[Table[# &[ Apply[sol, set[[i]]]]  , {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]


plot of euclidean norm:



Plot[Table[Sqrt[ #.#] &[ Apply[sol, set[[i]]] ], {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]





share|improve this answer











$endgroup$













  • $begingroup$
    This does not answer my question for my reasons. First something like Plot[Table[Map[#[t] &, Apply[sol, set[[i]]]], {i, 2, 2}], {t, 0,tmax}] does not plot all of the second components of all the solutions. It plots all the components of the second solution. Next I meant Euclidean Norm, not some other norm (I thought it was self evident as that is the default used by Mathematica when given a vector). Playing around with your code snippet I haven't been able to get the desired result
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    My plot shows 3x3 solutions as you asked for!
    $endgroup$
    – Ulrich Neumann
    9 hours ago










  • $begingroup$
    Sorry my terminology may have confused you. For the context of my problem as I am solving a system of ODEs one function (for example $P(t)$) is a component of the solution $(P(t),B(t),I(t))$.
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    If I have three solutions $(P_1,B_1,I_1)$,$(P_2,B_2,I_2)$,$(P_3,B_3,I_3)$ (with the difference being they start at different initial conditions), I am looking for plots of the following (as examples): $P_1,P_2,P_3$ versus time, and $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ versus time.
    $endgroup$
    – AzJ
    9 hours ago












  • $begingroup$
    Thanks for your corrected answer
    $endgroup$
    – AzJ
    9 hours ago











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190949%2ftrying-to-plot-the-norm-of-the-solutions-to-ndsolve%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









3












$begingroup$



  • plot the norm of the solutions of a differential equation system versus time.




Plot[Evaluate@(Norm[Through[sol[## & @@ #][t]]] & /@ set), {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> Large,
PlotLegends -> Placed[ToString /@ set, Top],
PlotLabel -> (Norm[{P[t], B[t], i[t]}])]


enter image description here





  • plot one component of the solutions of a differential equation system versus time.






Row[ParametricPlot[Evaluate@Thread[{t, (Through[sol[## & @@ #][t]] & /@ set)[[All, #]]}], 
{t, 0, tmax}, PlotRange -> All,
PlotLegends -> Placed[set[[All, #]], Top] , AspectRatio -> 1,
ImageSize -> 300, PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1,
2, 3}, Spacer[5]]


enter image description here



Alternatively, you can use Plot:



Row[Plot[Evaluate@(Through[sol[## & @@ #][t]] & /@ set)[[All, #]], {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> 300,
PlotLegends -> Placed[set[[All, #]], Top] ,
PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1, 2, 3}, Spacer[5]]


enter image description here






share|improve this answer











$endgroup$









  • 1




    $begingroup$
    I really like this solution exactly what I was looking for and more.
    $endgroup$
    – AzJ
    9 hours ago
















3












$begingroup$



  • plot the norm of the solutions of a differential equation system versus time.




Plot[Evaluate@(Norm[Through[sol[## & @@ #][t]]] & /@ set), {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> Large,
PlotLegends -> Placed[ToString /@ set, Top],
PlotLabel -> (Norm[{P[t], B[t], i[t]}])]


enter image description here





  • plot one component of the solutions of a differential equation system versus time.






Row[ParametricPlot[Evaluate@Thread[{t, (Through[sol[## & @@ #][t]] & /@ set)[[All, #]]}], 
{t, 0, tmax}, PlotRange -> All,
PlotLegends -> Placed[set[[All, #]], Top] , AspectRatio -> 1,
ImageSize -> 300, PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1,
2, 3}, Spacer[5]]


enter image description here



Alternatively, you can use Plot:



Row[Plot[Evaluate@(Through[sol[## & @@ #][t]] & /@ set)[[All, #]], {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> 300,
PlotLegends -> Placed[set[[All, #]], Top] ,
PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1, 2, 3}, Spacer[5]]


enter image description here






share|improve this answer











$endgroup$









  • 1




    $begingroup$
    I really like this solution exactly what I was looking for and more.
    $endgroup$
    – AzJ
    9 hours ago














3












3








3





$begingroup$



  • plot the norm of the solutions of a differential equation system versus time.




Plot[Evaluate@(Norm[Through[sol[## & @@ #][t]]] & /@ set), {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> Large,
PlotLegends -> Placed[ToString /@ set, Top],
PlotLabel -> (Norm[{P[t], B[t], i[t]}])]


enter image description here





  • plot one component of the solutions of a differential equation system versus time.






Row[ParametricPlot[Evaluate@Thread[{t, (Through[sol[## & @@ #][t]] & /@ set)[[All, #]]}], 
{t, 0, tmax}, PlotRange -> All,
PlotLegends -> Placed[set[[All, #]], Top] , AspectRatio -> 1,
ImageSize -> 300, PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1,
2, 3}, Spacer[5]]


enter image description here



Alternatively, you can use Plot:



Row[Plot[Evaluate@(Through[sol[## & @@ #][t]] & /@ set)[[All, #]], {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> 300,
PlotLegends -> Placed[set[[All, #]], Top] ,
PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1, 2, 3}, Spacer[5]]


enter image description here






share|improve this answer











$endgroup$





  • plot the norm of the solutions of a differential equation system versus time.




Plot[Evaluate@(Norm[Through[sol[## & @@ #][t]]] & /@ set), {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> Large,
PlotLegends -> Placed[ToString /@ set, Top],
PlotLabel -> (Norm[{P[t], B[t], i[t]}])]


enter image description here





  • plot one component of the solutions of a differential equation system versus time.






Row[ParametricPlot[Evaluate@Thread[{t, (Through[sol[## & @@ #][t]] & /@ set)[[All, #]]}], 
{t, 0, tmax}, PlotRange -> All,
PlotLegends -> Placed[set[[All, #]], Top] , AspectRatio -> 1,
ImageSize -> 300, PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1,
2, 3}, Spacer[5]]


enter image description here



Alternatively, you can use Plot:



Row[Plot[Evaluate@(Through[sol[## & @@ #][t]] & /@ set)[[All, #]], {t, 0, tmax}, 
PlotRange -> All, AspectRatio -> 1, ImageSize -> 300,
PlotLegends -> Placed[set[[All, #]], Top] ,
PlotLabel -> ({P[t], B[t], i[t]}[[#]])] & /@ {1, 2, 3}, Spacer[5]]


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 8 hours ago

























answered 9 hours ago









kglrkglr

182k10200414




182k10200414








  • 1




    $begingroup$
    I really like this solution exactly what I was looking for and more.
    $endgroup$
    – AzJ
    9 hours ago














  • 1




    $begingroup$
    I really like this solution exactly what I was looking for and more.
    $endgroup$
    – AzJ
    9 hours ago








1




1




$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
9 hours ago




$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
9 hours ago











2












$begingroup$

sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,i[0] == init0}}, {P[t], B[t], i[t]}, {t, 0, tmax}, {init1, init2,init0}]


plot of solutions:



Plot[Table[# &[ Apply[sol, set[[i]]]]  , {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]


plot of euclidean norm:



Plot[Table[Sqrt[ #.#] &[ Apply[sol, set[[i]]] ], {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]





share|improve this answer











$endgroup$













  • $begingroup$
    This does not answer my question for my reasons. First something like Plot[Table[Map[#[t] &, Apply[sol, set[[i]]]], {i, 2, 2}], {t, 0,tmax}] does not plot all of the second components of all the solutions. It plots all the components of the second solution. Next I meant Euclidean Norm, not some other norm (I thought it was self evident as that is the default used by Mathematica when given a vector). Playing around with your code snippet I haven't been able to get the desired result
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    My plot shows 3x3 solutions as you asked for!
    $endgroup$
    – Ulrich Neumann
    9 hours ago










  • $begingroup$
    Sorry my terminology may have confused you. For the context of my problem as I am solving a system of ODEs one function (for example $P(t)$) is a component of the solution $(P(t),B(t),I(t))$.
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    If I have three solutions $(P_1,B_1,I_1)$,$(P_2,B_2,I_2)$,$(P_3,B_3,I_3)$ (with the difference being they start at different initial conditions), I am looking for plots of the following (as examples): $P_1,P_2,P_3$ versus time, and $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ versus time.
    $endgroup$
    – AzJ
    9 hours ago












  • $begingroup$
    Thanks for your corrected answer
    $endgroup$
    – AzJ
    9 hours ago
















2












$begingroup$

sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,i[0] == init0}}, {P[t], B[t], i[t]}, {t, 0, tmax}, {init1, init2,init0}]


plot of solutions:



Plot[Table[# &[ Apply[sol, set[[i]]]]  , {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]


plot of euclidean norm:



Plot[Table[Sqrt[ #.#] &[ Apply[sol, set[[i]]] ], {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]





share|improve this answer











$endgroup$













  • $begingroup$
    This does not answer my question for my reasons. First something like Plot[Table[Map[#[t] &, Apply[sol, set[[i]]]], {i, 2, 2}], {t, 0,tmax}] does not plot all of the second components of all the solutions. It plots all the components of the second solution. Next I meant Euclidean Norm, not some other norm (I thought it was self evident as that is the default used by Mathematica when given a vector). Playing around with your code snippet I haven't been able to get the desired result
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    My plot shows 3x3 solutions as you asked for!
    $endgroup$
    – Ulrich Neumann
    9 hours ago










  • $begingroup$
    Sorry my terminology may have confused you. For the context of my problem as I am solving a system of ODEs one function (for example $P(t)$) is a component of the solution $(P(t),B(t),I(t))$.
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    If I have three solutions $(P_1,B_1,I_1)$,$(P_2,B_2,I_2)$,$(P_3,B_3,I_3)$ (with the difference being they start at different initial conditions), I am looking for plots of the following (as examples): $P_1,P_2,P_3$ versus time, and $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ versus time.
    $endgroup$
    – AzJ
    9 hours ago












  • $begingroup$
    Thanks for your corrected answer
    $endgroup$
    – AzJ
    9 hours ago














2












2








2





$begingroup$

sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,i[0] == init0}}, {P[t], B[t], i[t]}, {t, 0, tmax}, {init1, init2,init0}]


plot of solutions:



Plot[Table[# &[ Apply[sol, set[[i]]]]  , {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]


plot of euclidean norm:



Plot[Table[Sqrt[ #.#] &[ Apply[sol, set[[i]]] ], {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]





share|improve this answer











$endgroup$



sol = ParametricNDSolveValue[{ODEsys, {P[0] == init1, B[0] == init2,i[0] == init0}}, {P[t], B[t], i[t]}, {t, 0, tmax}, {init1, init2,init0}]


plot of solutions:



Plot[Table[# &[ Apply[sol, set[[i]]]]  , {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]


plot of euclidean norm:



Plot[Table[Sqrt[ #.#] &[ Apply[sol, set[[i]]] ], {i, 1, Length[set]}] , {t, 0,tmax}, PlotRange -> {0, Automatic}]






share|improve this answer














share|improve this answer



share|improve this answer








edited 9 hours ago

























answered 11 hours ago









Ulrich NeumannUlrich Neumann

8,592516




8,592516












  • $begingroup$
    This does not answer my question for my reasons. First something like Plot[Table[Map[#[t] &, Apply[sol, set[[i]]]], {i, 2, 2}], {t, 0,tmax}] does not plot all of the second components of all the solutions. It plots all the components of the second solution. Next I meant Euclidean Norm, not some other norm (I thought it was self evident as that is the default used by Mathematica when given a vector). Playing around with your code snippet I haven't been able to get the desired result
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    My plot shows 3x3 solutions as you asked for!
    $endgroup$
    – Ulrich Neumann
    9 hours ago










  • $begingroup$
    Sorry my terminology may have confused you. For the context of my problem as I am solving a system of ODEs one function (for example $P(t)$) is a component of the solution $(P(t),B(t),I(t))$.
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    If I have three solutions $(P_1,B_1,I_1)$,$(P_2,B_2,I_2)$,$(P_3,B_3,I_3)$ (with the difference being they start at different initial conditions), I am looking for plots of the following (as examples): $P_1,P_2,P_3$ versus time, and $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ versus time.
    $endgroup$
    – AzJ
    9 hours ago












  • $begingroup$
    Thanks for your corrected answer
    $endgroup$
    – AzJ
    9 hours ago


















  • $begingroup$
    This does not answer my question for my reasons. First something like Plot[Table[Map[#[t] &, Apply[sol, set[[i]]]], {i, 2, 2}], {t, 0,tmax}] does not plot all of the second components of all the solutions. It plots all the components of the second solution. Next I meant Euclidean Norm, not some other norm (I thought it was self evident as that is the default used by Mathematica when given a vector). Playing around with your code snippet I haven't been able to get the desired result
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    My plot shows 3x3 solutions as you asked for!
    $endgroup$
    – Ulrich Neumann
    9 hours ago










  • $begingroup$
    Sorry my terminology may have confused you. For the context of my problem as I am solving a system of ODEs one function (for example $P(t)$) is a component of the solution $(P(t),B(t),I(t))$.
    $endgroup$
    – AzJ
    9 hours ago










  • $begingroup$
    If I have three solutions $(P_1,B_1,I_1)$,$(P_2,B_2,I_2)$,$(P_3,B_3,I_3)$ (with the difference being they start at different initial conditions), I am looking for plots of the following (as examples): $P_1,P_2,P_3$ versus time, and $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ versus time.
    $endgroup$
    – AzJ
    9 hours ago












  • $begingroup$
    Thanks for your corrected answer
    $endgroup$
    – AzJ
    9 hours ago
















$begingroup$
This does not answer my question for my reasons. First something like Plot[Table[Map[#[t] &, Apply[sol, set[[i]]]], {i, 2, 2}], {t, 0,tmax}] does not plot all of the second components of all the solutions. It plots all the components of the second solution. Next I meant Euclidean Norm, not some other norm (I thought it was self evident as that is the default used by Mathematica when given a vector). Playing around with your code snippet I haven't been able to get the desired result
$endgroup$
– AzJ
9 hours ago




$begingroup$
This does not answer my question for my reasons. First something like Plot[Table[Map[#[t] &, Apply[sol, set[[i]]]], {i, 2, 2}], {t, 0,tmax}] does not plot all of the second components of all the solutions. It plots all the components of the second solution. Next I meant Euclidean Norm, not some other norm (I thought it was self evident as that is the default used by Mathematica when given a vector). Playing around with your code snippet I haven't been able to get the desired result
$endgroup$
– AzJ
9 hours ago












$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
9 hours ago




$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
9 hours ago












$begingroup$
Sorry my terminology may have confused you. For the context of my problem as I am solving a system of ODEs one function (for example $P(t)$) is a component of the solution $(P(t),B(t),I(t))$.
$endgroup$
– AzJ
9 hours ago




$begingroup$
Sorry my terminology may have confused you. For the context of my problem as I am solving a system of ODEs one function (for example $P(t)$) is a component of the solution $(P(t),B(t),I(t))$.
$endgroup$
– AzJ
9 hours ago












$begingroup$
If I have three solutions $(P_1,B_1,I_1)$,$(P_2,B_2,I_2)$,$(P_3,B_3,I_3)$ (with the difference being they start at different initial conditions), I am looking for plots of the following (as examples): $P_1,P_2,P_3$ versus time, and $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ versus time.
$endgroup$
– AzJ
9 hours ago






$begingroup$
If I have three solutions $(P_1,B_1,I_1)$,$(P_2,B_2,I_2)$,$(P_3,B_3,I_3)$ (with the difference being they start at different initial conditions), I am looking for plots of the following (as examples): $P_1,P_2,P_3$ versus time, and $||(P_1,B_1,I_3)||=sqrt{P_1^2+B_1^2+I_3^2}$ versus time.
$endgroup$
– AzJ
9 hours ago














$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
9 hours ago




$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
9 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematica Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f190949%2ftrying-to-plot-the-norm-of-the-solutions-to-ndsolve%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to label and detect the document text images

Vallis Paradisi

Tabula Rosettana