Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can I implement Hyperbolic numbers in Mathematica? How could I express their polar form? How could I calculate their power?

share|improve this question
6  
How to write a good question! –  halirutan Jan 25 '13 at 15:20
2  
Depends on what exactly you want to do with them. For the "standard" case x+j*y with j^2=1, could use symmetric 2x2 matrices. –  Daniel Lichtblau Jan 26 '13 at 22:33
add comment

1 Answer

ScalarQ[c_] := NumericQ[c] && ! MatchQ[Head[c], Complex | Hyperbolic];

Hyperbolic /: Hyperbolic[a_, 0] := a;

Hyperbolic /: c_?ScalarQ + Hyperbolic[a_, b_] := Hyperbolic[c + a, b];

Hyperbolic /: Hyperbolic[a_, b_] + Hyperbolic[c_, d_] := 
 Hyperbolic[a + c, b + d];

Hyperbolic /: c_?ScalarQ*Hyperbolic[a_, b_] /; ScalarQ[c] := 
 Hyperbolic[c a, c b];

Hyperbolic /: Hyperbolic[a_, b_]*Hyperbolic[c_, d_] := 
 Hyperbolic[a c + b*d, b c + a d];

Hyperbolic /: Power[Hyperbolic[a_, b_], 0] := 1;

Hyperbolic /: Power[Hyperbolic[a_, b_], -1] := 
 Hyperbolic[a/(a^2 - b^2), -b/(a^2 - b^2)];

Hyperbolic /: Power[Hyperbolic[a_, b_], n_Integer?Positive] := 
 Hyperbolic[a, b] Power[Hyperbolic[a, b], n - 1];

Hyperbolic /: Power[Hyperbolic[a_, b_], n_Integer?Negative] := 
 1/Power[Hyperbolic[a, b], -n];

Hyperbolic /: Power[Hyperbolic[a_, b_], x_?ScalarQ] := 
 Which[a^2 - b^2 > 1, 
  Hyperbolic[(Sqrt[Abs[a^2 - b^2]])^x*
    Cosh[x*ArcTan[b/a]], (Sqrt[Abs[a^2 - b^2]])^x*
    Sinh[x*ArcTan[b/a]]], a^2 - b^2 < -1, 
  Hyperbolic[(Sqrt[Abs[a^2 - b^2]])^x*
    Sinh[x*ArcTan[b/a]], (Sqrt[Abs[a^2 - b^2]])^x*
    Cosh[x*ArcTan[b/a]]], a^2 - b^2 == 0, 0];

Hyperbolic /: 
 f_[Hyperbolic[a_, b_]] /; MemberQ[Attributes[f], NumericFunction] := 
 Hyperbolic[f[a], b f'[a]];
share|improve this answer
add comment

Your Answer

 
discard

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.