Integrating a list of valuesList operation on specific elementsEfficient way to obtain values of a function defined by an IntegralNumerical integration of modified bessel functionIntegrating an interpolating functionNumerical Integral with Boolean as part of argumentHow to set a line coordinate for a symbolic line integral over a curve?Integrating curve peaksStrange results by integrating Abs[Sin[a - t]]Integrating over colorsIntegrating only over positive values of an oscillating function

How can I determine if the org that I'm currently connected to is a scratch org?

Can I run a new neutral wire to repair a broken circuit?

Do UK voters know if their MP will be the Speaker of the House?

Would Slavery Reparations be considered Bills of Attainder and hence Illegal?

How can saying a song's name be a copyright violation?

Mathematica command that allows it to read my intentions

Alternative to sending password over mail?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

What is the most common color to indicate the input-field is disabled?

Are there any examples of a variable being normally distributed that is *not* due to the Central Limit Theorem?

How to Recreate this in LaTeX? (Unsure What the Notation is Called)

Cursor Replacement for Newbies

Size of subfigure fitting its content (tikzpicture)

Why no variance term in Bayesian logistic regression?

Short story with a alien planet, government officials must wear exploding medallions

Could the museum Saturn V's be refitted for one more flight?

Arrow those variables!

How seriously should I take size and weight limits of hand luggage?

Why didn't Boeing produce its own regional jet?

Im going to France and my passport expires June 19th

Why do bosons tend to occupy the same state?

Is it possible to create a QR code using text?

Should I tell management that I intend to leave due to bad software development practices?

Avoiding the "not like other girls" trope?



Integrating a list of values


List operation on specific elementsEfficient way to obtain values of a function defined by an IntegralNumerical integration of modified bessel functionIntegrating an interpolating functionNumerical Integral with Boolean as part of argumentHow to set a line coordinate for a symbolic line integral over a curve?Integrating curve peaksStrange results by integrating Abs[Sin[a - t]]Integrating over colorsIntegrating only over positive values of an oscillating function













2












$begingroup$


The data given here



data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1]


generates the following curve



ListPlot[data]


I want to know, how to compute the integral of this curve using only the data given above.










share|improve this question











$endgroup$







  • 3




    $begingroup$
    If you only have a list of function values, you need to give the step size as well.
    $endgroup$
    – J. M. is slightly pensive
    2 days ago















2












$begingroup$


The data given here



data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1]


generates the following curve



ListPlot[data]


I want to know, how to compute the integral of this curve using only the data given above.










share|improve this question











$endgroup$







  • 3




    $begingroup$
    If you only have a list of function values, you need to give the step size as well.
    $endgroup$
    – J. M. is slightly pensive
    2 days ago













2












2








2





$begingroup$


The data given here



data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1]


generates the following curve



ListPlot[data]


I want to know, how to compute the integral of this curve using only the data given above.










share|improve this question











$endgroup$




The data given here



data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1]


generates the following curve



ListPlot[data]


I want to know, how to compute the integral of this curve using only the data given above.







list-manipulation calculus-and-analysis numerical-integration






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









J. M. is slightly pensive

99k10311467




99k10311467










asked 2 days ago









Tobias FritznTobias Fritzn

1945




1945







  • 3




    $begingroup$
    If you only have a list of function values, you need to give the step size as well.
    $endgroup$
    – J. M. is slightly pensive
    2 days ago












  • 3




    $begingroup$
    If you only have a list of function values, you need to give the step size as well.
    $endgroup$
    – J. M. is slightly pensive
    2 days ago







3




3




$begingroup$
If you only have a list of function values, you need to give the step size as well.
$endgroup$
– J. M. is slightly pensive
2 days ago




$begingroup$
If you only have a list of function values, you need to give the step size as well.
$endgroup$
– J. M. is slightly pensive
2 days ago










4 Answers
4






active

oldest

votes


















2












$begingroup$

Using Tai's method:



ω = ConstantArray[0.1, Length[data]];
ω[[1]] *= 0.5;
ω[[-1]] *= 0.5;
ω.data


Alternatively



a = Table[x, Clip[Sin[x], 0., 1.], x, 0, 2 π, 0.1];
Integrate[Interpolation[a][x], x, a[[1, 1]], a[[-1, 1]]]



2.00038







share|improve this answer









$endgroup$












  • $begingroup$
    For Interpolation you can also play with the InterpolationOrder option to increase the accuracy (sometimes). In this case it doesn't do much though.
    $endgroup$
    – Roman
    2 days ago










  • $begingroup$
    Jepp. The reseason is the kink in the middle of the integral. This way, one cannot profit from higher order quadrature rules. Trapezoidal rule is almost optimal.
    $endgroup$
    – Henrik Schumacher
    2 days ago










  • $begingroup$
    I want the integral as a plot, a curve. Any way of doing that?
    $endgroup$
    – Tobias Fritzn
    2 days ago



















2












$begingroup$

Assuming the stepsize is 0.1 as suggested by the construction of the Table, you can calculate:



0.1*Total[data]


to get the numerical integral. To visualize the integral and plot it you can ListPlot:



0.1*Accumulate[data]


Hence:



data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1];
ListPlot[data, 0.1*Accumulate[data]]


enter image description here






share|improve this answer











$endgroup$












  • $begingroup$
    How is the function Accumulate related to Integration?
    $endgroup$
    – Tobias Fritzn
    2 days ago






  • 1




    $begingroup$
    As you are accumulating the data, you are integrating the function up to that point. So this is the answer to your statement that you "want the integral as a plot."
    $endgroup$
    – bill s
    2 days ago











  • $begingroup$
    Thanks, @bill, it works nice. But looking at the definition of Accumulate[], it is not immediately clear how it should give an integral when multiplied by the stepsize. I mean given the definition Accumulate[i,j,k]=i,i+j,i+j+k, how does this lead to integration?
    $endgroup$
    – Tobias Fritzn
    yesterday











  • $begingroup$
    This is called the Rieman approximation to the integral.
    $endgroup$
    – bill s
    yesterday










  • $begingroup$
    Correct me if I am wrong. In a Rieman sum, nth term is not the sum of all (n-1) terms, which seems to be the case with Accumulate[]. en.wikipedia.org/wiki/Riemann_sum
    $endgroup$
    – Tobias Fritzn
    yesterday


















1












$begingroup$

You mention that you want the integral as a plot in a comment; I wonder if the following is what you had in mind. Here I am using your definition of data, and assuming a $0.1$ step size, as hinted at by your Table expression.



tuples = Transpose@Range[0, 2 Pi, 0.1], data;

Show[
Plot[
NIntegrate[Interpolation[tuples][x], x, 0, xmax, Method -> "Trapezoidal"],
xmax, 0, 2 Pi, PlotLegends -> "integral"
],
ListPlot[
Style[tuples, Thick, ColorData[97][2]],
Mesh -> All, MeshStyle -> Directive[Black, PointSize[0.01]],
PlotLegends -> "data", Joined -> True
]
]


Mathematica graphics






share|improve this answer









$endgroup$




















    0












    $begingroup$

    It seems that Simpson's rule has not been mentioned yet, which is the result from a 2nd-order interpolation and will have a smaller error than that from a 1st-order one. So according to the formula, the inputs are the List of samples of the function data and the step size h:



    simpsoncoefficients[n_] := SparseArray[1 -> 1, -1 -> 1, i_?EvenQ -> 4, n, 2]
    integral[data_, h_] := (h/3) simpsoncoefficients[Length[#]].# &[data]


    Then integral[data, 0.1] gives 2.00024.






    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%2f194373%2fintegrating-a-list-of-values%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2












      $begingroup$

      Using Tai's method:



      ω = ConstantArray[0.1, Length[data]];
      ω[[1]] *= 0.5;
      ω[[-1]] *= 0.5;
      ω.data


      Alternatively



      a = Table[x, Clip[Sin[x], 0., 1.], x, 0, 2 π, 0.1];
      Integrate[Interpolation[a][x], x, a[[1, 1]], a[[-1, 1]]]



      2.00038







      share|improve this answer









      $endgroup$












      • $begingroup$
        For Interpolation you can also play with the InterpolationOrder option to increase the accuracy (sometimes). In this case it doesn't do much though.
        $endgroup$
        – Roman
        2 days ago










      • $begingroup$
        Jepp. The reseason is the kink in the middle of the integral. This way, one cannot profit from higher order quadrature rules. Trapezoidal rule is almost optimal.
        $endgroup$
        – Henrik Schumacher
        2 days ago










      • $begingroup$
        I want the integral as a plot, a curve. Any way of doing that?
        $endgroup$
        – Tobias Fritzn
        2 days ago
















      2












      $begingroup$

      Using Tai's method:



      ω = ConstantArray[0.1, Length[data]];
      ω[[1]] *= 0.5;
      ω[[-1]] *= 0.5;
      ω.data


      Alternatively



      a = Table[x, Clip[Sin[x], 0., 1.], x, 0, 2 π, 0.1];
      Integrate[Interpolation[a][x], x, a[[1, 1]], a[[-1, 1]]]



      2.00038







      share|improve this answer









      $endgroup$












      • $begingroup$
        For Interpolation you can also play with the InterpolationOrder option to increase the accuracy (sometimes). In this case it doesn't do much though.
        $endgroup$
        – Roman
        2 days ago










      • $begingroup$
        Jepp. The reseason is the kink in the middle of the integral. This way, one cannot profit from higher order quadrature rules. Trapezoidal rule is almost optimal.
        $endgroup$
        – Henrik Schumacher
        2 days ago










      • $begingroup$
        I want the integral as a plot, a curve. Any way of doing that?
        $endgroup$
        – Tobias Fritzn
        2 days ago














      2












      2








      2





      $begingroup$

      Using Tai's method:



      ω = ConstantArray[0.1, Length[data]];
      ω[[1]] *= 0.5;
      ω[[-1]] *= 0.5;
      ω.data


      Alternatively



      a = Table[x, Clip[Sin[x], 0., 1.], x, 0, 2 π, 0.1];
      Integrate[Interpolation[a][x], x, a[[1, 1]], a[[-1, 1]]]



      2.00038







      share|improve this answer









      $endgroup$



      Using Tai's method:



      ω = ConstantArray[0.1, Length[data]];
      ω[[1]] *= 0.5;
      ω[[-1]] *= 0.5;
      ω.data


      Alternatively



      a = Table[x, Clip[Sin[x], 0., 1.], x, 0, 2 π, 0.1];
      Integrate[Interpolation[a][x], x, a[[1, 1]], a[[-1, 1]]]



      2.00038








      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered 2 days ago









      Henrik SchumacherHenrik Schumacher

      59.1k582164




      59.1k582164











      • $begingroup$
        For Interpolation you can also play with the InterpolationOrder option to increase the accuracy (sometimes). In this case it doesn't do much though.
        $endgroup$
        – Roman
        2 days ago










      • $begingroup$
        Jepp. The reseason is the kink in the middle of the integral. This way, one cannot profit from higher order quadrature rules. Trapezoidal rule is almost optimal.
        $endgroup$
        – Henrik Schumacher
        2 days ago










      • $begingroup$
        I want the integral as a plot, a curve. Any way of doing that?
        $endgroup$
        – Tobias Fritzn
        2 days ago

















      • $begingroup$
        For Interpolation you can also play with the InterpolationOrder option to increase the accuracy (sometimes). In this case it doesn't do much though.
        $endgroup$
        – Roman
        2 days ago










      • $begingroup$
        Jepp. The reseason is the kink in the middle of the integral. This way, one cannot profit from higher order quadrature rules. Trapezoidal rule is almost optimal.
        $endgroup$
        – Henrik Schumacher
        2 days ago










      • $begingroup$
        I want the integral as a plot, a curve. Any way of doing that?
        $endgroup$
        – Tobias Fritzn
        2 days ago
















      $begingroup$
      For Interpolation you can also play with the InterpolationOrder option to increase the accuracy (sometimes). In this case it doesn't do much though.
      $endgroup$
      – Roman
      2 days ago




      $begingroup$
      For Interpolation you can also play with the InterpolationOrder option to increase the accuracy (sometimes). In this case it doesn't do much though.
      $endgroup$
      – Roman
      2 days ago












      $begingroup$
      Jepp. The reseason is the kink in the middle of the integral. This way, one cannot profit from higher order quadrature rules. Trapezoidal rule is almost optimal.
      $endgroup$
      – Henrik Schumacher
      2 days ago




      $begingroup$
      Jepp. The reseason is the kink in the middle of the integral. This way, one cannot profit from higher order quadrature rules. Trapezoidal rule is almost optimal.
      $endgroup$
      – Henrik Schumacher
      2 days ago












      $begingroup$
      I want the integral as a plot, a curve. Any way of doing that?
      $endgroup$
      – Tobias Fritzn
      2 days ago





      $begingroup$
      I want the integral as a plot, a curve. Any way of doing that?
      $endgroup$
      – Tobias Fritzn
      2 days ago












      2












      $begingroup$

      Assuming the stepsize is 0.1 as suggested by the construction of the Table, you can calculate:



      0.1*Total[data]


      to get the numerical integral. To visualize the integral and plot it you can ListPlot:



      0.1*Accumulate[data]


      Hence:



      data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1];
      ListPlot[data, 0.1*Accumulate[data]]


      enter image description here






      share|improve this answer











      $endgroup$












      • $begingroup$
        How is the function Accumulate related to Integration?
        $endgroup$
        – Tobias Fritzn
        2 days ago






      • 1




        $begingroup$
        As you are accumulating the data, you are integrating the function up to that point. So this is the answer to your statement that you "want the integral as a plot."
        $endgroup$
        – bill s
        2 days ago











      • $begingroup$
        Thanks, @bill, it works nice. But looking at the definition of Accumulate[], it is not immediately clear how it should give an integral when multiplied by the stepsize. I mean given the definition Accumulate[i,j,k]=i,i+j,i+j+k, how does this lead to integration?
        $endgroup$
        – Tobias Fritzn
        yesterday











      • $begingroup$
        This is called the Rieman approximation to the integral.
        $endgroup$
        – bill s
        yesterday










      • $begingroup$
        Correct me if I am wrong. In a Rieman sum, nth term is not the sum of all (n-1) terms, which seems to be the case with Accumulate[]. en.wikipedia.org/wiki/Riemann_sum
        $endgroup$
        – Tobias Fritzn
        yesterday















      2












      $begingroup$

      Assuming the stepsize is 0.1 as suggested by the construction of the Table, you can calculate:



      0.1*Total[data]


      to get the numerical integral. To visualize the integral and plot it you can ListPlot:



      0.1*Accumulate[data]


      Hence:



      data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1];
      ListPlot[data, 0.1*Accumulate[data]]


      enter image description here






      share|improve this answer











      $endgroup$












      • $begingroup$
        How is the function Accumulate related to Integration?
        $endgroup$
        – Tobias Fritzn
        2 days ago






      • 1




        $begingroup$
        As you are accumulating the data, you are integrating the function up to that point. So this is the answer to your statement that you "want the integral as a plot."
        $endgroup$
        – bill s
        2 days ago











      • $begingroup$
        Thanks, @bill, it works nice. But looking at the definition of Accumulate[], it is not immediately clear how it should give an integral when multiplied by the stepsize. I mean given the definition Accumulate[i,j,k]=i,i+j,i+j+k, how does this lead to integration?
        $endgroup$
        – Tobias Fritzn
        yesterday











      • $begingroup$
        This is called the Rieman approximation to the integral.
        $endgroup$
        – bill s
        yesterday










      • $begingroup$
        Correct me if I am wrong. In a Rieman sum, nth term is not the sum of all (n-1) terms, which seems to be the case with Accumulate[]. en.wikipedia.org/wiki/Riemann_sum
        $endgroup$
        – Tobias Fritzn
        yesterday













      2












      2








      2





      $begingroup$

      Assuming the stepsize is 0.1 as suggested by the construction of the Table, you can calculate:



      0.1*Total[data]


      to get the numerical integral. To visualize the integral and plot it you can ListPlot:



      0.1*Accumulate[data]


      Hence:



      data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1];
      ListPlot[data, 0.1*Accumulate[data]]


      enter image description here






      share|improve this answer











      $endgroup$



      Assuming the stepsize is 0.1 as suggested by the construction of the Table, you can calculate:



      0.1*Total[data]


      to get the numerical integral. To visualize the integral and plot it you can ListPlot:



      0.1*Accumulate[data]


      Hence:



      data = Table[Clip[Sin[x], 0, 1], x, 0, 2 [Pi], 0.1];
      ListPlot[data, 0.1*Accumulate[data]]


      enter image description here







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited 2 days ago

























      answered 2 days ago









      bill sbill s

      54.9k377158




      54.9k377158











      • $begingroup$
        How is the function Accumulate related to Integration?
        $endgroup$
        – Tobias Fritzn
        2 days ago






      • 1




        $begingroup$
        As you are accumulating the data, you are integrating the function up to that point. So this is the answer to your statement that you "want the integral as a plot."
        $endgroup$
        – bill s
        2 days ago











      • $begingroup$
        Thanks, @bill, it works nice. But looking at the definition of Accumulate[], it is not immediately clear how it should give an integral when multiplied by the stepsize. I mean given the definition Accumulate[i,j,k]=i,i+j,i+j+k, how does this lead to integration?
        $endgroup$
        – Tobias Fritzn
        yesterday











      • $begingroup$
        This is called the Rieman approximation to the integral.
        $endgroup$
        – bill s
        yesterday










      • $begingroup$
        Correct me if I am wrong. In a Rieman sum, nth term is not the sum of all (n-1) terms, which seems to be the case with Accumulate[]. en.wikipedia.org/wiki/Riemann_sum
        $endgroup$
        – Tobias Fritzn
        yesterday
















      • $begingroup$
        How is the function Accumulate related to Integration?
        $endgroup$
        – Tobias Fritzn
        2 days ago






      • 1




        $begingroup$
        As you are accumulating the data, you are integrating the function up to that point. So this is the answer to your statement that you "want the integral as a plot."
        $endgroup$
        – bill s
        2 days ago











      • $begingroup$
        Thanks, @bill, it works nice. But looking at the definition of Accumulate[], it is not immediately clear how it should give an integral when multiplied by the stepsize. I mean given the definition Accumulate[i,j,k]=i,i+j,i+j+k, how does this lead to integration?
        $endgroup$
        – Tobias Fritzn
        yesterday











      • $begingroup$
        This is called the Rieman approximation to the integral.
        $endgroup$
        – bill s
        yesterday










      • $begingroup$
        Correct me if I am wrong. In a Rieman sum, nth term is not the sum of all (n-1) terms, which seems to be the case with Accumulate[]. en.wikipedia.org/wiki/Riemann_sum
        $endgroup$
        – Tobias Fritzn
        yesterday















      $begingroup$
      How is the function Accumulate related to Integration?
      $endgroup$
      – Tobias Fritzn
      2 days ago




      $begingroup$
      How is the function Accumulate related to Integration?
      $endgroup$
      – Tobias Fritzn
      2 days ago




      1




      1




      $begingroup$
      As you are accumulating the data, you are integrating the function up to that point. So this is the answer to your statement that you "want the integral as a plot."
      $endgroup$
      – bill s
      2 days ago





      $begingroup$
      As you are accumulating the data, you are integrating the function up to that point. So this is the answer to your statement that you "want the integral as a plot."
      $endgroup$
      – bill s
      2 days ago













      $begingroup$
      Thanks, @bill, it works nice. But looking at the definition of Accumulate[], it is not immediately clear how it should give an integral when multiplied by the stepsize. I mean given the definition Accumulate[i,j,k]=i,i+j,i+j+k, how does this lead to integration?
      $endgroup$
      – Tobias Fritzn
      yesterday





      $begingroup$
      Thanks, @bill, it works nice. But looking at the definition of Accumulate[], it is not immediately clear how it should give an integral when multiplied by the stepsize. I mean given the definition Accumulate[i,j,k]=i,i+j,i+j+k, how does this lead to integration?
      $endgroup$
      – Tobias Fritzn
      yesterday













      $begingroup$
      This is called the Rieman approximation to the integral.
      $endgroup$
      – bill s
      yesterday




      $begingroup$
      This is called the Rieman approximation to the integral.
      $endgroup$
      – bill s
      yesterday












      $begingroup$
      Correct me if I am wrong. In a Rieman sum, nth term is not the sum of all (n-1) terms, which seems to be the case with Accumulate[]. en.wikipedia.org/wiki/Riemann_sum
      $endgroup$
      – Tobias Fritzn
      yesterday




      $begingroup$
      Correct me if I am wrong. In a Rieman sum, nth term is not the sum of all (n-1) terms, which seems to be the case with Accumulate[]. en.wikipedia.org/wiki/Riemann_sum
      $endgroup$
      – Tobias Fritzn
      yesterday











      1












      $begingroup$

      You mention that you want the integral as a plot in a comment; I wonder if the following is what you had in mind. Here I am using your definition of data, and assuming a $0.1$ step size, as hinted at by your Table expression.



      tuples = Transpose@Range[0, 2 Pi, 0.1], data;

      Show[
      Plot[
      NIntegrate[Interpolation[tuples][x], x, 0, xmax, Method -> "Trapezoidal"],
      xmax, 0, 2 Pi, PlotLegends -> "integral"
      ],
      ListPlot[
      Style[tuples, Thick, ColorData[97][2]],
      Mesh -> All, MeshStyle -> Directive[Black, PointSize[0.01]],
      PlotLegends -> "data", Joined -> True
      ]
      ]


      Mathematica graphics






      share|improve this answer









      $endgroup$

















        1












        $begingroup$

        You mention that you want the integral as a plot in a comment; I wonder if the following is what you had in mind. Here I am using your definition of data, and assuming a $0.1$ step size, as hinted at by your Table expression.



        tuples = Transpose@Range[0, 2 Pi, 0.1], data;

        Show[
        Plot[
        NIntegrate[Interpolation[tuples][x], x, 0, xmax, Method -> "Trapezoidal"],
        xmax, 0, 2 Pi, PlotLegends -> "integral"
        ],
        ListPlot[
        Style[tuples, Thick, ColorData[97][2]],
        Mesh -> All, MeshStyle -> Directive[Black, PointSize[0.01]],
        PlotLegends -> "data", Joined -> True
        ]
        ]


        Mathematica graphics






        share|improve this answer









        $endgroup$















          1












          1








          1





          $begingroup$

          You mention that you want the integral as a plot in a comment; I wonder if the following is what you had in mind. Here I am using your definition of data, and assuming a $0.1$ step size, as hinted at by your Table expression.



          tuples = Transpose@Range[0, 2 Pi, 0.1], data;

          Show[
          Plot[
          NIntegrate[Interpolation[tuples][x], x, 0, xmax, Method -> "Trapezoidal"],
          xmax, 0, 2 Pi, PlotLegends -> "integral"
          ],
          ListPlot[
          Style[tuples, Thick, ColorData[97][2]],
          Mesh -> All, MeshStyle -> Directive[Black, PointSize[0.01]],
          PlotLegends -> "data", Joined -> True
          ]
          ]


          Mathematica graphics






          share|improve this answer









          $endgroup$



          You mention that you want the integral as a plot in a comment; I wonder if the following is what you had in mind. Here I am using your definition of data, and assuming a $0.1$ step size, as hinted at by your Table expression.



          tuples = Transpose@Range[0, 2 Pi, 0.1], data;

          Show[
          Plot[
          NIntegrate[Interpolation[tuples][x], x, 0, xmax, Method -> "Trapezoidal"],
          xmax, 0, 2 Pi, PlotLegends -> "integral"
          ],
          ListPlot[
          Style[tuples, Thick, ColorData[97][2]],
          Mesh -> All, MeshStyle -> Directive[Black, PointSize[0.01]],
          PlotLegends -> "data", Joined -> True
          ]
          ]


          Mathematica graphics







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 2 days ago









          MarcoBMarcoB

          38.5k557115




          38.5k557115





















              0












              $begingroup$

              It seems that Simpson's rule has not been mentioned yet, which is the result from a 2nd-order interpolation and will have a smaller error than that from a 1st-order one. So according to the formula, the inputs are the List of samples of the function data and the step size h:



              simpsoncoefficients[n_] := SparseArray[1 -> 1, -1 -> 1, i_?EvenQ -> 4, n, 2]
              integral[data_, h_] := (h/3) simpsoncoefficients[Length[#]].# &[data]


              Then integral[data, 0.1] gives 2.00024.






              share|improve this answer











              $endgroup$

















                0












                $begingroup$

                It seems that Simpson's rule has not been mentioned yet, which is the result from a 2nd-order interpolation and will have a smaller error than that from a 1st-order one. So according to the formula, the inputs are the List of samples of the function data and the step size h:



                simpsoncoefficients[n_] := SparseArray[1 -> 1, -1 -> 1, i_?EvenQ -> 4, n, 2]
                integral[data_, h_] := (h/3) simpsoncoefficients[Length[#]].# &[data]


                Then integral[data, 0.1] gives 2.00024.






                share|improve this answer











                $endgroup$















                  0












                  0








                  0





                  $begingroup$

                  It seems that Simpson's rule has not been mentioned yet, which is the result from a 2nd-order interpolation and will have a smaller error than that from a 1st-order one. So according to the formula, the inputs are the List of samples of the function data and the step size h:



                  simpsoncoefficients[n_] := SparseArray[1 -> 1, -1 -> 1, i_?EvenQ -> 4, n, 2]
                  integral[data_, h_] := (h/3) simpsoncoefficients[Length[#]].# &[data]


                  Then integral[data, 0.1] gives 2.00024.






                  share|improve this answer











                  $endgroup$



                  It seems that Simpson's rule has not been mentioned yet, which is the result from a 2nd-order interpolation and will have a smaller error than that from a 1st-order one. So according to the formula, the inputs are the List of samples of the function data and the step size h:



                  simpsoncoefficients[n_] := SparseArray[1 -> 1, -1 -> 1, i_?EvenQ -> 4, n, 2]
                  integral[data_, h_] := (h/3) simpsoncoefficients[Length[#]].# &[data]


                  Then integral[data, 0.1] gives 2.00024.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited yesterday

























                  answered 2 days ago









                  Αλέξανδρος ΖεγγΑλέξανδρος Ζεγγ

                  4,49011029




                  4,49011029



























                      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%2f194373%2fintegrating-a-list-of-values%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

                      getting Checkpoint VPN SSL Network Extender working in the command lineHow to connect to CheckPoint VPN on Ubuntu 18.04LTS?Will the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayVPN SSL Network Extender in FirefoxLinux Checkpoint SNX tool configuration issuesCheck Point - Connect under Linux - snx + OTPSNX VPN Ububuntu 18.XXUsing Checkpoint VPN SSL Network Extender CLI with certificateVPN with network manager (nm-applet) is not workingWill the Linux ( red-hat ) Open VPNC Client connect to checkpoint or nortel VPN gateways?VPN client for linux machine + support checkpoint gatewayImport VPN config files to NetworkManager from command lineTrouble connecting to VPN using network-manager, while command line worksStart a VPN connection with PPTP protocol on command linestarting a docker service daemon breaks the vpn networkCan't connect to vpn with Network-managerVPN SSL Network Extender in FirefoxUsing Checkpoint VPN SSL Network Extender CLI with certificate

                      Cannot Extend partition with GParted The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsCan't increase partition size with GParted?GParted doesn't recognize the unallocated space after my current partitionWhat is the best way to add unallocated space located before to Ubuntu 12.04 partition with GParted live?I can't figure out how to extend my Arch home partition into free spaceGparted Linux Mint 18.1 issueTrying to extend but swap partition is showing as Unknown in Gparted, shows proper from fdiskRearrange partitions in gparted to extend a partitionUnable to extend partition even though unallocated space is next to it using GPartedAllocate free space to root partitiongparted: how to merge unallocated space with a partition

                      Marilyn Monroe Ny fiainany manokana | Jereo koa | Meny fitetezanafanitarana azy.