| Alternative 1 | |
|---|---|
| Error | 1.1 |
| Cost | 26624 |
(FPCore (t l Om Omc) :precision binary64 (asin (sqrt (/ (- 1.0 (pow (/ Om Omc) 2.0)) (+ 1.0 (* 2.0 (pow (/ t l) 2.0)))))))
(FPCore (t l Om Omc)
:precision binary64
(if (<= (/ t l) -4e+111)
(asin (/ (- (sqrt 0.5)) (/ t l)))
(if (<= (/ t l) 2e+143)
(asin
(sqrt
(/
(- 1.0 (/ (/ Om Omc) (/ Omc Om)))
(+ 1.0 (* 2.0 (* (/ t l) (/ t l)))))))
(asin (* l (/ (sqrt 0.5) t))))))double code(double t, double l, double Om, double Omc) {
return asin(sqrt(((1.0 - pow((Om / Omc), 2.0)) / (1.0 + (2.0 * pow((t / l), 2.0))))));
}
double code(double t, double l, double Om, double Omc) {
double tmp;
if ((t / l) <= -4e+111) {
tmp = asin((-sqrt(0.5) / (t / l)));
} else if ((t / l) <= 2e+143) {
tmp = asin(sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = asin((l * (sqrt(0.5) / t)));
}
return tmp;
}
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
code = asin(sqrt(((1.0d0 - ((om / omc) ** 2.0d0)) / (1.0d0 + (2.0d0 * ((t / l) ** 2.0d0))))))
end function
real(8) function code(t, l, om, omc)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: om
real(8), intent (in) :: omc
real(8) :: tmp
if ((t / l) <= (-4d+111)) then
tmp = asin((-sqrt(0.5d0) / (t / l)))
else if ((t / l) <= 2d+143) then
tmp = asin(sqrt(((1.0d0 - ((om / omc) / (omc / om))) / (1.0d0 + (2.0d0 * ((t / l) * (t / l)))))))
else
tmp = asin((l * (sqrt(0.5d0) / t)))
end if
code = tmp
end function
public static double code(double t, double l, double Om, double Omc) {
return Math.asin(Math.sqrt(((1.0 - Math.pow((Om / Omc), 2.0)) / (1.0 + (2.0 * Math.pow((t / l), 2.0))))));
}
public static double code(double t, double l, double Om, double Omc) {
double tmp;
if ((t / l) <= -4e+111) {
tmp = Math.asin((-Math.sqrt(0.5) / (t / l)));
} else if ((t / l) <= 2e+143) {
tmp = Math.asin(Math.sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l)))))));
} else {
tmp = Math.asin((l * (Math.sqrt(0.5) / t)));
}
return tmp;
}
def code(t, l, Om, Omc): return math.asin(math.sqrt(((1.0 - math.pow((Om / Omc), 2.0)) / (1.0 + (2.0 * math.pow((t / l), 2.0))))))
def code(t, l, Om, Omc): tmp = 0 if (t / l) <= -4e+111: tmp = math.asin((-math.sqrt(0.5) / (t / l))) elif (t / l) <= 2e+143: tmp = math.asin(math.sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l))))))) else: tmp = math.asin((l * (math.sqrt(0.5) / t))) return tmp
function code(t, l, Om, Omc) return asin(sqrt(Float64(Float64(1.0 - (Float64(Om / Omc) ^ 2.0)) / Float64(1.0 + Float64(2.0 * (Float64(t / l) ^ 2.0)))))) end
function code(t, l, Om, Omc) tmp = 0.0 if (Float64(t / l) <= -4e+111) tmp = asin(Float64(Float64(-sqrt(0.5)) / Float64(t / l))); elseif (Float64(t / l) <= 2e+143) tmp = asin(sqrt(Float64(Float64(1.0 - Float64(Float64(Om / Omc) / Float64(Omc / Om))) / Float64(1.0 + Float64(2.0 * Float64(Float64(t / l) * Float64(t / l))))))); else tmp = asin(Float64(l * Float64(sqrt(0.5) / t))); end return tmp end
function tmp = code(t, l, Om, Omc) tmp = asin(sqrt(((1.0 - ((Om / Omc) ^ 2.0)) / (1.0 + (2.0 * ((t / l) ^ 2.0)))))); end
function tmp_2 = code(t, l, Om, Omc) tmp = 0.0; if ((t / l) <= -4e+111) tmp = asin((-sqrt(0.5) / (t / l))); elseif ((t / l) <= 2e+143) tmp = asin(sqrt(((1.0 - ((Om / Omc) / (Omc / Om))) / (1.0 + (2.0 * ((t / l) * (t / l))))))); else tmp = asin((l * (sqrt(0.5) / t))); end tmp_2 = tmp; end
code[t_, l_, Om_, Omc_] := N[ArcSin[N[Sqrt[N[(N[(1.0 - N[Power[N[(Om / Omc), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(2.0 * N[Power[N[(t / l), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
code[t_, l_, Om_, Omc_] := If[LessEqual[N[(t / l), $MachinePrecision], -4e+111], N[ArcSin[N[((-N[Sqrt[0.5], $MachinePrecision]) / N[(t / l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(t / l), $MachinePrecision], 2e+143], N[ArcSin[N[Sqrt[N[(N[(1.0 - N[(N[(Om / Omc), $MachinePrecision] / N[(Omc / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(2.0 * N[(N[(t / l), $MachinePrecision] * N[(t / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], N[ArcSin[N[(l * N[(N[Sqrt[0.5], $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\sin^{-1} \left(\sqrt{\frac{1 - {\left(\frac{Om}{Omc}\right)}^{2}}{1 + 2 \cdot {\left(\frac{t}{\ell}\right)}^{2}}}\right)
\begin{array}{l}
\mathbf{if}\;\frac{t}{\ell} \leq -4 \cdot 10^{+111}:\\
\;\;\;\;\sin^{-1} \left(\frac{-\sqrt{0.5}}{\frac{t}{\ell}}\right)\\
\mathbf{elif}\;\frac{t}{\ell} \leq 2 \cdot 10^{+143}:\\
\;\;\;\;\sin^{-1} \left(\sqrt{\frac{1 - \frac{\frac{Om}{Omc}}{\frac{Omc}{Om}}}{1 + 2 \cdot \left(\frac{t}{\ell} \cdot \frac{t}{\ell}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin^{-1} \left(\ell \cdot \frac{\sqrt{0.5}}{t}\right)\\
\end{array}
Results
if (/.f64 t l) < -3.99999999999999983e111Initial program 28.8
Applied egg-rr1.2
Simplified1.2
[Start]1.2 | \[ \sin^{-1} \left(\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}} \cdot \frac{1}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
|---|---|
associate-*r/ [=>]1.2 | \[ \sin^{-1} \color{blue}{\left(\frac{\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}} \cdot 1}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)}
\] |
unpow2 [=>]1.2 | \[ \sin^{-1} \left(\frac{\sqrt{1 - \color{blue}{\frac{Om}{Omc} \cdot \frac{Om}{Omc}}} \cdot 1}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
times-frac [<=]9.8 | \[ \sin^{-1} \left(\frac{\sqrt{1 - \color{blue}{\frac{Om \cdot Om}{Omc \cdot Omc}}} \cdot 1}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
unpow2 [<=]9.8 | \[ \sin^{-1} \left(\frac{\sqrt{1 - \frac{\color{blue}{{Om}^{2}}}{Omc \cdot Omc}} \cdot 1}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
unpow2 [<=]9.8 | \[ \sin^{-1} \left(\frac{\sqrt{1 - \frac{{Om}^{2}}{\color{blue}{{Omc}^{2}}}} \cdot 1}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
*-rgt-identity [=>]9.8 | \[ \sin^{-1} \left(\frac{\color{blue}{\sqrt{1 - \frac{{Om}^{2}}{{Omc}^{2}}}}}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
unpow2 [=>]9.8 | \[ \sin^{-1} \left(\frac{\sqrt{1 - \frac{\color{blue}{Om \cdot Om}}{{Omc}^{2}}}}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
unpow2 [=>]9.8 | \[ \sin^{-1} \left(\frac{\sqrt{1 - \frac{Om \cdot Om}{\color{blue}{Omc \cdot Omc}}}}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
times-frac [=>]1.2 | \[ \sin^{-1} \left(\frac{\sqrt{1 - \color{blue}{\frac{Om}{Omc} \cdot \frac{Om}{Omc}}}}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
unpow2 [<=]1.2 | \[ \sin^{-1} \left(\frac{\sqrt{1 - \color{blue}{{\left(\frac{Om}{Omc}\right)}^{2}}}}{\mathsf{hypot}\left(1, \frac{t}{\ell} \cdot \sqrt{2}\right)}\right)
\] |
Applied egg-rr1.2
Taylor expanded in Om around 0 35.1
Simplified35.3
[Start]35.1 | \[ \sin^{-1} \left(\sqrt{\frac{1}{1 + \frac{{\left(\sqrt{2}\right)}^{2} \cdot {t}^{2}}{{\ell}^{2}}}}\right)
\] |
|---|---|
associate-/l* [=>]35.1 | \[ \sin^{-1} \left(\sqrt{\frac{1}{1 + \color{blue}{\frac{{\left(\sqrt{2}\right)}^{2}}{\frac{{\ell}^{2}}{{t}^{2}}}}}}\right)
\] |
associate-/r/ [=>]35.4 | \[ \sin^{-1} \left(\sqrt{\frac{1}{1 + \color{blue}{\frac{{\left(\sqrt{2}\right)}^{2}}{{\ell}^{2}} \cdot {t}^{2}}}}\right)
\] |
unpow2 [=>]35.4 | \[ \sin^{-1} \left(\sqrt{\frac{1}{1 + \frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{{\ell}^{2}} \cdot {t}^{2}}}\right)
\] |
rem-square-sqrt [=>]35.3 | \[ \sin^{-1} \left(\sqrt{\frac{1}{1 + \frac{\color{blue}{2}}{{\ell}^{2}} \cdot {t}^{2}}}\right)
\] |
unpow2 [=>]35.3 | \[ \sin^{-1} \left(\sqrt{\frac{1}{1 + \frac{2}{\color{blue}{\ell \cdot \ell}} \cdot {t}^{2}}}\right)
\] |
unpow2 [=>]35.3 | \[ \sin^{-1} \left(\sqrt{\frac{1}{1 + \frac{2}{\ell \cdot \ell} \cdot \color{blue}{\left(t \cdot t\right)}}}\right)
\] |
Taylor expanded in t around -inf 0.8
Simplified1.6
[Start]0.8 | \[ \sin^{-1} \left(-1 \cdot \frac{\sqrt{0.5} \cdot \ell}{t}\right)
\] |
|---|---|
mul-1-neg [=>]0.8 | \[ \sin^{-1} \color{blue}{\left(-\frac{\sqrt{0.5} \cdot \ell}{t}\right)}
\] |
associate-/l* [=>]1.6 | \[ \sin^{-1} \left(-\color{blue}{\frac{\sqrt{0.5}}{\frac{t}{\ell}}}\right)
\] |
if -3.99999999999999983e111 < (/.f64 t l) < 2e143Initial program 0.9
Applied egg-rr2.8
Applied egg-rr0.9
Applied egg-rr0.9
if 2e143 < (/.f64 t l) Initial program 29.8
Taylor expanded in t around -inf 35.8
Simplified32.5
[Start]35.8 | \[ \sin^{-1} \left(-1 \cdot \left(\frac{\sqrt{0.5} \cdot \ell}{t} \cdot \sqrt{1 - \frac{{Om}^{2}}{{Omc}^{2}}}\right)\right)
\] |
|---|---|
mul-1-neg [=>]35.8 | \[ \sin^{-1} \color{blue}{\left(-\frac{\sqrt{0.5} \cdot \ell}{t} \cdot \sqrt{1 - \frac{{Om}^{2}}{{Omc}^{2}}}\right)}
\] |
*-commutative [=>]35.8 | \[ \sin^{-1} \left(-\color{blue}{\sqrt{1 - \frac{{Om}^{2}}{{Omc}^{2}}} \cdot \frac{\sqrt{0.5} \cdot \ell}{t}}\right)
\] |
unpow2 [=>]35.8 | \[ \sin^{-1} \left(-\sqrt{1 - \frac{\color{blue}{Om \cdot Om}}{{Omc}^{2}}} \cdot \frac{\sqrt{0.5} \cdot \ell}{t}\right)
\] |
unpow2 [=>]35.8 | \[ \sin^{-1} \left(-\sqrt{1 - \frac{Om \cdot Om}{\color{blue}{Omc \cdot Omc}}} \cdot \frac{\sqrt{0.5} \cdot \ell}{t}\right)
\] |
times-frac [=>]32.5 | \[ \sin^{-1} \left(-\sqrt{1 - \color{blue}{\frac{Om}{Omc} \cdot \frac{Om}{Omc}}} \cdot \frac{\sqrt{0.5} \cdot \ell}{t}\right)
\] |
unpow2 [<=]32.5 | \[ \sin^{-1} \left(-\sqrt{1 - \color{blue}{{\left(\frac{Om}{Omc}\right)}^{2}}} \cdot \frac{\sqrt{0.5} \cdot \ell}{t}\right)
\] |
*-commutative [=>]32.5 | \[ \sin^{-1} \left(-\sqrt{1 - {\left(\frac{Om}{Omc}\right)}^{2}} \cdot \frac{\color{blue}{\ell \cdot \sqrt{0.5}}}{t}\right)
\] |
Taylor expanded in Om around 0 32.5
Applied egg-rr0.6
Simplified0.6
[Start]0.6 | \[ 0 + \sin^{-1} \left(\ell \cdot \frac{\sqrt{0.5}}{t}\right)
\] |
|---|---|
+-lft-identity [=>]0.6 | \[ \color{blue}{\sin^{-1} \left(\ell \cdot \frac{\sqrt{0.5}}{t}\right)}
\] |
Final simplification1.0
| Alternative 1 | |
|---|---|
| Error | 1.1 |
| Cost | 26624 |
| Alternative 2 | |
|---|---|
| Error | 1.7 |
| Cost | 19712 |
| Alternative 3 | |
|---|---|
| Error | 2.1 |
| Cost | 13896 |
| Alternative 4 | |
|---|---|
| Error | 12.9 |
| Cost | 13641 |
| Alternative 5 | |
|---|---|
| Error | 12.9 |
| Cost | 13640 |
| Alternative 6 | |
|---|---|
| Error | 2.2 |
| Cost | 13640 |
| Alternative 7 | |
|---|---|
| Error | 31.3 |
| Cost | 7104 |
| Alternative 8 | |
|---|---|
| Error | 31.6 |
| Cost | 6464 |
herbie shell --seed 2023237
(FPCore (t l Om Omc)
:name "Toniolo and Linder, Equation (2)"
:precision binary64
(asin (sqrt (/ (- 1.0 (pow (/ Om Omc) 2.0)) (+ 1.0 (* 2.0 (pow (/ t l) 2.0)))))))