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 Number
s in most places through the magic of mutiple dispatch. (GQ
s do not behave identically to Number
s 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.GQ
— TypeGQ{d,X<:AbstractFloat}
Represents a quantity with dimensions $[T^d]$. A GQ
can be represented mathematically as $x s^d$ where $d ∈ ℤ$.
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.
- Unary
+
and-
operators for allGQ
types - Binary
+
and-
operators forGQ
types with like dimensions *
,/
operators for allGQ
types^
operator for various cases where the output is a validGQ
sqrt
cbrt
,root
functions for cases where the output is a validGQ
==
,!=
,<
,<=
,>
,>=
,≈
operators forGQ
types with like dimensions- Trigonometric functions (
sin
,cos
,sincos
,tan
,csc
,sec
,cot
) for dimensionless inputs - Inverse trigonometric functions (
asin
,acos
,atan
,acsc
,asec
,acot
) for dimensionless inputs atan
function for a pair ofGQ
s types with like dimensionsexp
,exp2
,exp10
,log
,log2
,log10
functions for dimensionless inputsabs
,sign
,floor
,ceil
functions for allGQ
typesisfinite
andisnan
functions for allGQ
typeszero
andoneunit
functions for allGQ
typestaylor_horner
andtaylor_horner_integral
functions