Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This example works to define InverseFunction on the first argument of a function

f = Function[{##} /. {x_, y_} :> Beta[x, y] - x + y];
g = InverseFunction[f, 1, 2];
g[3, 4]
(*Root[{1 + Beta[#1, 4] - #1 &, 1.17659010788279817113535497590}]*)
(* 1.17659 *)

When changing the definition of f to use x_Integer instead of x it no longer works

f = Function[{##} /. {x_Integer, y_Integer} :> Beta[x, y] - x + y];
g = InverseFunction[f, 1, 2];
g[3, 4]

Returns unevaluated

InverseFunction[{##1} /. {x_Integer, y_Integer} :> Beta[x, y] - x + y &, 1, 2][3, 4]

How to make InverseFunction work on functions defined with restrictions on its arguments? I looked at ConditionalExpression but could not figure how to use it here.

V 9.01 on windows

share|improve this question
up vote 1 down vote accepted

Since for real input there isn't any errors spat out, I assume the function is invertible in the first variable so one way to get the function you want is to constrain the inverse to be an integer. A way to do this is:

Clear[f, g, intg]
f[x_, y_] := Beta[x, y] - x + y;
g[z_, y_] := InverseFunction[f, 1, 2][z, y];
intg[z_, y_Integer] :=
 If[IntegerQ@# || IntegerPart@# == #, IntegerPart@#,] &@g[z, y]

The second condition in If is so that if the inversion is done numerically you force the result to be an integer (but this is to some accuracy i.e. 4 == 4. (1 + 1 10^-14) is True while 4 == 4. (1 + 1 10^-13) is False).


f[3, 2]
(* -11/12 *)


(* 3 *)



is unevaluated.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.