Ask Your Question
0

Calculating inverse of a function

asked 2020-03-09 09:50:35 -0600

gg gravatar image

updated 2020-03-11 01:24:54 -0600

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 03:27:08 -0600

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 09:50:35 -0600

Seen: 131 times

Last updated: Mar 11