Trying to plot the norm of the solutions to NDsolve
$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]
plotting differential-equations syntax
$endgroup$
add a comment |
$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]
plotting differential-equations syntax
$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
6 hours ago
add a comment |
$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]
plotting differential-equations syntax
$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
plotting differential-equations syntax
asked 8 hours ago
AzJAzJ
33518
33518
$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
6 hours ago
add a comment |
$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
6 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
6 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
6 hours ago
add a comment |
2 Answers
2
active
oldest
votes
$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]}])]
- 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]]
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]]
$endgroup$
1
$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
5 hours ago
add a comment |
$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}]
$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
6 hours ago
$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
6 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
6 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
6 hours ago
$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
5 hours ago
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
$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]}])]
- 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]]
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]]
$endgroup$
1
$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
5 hours ago
add a comment |
$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]}])]
- 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]]
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]]
$endgroup$
1
$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
5 hours ago
add a comment |
$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]}])]
- 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]]
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]]
$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]}])]
- 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]]
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]]
edited 4 hours ago
answered 5 hours ago
kglrkglr
182k10200414
182k10200414
1
$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
5 hours ago
add a comment |
1
$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
5 hours ago
1
1
$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
5 hours ago
$begingroup$
I really like this solution exactly what I was looking for and more.
$endgroup$
– AzJ
5 hours ago
add a comment |
$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}]
$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
6 hours ago
$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
6 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
6 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
6 hours ago
$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
5 hours ago
add a comment |
$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}]
$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
6 hours ago
$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
6 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
6 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
6 hours ago
$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
5 hours ago
add a comment |
$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}]
$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}]
edited 5 hours ago
answered 8 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
6 hours ago
$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
6 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
6 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
6 hours ago
$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
5 hours ago
add a comment |
$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
6 hours ago
$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
6 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
6 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
6 hours ago
$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
5 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
6 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
6 hours ago
$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
6 hours ago
$begingroup$
My plot shows 3x3 solutions as you asked for!
$endgroup$
– Ulrich Neumann
6 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
6 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
6 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
6 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
6 hours ago
$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
5 hours ago
$begingroup$
Thanks for your corrected answer
$endgroup$
– AzJ
5 hours ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
$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
6 hours ago