Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Piecewise Symbolic Function with Conditional Statement

I wish to incorporate a conditional Python expression (if ... else ...) in a symbolic function.

Suppose I have a piecewise function k(n) defined for n = 1,2,3... as in the following pseudocode:

k(n) =
    2 if n = 1
    n otherwise

I compose this with another function g(x) and wish to integrate the result. For example,

f(x)=g(x)/k(n)
f(n=...).integrate(x, 0, 1)

How can implement a non-evaluating conditional in a symbolic Sage function?