# Evaluation of a function and it's inverse with parameters

The following code works perfectly :

var('W1, W2, Ub, p')
a, x, y = SR.var('a,x,y')
W2=W
U(x)=x^a

assume(a, 'real')
assume(a, 'noninteger')   # or alternatively 'integer'
assume(x, 'real')
assume(y, 'real')
assume(x > 0)
assume(y > 0)
U(x).substitute(x==y)
show(U(x))
V=solve(x == U(y), [y]).rhs().function(x)
show(V)
VV=((Ub-p*U(W2))/(1-p))^(1/a)
show(VV)


But now I want to be also able to attribute some values to the parameters and the variable to achieve an evaluation and plot according to the parameter values. I need the function and it's inverse. I have seen the methode lambda x in the documentation but it's end with an error.

edit retag close merge delete

Please use minimal code to illustrate and explain the issue. Which is the function involved, and why are we not defining it explicitly? Do we need a and W2 for instance? What is W above? If we do not need them, please do not mention them. Do we need indeed the many assumed properties? (Or only the one in a...) If yes, there must be a big magic to have them also in the function V. The line with V = ... is a big adventure, this is not a good style to introduce things in a clear manner. Why not defining V explicitly when...

forget()
var('a,x,y');
assume(a, 'real')
assume(a, 'noninteger')
assume(x > 0)
U(x) = x^a
V = solve(x == U(y), [y]).rhs().function(x)

sage: V
x |--> x^(1/a)
sage: V.subs( {a : 2} )
x |--> sqrt(x)