Vector-valued ParametricNDSolve, solving for a combinationVector ParametricNDSolve and FindRoot interactionIs it possible to give the closed-form of the stiffness matrix of triangular prism element?Frequency domain Maxwell equations with PML boundary conditionsJacobian of ParametricNDSolve and FindRoot for the Three Body ProblemGiven a vector field construct a corresponding stream functionNumerically solving two coupled nonlinear PDEs

Digital signature that is only verifiable by one specific person

When is the phrase "j'ai bon" used?

How did the European Union reach the figure of 3% as a maximum allowed deficit?

King or Queen-Which piece is which?

What is the context for Napoleon's quote "[the Austrians] did not know the value of five minutes"?

Checking if argument is a floating point without breaking on control sequences in argument

Boundaries and Buddhism

How can I prevent a user from copying files on another hard drive?

How to make a villain when your PCs are villains?

How to address players struggling with simple controls?

Build a scale without computer

Are there any individual aliens that have gained superpowers in the Marvel universe?

How can I maintain game balance while allowing my player to craft genuinely useful items?

Got a new frameset, don't know why I need this split ring collar?

In windows systems, is renaming files functionally similar to deleting them?

How can the US president give an order to a civilian?

Is it a bad idea to have a pen name with only an initial for a surname?

How could I create a situation in which a PC has to make a saving throw or be forced to pet a dog?

how to find which software is doing ssh connection?

Is this broken pipe the reason my freezer is not working? Can it be fixed?

How did space travel spread throughout the Star Wars galaxy?

Using roof rails to set up hammock

What is "dot" sign in •NO?

How do I correctly reduce geometry on part of a mesh?



Vector-valued ParametricNDSolve, solving for a combination


Vector ParametricNDSolve and FindRoot interactionIs it possible to give the closed-form of the stiffness matrix of triangular prism element?Frequency domain Maxwell equations with PML boundary conditionsJacobian of ParametricNDSolve and FindRoot for the Three Body ProblemGiven a vector field construct a corresponding stream functionNumerically solving two coupled nonlinear PDEs













4












$begingroup$


I am integrating two vector differential equations using ParametricNDSolve, one for $mathbfY$ and one for $mathbfZ$, and then I'm interested in a combination of the two of them. ParametricNDSolve allows for specifying the output to just be a function of the two, for instance $mathbfY cdot mathbfZ$, but the combination I want is (for the case of sixth order vector equations):
$$psi = y_1 z_6 -y_2 z_5 + y_3 z_4 + y_4 z_3 - y_5 z_2 +y_6 z_1$$



Is there a way to get ParametricNDSolve to give me this combination directly?



Example code:



A = 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, q, 0, -Sin[x], 0;
Q[x_, q_] = 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, -Sin[x],0, 0, 1, 0,
0, 0, 0, 0, 1, 0, -q, 0, 0, -Sin[x], 0, 1, 0, -q, 0, 0, 0, 0;
n = Length[Q[x, q]];
cA = With[code = N@A, Compile[x, _Real, q, _Real, code]];
F[x_?NumericQ, q_?NumericQ, Y_?VectorQ] :=
(Q[x, q] - DiagonalMatrix[ConstantArray[1, n]]).Y;
xa = -4; xb = 4; xm = 0;
k = -((-xb + xm)/(xa - xm)); c = -((-xa xm + xb xm)/(xa - xm));
Y0 = 0, 0, 0, 0, -1, 0;
Z0 = 0, 1, 0, 0, 0, 0;

YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
Z'[x] == 1/k F[k x + c , q, Z[x]], Z[xa] == Z0, Y, Z, x, xa, xm, q];


I'm interested in finding where $psi=0$, which I can do with this construction, but is there a more direct way to get it out of the ParametricNDSolveValue?



psi[q_?NumericQ] := (Y[1] Z[6] - Y[2] Z[5] + Y[3] Z[4] + Y[4] Z[3] - 
Y[5] Z[2] + Y[6] Z[1]) /. Y[a_] :> YZsol[q][[1]][xm][[a]],
Z[a_] :> YZsol[q][[2]][xm][[a]];

FindRoot[psi[q], q, 3]


Edit:



Carl's answer does exactly what I need, but I see a strange timing effect, where after I use FindRoot it takes 6 times longer to do the same calculation:



Clear[YZsol2]; YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0, Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y[xm].form.Z[xm], x, xa, xm, q]; 
AbsoluteTiming[YZsol2 /@ Range[20]]
(* 0.259752, Null *)

Clear[YZsol3]; YZsol3 =
ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y[xm].form.Z[xm], x, xa, xm, q];
FindRoot[YZsol3[q], q, 3];
AbsoluteTiming[YZsol3 /@ Range[20]]
(* 1.69719, Null *)









share|improve this question











$endgroup$
















    4












    $begingroup$


    I am integrating two vector differential equations using ParametricNDSolve, one for $mathbfY$ and one for $mathbfZ$, and then I'm interested in a combination of the two of them. ParametricNDSolve allows for specifying the output to just be a function of the two, for instance $mathbfY cdot mathbfZ$, but the combination I want is (for the case of sixth order vector equations):
    $$psi = y_1 z_6 -y_2 z_5 + y_3 z_4 + y_4 z_3 - y_5 z_2 +y_6 z_1$$



    Is there a way to get ParametricNDSolve to give me this combination directly?



    Example code:



    A = 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, q, 0, -Sin[x], 0;
    Q[x_, q_] = 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, -Sin[x],0, 0, 1, 0,
    0, 0, 0, 0, 1, 0, -q, 0, 0, -Sin[x], 0, 1, 0, -q, 0, 0, 0, 0;
    n = Length[Q[x, q]];
    cA = With[code = N@A, Compile[x, _Real, q, _Real, code]];
    F[x_?NumericQ, q_?NumericQ, Y_?VectorQ] :=
    (Q[x, q] - DiagonalMatrix[ConstantArray[1, n]]).Y;
    xa = -4; xb = 4; xm = 0;
    k = -((-xb + xm)/(xa - xm)); c = -((-xa xm + xb xm)/(xa - xm));
    Y0 = 0, 0, 0, 0, -1, 0;
    Z0 = 0, 1, 0, 0, 0, 0;

    YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
    Z'[x] == 1/k F[k x + c , q, Z[x]], Z[xa] == Z0, Y, Z, x, xa, xm, q];


    I'm interested in finding where $psi=0$, which I can do with this construction, but is there a more direct way to get it out of the ParametricNDSolveValue?



    psi[q_?NumericQ] := (Y[1] Z[6] - Y[2] Z[5] + Y[3] Z[4] + Y[4] Z[3] - 
    Y[5] Z[2] + Y[6] Z[1]) /. Y[a_] :> YZsol[q][[1]][xm][[a]],
    Z[a_] :> YZsol[q][[2]][xm][[a]];

    FindRoot[psi[q], q, 3]


    Edit:



    Carl's answer does exactly what I need, but I see a strange timing effect, where after I use FindRoot it takes 6 times longer to do the same calculation:



    Clear[YZsol2]; YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0, Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y[xm].form.Z[xm], x, xa, xm, q]; 
    AbsoluteTiming[YZsol2 /@ Range[20]]
    (* 0.259752, Null *)

    Clear[YZsol3]; YZsol3 =
    ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
    Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y[xm].form.Z[xm], x, xa, xm, q];
    FindRoot[YZsol3[q], q, 3];
    AbsoluteTiming[YZsol3 /@ Range[20]]
    (* 1.69719, Null *)









    share|improve this question











    $endgroup$














      4












      4








      4





      $begingroup$


      I am integrating two vector differential equations using ParametricNDSolve, one for $mathbfY$ and one for $mathbfZ$, and then I'm interested in a combination of the two of them. ParametricNDSolve allows for specifying the output to just be a function of the two, for instance $mathbfY cdot mathbfZ$, but the combination I want is (for the case of sixth order vector equations):
      $$psi = y_1 z_6 -y_2 z_5 + y_3 z_4 + y_4 z_3 - y_5 z_2 +y_6 z_1$$



      Is there a way to get ParametricNDSolve to give me this combination directly?



      Example code:



      A = 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, q, 0, -Sin[x], 0;
      Q[x_, q_] = 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, -Sin[x],0, 0, 1, 0,
      0, 0, 0, 0, 1, 0, -q, 0, 0, -Sin[x], 0, 1, 0, -q, 0, 0, 0, 0;
      n = Length[Q[x, q]];
      cA = With[code = N@A, Compile[x, _Real, q, _Real, code]];
      F[x_?NumericQ, q_?NumericQ, Y_?VectorQ] :=
      (Q[x, q] - DiagonalMatrix[ConstantArray[1, n]]).Y;
      xa = -4; xb = 4; xm = 0;
      k = -((-xb + xm)/(xa - xm)); c = -((-xa xm + xb xm)/(xa - xm));
      Y0 = 0, 0, 0, 0, -1, 0;
      Z0 = 0, 1, 0, 0, 0, 0;

      YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
      Z'[x] == 1/k F[k x + c , q, Z[x]], Z[xa] == Z0, Y, Z, x, xa, xm, q];


      I'm interested in finding where $psi=0$, which I can do with this construction, but is there a more direct way to get it out of the ParametricNDSolveValue?



      psi[q_?NumericQ] := (Y[1] Z[6] - Y[2] Z[5] + Y[3] Z[4] + Y[4] Z[3] - 
      Y[5] Z[2] + Y[6] Z[1]) /. Y[a_] :> YZsol[q][[1]][xm][[a]],
      Z[a_] :> YZsol[q][[2]][xm][[a]];

      FindRoot[psi[q], q, 3]


      Edit:



      Carl's answer does exactly what I need, but I see a strange timing effect, where after I use FindRoot it takes 6 times longer to do the same calculation:



      Clear[YZsol2]; YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0, Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y[xm].form.Z[xm], x, xa, xm, q]; 
      AbsoluteTiming[YZsol2 /@ Range[20]]
      (* 0.259752, Null *)

      Clear[YZsol3]; YZsol3 =
      ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
      Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y[xm].form.Z[xm], x, xa, xm, q];
      FindRoot[YZsol3[q], q, 3];
      AbsoluteTiming[YZsol3 /@ Range[20]]
      (* 1.69719, Null *)









      share|improve this question











      $endgroup$




      I am integrating two vector differential equations using ParametricNDSolve, one for $mathbfY$ and one for $mathbfZ$, and then I'm interested in a combination of the two of them. ParametricNDSolve allows for specifying the output to just be a function of the two, for instance $mathbfY cdot mathbfZ$, but the combination I want is (for the case of sixth order vector equations):
      $$psi = y_1 z_6 -y_2 z_5 + y_3 z_4 + y_4 z_3 - y_5 z_2 +y_6 z_1$$



      Is there a way to get ParametricNDSolve to give me this combination directly?



      Example code:



      A = 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, q, 0, -Sin[x], 0;
      Q[x_, q_] = 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, -Sin[x],0, 0, 1, 0,
      0, 0, 0, 0, 1, 0, -q, 0, 0, -Sin[x], 0, 1, 0, -q, 0, 0, 0, 0;
      n = Length[Q[x, q]];
      cA = With[code = N@A, Compile[x, _Real, q, _Real, code]];
      F[x_?NumericQ, q_?NumericQ, Y_?VectorQ] :=
      (Q[x, q] - DiagonalMatrix[ConstantArray[1, n]]).Y;
      xa = -4; xb = 4; xm = 0;
      k = -((-xb + xm)/(xa - xm)); c = -((-xa xm + xb xm)/(xa - xm));
      Y0 = 0, 0, 0, 0, -1, 0;
      Z0 = 0, 1, 0, 0, 0, 0;

      YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
      Z'[x] == 1/k F[k x + c , q, Z[x]], Z[xa] == Z0, Y, Z, x, xa, xm, q];


      I'm interested in finding where $psi=0$, which I can do with this construction, but is there a more direct way to get it out of the ParametricNDSolveValue?



      psi[q_?NumericQ] := (Y[1] Z[6] - Y[2] Z[5] + Y[3] Z[4] + Y[4] Z[3] - 
      Y[5] Z[2] + Y[6] Z[1]) /. Y[a_] :> YZsol[q][[1]][xm][[a]],
      Z[a_] :> YZsol[q][[2]][xm][[a]];

      FindRoot[psi[q], q, 3]


      Edit:



      Carl's answer does exactly what I need, but I see a strange timing effect, where after I use FindRoot it takes 6 times longer to do the same calculation:



      Clear[YZsol2]; YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0, Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y[xm].form.Z[xm], x, xa, xm, q]; 
      AbsoluteTiming[YZsol2 /@ Range[20]]
      (* 0.259752, Null *)

      Clear[YZsol3]; YZsol3 =
      ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
      Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y[xm].form.Z[xm], x, xa, xm, q];
      FindRoot[YZsol3[q], q, 3];
      AbsoluteTiming[YZsol3 /@ Range[20]]
      (* 1.69719, Null *)






      differential-equations






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 31 at 19:42







      KraZug

















      asked May 31 at 12:22









      KraZugKraZug

      3,71421131




      3,71421131




















          2 Answers
          2






          active

          oldest

          votes


















          5












          $begingroup$

          Define a quadratic form matrix:



          form = 
          0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, -1, 0,
          0, 0, 0, 1, 0, 0,
          0, 0, 1, 0, 0, 0,
          0, -1, 0, 0, 0, 0,
          1, 0, 0, 0, 0, 0
          ;


          Then:



          YZsol2 = ParametricNDSolveValue[
          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          Y[xm] . form . Z[xm],
          x,xa,xm,
          q
          ];


          will produce the desired function. For example:



          YZsol2 /@ Range[0, 4]
          psi /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Another possibility is to include your desired output as an additional equation (constraint):



          YZsol3 = ParametricNDSolveValue[

          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          U[x] == Y[x] . form . Z[x]
          ,
          U[xm],
          x,xa,xm,
          q
          ];


          Check:



          YZsol3 /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Note that there is a bug as of June 2019 with using this inside a FindRoot, which makes it much slower unless we add Method -> "ParametricSensitivity" -> None as detailed in Vector ParametricNDSolve and FindRoot interaction).






          share|improve this answer











          $endgroup$












          • $begingroup$
            Thanks, of course that is a way to write it as a vector/matrix equation
            $endgroup$
            – KraZug
            May 31 at 14:31











          • $begingroup$
            Huh, that works really well, except they are both much slower than the original formulation. The constraint version also fails to find the root (presumably because it is using a different internal method on the NDSolve.
            $endgroup$
            – KraZug
            May 31 at 14:42










          • $begingroup$
            I edited your answer to include a link to another question where I show the workaround to not be slow with FindRoot.
            $endgroup$
            – KraZug
            Jun 7 at 7:35


















          2












          $begingroup$

          A hybrid of yours and @CarlWoll's approach seems to perform well after FindRoot.



          Clear[YZsol, psi2]
          form = Reverse@DiagonalMatrix@PadRight[, 6, 1, -1, 1];
          YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y, Z, x, xa,
          xm, q];
          psi2[q_?NumericQ] := (Y.form.Z) /. Y :> YZsol[q][[1]][xm],
          Z :> YZsol[q][[2]][xm];
          FindRoot[psi2[q], q, 3]
          AbsoluteTiming[psi2 /@ Range[20]]

          Clear[YZsol2];
          YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          AbsoluteTiming[YZsol2 /@ Range[20]]


          Clear[YZsol3]; YZsol3 =
          ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          FindRoot[YZsol3[q], q, 3];
          AbsoluteTiming[YZsol3 /@ Range[20]]
          (* q -> 3.55393 *)
          (* 0.279002, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 0.337883, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 2.20664, -148.785, -6240.83, -7841.05, 12815., 63393.6,
          134180., 197976., 214748.,
          139054., -71335.6, -446840., -998421., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22467*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)





          share|improve this answer









          $endgroup$












          • $begingroup$
            Er… what's the difference between YZsol2 and YZsol3?
            $endgroup$
            – xzczd
            Jun 1 at 4:53










          • $begingroup$
            @xzczd, there is no difference, just one has FindRoot applied first
            $endgroup$
            – KraZug
            Jun 1 at 6:40










          • $begingroup$
            @KraZug So, if FindRoot is called first, the corresponding ParametricFunction will be slower?
            $endgroup$
            – xzczd
            Jun 1 at 9:09










          • $begingroup$
            This is basically the same as my approach directly. I was thinking that using ParametricNDSolve to calculate the quantity of interest would be faster and perhaps more accurate.
            $endgroup$
            – KraZug
            Jun 1 at 9:11










          • $begingroup$
            @xzczd, exactly. And the FindRoot is slower too. It is marginally faster to evaluate individual points until you use FindRoot , then it slows down considerably
            $endgroup$
            – KraZug
            Jun 1 at 9:13











          Your Answer








          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%2f199458%2fvector-valued-parametricndsolve-solving-for-a-combination%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









          5












          $begingroup$

          Define a quadratic form matrix:



          form = 
          0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, -1, 0,
          0, 0, 0, 1, 0, 0,
          0, 0, 1, 0, 0, 0,
          0, -1, 0, 0, 0, 0,
          1, 0, 0, 0, 0, 0
          ;


          Then:



          YZsol2 = ParametricNDSolveValue[
          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          Y[xm] . form . Z[xm],
          x,xa,xm,
          q
          ];


          will produce the desired function. For example:



          YZsol2 /@ Range[0, 4]
          psi /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Another possibility is to include your desired output as an additional equation (constraint):



          YZsol3 = ParametricNDSolveValue[

          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          U[x] == Y[x] . form . Z[x]
          ,
          U[xm],
          x,xa,xm,
          q
          ];


          Check:



          YZsol3 /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Note that there is a bug as of June 2019 with using this inside a FindRoot, which makes it much slower unless we add Method -> "ParametricSensitivity" -> None as detailed in Vector ParametricNDSolve and FindRoot interaction).






          share|improve this answer











          $endgroup$












          • $begingroup$
            Thanks, of course that is a way to write it as a vector/matrix equation
            $endgroup$
            – KraZug
            May 31 at 14:31











          • $begingroup$
            Huh, that works really well, except they are both much slower than the original formulation. The constraint version also fails to find the root (presumably because it is using a different internal method on the NDSolve.
            $endgroup$
            – KraZug
            May 31 at 14:42










          • $begingroup$
            I edited your answer to include a link to another question where I show the workaround to not be slow with FindRoot.
            $endgroup$
            – KraZug
            Jun 7 at 7:35















          5












          $begingroup$

          Define a quadratic form matrix:



          form = 
          0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, -1, 0,
          0, 0, 0, 1, 0, 0,
          0, 0, 1, 0, 0, 0,
          0, -1, 0, 0, 0, 0,
          1, 0, 0, 0, 0, 0
          ;


          Then:



          YZsol2 = ParametricNDSolveValue[
          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          Y[xm] . form . Z[xm],
          x,xa,xm,
          q
          ];


          will produce the desired function. For example:



          YZsol2 /@ Range[0, 4]
          psi /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Another possibility is to include your desired output as an additional equation (constraint):



          YZsol3 = ParametricNDSolveValue[

          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          U[x] == Y[x] . form . Z[x]
          ,
          U[xm],
          x,xa,xm,
          q
          ];


          Check:



          YZsol3 /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Note that there is a bug as of June 2019 with using this inside a FindRoot, which makes it much slower unless we add Method -> "ParametricSensitivity" -> None as detailed in Vector ParametricNDSolve and FindRoot interaction).






          share|improve this answer











          $endgroup$












          • $begingroup$
            Thanks, of course that is a way to write it as a vector/matrix equation
            $endgroup$
            – KraZug
            May 31 at 14:31











          • $begingroup$
            Huh, that works really well, except they are both much slower than the original formulation. The constraint version also fails to find the root (presumably because it is using a different internal method on the NDSolve.
            $endgroup$
            – KraZug
            May 31 at 14:42










          • $begingroup$
            I edited your answer to include a link to another question where I show the workaround to not be slow with FindRoot.
            $endgroup$
            – KraZug
            Jun 7 at 7:35













          5












          5








          5





          $begingroup$

          Define a quadratic form matrix:



          form = 
          0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, -1, 0,
          0, 0, 0, 1, 0, 0,
          0, 0, 1, 0, 0, 0,
          0, -1, 0, 0, 0, 0,
          1, 0, 0, 0, 0, 0
          ;


          Then:



          YZsol2 = ParametricNDSolveValue[
          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          Y[xm] . form . Z[xm],
          x,xa,xm,
          q
          ];


          will produce the desired function. For example:



          YZsol2 /@ Range[0, 4]
          psi /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Another possibility is to include your desired output as an additional equation (constraint):



          YZsol3 = ParametricNDSolveValue[

          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          U[x] == Y[x] . form . Z[x]
          ,
          U[xm],
          x,xa,xm,
          q
          ];


          Check:



          YZsol3 /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Note that there is a bug as of June 2019 with using this inside a FindRoot, which makes it much slower unless we add Method -> "ParametricSensitivity" -> None as detailed in Vector ParametricNDSolve and FindRoot interaction).






          share|improve this answer











          $endgroup$



          Define a quadratic form matrix:



          form = 
          0, 0, 0, 0, 0, 1,
          0, 0, 0, 0, -1, 0,
          0, 0, 0, 1, 0, 0,
          0, 0, 1, 0, 0, 0,
          0, -1, 0, 0, 0, 0,
          1, 0, 0, 0, 0, 0
          ;


          Then:



          YZsol2 = ParametricNDSolveValue[
          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          Y[xm] . form . Z[xm],
          x,xa,xm,
          q
          ];


          will produce the desired function. For example:



          YZsol2 /@ Range[0, 4]
          psi /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Another possibility is to include your desired output as an additional equation (constraint):



          YZsol3 = ParametricNDSolveValue[

          Y'[x] == F[x,q,Y[x]], Y[xa]==Y0,
          Z'[x] == 1/k F[k x+c,q,Z[x]], Z[xa]==Z0,
          U[x] == Y[x] . form . Z[x]
          ,
          U[xm],
          x,xa,xm,
          q
          ];


          Check:



          YZsol3 /@ Range[0, 4]



          -24.1853, -148.784, -6240.84, -7841.06, 12815.




          Note that there is a bug as of June 2019 with using this inside a FindRoot, which makes it much slower unless we add Method -> "ParametricSensitivity" -> None as detailed in Vector ParametricNDSolve and FindRoot interaction).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 7 at 7:20









          KraZug

          3,71421131




          3,71421131










          answered May 31 at 14:13









          Carl WollCarl Woll

          84.1k3107218




          84.1k3107218











          • $begingroup$
            Thanks, of course that is a way to write it as a vector/matrix equation
            $endgroup$
            – KraZug
            May 31 at 14:31











          • $begingroup$
            Huh, that works really well, except they are both much slower than the original formulation. The constraint version also fails to find the root (presumably because it is using a different internal method on the NDSolve.
            $endgroup$
            – KraZug
            May 31 at 14:42










          • $begingroup$
            I edited your answer to include a link to another question where I show the workaround to not be slow with FindRoot.
            $endgroup$
            – KraZug
            Jun 7 at 7:35
















          • $begingroup$
            Thanks, of course that is a way to write it as a vector/matrix equation
            $endgroup$
            – KraZug
            May 31 at 14:31











          • $begingroup$
            Huh, that works really well, except they are both much slower than the original formulation. The constraint version also fails to find the root (presumably because it is using a different internal method on the NDSolve.
            $endgroup$
            – KraZug
            May 31 at 14:42










          • $begingroup$
            I edited your answer to include a link to another question where I show the workaround to not be slow with FindRoot.
            $endgroup$
            – KraZug
            Jun 7 at 7:35















          $begingroup$
          Thanks, of course that is a way to write it as a vector/matrix equation
          $endgroup$
          – KraZug
          May 31 at 14:31





          $begingroup$
          Thanks, of course that is a way to write it as a vector/matrix equation
          $endgroup$
          – KraZug
          May 31 at 14:31













          $begingroup$
          Huh, that works really well, except they are both much slower than the original formulation. The constraint version also fails to find the root (presumably because it is using a different internal method on the NDSolve.
          $endgroup$
          – KraZug
          May 31 at 14:42




          $begingroup$
          Huh, that works really well, except they are both much slower than the original formulation. The constraint version also fails to find the root (presumably because it is using a different internal method on the NDSolve.
          $endgroup$
          – KraZug
          May 31 at 14:42












          $begingroup$
          I edited your answer to include a link to another question where I show the workaround to not be slow with FindRoot.
          $endgroup$
          – KraZug
          Jun 7 at 7:35




          $begingroup$
          I edited your answer to include a link to another question where I show the workaround to not be slow with FindRoot.
          $endgroup$
          – KraZug
          Jun 7 at 7:35











          2












          $begingroup$

          A hybrid of yours and @CarlWoll's approach seems to perform well after FindRoot.



          Clear[YZsol, psi2]
          form = Reverse@DiagonalMatrix@PadRight[, 6, 1, -1, 1];
          YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y, Z, x, xa,
          xm, q];
          psi2[q_?NumericQ] := (Y.form.Z) /. Y :> YZsol[q][[1]][xm],
          Z :> YZsol[q][[2]][xm];
          FindRoot[psi2[q], q, 3]
          AbsoluteTiming[psi2 /@ Range[20]]

          Clear[YZsol2];
          YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          AbsoluteTiming[YZsol2 /@ Range[20]]


          Clear[YZsol3]; YZsol3 =
          ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          FindRoot[YZsol3[q], q, 3];
          AbsoluteTiming[YZsol3 /@ Range[20]]
          (* q -> 3.55393 *)
          (* 0.279002, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 0.337883, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 2.20664, -148.785, -6240.83, -7841.05, 12815., 63393.6,
          134180., 197976., 214748.,
          139054., -71335.6, -446840., -998421., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22467*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)





          share|improve this answer









          $endgroup$












          • $begingroup$
            Er… what's the difference between YZsol2 and YZsol3?
            $endgroup$
            – xzczd
            Jun 1 at 4:53










          • $begingroup$
            @xzczd, there is no difference, just one has FindRoot applied first
            $endgroup$
            – KraZug
            Jun 1 at 6:40










          • $begingroup$
            @KraZug So, if FindRoot is called first, the corresponding ParametricFunction will be slower?
            $endgroup$
            – xzczd
            Jun 1 at 9:09










          • $begingroup$
            This is basically the same as my approach directly. I was thinking that using ParametricNDSolve to calculate the quantity of interest would be faster and perhaps more accurate.
            $endgroup$
            – KraZug
            Jun 1 at 9:11










          • $begingroup$
            @xzczd, exactly. And the FindRoot is slower too. It is marginally faster to evaluate individual points until you use FindRoot , then it slows down considerably
            $endgroup$
            – KraZug
            Jun 1 at 9:13















          2












          $begingroup$

          A hybrid of yours and @CarlWoll's approach seems to perform well after FindRoot.



          Clear[YZsol, psi2]
          form = Reverse@DiagonalMatrix@PadRight[, 6, 1, -1, 1];
          YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y, Z, x, xa,
          xm, q];
          psi2[q_?NumericQ] := (Y.form.Z) /. Y :> YZsol[q][[1]][xm],
          Z :> YZsol[q][[2]][xm];
          FindRoot[psi2[q], q, 3]
          AbsoluteTiming[psi2 /@ Range[20]]

          Clear[YZsol2];
          YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          AbsoluteTiming[YZsol2 /@ Range[20]]


          Clear[YZsol3]; YZsol3 =
          ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          FindRoot[YZsol3[q], q, 3];
          AbsoluteTiming[YZsol3 /@ Range[20]]
          (* q -> 3.55393 *)
          (* 0.279002, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 0.337883, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 2.20664, -148.785, -6240.83, -7841.05, 12815., 63393.6,
          134180., 197976., 214748.,
          139054., -71335.6, -446840., -998421., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22467*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)





          share|improve this answer









          $endgroup$












          • $begingroup$
            Er… what's the difference between YZsol2 and YZsol3?
            $endgroup$
            – xzczd
            Jun 1 at 4:53










          • $begingroup$
            @xzczd, there is no difference, just one has FindRoot applied first
            $endgroup$
            – KraZug
            Jun 1 at 6:40










          • $begingroup$
            @KraZug So, if FindRoot is called first, the corresponding ParametricFunction will be slower?
            $endgroup$
            – xzczd
            Jun 1 at 9:09










          • $begingroup$
            This is basically the same as my approach directly. I was thinking that using ParametricNDSolve to calculate the quantity of interest would be faster and perhaps more accurate.
            $endgroup$
            – KraZug
            Jun 1 at 9:11










          • $begingroup$
            @xzczd, exactly. And the FindRoot is slower too. It is marginally faster to evaluate individual points until you use FindRoot , then it slows down considerably
            $endgroup$
            – KraZug
            Jun 1 at 9:13













          2












          2








          2





          $begingroup$

          A hybrid of yours and @CarlWoll's approach seems to perform well after FindRoot.



          Clear[YZsol, psi2]
          form = Reverse@DiagonalMatrix@PadRight[, 6, 1, -1, 1];
          YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y, Z, x, xa,
          xm, q];
          psi2[q_?NumericQ] := (Y.form.Z) /. Y :> YZsol[q][[1]][xm],
          Z :> YZsol[q][[2]][xm];
          FindRoot[psi2[q], q, 3]
          AbsoluteTiming[psi2 /@ Range[20]]

          Clear[YZsol2];
          YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          AbsoluteTiming[YZsol2 /@ Range[20]]


          Clear[YZsol3]; YZsol3 =
          ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          FindRoot[YZsol3[q], q, 3];
          AbsoluteTiming[YZsol3 /@ Range[20]]
          (* q -> 3.55393 *)
          (* 0.279002, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 0.337883, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 2.20664, -148.785, -6240.83, -7841.05, 12815., 63393.6,
          134180., 197976., 214748.,
          139054., -71335.6, -446840., -998421., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22467*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)





          share|improve this answer









          $endgroup$



          A hybrid of yours and @CarlWoll's approach seems to perform well after FindRoot.



          Clear[YZsol, psi2]
          form = Reverse@DiagonalMatrix@PadRight[, 6, 1, -1, 1];
          YZsol = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0, Y, Z, x, xa,
          xm, q];
          psi2[q_?NumericQ] := (Y.form.Z) /. Y :> YZsol[q][[1]][xm],
          Z :> YZsol[q][[2]][xm];
          FindRoot[psi2[q], q, 3]
          AbsoluteTiming[psi2 /@ Range[20]]

          Clear[YZsol2];
          YZsol2 = ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          AbsoluteTiming[YZsol2 /@ Range[20]]


          Clear[YZsol3]; YZsol3 =
          ParametricNDSolveValue[Y'[x] == F[x, q, Y[x]], Y[xa] == Y0,
          Z'[x] == 1/k F[k x + c, q, Z[x]], Z[xa] == Z0,
          Y[xm].form.Z[xm], x, xa, xm, q];
          FindRoot[YZsol3[q], q, 3];
          AbsoluteTiming[YZsol3 /@ Range[20]]
          (* q -> 3.55393 *)
          (* 0.279002, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 0.337883, -148.784, -6240.84, -7841.06, 12815., 63393.7,
          134180., 197976., 214749.,
          139054., -71335.6, -446840., -998422., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22468*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)
          (* 2.20664, -148.785, -6240.83, -7841.05, 12815., 63393.6,
          134180., 197976., 214748.,
          139054., -71335.6, -446840., -998421., -1.71155*10^6, -2.5422*10^6,
          -3.41516*10^6, -4.22467*10^6, -4.83742*10^6, -5.09767*10^6,
          -4.83432*10^6, -3.86961*10^6 *)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 31 at 22:38









          Tim LaskaTim Laska

          1,1911210




          1,1911210











          • $begingroup$
            Er… what's the difference between YZsol2 and YZsol3?
            $endgroup$
            – xzczd
            Jun 1 at 4:53










          • $begingroup$
            @xzczd, there is no difference, just one has FindRoot applied first
            $endgroup$
            – KraZug
            Jun 1 at 6:40










          • $begingroup$
            @KraZug So, if FindRoot is called first, the corresponding ParametricFunction will be slower?
            $endgroup$
            – xzczd
            Jun 1 at 9:09










          • $begingroup$
            This is basically the same as my approach directly. I was thinking that using ParametricNDSolve to calculate the quantity of interest would be faster and perhaps more accurate.
            $endgroup$
            – KraZug
            Jun 1 at 9:11










          • $begingroup$
            @xzczd, exactly. And the FindRoot is slower too. It is marginally faster to evaluate individual points until you use FindRoot , then it slows down considerably
            $endgroup$
            – KraZug
            Jun 1 at 9:13
















          • $begingroup$
            Er… what's the difference between YZsol2 and YZsol3?
            $endgroup$
            – xzczd
            Jun 1 at 4:53










          • $begingroup$
            @xzczd, there is no difference, just one has FindRoot applied first
            $endgroup$
            – KraZug
            Jun 1 at 6:40










          • $begingroup$
            @KraZug So, if FindRoot is called first, the corresponding ParametricFunction will be slower?
            $endgroup$
            – xzczd
            Jun 1 at 9:09










          • $begingroup$
            This is basically the same as my approach directly. I was thinking that using ParametricNDSolve to calculate the quantity of interest would be faster and perhaps more accurate.
            $endgroup$
            – KraZug
            Jun 1 at 9:11










          • $begingroup$
            @xzczd, exactly. And the FindRoot is slower too. It is marginally faster to evaluate individual points until you use FindRoot , then it slows down considerably
            $endgroup$
            – KraZug
            Jun 1 at 9:13















          $begingroup$
          Er… what's the difference between YZsol2 and YZsol3?
          $endgroup$
          – xzczd
          Jun 1 at 4:53




          $begingroup$
          Er… what's the difference between YZsol2 and YZsol3?
          $endgroup$
          – xzczd
          Jun 1 at 4:53












          $begingroup$
          @xzczd, there is no difference, just one has FindRoot applied first
          $endgroup$
          – KraZug
          Jun 1 at 6:40




          $begingroup$
          @xzczd, there is no difference, just one has FindRoot applied first
          $endgroup$
          – KraZug
          Jun 1 at 6:40












          $begingroup$
          @KraZug So, if FindRoot is called first, the corresponding ParametricFunction will be slower?
          $endgroup$
          – xzczd
          Jun 1 at 9:09




          $begingroup$
          @KraZug So, if FindRoot is called first, the corresponding ParametricFunction will be slower?
          $endgroup$
          – xzczd
          Jun 1 at 9:09












          $begingroup$
          This is basically the same as my approach directly. I was thinking that using ParametricNDSolve to calculate the quantity of interest would be faster and perhaps more accurate.
          $endgroup$
          – KraZug
          Jun 1 at 9:11




          $begingroup$
          This is basically the same as my approach directly. I was thinking that using ParametricNDSolve to calculate the quantity of interest would be faster and perhaps more accurate.
          $endgroup$
          – KraZug
          Jun 1 at 9:11












          $begingroup$
          @xzczd, exactly. And the FindRoot is slower too. It is marginally faster to evaluate individual points until you use FindRoot , then it slows down considerably
          $endgroup$
          – KraZug
          Jun 1 at 9:13




          $begingroup$
          @xzczd, exactly. And the FindRoot is slower too. It is marginally faster to evaluate individual points until you use FindRoot , then it slows down considerably
          $endgroup$
          – KraZug
          Jun 1 at 9:13

















          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%2f199458%2fvector-valued-parametricndsolve-solving-for-a-combination%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

          Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

          Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

          What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company