Finding NDSolve method details












2












$begingroup$


I have eqs about the NDSolve, I know this code given the solving automatically.



How can I find out what method is used behind the scenes? How can I gauge the reliability level, find how many iterations have been used, the order of method. How can I estimate the error?



I found hints on this site, but I still do not fully understand.



It is impossible to say NDSolve has automatically solution for publishing paper?



I used this code related to my system:



r = 0.431201; β = 2.99 *10^-6; σ = 0.7; δ = 0.57;
{m = 0.3, η = 0.1, μ = 0.1, ρ = 0.3};


S = {N1'[t] == r N1[t] (1 - β N1[t]) - η N1[t] I1[t],
I1'[t] == σ + (ρ N1[t] I1[t])/( m + N1[t]) - δ I1[t] - μ N1[t] I1[t]};

c = {N1[0] == 1, I1[0] == 1.22};

Select[Flatten[
Trace[
NDSolve[{S, c}, {N1, I1}, {t, 0, 30}],
TraceInternal -> True]],
!FreeQ[#, Method | NDSolve`MethodData] &]


but I don't understand the output.










share|improve this question











$endgroup$








  • 2




    $begingroup$
    Partial duplicate: mathematica.stackexchange.com/questions/145/…
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    Another partial duplicate: mathematica.stackexchange.com/questions/102704/…
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    You say you don't understand some technique or other, nor the output of your Trace command. But the first is a very general statement about things already explained and the second is about a command that no one else can reproduce
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    "It is impossible to say NDSolve has automatically solution for publishing paper. " Simply saying "I've used NDSolve function of software Mathematica" is enough in many cases, AFAIK.
    $endgroup$
    – xzczd
    3 hours ago






  • 2




    $begingroup$
    Well, if the reviewer insists on such stuff, given that your system isn't that difficult, a possible workaround at this point is to choose a primary method like classical RK4 to solve the problem. The way to choose classical RK4 in NDSolve can be found in tutorial/NDSolveExplicitRungeKutta#1456351317, then you just need to set Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4, "Coefficients" -> ClassicalRungeKuttaCoefficients}, StartingStepSize -> 1/20000, MaxSteps -> Infinity in NDSolve. The solving process is slower but gives the same result as given by default.
    $endgroup$
    – xzczd
    2 hours ago
















2












$begingroup$


I have eqs about the NDSolve, I know this code given the solving automatically.



How can I find out what method is used behind the scenes? How can I gauge the reliability level, find how many iterations have been used, the order of method. How can I estimate the error?



I found hints on this site, but I still do not fully understand.



It is impossible to say NDSolve has automatically solution for publishing paper?



I used this code related to my system:



r = 0.431201; β = 2.99 *10^-6; σ = 0.7; δ = 0.57;
{m = 0.3, η = 0.1, μ = 0.1, ρ = 0.3};


S = {N1'[t] == r N1[t] (1 - β N1[t]) - η N1[t] I1[t],
I1'[t] == σ + (ρ N1[t] I1[t])/( m + N1[t]) - δ I1[t] - μ N1[t] I1[t]};

c = {N1[0] == 1, I1[0] == 1.22};

Select[Flatten[
Trace[
NDSolve[{S, c}, {N1, I1}, {t, 0, 30}],
TraceInternal -> True]],
!FreeQ[#, Method | NDSolve`MethodData] &]


but I don't understand the output.










share|improve this question











$endgroup$








  • 2




    $begingroup$
    Partial duplicate: mathematica.stackexchange.com/questions/145/…
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    Another partial duplicate: mathematica.stackexchange.com/questions/102704/…
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    You say you don't understand some technique or other, nor the output of your Trace command. But the first is a very general statement about things already explained and the second is about a command that no one else can reproduce
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    "It is impossible to say NDSolve has automatically solution for publishing paper. " Simply saying "I've used NDSolve function of software Mathematica" is enough in many cases, AFAIK.
    $endgroup$
    – xzczd
    3 hours ago






  • 2




    $begingroup$
    Well, if the reviewer insists on such stuff, given that your system isn't that difficult, a possible workaround at this point is to choose a primary method like classical RK4 to solve the problem. The way to choose classical RK4 in NDSolve can be found in tutorial/NDSolveExplicitRungeKutta#1456351317, then you just need to set Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4, "Coefficients" -> ClassicalRungeKuttaCoefficients}, StartingStepSize -> 1/20000, MaxSteps -> Infinity in NDSolve. The solving process is slower but gives the same result as given by default.
    $endgroup$
    – xzczd
    2 hours ago














2












2








2





$begingroup$


I have eqs about the NDSolve, I know this code given the solving automatically.



How can I find out what method is used behind the scenes? How can I gauge the reliability level, find how many iterations have been used, the order of method. How can I estimate the error?



I found hints on this site, but I still do not fully understand.



It is impossible to say NDSolve has automatically solution for publishing paper?



I used this code related to my system:



r = 0.431201; β = 2.99 *10^-6; σ = 0.7; δ = 0.57;
{m = 0.3, η = 0.1, μ = 0.1, ρ = 0.3};


S = {N1'[t] == r N1[t] (1 - β N1[t]) - η N1[t] I1[t],
I1'[t] == σ + (ρ N1[t] I1[t])/( m + N1[t]) - δ I1[t] - μ N1[t] I1[t]};

c = {N1[0] == 1, I1[0] == 1.22};

Select[Flatten[
Trace[
NDSolve[{S, c}, {N1, I1}, {t, 0, 30}],
TraceInternal -> True]],
!FreeQ[#, Method | NDSolve`MethodData] &]


but I don't understand the output.










share|improve this question











$endgroup$




I have eqs about the NDSolve, I know this code given the solving automatically.



How can I find out what method is used behind the scenes? How can I gauge the reliability level, find how many iterations have been used, the order of method. How can I estimate the error?



I found hints on this site, but I still do not fully understand.



It is impossible to say NDSolve has automatically solution for publishing paper?



I used this code related to my system:



r = 0.431201; β = 2.99 *10^-6; σ = 0.7; δ = 0.57;
{m = 0.3, η = 0.1, μ = 0.1, ρ = 0.3};


S = {N1'[t] == r N1[t] (1 - β N1[t]) - η N1[t] I1[t],
I1'[t] == σ + (ρ N1[t] I1[t])/( m + N1[t]) - δ I1[t] - μ N1[t] I1[t]};

c = {N1[0] == 1, I1[0] == 1.22};

Select[Flatten[
Trace[
NDSolve[{S, c}, {N1, I1}, {t, 0, 30}],
TraceInternal -> True]],
!FreeQ[#, Method | NDSolve`MethodData] &]


but I don't understand the output.







differential-equations implementation-details






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago









xzczd

27.4k573254




27.4k573254










asked 5 hours ago









sana alharbisana alharbi

356




356








  • 2




    $begingroup$
    Partial duplicate: mathematica.stackexchange.com/questions/145/…
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    Another partial duplicate: mathematica.stackexchange.com/questions/102704/…
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    You say you don't understand some technique or other, nor the output of your Trace command. But the first is a very general statement about things already explained and the second is about a command that no one else can reproduce
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    "It is impossible to say NDSolve has automatically solution for publishing paper. " Simply saying "I've used NDSolve function of software Mathematica" is enough in many cases, AFAIK.
    $endgroup$
    – xzczd
    3 hours ago






  • 2




    $begingroup$
    Well, if the reviewer insists on such stuff, given that your system isn't that difficult, a possible workaround at this point is to choose a primary method like classical RK4 to solve the problem. The way to choose classical RK4 in NDSolve can be found in tutorial/NDSolveExplicitRungeKutta#1456351317, then you just need to set Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4, "Coefficients" -> ClassicalRungeKuttaCoefficients}, StartingStepSize -> 1/20000, MaxSteps -> Infinity in NDSolve. The solving process is slower but gives the same result as given by default.
    $endgroup$
    – xzczd
    2 hours ago














  • 2




    $begingroup$
    Partial duplicate: mathematica.stackexchange.com/questions/145/…
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    Another partial duplicate: mathematica.stackexchange.com/questions/102704/…
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    You say you don't understand some technique or other, nor the output of your Trace command. But the first is a very general statement about things already explained and the second is about a command that no one else can reproduce
    $endgroup$
    – Michael E2
    5 hours ago






  • 1




    $begingroup$
    "It is impossible to say NDSolve has automatically solution for publishing paper. " Simply saying "I've used NDSolve function of software Mathematica" is enough in many cases, AFAIK.
    $endgroup$
    – xzczd
    3 hours ago






  • 2




    $begingroup$
    Well, if the reviewer insists on such stuff, given that your system isn't that difficult, a possible workaround at this point is to choose a primary method like classical RK4 to solve the problem. The way to choose classical RK4 in NDSolve can be found in tutorial/NDSolveExplicitRungeKutta#1456351317, then you just need to set Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4, "Coefficients" -> ClassicalRungeKuttaCoefficients}, StartingStepSize -> 1/20000, MaxSteps -> Infinity in NDSolve. The solving process is slower but gives the same result as given by default.
    $endgroup$
    – xzczd
    2 hours ago








2




2




$begingroup$
Partial duplicate: mathematica.stackexchange.com/questions/145/…
$endgroup$
– Michael E2
5 hours ago




$begingroup$
Partial duplicate: mathematica.stackexchange.com/questions/145/…
$endgroup$
– Michael E2
5 hours ago




1




1




$begingroup$
Another partial duplicate: mathematica.stackexchange.com/questions/102704/…
$endgroup$
– Michael E2
5 hours ago




$begingroup$
Another partial duplicate: mathematica.stackexchange.com/questions/102704/…
$endgroup$
– Michael E2
5 hours ago




1




1




$begingroup$
You say you don't understand some technique or other, nor the output of your Trace command. But the first is a very general statement about things already explained and the second is about a command that no one else can reproduce
$endgroup$
– Michael E2
5 hours ago




$begingroup$
You say you don't understand some technique or other, nor the output of your Trace command. But the first is a very general statement about things already explained and the second is about a command that no one else can reproduce
$endgroup$
– Michael E2
5 hours ago




1




1




$begingroup$
"It is impossible to say NDSolve has automatically solution for publishing paper. " Simply saying "I've used NDSolve function of software Mathematica" is enough in many cases, AFAIK.
$endgroup$
– xzczd
3 hours ago




$begingroup$
"It is impossible to say NDSolve has automatically solution for publishing paper. " Simply saying "I've used NDSolve function of software Mathematica" is enough in many cases, AFAIK.
$endgroup$
– xzczd
3 hours ago




2




2




$begingroup$
Well, if the reviewer insists on such stuff, given that your system isn't that difficult, a possible workaround at this point is to choose a primary method like classical RK4 to solve the problem. The way to choose classical RK4 in NDSolve can be found in tutorial/NDSolveExplicitRungeKutta#1456351317, then you just need to set Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4, "Coefficients" -> ClassicalRungeKuttaCoefficients}, StartingStepSize -> 1/20000, MaxSteps -> Infinity in NDSolve. The solving process is slower but gives the same result as given by default.
$endgroup$
– xzczd
2 hours ago




$begingroup$
Well, if the reviewer insists on such stuff, given that your system isn't that difficult, a possible workaround at this point is to choose a primary method like classical RK4 to solve the problem. The way to choose classical RK4 in NDSolve can be found in tutorial/NDSolveExplicitRungeKutta#1456351317, then you just need to set Method -> {"ExplicitRungeKutta", "DifferenceOrder" -> 4, "Coefficients" -> ClassicalRungeKuttaCoefficients}, StartingStepSize -> 1/20000, MaxSteps -> Infinity in NDSolve. The solving process is slower but gives the same result as given by default.
$endgroup$
– xzczd
2 hours ago










1 Answer
1






active

oldest

votes


















3












$begingroup$

Comment



In response to your question, you already got very valuable comments. I will just try to comment on




How can I estimate the error?




For this I am going to plot residual error at steps and time, which will show the reliability and accuracy of NDSolve,



r = 0.431201; [Beta] = 2.99*10^-6; [Sigma] = 0.7; [Delta] = 0.57;
m = 0.3; [Eta] = 0.1; [Mu] = 0.1; [Rho] = 0.3;

ode = {N1'[t] == r N1[t] (1 - [Beta] N1[t]) - [Eta] N1[t] I1[t],
I1'[t] == [Sigma] + ([Rho] N1[t] I1[t])/(m + N1[t]) - [Delta] I1[t] - [Mu] N1[t] I1[t]};

bcs = {N1[0] == 1, I1[0] == 1.22};

residuals = ode /. Equal -> Subtract;

{s} = NDSolve[{ode, bcs}, {N1, I1}, {t, 20}, InterpolationOrder -> All];

N1["Coordinates"] /. s;

residuals /. t -> N1["Coordinates"] /. s;

ListPlot[Abs[Flatten /@ (residuals /. t -> N1["Coordinates"] /. s)], Frame -> True]


enter image description here



With[{data = {Table[{t, Abs@residuals[[1]]} /. s, {t, N1["Coordinates"] /. s // Flatten}]}}, 
ListLogPlot[data, Frame -> True, PlotRange -> All]]


enter image description here



Note: I adopted the above from this website but unable to find the link.






share|improve this answer









$endgroup$













    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%2f193858%2ffinding-ndsolve-method-details%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3












    $begingroup$

    Comment



    In response to your question, you already got very valuable comments. I will just try to comment on




    How can I estimate the error?




    For this I am going to plot residual error at steps and time, which will show the reliability and accuracy of NDSolve,



    r = 0.431201; [Beta] = 2.99*10^-6; [Sigma] = 0.7; [Delta] = 0.57;
    m = 0.3; [Eta] = 0.1; [Mu] = 0.1; [Rho] = 0.3;

    ode = {N1'[t] == r N1[t] (1 - [Beta] N1[t]) - [Eta] N1[t] I1[t],
    I1'[t] == [Sigma] + ([Rho] N1[t] I1[t])/(m + N1[t]) - [Delta] I1[t] - [Mu] N1[t] I1[t]};

    bcs = {N1[0] == 1, I1[0] == 1.22};

    residuals = ode /. Equal -> Subtract;

    {s} = NDSolve[{ode, bcs}, {N1, I1}, {t, 20}, InterpolationOrder -> All];

    N1["Coordinates"] /. s;

    residuals /. t -> N1["Coordinates"] /. s;

    ListPlot[Abs[Flatten /@ (residuals /. t -> N1["Coordinates"] /. s)], Frame -> True]


    enter image description here



    With[{data = {Table[{t, Abs@residuals[[1]]} /. s, {t, N1["Coordinates"] /. s // Flatten}]}}, 
    ListLogPlot[data, Frame -> True, PlotRange -> All]]


    enter image description here



    Note: I adopted the above from this website but unable to find the link.






    share|improve this answer









    $endgroup$


















      3












      $begingroup$

      Comment



      In response to your question, you already got very valuable comments. I will just try to comment on




      How can I estimate the error?




      For this I am going to plot residual error at steps and time, which will show the reliability and accuracy of NDSolve,



      r = 0.431201; [Beta] = 2.99*10^-6; [Sigma] = 0.7; [Delta] = 0.57;
      m = 0.3; [Eta] = 0.1; [Mu] = 0.1; [Rho] = 0.3;

      ode = {N1'[t] == r N1[t] (1 - [Beta] N1[t]) - [Eta] N1[t] I1[t],
      I1'[t] == [Sigma] + ([Rho] N1[t] I1[t])/(m + N1[t]) - [Delta] I1[t] - [Mu] N1[t] I1[t]};

      bcs = {N1[0] == 1, I1[0] == 1.22};

      residuals = ode /. Equal -> Subtract;

      {s} = NDSolve[{ode, bcs}, {N1, I1}, {t, 20}, InterpolationOrder -> All];

      N1["Coordinates"] /. s;

      residuals /. t -> N1["Coordinates"] /. s;

      ListPlot[Abs[Flatten /@ (residuals /. t -> N1["Coordinates"] /. s)], Frame -> True]


      enter image description here



      With[{data = {Table[{t, Abs@residuals[[1]]} /. s, {t, N1["Coordinates"] /. s // Flatten}]}}, 
      ListLogPlot[data, Frame -> True, PlotRange -> All]]


      enter image description here



      Note: I adopted the above from this website but unable to find the link.






      share|improve this answer









      $endgroup$
















        3












        3








        3





        $begingroup$

        Comment



        In response to your question, you already got very valuable comments. I will just try to comment on




        How can I estimate the error?




        For this I am going to plot residual error at steps and time, which will show the reliability and accuracy of NDSolve,



        r = 0.431201; [Beta] = 2.99*10^-6; [Sigma] = 0.7; [Delta] = 0.57;
        m = 0.3; [Eta] = 0.1; [Mu] = 0.1; [Rho] = 0.3;

        ode = {N1'[t] == r N1[t] (1 - [Beta] N1[t]) - [Eta] N1[t] I1[t],
        I1'[t] == [Sigma] + ([Rho] N1[t] I1[t])/(m + N1[t]) - [Delta] I1[t] - [Mu] N1[t] I1[t]};

        bcs = {N1[0] == 1, I1[0] == 1.22};

        residuals = ode /. Equal -> Subtract;

        {s} = NDSolve[{ode, bcs}, {N1, I1}, {t, 20}, InterpolationOrder -> All];

        N1["Coordinates"] /. s;

        residuals /. t -> N1["Coordinates"] /. s;

        ListPlot[Abs[Flatten /@ (residuals /. t -> N1["Coordinates"] /. s)], Frame -> True]


        enter image description here



        With[{data = {Table[{t, Abs@residuals[[1]]} /. s, {t, N1["Coordinates"] /. s // Flatten}]}}, 
        ListLogPlot[data, Frame -> True, PlotRange -> All]]


        enter image description here



        Note: I adopted the above from this website but unable to find the link.






        share|improve this answer









        $endgroup$



        Comment



        In response to your question, you already got very valuable comments. I will just try to comment on




        How can I estimate the error?




        For this I am going to plot residual error at steps and time, which will show the reliability and accuracy of NDSolve,



        r = 0.431201; [Beta] = 2.99*10^-6; [Sigma] = 0.7; [Delta] = 0.57;
        m = 0.3; [Eta] = 0.1; [Mu] = 0.1; [Rho] = 0.3;

        ode = {N1'[t] == r N1[t] (1 - [Beta] N1[t]) - [Eta] N1[t] I1[t],
        I1'[t] == [Sigma] + ([Rho] N1[t] I1[t])/(m + N1[t]) - [Delta] I1[t] - [Mu] N1[t] I1[t]};

        bcs = {N1[0] == 1, I1[0] == 1.22};

        residuals = ode /. Equal -> Subtract;

        {s} = NDSolve[{ode, bcs}, {N1, I1}, {t, 20}, InterpolationOrder -> All];

        N1["Coordinates"] /. s;

        residuals /. t -> N1["Coordinates"] /. s;

        ListPlot[Abs[Flatten /@ (residuals /. t -> N1["Coordinates"] /. s)], Frame -> True]


        enter image description here



        With[{data = {Table[{t, Abs@residuals[[1]]} /. s, {t, N1["Coordinates"] /. s // Flatten}]}}, 
        ListLogPlot[data, Frame -> True, PlotRange -> All]]


        enter image description here



        Note: I adopted the above from this website but unable to find the link.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 1 hour ago









        zhkzhk

        10k11433




        10k11433






























            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%2f193858%2ffinding-ndsolve-method-details%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

            Knooppunt Holsloot

            Altaar (religie)

            Gregoriusmis