Hi, @aerappa and I are looking for a package that would allow us to easily represent and work with (mathematical) functions that are defined in a piecewise manner.
To be a bit more specific, assuming we are working with a function such as
we’d like to be able to efficiently represent it as a Julia object and evaluate it or its derivatives at any point using code that could ideally look like (don’t mind the API; I just made it up for the purpose of this post in order to clarify what we need):
f = PieceWise(exp, 0.0,
Polynomial([1,1]))
f′ = derivative(f)
f(-1.0), f′(-1.0) # == exp(-1), exp(-1)
f( 1.0), f′( 1.0) # == 2, 1
On the one hand, this seems easy enough to implement on our own. On the other hand, it looks general enough that someone might have registered a package to do this (and why reinvent the wheel?). But I haven’t found anything like this (yet!). Does anyone here know of an existing package that would do something this?