I have two real-valued variables, A
and E
. I want to define a third variable D
such that:
if 0 <= E: D = A
elif E < 0: D = A + E
These variables are part of an extremely long expression (over 1200 characters) that I am trying to simplify. Working with a shorter related expression (around 100 characters), I found that a lot of the D
and E
instances either canceled out or reduced to A
s that could be combined with other A
s in the same parts of the expression, regardless of if E
is assumed to be positive or negative. Working through the long expression by hand in the same way would be the height of tedium, so I'm trying to see if Sage can help out.
Is this possible? Is there a better way to get the desired result? I've tried a few different syntaxes, but all give the error "SyntaxError: multiple statements found while compiling a single statement". I am brand-new to Sage, so forgive me if this should be obvious. I've browsed the documentation but didn't see a clear answer one way or the other.