Composition of piecewise function
[Remark: This is not a question but I do not know how to signal a mistake in the doc.
[http://fe.math.kobe-u.ac.jp/icms2010-...
uses Piecewise
which leads to an error, not piecewise
which is good.]
Here is my question:
This code does exactly what I expect
A = 1000
g(x) = x^2
f = piecewise([[[1, 1], (A/12)],
[[2, 2], (A/(12 - 1) - 1*10)],
[[3, 3], (A/(12 - 2) - 2*10)]])
show(f(1), ", ", f(2), ", ", f(3))
fg = piecewise([[[1, 1], g(A/12)],
[[2, 2], g(A/(12 - 1) - 1*10)],
[[3, 3], g(A/(12 - 2) - 2*10)]])
show(fg(1), ", ", fg(2), ", ", fg(3))
but I have a lot of g(x)
to compose with f
so I would like
to know if there is a way to define a composition of functions
for piecewise functions (here defined on subset of ZZ
).
There is also the problem where I have a function h
which is itself a piecewise function on the same set and I want
fgh = piecewise([[[1, 1], h(1)*g(A/12)],
[[2, 2], h(2)*g(A/(12 - 1) - 1*10)],
[[3, 3], h(3)*g(A/(12 - 2) - 2*10)]])
show(fg(1), ", ", fg(2), ", ", fg(3))
This documentation link is obsolete and not official. Use only doc.sagemath.org
The documentation you link to is the documentation for Sage 4.5.1, released on 2010-07-19.
It accurately describes how Sage 4.5.1 works.
The piecewise functionality in Sage has since evolved, with some non-backward compatible changes.
Ideally, consult the documentation for the version of Sage you are using.
Ideally, provide complete code, for anyone to copy-paste to explore the question.
To make sure of that, paste the commands from your question in a fresh Sage session.
Doing so gives a sense of what others will experience when trying to help.
I have rewrited completely my question.
I cannot see the rewritten question.