Hi! On 2015-09-10, springfield .gion <[email protected]> wrote: > Hi, I wanted to get the sum of two piecewise linear functions, but the > obvious thing does not seem to work; is there an easy (= already > implemented) way to do this? > here is what I mean: > > R.<t> = RR[] > a = Piecewise([[0,1],t]) > b = Piecewise([[0,1],t]) > c = a+b
In the definition of a and b, you forgot a couple of brackets. First of all, it seems that the [0,1] (a Python list) has to be replaced by a tuple (0,1) (don't ask me why), and even if your piecewise linear function only has a single part, it is still needed to provide a *list* of parts (you only give the single part, but it has to be enclosed in square brackets). The following works: sage: a = Piecewise([[(0,1),t]]) sage: b = Piecewise([[(0,1),t]]) sage: a+b Piecewise defined function with 1 parts, [[(0, 1), 2.00000000000000*t]] Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
