4
$\begingroup$

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}]*)
N[%]
(* 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

$\endgroup$

1 Answer 1

2
$\begingroup$

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).

Now

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

and

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

but

intg[-0.91666,2]

is unevaluated.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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