Quantities

It turns out that we can write the entire pulsar timing formula (e.g., see Equations 1-2 of Susobhanan+ 2024) can be expressed such that all quantities appearing therein have dimensions of the form [T^n]. In practice, this is achieved by absorbing certain constants appearing in the timing formula into measurable quantities.

For example, DM -> DMconst*DM; M2 -> G*M2/c^3; PX -> PX*c/AU; etc.

This means that we can represent all quantities in pulsar timing in the form x*s^p after some scaling, where x is the value of the scaled quantity in SI units, s is second, and p is an integer. This is implemented in the GeometricUnits.jl package as the GQ{p,F<:AbstractFloat} type (with p ∈ Integer). This package overloads all the arithmetic and comparison operators as well as elementary mathematical functions for the GQ type. i.e., GQ types can be used just like Numbers in most places through the magic of mutiple dispatch. (GQs do not behave identically to Numbers in some contexts, so GQ is not a subtype of Number.) It also defines iterators and such for the GQ type so that we can use it with packages like LinearAlgebra.jl

GeometricUnits.GQType
GQ{d,X<:AbstractFloat}

Represents a quantity with dimensions $[T^d]$. A GQ can be represented mathematically as $x s^d$ where $d ∈ ℤ$.

source

Note that the dimensionality p is a type parameter, which means that the dimensional correctness will be enforced by the Julia language at "compile time", and it will refuse to execute dimensionally incorrect expressions. This provides strong assurances for code correctness. Further, since p is a type parameter, there is no run time penalty for ensuring dimensional correctness.

GeometricUnits.jl also implements the following operations.

  1. Unary + and - operators for all GQ types
  2. Binary + and - operators for GQ types with like dimensions
  3. *, / operators for all GQ types
  4. ^ operator for various cases where the output is a valid GQ
  5. sqrt cbrt, root functions for cases where the output is a valid GQ
  6. ==, !=, <, <=, >, >=, operators for GQ types with like dimensions
  7. Trigonometric functions (sin, cos, sincos, tan, csc, sec, cot) for dimensionless inputs
  8. Inverse trigonometric functions (asin, acos, atan, acsc, asec, acot) for dimensionless inputs
  9. atan function for a pair of GQs types with like dimensions
  10. exp, exp2, exp10, log, log2, log10 functions for dimensionless inputs
  11. abs, sign, floor, ceil functions for all GQ types
  12. isfinite and isnan functions for all GQ types
  13. zero and oneunit functions for all GQ types
  14. taylor_horner and taylor_horner_integral functions