Ask Your Question

terrygarcia's profile - activity

2019-02-15 00:29:14 -0500 received badge  Famous Question (source)
2018-02-28 10:43:21 -0500 received badge  Notable Question (source)
2017-08-10 08:33:47 -0500 received badge  Student (source)
2017-07-26 18:02:46 -0500 received badge  Popular Question (source)
2017-07-21 16:57:36 -0500 commented answer Piecewise Symbolic Function with Conditional Statement

There isn't any sort of conditional statement in the above code, which is what my question addresses.

2017-07-21 12:52:38 -0500 asked a question 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(n=...).integrate(x, 0, 1)

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