Toolbox

Dictionaries

CamiMath.dictSuperscriptConstant
dictSuperscript
julia> dictSuperscript
Dict{Char, Char} with 38 entries:
  'n' => 'ⁿ'
  'f' => 'ᶠ'
  'w' => 'ʷ'
  '1' => '¹'
  'd' => 'ᵈ'
  'e' => 'ᵉ'
  ⋮   => ⋮

Example:

julia> get(dictSuperscript, 'n', "not found")
'ⁿ': Unicode U+207F (category Lm: Letter, modifier)
source
CamiMath.dictSubscriptConstant
dictSuperscript
julia> dictSubscript
Dict{Char, Char} with 25 entries:
  'n' => 'ₙ'
  '1' => '₁'
  'e' => 'ₑ'
  '7' => '₇'
  '6' => '₆'
  'o' => 'ₒ'
  ⋮   => ⋮

Example:

julia> get(dictSubscript, 'n', "not found")
'ₙ': Unicode U+2099 (category Lm: Letter, modifier)
source
CamiMath.dictUndoSmallConstant
dictUndoSmall
julia> dictUndoSmall
Dict{Char, Char} with 62 entries:
  'ᵉ' => 'e'
  'ₓ' => 'x'
  'ₖ' => 'k'
  'ⁿ' => 'n'
  '𐞥' => 'q'
  'ₕ' => 'h'
  ⋮   => ⋮

Example:

julia> get(dictUndoSmall, 'ⁿ', "not found")
'n': ASCII/Unicode U+006E (category Ll: Letter, lowercase)
source

Superscript tools

CamiMath.supMethod
sup(i::T) where T<:Real

Superscript notation for integers and rational numbers and all lowercase characters

Examples:

julia> sup(3) * 'P'
"³P"

julia> 'D' * sup(5//2)
"D₅⸝₂"

julia> 'D' * sub(50//20)
"D₅⸝₂"

julia> 'D' * sub(50//21)
"D₅₀⸝₂₁"
sup(str::String)

Example:

julia> 'D' * sup("superscript")
"Dˢᵘᵖᵉʳˢᶜʳⁱᵖᵗ"
source
CamiMath.undosupMethod
undosup(str::Union{Char, String})

Undo conversion of Integer or Rational{Int} to superscript String Examples:

julia> undosup("⁻⁵ᐟ²")
-5//2
source

Subscript tools

CamiMath.subMethod
sub(i::T) where T<:Real

Subscript notation for integers, rational numbers and a subset of lowercase characters ('a', 'e', 'h', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'x')

Examples:

julia> 'D' * sub(5//2)
"D₅⸝₂"

julia> 'D' * sub(50//20)
"D₅⸝₂"

julia> 'D' * sub(50//21)
"D₅₀⸝₂₁"
sub(str::String)

Example:

julia> "m" * sub("e")
"mₑ"

julia> 'D' * sub("50/21")
"D₅₀⸝₂₁"
source
CamiMath.undosubMethod
undosub(str::Union{Char, String})

Undo conversion of Integer or Rational{Int} to subscript String Examples:

undosub("₋₅⸝₂")
-5//2
source

Tiny character tools

CamiMath.undosmallMethod
undosmall(str::Union{Char, String})

Reset to normal size String

Examples:

julia> undosmall("ˢᵘᵖᵉʳˢᶜʳⁱᵖᵗ")
"superscript"

julia> undosmall("⁻⁵ᐟ²")
"-5/2"

julia> undosmall("₋₅⸝₂")
"-5/2"
source
CamiMath.fracMethod
frac(i::Rational{Int})

Fraction notation for rational numbers

Examples:

julia> frac(-5//2)
"-⁵/₂"
source

Rational covert to String

CamiMath.strRationalMethod
strRational(n::T) where T<:Union{Rational{}, Int, BigInt}

Fraction notation for rational numbers and integers

Examples:

julia> strRational(-5//2)
"-5/2"
source

logical tools

CamiMath.isforwardMethod
function isforward(sense)

Boolean status of sense, with options: fwd (forward) and bwd (backward).

Example:

julia> isforward(fwd)
true
source
CamiMath.isbackwardMethod
function isbackward(sense)

Boolean status of sense, with options: fwd (forward) and bwd (backward).

Example:

julia> isbackward(fwd)
false
source
CamiMath.isregularMethod
function isregular(sense::Type)

Boolean status of sense, with options: reg (regular) and rev (reversed).

Example:

julia> isregular(reg)
true
source
CamiMath.isreversedMethod
function isreversed(sense::Type)

Boolean status of sense, with options: reg (regular) and rev (reversed).

Example:

julia> isreversed(rev)
true
source

Mathematics tools

CamiMath.Type_IOPFunction
Type_IOP(n::Integer, nc::Integer [, a [; nam="" [; msg=true]]])

BigInt if n is a BigInt or n > nc, otherwise Int; a is an auxiliary second variable.

  • nam : function name

  • msg : integer-overflow protection (IOP) - warning on activation

Examples:

julia> Type_IOP(1, 1)
Int64

julia> Type_IOP(big(1), 1)
BigInt

julia> Type_IOP(2, 1)
BigInt

julia> Type_IOP(1, 1; nam="test")
Int64

julia> Type_IOP(2, 1, 0; nam="test")
 IOP capture at test(2, 0): output converted to BigInt
BigInt
source
CamiMath.log10_characteristicMethod
log10_characteristic(x)

characteristic power-of-10 of the number x

Examples:

julia> log10_characteristic.([3,30,300])
3-element Vector{Int64}:
 0
 1
 2
source
CamiMath.log10_mantissaMethod
log10_mantissa(x)

log10 mantissa of the number x

Examples:

julia> log10_mantissa.([3,30,300])
3-element Vector{Float64}:
 0.47712125471966244
 0.4771212547196624
 0.4771212547196626
source
CamiMath.texpMethod
texp(x::T, a::T, p::Int) where T <: Real

Truncated exponential: Taylor expansion of $exp(x)$ about $x = a$ up to order p,

\[ \mathsf{texp}(x,a,p) = 1+(x-a)+\frac{1}{2}(x-a)^2+⋯+\frac{1}{p!}(x-a)^p\]

Examples:

julia> texp(1.0, 0.0, 5)
2.7166666666666663

julia> texp(1, 0, 5)
163//60
source

Divisor

CamiMath.normalize_rationalsMethod
normalize_rationals(v::Vector{Rational{T}}) where T<:Integer

Numerators separated from divisor

Example:

julia> normalize_rationals([1//1, 1//2, 1//3])
([6, 3, 2], 6)
source
CamiMath.divisorMethod
divisor(v::Vector{Rational{T}}) where T<:Integer

Greatest common denominator of the set of rational numbers v

Example:

julia> divisor([1//1, 1//2, 1//3])
6
source
CamiMath.numeratorsMethod
numerators(v::Vector{Rational{T}}) where T<:Integer

Numerators for the standard devisor of the set of rational numbers v

Example:

julia> numerators([1//1, 1//2, 1//3])
3-element Vector{Int64}:
 6
 3
 2
source

Conversion to Big types

CamiMath.convertToBigMethod
convertToBig(x::T) where T

Conversion from 64-bit-based types to BigInt-based types:

  • Int => BigInt,
  • Vector{Int} => Vector{BigInt},
  • Vector{Vector{Int}} => Vector{Vector{BigInt}},
  • Rational{Int} => Rational{BigInt},
  • Vector{Rational{Int}} => Vector{Rational{BigInt}},
  • Vector{Vector{Rational{Int}}} => Vector{Vector{Rational{BigInt}}},
  • Float64 => BigFloat,
  • Vector{Float64} => Vector{BigFloat},
  • Vector{Vector{Float64}} => Vector{Vector{BigFloat}},
  • Complex{Float64} => Complex{BigFloat},
  • Vector{Complex{Float64}} => Vector{Complex{BigFloat}},
  • Vector{Vector{Complex{Float64}}} => Vector{Vector{Complex{BigFloat}}}

Example:

julia> [[1 // 1, 1 // 2], [1 // 1, 1 // 2]]
2-element Vector{Vector{Rational{Int64}}}:
 [1, 1//2]
 [1, 1//2]

julia> convertToBig([[1 // 1, 1 // 2], [1 // 1, 1 // 2]])
2-element Vector{Vector{Rational{BigInt}}}:
 [1, 1//2]
 [1, 1//2]
source