Ticket #1773 (new defect)
piecewise functions and integration / arithmetic do not play well together
|Reported by:||was||Owned by:||gfurnish|
On 1/13/08, Hector Villafuerte <> wrote: > > I defined a piecewise function (specifically, a triangular wave) like this: > > sage: f1(x) = -abs(x) + 1 > sage: f2(x) = abs(x - 2) - 1 > sage: tri_wave = piecewise([ [(-1,1), f1], [(1,3), f2]]) > > One can plot it and it looks very nice: > > sage: tri_wave.plot() > > But while calculating this integral I get "ValueError: Value not > defined outside of domain." > > sage: integrate(tri_wave(x)^2, x, -1, 3) > > Is there a way to integrate piecewise-defined functions? > As always, thanks for your help, This is clearly broken. As a band-aide, you can at least numerically integrate as follows: sage: integral_numerical(lambda x: tri_wave(x)^2, -1, 3) (1.3333333333333333, 1.4765966227514582e-14) The first output (1.3333...) is the answer, and the second is an error bound. -- William
- Owner changed from was to gfurnish
- Status changed from new to assigned
Note: See TracTickets for help on using tickets.