Ask Your Question
0

Calculating inverse of a function

asked 2020-03-09 15:50:35 +0100

gg gravatar image

updated 2020-03-11 07:24:54 +0100

Is there any straightforward way to calculate inverse of a function in sage? For example:

f(x) = 2 * x  - 1
f^-1(x) = ( x + 3 ) / 2

I have encountered solutions like this. But this was answered 9 years ago, I hope there exist a better way to do now.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-03-10 09:27:08 +0100

Emmanuel Charpentier gravatar image

This cas is especially simple:

sage: f(x)=2*x-1
sage: var("y")
y
sage: solve(f(x)==y,x)
[x == 1/2*y + 1/2]
sage: f_1(y)=solve(f(x)==y,x)[0]; f_1
y |--> x == 1/2*y + 1/2

Other cases may be more problematic (the equation may have more than one solution, or no solution at all, or sotutions that solve isn't able to find). But this is a start.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-03-09 15:50:35 +0100

Seen: 1,220 times

Last updated: Mar 11 '20