# How do I improve this code for hyperbolic numbers so to allow equation-solving?

I have the following code, which allows evaluating expressions with split-complex unity J:

Unprotect[Power]; Power[0, 0] = 1; Protect[Power];
$Pre = If[FreeQ[#, J], #, Module[{tmp}, tmp = Evaluate[ MatrixFunction[Function[J, #], {{0, 1}, {1, 0}}]] // FullSimplify; tmp /. {{a_, b_}, {b_, a_}} -> a + J b]] &;  After first run it allows evaluating functions of J just as if it was an embedded constant. But trying to slove equations with it fails, and returns useless output. Can this code be modified so that Solve and Reduce also would work? An example of possible equations: Solve[(a+b J)^2==1,{a,b}] Solve[(a+b J)^2 == (a + b J), {a, b}] Solve[(a+b J)^2==J,{a,b}] Solve[(a+b J)^(a+b J)==1,{a,b}] • Why not simply define J^2==1 ? (after unprotecting Power) Commented Oct 3, 2021 at 10:01 • @DanielHuber does not work for me, makes things worse, even expressions after this are not evaluated. Commented Oct 3, 2021 at 10:09 • I have MMA 12.3. what version do you have? For your first equation I get the result: : {{b -> -Sqrt[J] - a J}, {b -> Sqrt[J] - a J}} Commented Oct 3, 2021 at 13:15 • @DanielHuber I get nonsciential MatrixFunction[ Function[J, {{b -> -Sqrt[J] - a J}, {b -> Sqrt[J] - a J}}], J] Is it what you get as well? Commented Oct 3, 2021 at 13:20 • @DanielHuber and for Solve[(a+b J)^2==1,{a,b}] I do not get anything. Commented Oct 3, 2021 at 13:24 ## 3 Answers One solution is: JEq[a_] := (a /. {J -> 1}) && (a /. {J -> -1}) JEv[a_] := Module[{c, d}, (c + J d) /. Solve[JEq[a == c + J d], {c, d}][[1]]]  Here JEq turns any split-complex (hyperbolic) equation into a conjunction of real equations, allowing it to be solved. And JEv evaluates a split-complex expression. Example for JEq: In[2]:= JEq[(a + b J)^2 == 1] Out[2]= (a + b)^2 == 1 && (a - b)^2 == 1 In[3]:= Solve[JEq[(a + b J)^2 == 1], {a, b}] Out[3]= {{a -> -1, b -> 0}, {a -> 0, b -> -1}, {a -> 0, b -> 1}, {a -> 1, b -> 0}}  Example for JEv: In[4]:= JEv[1/(a + J*b)] Out[4]= a/((a - b) (a + b)) - (b J)/((a - b) (a + b))  They will work correctly for most expressions or equations, including exponential ones: In[5]:= JEv[2^(1 + 2 J)] Out[5]= 17/4 + (15 J)/4  Edit: this piece of code should remove the need to wrap split-complex equations in JEq, by doing the transformation automatically. Unprotect[Equal]; Equal[a_, b_] := Activate[JEq[Inactive[Equal][a, b]]] /; Not[FreeQ[a, J] && FreeQ[b, J]] Protect[Equal];  I do not know how to do powering with matrices as powers. The first three can be handled as below. jmat = {{0, 1}, {1, 0}}; iden2 = IdentityMatrix[2]; mat = a*iden2 + b jmat; lpolys1 = Flatten[mat . mat - iden2]; lpolys2 = Flatten[mat . mat - mat]; lpolys3 = Flatten[mat . mat - jmat]; In[405]:= Solve[lpolys1 == 0, {a, b}] Solve[lpolys2 == 0, {a, b}] Solve[lpolys3 == 0, {a, b}] (* Out[405]= {{a -> 0, b -> -1}, {a -> 0, b -> 1}, {a -> -1, b -> 0}, {a -> 1, b -> 0}} *) (* Out[406]= {{a -> 0, b -> 0}, {a -> 1/2, b -> -(1/2)}, {a -> 1/2, b -> 1/2}, {a -> 1, b -> 0}} *) (* Out[407]= {{a -> -((-1)^(1/4)/Sqrt[2]), b -> (-1)^(3/4)/Sqrt[2]}, {a -> (-1)^(1/4)/Sqrt[2], b -> -((-1)^(3/4)/Sqrt[2])}, {a -> -((-1)^(3/4)/Sqrt[2]), b -> (-1)^(1/4)/Sqrt[2]}, {a -> (-1)^(3/4)/Sqrt[2], b -> -((-1)^(1/4)/Sqrt[2])}} *)  • This removes the possibility of working with arbitrary expressions of J. This is not what I wanted to do. Commented Oct 3, 2021 at 15:58 • And yet...it answers the question you actually asked. There's a moral in this, somewhere. Commented Oct 3, 2021 at 16:48 • I asked how to modify the code so that it would permit solve and reduce to work with split-complex numbers just like with any other expressions. Commented Oct 3, 2021 at 16:50 • Ah. I thought the objective was to solve for {a,b}. Offhand I do not see a way to go about this that does not use the standard 2x2 matrix representation for J. Commented Oct 3, 2021 at 22:32 Answering my own question. Adding this line to the front of a notebook simply allows to treat tessarines as any other number, including the equations: $Pre = (# /. J -> {-1, 1}) /. {x_, y_} -> (x + y)/2 + (J (y - x))/2 &;


Like this:

In:=Log[J]

Out:=(I Pi)/2 - (I Pi J)/2