|
58 | 58 | 0.125000000000... |
59 | 59 | """ |
60 | 60 |
|
61 | | -#***************************************************************************** |
| 61 | +# **************************************************************************** |
62 | 62 | # Copyright (C) 2006 William Stein <[email protected]> |
63 | 63 | # 2006 David Joyner <[email protected]> |
64 | 64 | # 2013 Volker Braun <[email protected]> |
|
68 | 68 | # the Free Software Foundation, either version 2 of the License, or |
69 | 69 | # (at your option) any later version. |
70 | 70 | # http://www.gnu.org/licenses/ |
71 | | -#***************************************************************************** |
| 71 | +# **************************************************************************** |
72 | 72 |
|
73 | 73 | from __future__ import absolute_import, division, print_function |
74 | 74 |
|
@@ -290,6 +290,26 @@ def simplify(ex): |
290 | 290 |
|
291 | 291 | class EvaluationMethods(object): |
292 | 292 |
|
| 293 | + def __pow__(self, parameters, variable, n): |
| 294 | + """ |
| 295 | + Return the `n`-th power of the piecewise function by applying the |
| 296 | + operation to each piece. |
| 297 | +
|
| 298 | + INPUT: |
| 299 | +
|
| 300 | + - ``n`` -- number or symbolic expression |
| 301 | +
|
| 302 | + EXAMPLES:: |
| 303 | +
|
| 304 | + sage: f1(x) = -abs(x) + 1; f2(x) = abs(x - 2) - 1 |
| 305 | + sage: f = piecewise([ [(-1,1), f1], [(1,3), f2]]) |
| 306 | + sage: (f^2).integral(definite=True) |
| 307 | + 4/3 |
| 308 | + """ |
| 309 | + return piecewise(zip(self.domains(), |
| 310 | + [ex**n for ex in self.expressions()]), |
| 311 | + var=variable) |
| 312 | + |
293 | 313 | def expression_at(self, parameters, variable, point): |
294 | 314 | """ |
295 | 315 | Return the expression defining the piecewise function at |
@@ -702,6 +722,7 @@ def piecewise_add(self, parameters, variable, other): |
702 | 722 | def integral(self, parameters, variable, x=None, a=None, b=None, definite=False): |
703 | 723 | r""" |
704 | 724 | By default, return the indefinite integral of the function. |
| 725 | +
|
705 | 726 | If definite=True is given, returns the definite integral. |
706 | 727 |
|
707 | 728 | AUTHOR: |
|
0 commit comments