Opened 11 years ago

Last modified 3 years ago

#10597 needs_work enhancement

Riemann sums, added trapezoid option

Reported by: gagansekhon Owned by: burcin
Priority: minor Milestone: sage-7.3
Component: calculus Keywords: riemann sums, trapezoid
Cc: Merged in:
Authors: Gagan Sekhon Reviewers: Dmitrii Pasechnik, Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description

For piecewise functions, added trapezoid option to riemann_sum and riemann_sum_integral_approximation to already existing option of left, right and midpoint.

Deprecated, trapezoid_integral_approximation and trapezoid

Attachments (2)

riemann_sums.patch (7.1 KB) - added by gagansekhon 11 years ago.
trac_10597.patch (7.2 KB) - added by gagansekhon 11 years ago.

Download all attachments as: .zip

Change History (18)

Changed 11 years ago by gagansekhon

Changed 11 years ago by gagansekhon

comment:1 Changed 11 years ago by gagansekhon

changed file name and commit message to reflect trac number. Pleases use trac_10597.patch only.

comment:2 Changed 11 years ago by gagansekhon

  • Type changed from PLEASE CHANGE to enhancement

comment:3 Changed 11 years ago by dimpase

  • Status changed from new to needs_review

comment:4 Changed 11 years ago by dimpase

  • Status changed from needs_review to positive_review

comment:5 Changed 11 years ago by jdemeyer

  • Reviewers set to Dmitrii Pasechnik

comment:6 Changed 11 years ago by jdemeyer

  • Status changed from positive_review to needs_work

There is a doctest failure:

sage -t  -force_lib devel/sage/doc/en/constructions/calculus.rst
**********************************************************************
File "/mnt/usb1/scratch/jdemeyer/merger/sage-4.6.2.alpha2/devel/sage-main/doc/en/constructions/calculus.rst", line 204:
    sage: f.trapezoid(4)
Expected:
    Piecewise defined function with 4 parts, [[(0, 1/2), 1/2*x],
    [(1/2, 1), 9/2*x - 2], [(1, 3/2), 1/2*x + 2],
    [(3/2, 2), -7/2*x + 8]]
Got:
    doctest:1: DeprecationWarning: _word_content is deprecated, use riemann_sum instead
    Piecewise defined function with 4 parts, [[(0, 1/2), 1/2*x], [(1/2, 1), 9/2*x - 2], [(1, 3/2), 1/2*x + 2], [(3/2, 2), -7/2*x + 8]]
**********************************************************************

comment:7 Changed 11 years ago by jdemeyer

  • Reviewers changed from Dmitrii Pasechnik to Dmitrii Pasechnik, Jeroen Demeyer

A further small comment: in the docstrings, you should use OUTPUT: instead of Output:.

comment:8 follow-up: Changed 11 years ago by gagansekhon

There is a discussion regarding this ticket on sage-devel. http://groups.google.com/group/sage-devel/browse_thread/thread/c2c196ea37c753ae/bacb7b1fc3042d56?lnk=gst&q=gagan#bacb7b1fc3042d56

Until we come to a consensus, I think we should not merge it.

comment:9 in reply to: ↑ 8 Changed 11 years ago by dimpase

Replying to gagansekhon:

There is a discussion regarding this ticket on sage-devel. http://groups.google.com/group/sage-devel/browse_thread/thread/c2c196ea37c753ae/bacb7b1fc3042d56?lnk=gst&q=gagan#bacb7b1fc3042d56

Until we come to a consensus, I think we should not merge it.

Do you refer to the objection that trapezoid rule is not a Riemann sum? IMHO it is moot.

comment:10 Changed 8 years ago by jdemeyer

  • Milestone changed from sage-5.11 to sage-5.12

comment:11 Changed 8 years ago by khalasz

While helping a high school Calculus student with basic integration I tried to use Sage to do some computational examples, and when it didn't work as I expected it to I came across this ticket. The student's textbook considered a trapezoidal sum to be a Riemann sum, so I think pushing this ticket through would be helpful from the standpoint of wanting Sage to be a useful educational tool.

It seems that only minor updates are needed to get this patch to a point where it would be acceptable. I would be willing to make these small changes. However, based on the discussion cited above, which didn't seem to come to any sort of conclusion, I am hesitant to do so. Any thoughts on whether this patch is worth cleaning up and adding to the Sage source? I vote yes, but of course I am no Sage guru.

comment:12 Changed 8 years ago by vbraun_spam

  • Milestone changed from sage-6.1 to sage-6.2

comment:13 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:14 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:15 Changed 5 years ago by mkoeppe

  • Milestone changed from sage-6.4 to sage-7.3

Patch is outdated after replacement of the piecewise implementation in #14801.

comment:16 Changed 3 years ago by DavidLowry

  • Keywords beginner removed

I was asked about this ticket recently by a beginner, since it has the beginner keyword. But after looking at the ticket, I think this is not a good beginner ticket, especially now that the underlying code has been completely rewritten since this was first proposed.

I'm removing the beginner tag. But I also suggest that this ticket be closed --- there are no longer any Riemann sums here, so the discussion as to whether a trapezoidal sum should be considered no longer applies.

Note: See TracTickets for help on using tickets.