Opened 12 years ago

Last modified 4 years ago

#10597 needs_work enhancement

Riemann sums, added trapezoid option

Reported by: Gagan Sekhon Owned by: Burcin Erocal
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 Gagan Sekhon 12 years ago.
trac_10597.patch (7.2 KB) - added by Gagan Sekhon 12 years ago.

Download all attachments as: .zip

Change History (18)

Changed 12 years ago by Gagan Sekhon

Attachment: riemann_sums.patch added

Changed 12 years ago by Gagan Sekhon

Attachment: trac_10597.patch added

comment:1 Changed 12 years ago by Gagan Sekhon

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

comment:2 Changed 12 years ago by Gagan Sekhon

Type: PLEASE CHANGEenhancement

comment:3 Changed 12 years ago by Dima Pasechnik

Status: newneeds_review

comment:4 Changed 12 years ago by Dima Pasechnik

Status: needs_reviewpositive_review

comment:5 Changed 12 years ago by Jeroen Demeyer

Reviewers: Dmitrii Pasechnik

comment:6 Changed 12 years ago by Jeroen Demeyer

Status: positive_reviewneeds_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 12 years ago by Jeroen Demeyer

Reviewers: Dmitrii PasechnikDmitrii Pasechnik, Jeroen Demeyer

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

comment:8 Changed 12 years ago by Gagan Sekhon

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 12 years ago by Dima Pasechnik

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 9 years ago by Jeroen Demeyer

Milestone: sage-5.11sage-5.12

comment:11 Changed 9 years ago by Kevin Halasz

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 9 years ago by For batch modifications

Milestone: sage-6.1sage-6.2

comment:13 Changed 8 years ago by For batch modifications

Milestone: sage-6.2sage-6.3

comment:14 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4

comment:15 Changed 6 years ago by Matthias Köppe

Milestone: sage-6.4sage-7.3

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

comment:16 Changed 4 years ago by David Lowry-Duda

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.