Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Composiiton of piecewise function

Remarks :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-dvd/SAGE/www.sagemath.org/doc/reference/sage/functions/piecewise.html uses Piecewise which leads to an error not piecewise which is good.

There is my question :

This code do 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 fo piecewise functions (here defined on subset of ZZ.

Composiiton of piecewise function

Remarks :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-dvd/SAGE/www.sagemath.org/doc/reference/sage/functions/piecewise.html uses Piecewise which leads to an error not piecewise which is good.

There is my question :

This code do 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]])
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]])
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 fo piecewise functions (here defined on subset of ZZ.

Composiiton of piecewise function

Remarks :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-dvd/SAGE/www.sagemath.org/doc/reference/sage/functions/piecewise.html uses Piecewise which leads to an error not piecewise which is good.

There is my question :

This code do 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 fo piecewise functions (here defined on subset of ZZ.

Composiiton Composition of piecewise function

Remarks :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-dvd/SAGE/www.sagemath.org/doc/reference/sage/functions/piecewise.html uses Piecewise which leads to an error not piecewise which is good.

There is my question :

This code do 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 fo piecewise functions (here defined on subset of ZZ.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)-110)],[[3,3],h(3)g(A/(12-2)-2*10)]]) show(fg(1),",",fg(2),",",fg(3))

Composition of piecewise function

Remarks :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-dvd/SAGE/www.sagemath.org/doc/reference/sage/functions/piecewise.html uses Piecewise which leads to an error not piecewise which is good.

There is my question :

This code do 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 fo 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)-110)],[[3,3],h(3)g(A/(12-2)-2*10)]])
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))

show(fg(1),",",fg(2),",",fg(3))

Composition of piecewise function

Remarks :This [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-dvd/SAGE/www.sagemath.org/doc/reference/sage/functions/piecewise.html [http://fe.math.kobe-u.ac.jp/icms2010-dvd/SAGE/www.sagemath.org/doc/reference/sage/functions/piecewise.html](http://fe.math.kobe-u.ac.jp/icms2010-dvd/SAGE/www.sagemath.org/doc/reference/sage/functions/piecewise.html) uses Piecewise which leads to an error error, not piecewise which is good.

There good.]

Here is my question :question:

This code do does exactly what I expect

A=1000
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))  
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))
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 like to know if there is a way to define a composition of functions fo functions for piecewise functions (here defined on subset of ZZ).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))
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))