How to increase the accuracy of a plot












3












$begingroup$


I have the following code below:



num = 25;
U[x_] := 50*(Sech[1.5*(x - 5.8)])^4 - 0.14*(Sech[0.5*(x - 6.5)])^2
V[x_] := U[x] - U[3.8]
Plot[V[x], {x, 0, 4.75}, PlotRange -> All];
A := 1.05459^2*0.01/2/1.6726/1.60219
{vals, funs} =
NDEigensystem[-(A/x)*D[x*D[[Psi][x], {x}], {x}] +
V[x]*[Psi][x], [Psi][x], {x, 0, 5}, num];


And I get the following graphic:



Enter image description here



Here, as I expect there should not be such a sharp peak at the beginning of the plot. So I tried to increase a number of points for the plot:



Plot[Evaluate[funs[[25]]/
Sqrt[NIntegrate[x*(funs[[25]])^2, {x, 0, 5},
AccuracyGoal -> 10]]], {x, 0, 5}, PlotLegends -> vals[[25]],
PlotRange -> All]


And get the following:



Enter image description here



It's the same graph, but in different ranges. How can I do the same, but in range from 0 to 5?










share|improve this question











$endgroup$












  • $begingroup$
    I think PlotPoints is the option you need
    $endgroup$
    – mikado
    Mar 9 at 13:19






  • 1




    $begingroup$
    This is not an issue of Plot. The interpolating function that you are using (funs[[25]]) already has this shape.
    $endgroup$
    – Sjoerd C. de Vries
    Mar 9 at 13:26


















3












$begingroup$


I have the following code below:



num = 25;
U[x_] := 50*(Sech[1.5*(x - 5.8)])^4 - 0.14*(Sech[0.5*(x - 6.5)])^2
V[x_] := U[x] - U[3.8]
Plot[V[x], {x, 0, 4.75}, PlotRange -> All];
A := 1.05459^2*0.01/2/1.6726/1.60219
{vals, funs} =
NDEigensystem[-(A/x)*D[x*D[[Psi][x], {x}], {x}] +
V[x]*[Psi][x], [Psi][x], {x, 0, 5}, num];


And I get the following graphic:



Enter image description here



Here, as I expect there should not be such a sharp peak at the beginning of the plot. So I tried to increase a number of points for the plot:



Plot[Evaluate[funs[[25]]/
Sqrt[NIntegrate[x*(funs[[25]])^2, {x, 0, 5},
AccuracyGoal -> 10]]], {x, 0, 5}, PlotLegends -> vals[[25]],
PlotRange -> All]


And get the following:



Enter image description here



It's the same graph, but in different ranges. How can I do the same, but in range from 0 to 5?










share|improve this question











$endgroup$












  • $begingroup$
    I think PlotPoints is the option you need
    $endgroup$
    – mikado
    Mar 9 at 13:19






  • 1




    $begingroup$
    This is not an issue of Plot. The interpolating function that you are using (funs[[25]]) already has this shape.
    $endgroup$
    – Sjoerd C. de Vries
    Mar 9 at 13:26
















3












3








3





$begingroup$


I have the following code below:



num = 25;
U[x_] := 50*(Sech[1.5*(x - 5.8)])^4 - 0.14*(Sech[0.5*(x - 6.5)])^2
V[x_] := U[x] - U[3.8]
Plot[V[x], {x, 0, 4.75}, PlotRange -> All];
A := 1.05459^2*0.01/2/1.6726/1.60219
{vals, funs} =
NDEigensystem[-(A/x)*D[x*D[[Psi][x], {x}], {x}] +
V[x]*[Psi][x], [Psi][x], {x, 0, 5}, num];


And I get the following graphic:



Enter image description here



Here, as I expect there should not be such a sharp peak at the beginning of the plot. So I tried to increase a number of points for the plot:



Plot[Evaluate[funs[[25]]/
Sqrt[NIntegrate[x*(funs[[25]])^2, {x, 0, 5},
AccuracyGoal -> 10]]], {x, 0, 5}, PlotLegends -> vals[[25]],
PlotRange -> All]


And get the following:



Enter image description here



It's the same graph, but in different ranges. How can I do the same, but in range from 0 to 5?










share|improve this question











$endgroup$




I have the following code below:



num = 25;
U[x_] := 50*(Sech[1.5*(x - 5.8)])^4 - 0.14*(Sech[0.5*(x - 6.5)])^2
V[x_] := U[x] - U[3.8]
Plot[V[x], {x, 0, 4.75}, PlotRange -> All];
A := 1.05459^2*0.01/2/1.6726/1.60219
{vals, funs} =
NDEigensystem[-(A/x)*D[x*D[[Psi][x], {x}], {x}] +
V[x]*[Psi][x], [Psi][x], {x, 0, 5}, num];


And I get the following graphic:



Enter image description here



Here, as I expect there should not be such a sharp peak at the beginning of the plot. So I tried to increase a number of points for the plot:



Plot[Evaluate[funs[[25]]/
Sqrt[NIntegrate[x*(funs[[25]])^2, {x, 0, 5},
AccuracyGoal -> 10]]], {x, 0, 5}, PlotLegends -> vals[[25]],
PlotRange -> All]


And get the following:



Enter image description here



It's the same graph, but in different ranges. How can I do the same, but in range from 0 to 5?







plotting graphics recursion precision-and-accuracy






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 16:39









Peter Mortensen

33427




33427










asked Mar 9 at 12:56









JohnJohn

33716




33716












  • $begingroup$
    I think PlotPoints is the option you need
    $endgroup$
    – mikado
    Mar 9 at 13:19






  • 1




    $begingroup$
    This is not an issue of Plot. The interpolating function that you are using (funs[[25]]) already has this shape.
    $endgroup$
    – Sjoerd C. de Vries
    Mar 9 at 13:26




















  • $begingroup$
    I think PlotPoints is the option you need
    $endgroup$
    – mikado
    Mar 9 at 13:19






  • 1




    $begingroup$
    This is not an issue of Plot. The interpolating function that you are using (funs[[25]]) already has this shape.
    $endgroup$
    – Sjoerd C. de Vries
    Mar 9 at 13:26


















$begingroup$
I think PlotPoints is the option you need
$endgroup$
– mikado
Mar 9 at 13:19




$begingroup$
I think PlotPoints is the option you need
$endgroup$
– mikado
Mar 9 at 13:19




1




1




$begingroup$
This is not an issue of Plot. The interpolating function that you are using (funs[[25]]) already has this shape.
$endgroup$
– Sjoerd C. de Vries
Mar 9 at 13:26






$begingroup$
This is not an issue of Plot. The interpolating function that you are using (funs[[25]]) already has this shape.
$endgroup$
– Sjoerd C. de Vries
Mar 9 at 13:26












1 Answer
1






active

oldest

votes


















7












$begingroup$

The problem does not seem to be in Plot but in NDEigensystem. Apparently, the default method used for your function is not ideal. If you provide a method explicitly it seems to work better.



{vals, funs} = 
NDEigensystem[
-(A/x)*D[x*D[ψ[x], {x}], {x}] + V[x]*ψ[x],
ψ[x],
{x, 0, 5},
num,
Method -> {"PDEDiscretization" ->
{"FiniteElement", {"MeshOptions" -> {"MaxCellMeasure" -> 0.001}}}}];

Multicolumn[Plot[#, {x, 0, 5}, PlotRange -> All] & /@ funs]


Mathematica graphics






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%2f192936%2fhow-to-increase-the-accuracy-of-a-plot%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









    7












    $begingroup$

    The problem does not seem to be in Plot but in NDEigensystem. Apparently, the default method used for your function is not ideal. If you provide a method explicitly it seems to work better.



    {vals, funs} = 
    NDEigensystem[
    -(A/x)*D[x*D[ψ[x], {x}], {x}] + V[x]*ψ[x],
    ψ[x],
    {x, 0, 5},
    num,
    Method -> {"PDEDiscretization" ->
    {"FiniteElement", {"MeshOptions" -> {"MaxCellMeasure" -> 0.001}}}}];

    Multicolumn[Plot[#, {x, 0, 5}, PlotRange -> All] & /@ funs]


    Mathematica graphics






    share|improve this answer









    $endgroup$


















      7












      $begingroup$

      The problem does not seem to be in Plot but in NDEigensystem. Apparently, the default method used for your function is not ideal. If you provide a method explicitly it seems to work better.



      {vals, funs} = 
      NDEigensystem[
      -(A/x)*D[x*D[ψ[x], {x}], {x}] + V[x]*ψ[x],
      ψ[x],
      {x, 0, 5},
      num,
      Method -> {"PDEDiscretization" ->
      {"FiniteElement", {"MeshOptions" -> {"MaxCellMeasure" -> 0.001}}}}];

      Multicolumn[Plot[#, {x, 0, 5}, PlotRange -> All] & /@ funs]


      Mathematica graphics






      share|improve this answer









      $endgroup$
















        7












        7








        7





        $begingroup$

        The problem does not seem to be in Plot but in NDEigensystem. Apparently, the default method used for your function is not ideal. If you provide a method explicitly it seems to work better.



        {vals, funs} = 
        NDEigensystem[
        -(A/x)*D[x*D[ψ[x], {x}], {x}] + V[x]*ψ[x],
        ψ[x],
        {x, 0, 5},
        num,
        Method -> {"PDEDiscretization" ->
        {"FiniteElement", {"MeshOptions" -> {"MaxCellMeasure" -> 0.001}}}}];

        Multicolumn[Plot[#, {x, 0, 5}, PlotRange -> All] & /@ funs]


        Mathematica graphics






        share|improve this answer









        $endgroup$



        The problem does not seem to be in Plot but in NDEigensystem. Apparently, the default method used for your function is not ideal. If you provide a method explicitly it seems to work better.



        {vals, funs} = 
        NDEigensystem[
        -(A/x)*D[x*D[ψ[x], {x}], {x}] + V[x]*ψ[x],
        ψ[x],
        {x, 0, 5},
        num,
        Method -> {"PDEDiscretization" ->
        {"FiniteElement", {"MeshOptions" -> {"MaxCellMeasure" -> 0.001}}}}];

        Multicolumn[Plot[#, {x, 0, 5}, PlotRange -> All] & /@ funs]


        Mathematica graphics







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 9 at 13:48









        Sjoerd C. de VriesSjoerd C. de Vries

        57.7k10155298




        57.7k10155298






























            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%2f192936%2fhow-to-increase-the-accuracy-of-a-plot%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Can I use Tabulator js library in my java Spring + Thymeleaf project?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents