| Alternative 1 | |
|---|---|
| Error | 27.9 |
| Cost | 57484 |
(FPCore (n U t l Om U*) :precision binary64 (sqrt (* (* (* 2.0 n) U) (- (- t (* 2.0 (/ (* l l) Om))) (* (* n (pow (/ l Om) 2.0)) (- U U*))))))
(FPCore (n U t l Om U*)
:precision binary64
(let* ((t_1 (pow (/ l Om) 2.0))
(t_2
(sqrt
(*
(+ (+ t (* (/ (* l l) Om) -2.0)) (* (* n t_1) (- U* U)))
(* (* 2.0 n) U)))))
(if (<= t_2 4e-161)
(pow (* (cbrt (* U t)) (cbrt (* 2.0 n))) 1.5)
(if (<= t_2 1e+151)
t_2
(if (<= t_2 INFINITY)
(*
(sqrt (* 2.0 (* n U)))
(sqrt (+ t (+ (* (/ l (/ Om l)) -2.0) (* n (* t_1 (- U* U)))))))
(sqrt
(fma 2.0 (* n (* U t)) (* -4.0 (* (/ n Om) (* l (* U l)))))))))))double code(double n, double U, double t, double l, double Om, double U_42_) {
return sqrt((((2.0 * n) * U) * ((t - (2.0 * ((l * l) / Om))) - ((n * pow((l / Om), 2.0)) * (U - U_42_)))));
}
double code(double n, double U, double t, double l, double Om, double U_42_) {
double t_1 = pow((l / Om), 2.0);
double t_2 = sqrt((((t + (((l * l) / Om) * -2.0)) + ((n * t_1) * (U_42_ - U))) * ((2.0 * n) * U)));
double tmp;
if (t_2 <= 4e-161) {
tmp = pow((cbrt((U * t)) * cbrt((2.0 * n))), 1.5);
} else if (t_2 <= 1e+151) {
tmp = t_2;
} else if (t_2 <= ((double) INFINITY)) {
tmp = sqrt((2.0 * (n * U))) * sqrt((t + (((l / (Om / l)) * -2.0) + (n * (t_1 * (U_42_ - U))))));
} else {
tmp = sqrt(fma(2.0, (n * (U * t)), (-4.0 * ((n / Om) * (l * (U * l))))));
}
return tmp;
}
function code(n, U, t, l, Om, U_42_) return sqrt(Float64(Float64(Float64(2.0 * n) * U) * Float64(Float64(t - Float64(2.0 * Float64(Float64(l * l) / Om))) - Float64(Float64(n * (Float64(l / Om) ^ 2.0)) * Float64(U - U_42_))))) end
function code(n, U, t, l, Om, U_42_) t_1 = Float64(l / Om) ^ 2.0 t_2 = sqrt(Float64(Float64(Float64(t + Float64(Float64(Float64(l * l) / Om) * -2.0)) + Float64(Float64(n * t_1) * Float64(U_42_ - U))) * Float64(Float64(2.0 * n) * U))) tmp = 0.0 if (t_2 <= 4e-161) tmp = Float64(cbrt(Float64(U * t)) * cbrt(Float64(2.0 * n))) ^ 1.5; elseif (t_2 <= 1e+151) tmp = t_2; elseif (t_2 <= Inf) tmp = Float64(sqrt(Float64(2.0 * Float64(n * U))) * sqrt(Float64(t + Float64(Float64(Float64(l / Float64(Om / l)) * -2.0) + Float64(n * Float64(t_1 * Float64(U_42_ - U))))))); else tmp = sqrt(fma(2.0, Float64(n * Float64(U * t)), Float64(-4.0 * Float64(Float64(n / Om) * Float64(l * Float64(U * l)))))); end return tmp end
code[n_, U_, t_, l_, Om_, U$42$_] := N[Sqrt[N[(N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision] * N[(N[(t - N[(2.0 * N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(n * N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[(U - U$42$), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[n_, U_, t_, l_, Om_, U$42$_] := Block[{t$95$1 = N[Power[N[(l / Om), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(N[(t + N[(N[(N[(l * l), $MachinePrecision] / Om), $MachinePrecision] * -2.0), $MachinePrecision]), $MachinePrecision] + N[(N[(n * t$95$1), $MachinePrecision] * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(2.0 * n), $MachinePrecision] * U), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, 4e-161], N[Power[N[(N[Power[N[(U * t), $MachinePrecision], 1/3], $MachinePrecision] * N[Power[N[(2.0 * n), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], If[LessEqual[t$95$2, 1e+151], t$95$2, If[LessEqual[t$95$2, Infinity], N[(N[Sqrt[N[(2.0 * N[(n * U), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(t + N[(N[(N[(l / N[(Om / l), $MachinePrecision]), $MachinePrecision] * -2.0), $MachinePrecision] + N[(n * N[(t$95$1 * N[(U$42$ - U), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(2.0 * N[(n * N[(U * t), $MachinePrecision]), $MachinePrecision] + N[(-4.0 * N[(N[(n / Om), $MachinePrecision] * N[(l * N[(U * l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}
\begin{array}{l}
t_1 := {\left(\frac{\ell}{Om}\right)}^{2}\\
t_2 := \sqrt{\left(\left(t + \frac{\ell \cdot \ell}{Om} \cdot -2\right) + \left(n \cdot t_1\right) \cdot \left(U* - U\right)\right) \cdot \left(\left(2 \cdot n\right) \cdot U\right)}\\
\mathbf{if}\;t_2 \leq 4 \cdot 10^{-161}:\\
\;\;\;\;{\left(\sqrt[3]{U \cdot t} \cdot \sqrt[3]{2 \cdot n}\right)}^{1.5}\\
\mathbf{elif}\;t_2 \leq 10^{+151}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq \infty:\\
\;\;\;\;\sqrt{2 \cdot \left(n \cdot U\right)} \cdot \sqrt{t + \left(\frac{\ell}{\frac{Om}{\ell}} \cdot -2 + n \cdot \left(t_1 \cdot \left(U* - U\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(2, n \cdot \left(U \cdot t\right), -4 \cdot \left(\frac{n}{Om} \cdot \left(\ell \cdot \left(U \cdot \ell\right)\right)\right)\right)}\\
\end{array}
if (sqrt.f64 (*.f64 (*.f64 (*.f64 2 n) U) (-.f64 (-.f64 t (*.f64 2 (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) 2)) (-.f64 U U*))))) < 4.00000000000000011e-161Initial program 55.6
Simplified55.6
[Start]55.6 | \[ \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}
\] |
|---|---|
associate-*l* [=>]55.6 | \[ \sqrt{\color{blue}{\left(2 \cdot \left(n \cdot U\right)\right)} \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}
\] |
associate-*l* [=>]55.6 | \[ \sqrt{\color{blue}{2 \cdot \left(\left(n \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)}}
\] |
*-commutative [=>]55.6 | \[ \sqrt{2 \cdot \color{blue}{\left(\left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right) \cdot \left(n \cdot U\right)\right)}}
\] |
Taylor expanded in l around 0 42.8
Applied egg-rr42.9
Applied egg-rr24.6
Simplified24.6
[Start]24.6 | \[ {\left(\sqrt[3]{2 \cdot n} \cdot \sqrt[3]{t \cdot U}\right)}^{1.5}
\] |
|---|---|
*-commutative [=>]24.6 | \[ {\color{blue}{\left(\sqrt[3]{t \cdot U} \cdot \sqrt[3]{2 \cdot n}\right)}}^{1.5}
\] |
if 4.00000000000000011e-161 < (sqrt.f64 (*.f64 (*.f64 (*.f64 2 n) U) (-.f64 (-.f64 t (*.f64 2 (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) 2)) (-.f64 U U*))))) < 1.00000000000000002e151Initial program 1.6
if 1.00000000000000002e151 < (sqrt.f64 (*.f64 (*.f64 (*.f64 2 n) U) (-.f64 (-.f64 t (*.f64 2 (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) 2)) (-.f64 U U*))))) < +inf.0Initial program 63.4
Simplified53.5
[Start]63.4 | \[ \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}
\] |
|---|---|
associate-*l* [=>]61.0 | \[ \sqrt{\color{blue}{\left(2 \cdot n\right) \cdot \left(U \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)}}
\] |
associate--l- [=>]61.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \color{blue}{\left(t - \left(2 \cdot \frac{\ell \cdot \ell}{Om} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)}\right)}
\] |
sub-neg [=>]61.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \color{blue}{\left(t + \left(-\left(2 \cdot \frac{\ell \cdot \ell}{Om} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)\right)}\right)}
\] |
sub-neg [<=]61.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \color{blue}{\left(t - \left(2 \cdot \frac{\ell \cdot \ell}{Om} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)}\right)}
\] |
cancel-sign-sub [<=]61.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \left(t - \color{blue}{\left(2 \cdot \frac{\ell \cdot \ell}{Om} - \left(-n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\right)\right)}
\] |
cancel-sign-sub [=>]61.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \left(t - \color{blue}{\left(2 \cdot \frac{\ell \cdot \ell}{Om} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\right)\right)}
\] |
associate-/l* [=>]54.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \left(t - \left(2 \cdot \color{blue}{\frac{\ell}{\frac{Om}{\ell}}} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)\right)}
\] |
associate-*l* [=>]53.5 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \left(t - \left(2 \cdot \frac{\ell}{\frac{Om}{\ell}} + \color{blue}{n \cdot \left({\left(\frac{\ell}{Om}\right)}^{2} \cdot \left(U - U*\right)\right)}\right)\right)\right)}
\] |
Applied egg-rr49.8
if +inf.0 < (sqrt.f64 (*.f64 (*.f64 (*.f64 2 n) U) (-.f64 (-.f64 t (*.f64 2 (/.f64 (*.f64 l l) Om))) (*.f64 (*.f64 n (pow.f64 (/.f64 l Om) 2)) (-.f64 U U*))))) Initial program 64.0
Simplified58.4
[Start]64.0 | \[ \sqrt{\left(\left(2 \cdot n\right) \cdot U\right) \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}
\] |
|---|---|
associate-*l* [=>]64.0 | \[ \sqrt{\color{blue}{\left(2 \cdot n\right) \cdot \left(U \cdot \left(\left(t - 2 \cdot \frac{\ell \cdot \ell}{Om}\right) - \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)}}
\] |
associate--l- [=>]64.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \color{blue}{\left(t - \left(2 \cdot \frac{\ell \cdot \ell}{Om} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)}\right)}
\] |
sub-neg [=>]64.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \color{blue}{\left(t + \left(-\left(2 \cdot \frac{\ell \cdot \ell}{Om} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)\right)}\right)}
\] |
sub-neg [<=]64.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \color{blue}{\left(t - \left(2 \cdot \frac{\ell \cdot \ell}{Om} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)}\right)}
\] |
cancel-sign-sub [<=]64.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \left(t - \color{blue}{\left(2 \cdot \frac{\ell \cdot \ell}{Om} - \left(-n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\right)\right)}
\] |
cancel-sign-sub [=>]64.0 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \left(t - \color{blue}{\left(2 \cdot \frac{\ell \cdot \ell}{Om} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)}\right)\right)}
\] |
associate-/l* [=>]58.6 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \left(t - \left(2 \cdot \color{blue}{\frac{\ell}{\frac{Om}{\ell}}} + \left(n \cdot {\left(\frac{\ell}{Om}\right)}^{2}\right) \cdot \left(U - U*\right)\right)\right)\right)}
\] |
associate-*l* [=>]58.4 | \[ \sqrt{\left(2 \cdot n\right) \cdot \left(U \cdot \left(t - \left(2 \cdot \frac{\ell}{\frac{Om}{\ell}} + \color{blue}{n \cdot \left({\left(\frac{\ell}{Om}\right)}^{2} \cdot \left(U - U*\right)\right)}\right)\right)\right)}
\] |
Taylor expanded in Om around inf 58.1
Simplified48.8
[Start]58.1 | \[ \sqrt{2 \cdot \left(n \cdot \left(t \cdot U\right)\right) + -4 \cdot \frac{n \cdot \left({\ell}^{2} \cdot U\right)}{Om}}
\] |
|---|---|
fma-def [=>]58.1 | \[ \sqrt{\color{blue}{\mathsf{fma}\left(2, n \cdot \left(t \cdot U\right), -4 \cdot \frac{n \cdot \left({\ell}^{2} \cdot U\right)}{Om}\right)}}
\] |
*-commutative [=>]58.1 | \[ \sqrt{\mathsf{fma}\left(2, n \cdot \color{blue}{\left(U \cdot t\right)}, -4 \cdot \frac{n \cdot \left({\ell}^{2} \cdot U\right)}{Om}\right)}
\] |
associate-/l* [=>]57.9 | \[ \sqrt{\mathsf{fma}\left(2, n \cdot \left(U \cdot t\right), -4 \cdot \color{blue}{\frac{n}{\frac{Om}{{\ell}^{2} \cdot U}}}\right)}
\] |
associate-/r/ [=>]57.0 | \[ \sqrt{\mathsf{fma}\left(2, n \cdot \left(U \cdot t\right), -4 \cdot \color{blue}{\left(\frac{n}{Om} \cdot \left({\ell}^{2} \cdot U\right)\right)}\right)}
\] |
unpow2 [=>]57.0 | \[ \sqrt{\mathsf{fma}\left(2, n \cdot \left(U \cdot t\right), -4 \cdot \left(\frac{n}{Om} \cdot \left(\color{blue}{\left(\ell \cdot \ell\right)} \cdot U\right)\right)\right)}
\] |
associate-*l* [=>]48.8 | \[ \sqrt{\mathsf{fma}\left(2, n \cdot \left(U \cdot t\right), -4 \cdot \left(\frac{n}{Om} \cdot \color{blue}{\left(\ell \cdot \left(\ell \cdot U\right)\right)}\right)\right)}
\] |
Final simplification24.5
| Alternative 1 | |
|---|---|
| Error | 27.9 |
| Cost | 57484 |
| Alternative 2 | |
|---|---|
| Error | 27.0 |
| Cost | 57484 |
| Alternative 3 | |
|---|---|
| Error | 24.8 |
| Cost | 57484 |
| Alternative 4 | |
|---|---|
| Error | 33.3 |
| Cost | 15520 |
| Alternative 5 | |
|---|---|
| Error | 29.9 |
| Cost | 14860 |
| Alternative 6 | |
|---|---|
| Error | 32.0 |
| Cost | 14804 |
| Alternative 7 | |
|---|---|
| Error | 31.8 |
| Cost | 14284 |
| Alternative 8 | |
|---|---|
| Error | 32.9 |
| Cost | 14028 |
| Alternative 9 | |
|---|---|
| Error | 32.1 |
| Cost | 14024 |
| Alternative 10 | |
|---|---|
| Error | 32.8 |
| Cost | 13900 |
| Alternative 11 | |
|---|---|
| Error | 32.9 |
| Cost | 13900 |
| Alternative 12 | |
|---|---|
| Error | 32.2 |
| Cost | 13512 |
| Alternative 13 | |
|---|---|
| Error | 34.8 |
| Cost | 8784 |
| Alternative 14 | |
|---|---|
| Error | 34.4 |
| Cost | 8656 |
| Alternative 15 | |
|---|---|
| Error | 35.5 |
| Cost | 8400 |
| Alternative 16 | |
|---|---|
| Error | 36.2 |
| Cost | 8144 |
| Alternative 17 | |
|---|---|
| Error | 35.3 |
| Cost | 7880 |
| Alternative 18 | |
|---|---|
| Error | 35.5 |
| Cost | 7625 |
| Alternative 19 | |
|---|---|
| Error | 32.9 |
| Cost | 7625 |
| Alternative 20 | |
|---|---|
| Error | 32.9 |
| Cost | 7625 |
| Alternative 21 | |
|---|---|
| Error | 32.9 |
| Cost | 7624 |
| Alternative 22 | |
|---|---|
| Error | 39.6 |
| Cost | 7113 |
| Alternative 23 | |
|---|---|
| Error | 39.5 |
| Cost | 7113 |
| Alternative 24 | |
|---|---|
| Error | 39.5 |
| Cost | 7112 |
| Alternative 25 | |
|---|---|
| Error | 40.5 |
| Cost | 6848 |
herbie shell --seed 2023011
(FPCore (n U t l Om U*)
:name "Toniolo and Linder, Equation (13)"
:precision binary64
(sqrt (* (* (* 2.0 n) U) (- (- t (* 2.0 (/ (* l l) Om))) (* (* n (pow (/ l Om) 2.0)) (- U U*))))))