3

I am trying to solve with:

ClearAll[myCeiling];
myCeiling /: InverseFunction[myCeiling[x_]] := myFloor[x];

using

Solve[a == myCeiling[b/7], b, InverseFunctions -> True]
(* => {{b -> 7*InverseFunction[myCeiling, 1, 1][a]}} *)

gets incorrect result (ignores the defined InverseFunction) and if I set

ClearAll[myCeiling];
myCeiling /: InverseFunction[myCeiling] := myFloor

the result is just empty list {}

How do I correctly define InverseFunction for my function to use with Solve and InverseFunctions -> True?

Edit

Setting DownValue also results in empty List:

ClearAll[myCeiling];
Unprotect[InverseFunction];
InverseFunction[myCeiling] := myFloor;
Solve[a == myCeiling[b/7], b, InverseFunctions -> True]
(* => {} *)

And since when I check the DownValues of InverseFunction they seem to be no different from any other definition

DownValues[InverseFunction][[1]]//FullForm
(* RuleDelayed[HoldPattern[InverseFunction[ArcCos]],Cos] *)
DownValues[InverseFunction][[29]]//FullForm
(* RuleDelayed[HoldPattern[InverseFunction[myCeiling]],myFloor] *)

I assume this might be some kind of bug in Solve?

grandrew
  • 550
  • 2
  • 10

1 Answers1

3

(This question is basically a duplicate of Define inverse for the custom operator, but I will customize that answer to your question.)

The issue you are running into is that Solve automatically verifies solutions when InverseFunction objects are involved. So, either use VerifySolutions->False:

Solve[a == myCeiling[b/7], b, InverseFunctions -> True, VerifySolutions->False]

{{b -> 7 myFloor[a]}}

or teach myCeiling how to handle myFloor objects:

myCeiling[myFloor[x_]] := x

Solve[a == myCeiling[b/7], b, InverseFunctions -> True]

{{b -> 7 myFloor[a]}}

Carl Woll
  • 130,679
  • 6
  • 243
  • 355