I'm trying to do something that seems very simple but isn't working.
Hence the post here :)
I want to define a very simple piecewise linear function. It's linear
with slope alpha up to a knot at c and then it's linear with slope
beta. Here's what I thought might work:
f(x) = (x<=c)*alpha*x + (x>c)*(alpha*c + beta*(x-c))
Putting the inequalities in there caused a big mess. So I tried
defining a Python Indicator function that turns Truth values into 0 or
1, and then I wrapped my relational expressions with it:
def Indicator(cond):
if (cond==True):
return 1
else:
return 0
This didn't work either:
sage: foo(x) = Indicator(x>4) ; foo
x |--> 0
Any other ideas? I suppose I could in this case define my piecewise
function as a Python function, but then I won't be able to do as much
with it later (e.g., differentiate it).
Thx as usual, Doug
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---