Average Error: 59.5 → 25.8
Time: 26.0s
Precision: binary64
Cost: 1602
Math TeX FPCore C \[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)\]
↓
\[\begin{array}{l}
\mathbf{if}\;D \leq -2.9238707485049054 \cdot 10^{+63}:\\
\;\;\;\;0\\
\mathbf{elif}\;D \leq 1.6115875034803501 \cdot 10^{+146}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right) \cdot \frac{M}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}\]
\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right) ↓
\begin{array}{l}
\mathbf{if}\;D \leq -2.9238707485049054 \cdot 10^{+63}:\\
\;\;\;\;0\\
\mathbf{elif}\;D \leq 1.6115875034803501 \cdot 10^{+146}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right) \cdot \frac{M}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array} (FPCore (c0 w h D d M)
:precision binary64
(*
(/ c0 (* 2.0 w))
(+
(/ (* c0 (* d d)) (* (* w h) (* D D)))
(sqrt
(-
(*
(/ (* c0 (* d d)) (* (* w h) (* D D)))
(/ (* c0 (* d d)) (* (* w h) (* D D))))
(* M M)))))) ↓
(FPCore (c0 w h D d M)
:precision binary64
(if (<= D -2.9238707485049054e+63)
0.0
(if (<= D 1.6115875034803501e+146)
(* 0.25 (* (* M (/ (* h (* D D)) d)) (/ M d)))
0.0))) double code(double c0, double w, double h, double D, double d, double M) {
return (c0 / (2.0 * w)) * (((c0 * (d * d)) / ((w * h) * (D * D))) + sqrt((((c0 * (d * d)) / ((w * h) * (D * D))) * ((c0 * (d * d)) / ((w * h) * (D * D)))) - (M * M)));
}
↓
double code(double c0, double w, double h, double D, double d, double M) {
double tmp;
if (D <= -2.9238707485049054e+63) {
tmp = 0.0;
} else if (D <= 1.6115875034803501e+146) {
tmp = 0.25 * ((M * ((h * (D * D)) / d)) * (M / d));
} else {
tmp = 0.0;
}
return tmp;
}
Try it out Enter valid numbers for all inputs
Alternatives Alternative 1 Error 27.0 Cost 21058
\[\begin{array}{l}
\mathbf{if}\;M \leq 1.0089094772484812 \cdot 10^{-187}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right) \cdot \frac{M}{d}\right)\\
\mathbf{elif}\;M \leq 6.647082908848975 \cdot 10^{+32}:\\
\;\;\;\;0.25 \cdot \left(\frac{M \cdot M}{d} \cdot \frac{D \cdot \left(D \cdot h\right)}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{M}{\sqrt[3]{d}}\right)\\
\end{array}\]
Alternative 2 Error 26.0 Cost 1409
\[\begin{array}{l}
\mathbf{if}\;D \cdot D \leq 2.3824290065840326 \cdot 10^{+299}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right) \cdot \frac{M}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \frac{\left(M \cdot M\right) \cdot \left(D \cdot \left(D \cdot h\right)\right)}{d \cdot d}\\
\end{array}\]
Alternative 3 Error 27.0 Cost 21314
\[\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 8.9040510693509 \cdot 10^{-320}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right) \cdot \frac{M}{d}\right)\\
\mathbf{elif}\;M \cdot M \leq 1.4195040828507912 \cdot 10^{+55}:\\
\;\;\;\;0.25 \cdot \left(\frac{M \cdot M}{d} \cdot \frac{h}{\frac{d}{D \cdot D}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{M}{\sqrt[3]{d}}\right)\\
\end{array}\]
Alternative 4 Error 27.0 Cost 21000
\[\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 8.9040510693509 \cdot 10^{-320} \lor \neg \left(M \cdot M \leq 1.4195040828507912 \cdot 10^{+55}\right):\\
\;\;\;\;0.25 \cdot \left(\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{M}{\sqrt[3]{d}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\frac{M \cdot M}{d} \cdot \frac{h}{\frac{d}{D \cdot D}}\right)\\
\end{array}\]
Alternative 5 Error 27.0 Cost 21000
\[\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 0 \lor \neg \left(M \cdot M \leq 2.62195929256777 \cdot 10^{+105}\right):\\
\;\;\;\;0.25 \cdot \left(\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{M}{\sqrt[3]{d}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\frac{M \cdot M}{d} \cdot \left(\frac{h}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \frac{D \cdot D}{\sqrt[3]{d}}\right)\right)\\
\end{array}\]
Alternative 6 Error 27.1 Cost 21000
\[\begin{array}{l}
\mathbf{if}\;M \cdot M \leq 0 \lor \neg \left(M \cdot M \leq 6.89936055196706 \cdot 10^{+117}\right):\\
\;\;\;\;0.25 \cdot \left(\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{M}{\sqrt[3]{d}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\frac{h}{\sqrt[3]{d} \cdot \sqrt[3]{d}} \cdot \left(\frac{M \cdot M}{d} \cdot \frac{D \cdot D}{\sqrt[3]{d}}\right)\right)\\
\end{array}\]
Alternative 7 Error 27.4 Cost 20416
\[0.25 \cdot \left(\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M}{\sqrt[3]{d} \cdot \sqrt[3]{d}}\right) \cdot \frac{M}{\sqrt[3]{d}}\right)\]
Alternative 8 Error 30.7 Cost 27528
\[\begin{array}{l}
\mathbf{if}\;M \leq -1.3365260190186299 \cdot 10^{+154} \lor \neg \left(M \leq 1.1307209009648695 \cdot 10^{+142}\right):\\
\;\;\;\;0.25 \cdot \left(\left(\sqrt{\frac{h \cdot \left(D \cdot D\right)}{d}} \cdot \frac{M}{\sqrt{d}}\right) \cdot \left(\sqrt{\frac{h \cdot \left(D \cdot D\right)}{d}} \cdot \frac{M}{\sqrt{d}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\sqrt[3]{\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M \cdot M}{d}} \cdot \left(\sqrt[3]{\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M \cdot M}{d}} \cdot \sqrt[3]{\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M \cdot M}{d}}\right)\right)\\
\end{array}\]
Alternative 9 Error 41.3 Cost 27521
\[\begin{array}{l}
\mathbf{if}\;d \leq -8.948325751090156 \cdot 10^{-85}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \frac{M \cdot M}{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} - \sqrt{\frac{c0}{h \cdot w} \cdot \frac{c0 \cdot {d}^{4}}{\left(h \cdot w\right) \cdot {D}^{4}} - M \cdot M}}\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(\sqrt{\frac{h \cdot \left(D \cdot D\right)}{d}} \cdot \frac{M}{\sqrt{d}}\right) \cdot \left(\sqrt{\frac{h \cdot \left(D \cdot D\right)}{d}} \cdot \frac{M}{\sqrt{d}}\right)\right)\\
\end{array}\]
Alternative 10 Error 47.1 Cost 30977
\[\begin{array}{l}
\mathbf{if}\;d \leq -1.8297134400212148 \cdot 10^{-258}:\\
\;\;\;\;\frac{c0}{2 \cdot w} \cdot \left(\sqrt{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} \cdot \frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} - M \cdot M} + \sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}} \cdot \left(\sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}} \cdot \sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;0.25 \cdot \left(\left(\sqrt{\frac{h \cdot \left(D \cdot D\right)}{d}} \cdot \frac{M}{\sqrt{d}}\right) \cdot \left(\sqrt{\frac{h \cdot \left(D \cdot D\right)}{d}} \cdot \frac{M}{\sqrt{d}}\right)\right)\\
\end{array}\]
Alternative 11 Error 60.5 Cost 30656
\[\frac{c0}{2 \cdot w} \cdot \left(\sqrt{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} \cdot \frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} - M \cdot M} + \sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}} \cdot \left(\sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}} \cdot \sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)}}\right)\right)\]
Alternative 12 Error 62.8 Cost 34688
\[\frac{c0}{2 \cdot w} \cdot \sqrt[3]{{\left(\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} + \sqrt{\frac{c0}{h \cdot w} \cdot \frac{c0 \cdot {d}^{4}}{\left(h \cdot w\right) \cdot {D}^{4}} - M \cdot M}\right)}^{3}}\]
Alternative 13 Error 62.8 Cost 84032
\[\frac{c0}{2 \cdot w} \cdot \left(\sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} + \sqrt{\frac{c0}{h \cdot w} \cdot \frac{c0 \cdot {d}^{4}}{\left(h \cdot w\right) \cdot {D}^{4}} - M \cdot M}} \cdot \left(\sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} + \sqrt{\frac{c0}{h \cdot w} \cdot \frac{c0 \cdot {d}^{4}}{\left(h \cdot w\right) \cdot {D}^{4}} - M \cdot M}} \cdot \sqrt[3]{\frac{\left(d \cdot d\right) \cdot c0}{\left(D \cdot D\right) \cdot \left(h \cdot w\right)} + \sqrt{\frac{c0}{h \cdot w} \cdot \frac{c0 \cdot {d}^{4}}{\left(h \cdot w\right) \cdot {D}^{4}} - M \cdot M}}\right)\right)\]
Error Derivation Split input into 2 regimes if D < -2.92387074850490543e63 or 1.6115875034803501e146 < D Initial program 41.8
\[0\]
if -2.92387074850490543e63 < D < 1.6115875034803501e146 Initial program 59.5
\[\frac{c0}{2 \cdot w} \cdot \left(\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} + \sqrt{\frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} \cdot \frac{c0 \cdot \left(d \cdot d\right)}{\left(w \cdot h\right) \cdot \left(D \cdot D\right)} - M \cdot M}\right)\]
Taylor expanded around -inf 38.1
\[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{w \cdot \left({M}^{2} \cdot \left({D}^{2} \cdot h\right)\right)}{c0 \cdot {d}^{2}}\right)}\]
Simplified38.1
\[\leadsto \frac{c0}{2 \cdot w} \cdot \color{blue}{\left(0.5 \cdot \frac{w \cdot \left(\left(M \cdot M\right) \cdot \left(h \cdot \left(D \cdot D\right)\right)\right)}{c0 \cdot \left(d \cdot d\right)}\right)}\]
Taylor expanded around 0 31.9
\[\leadsto \color{blue}{0.25 \cdot \frac{{M}^{2} \cdot \left({D}^{2} \cdot h\right)}{{d}^{2}}}\]
Simplified31.9
\[\leadsto \color{blue}{\frac{\left(h \cdot \left(D \cdot D\right)\right) \cdot \left(M \cdot M\right)}{d \cdot d} \cdot 0.25}\]
Using strategy rm Applied times-frac_binary64_1107 28.4
\[\leadsto \color{blue}{\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M \cdot M}{d}\right)} \cdot 0.25\]
Using strategy rm Applied *-un-lft-identity_binary64_1101 28.4
\[\leadsto \left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M \cdot M}{\color{blue}{1 \cdot d}}\right) \cdot 0.25\]
Applied times-frac_binary64_1107 24.8
\[\leadsto \left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \color{blue}{\left(\frac{M}{1} \cdot \frac{M}{d}\right)}\right) \cdot 0.25\]
Applied associate-*r*_binary64_1041 23.0
\[\leadsto \color{blue}{\left(\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot \frac{M}{1}\right) \cdot \frac{M}{d}\right)} \cdot 0.25\]
Simplified23.0
\[\leadsto \left(\color{blue}{\left(\frac{h \cdot \left(D \cdot D\right)}{d} \cdot M\right)} \cdot \frac{M}{d}\right) \cdot 0.25\]
Simplified23.0
\[\leadsto \color{blue}{0.25 \cdot \left(\left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right) \cdot \frac{M}{d}\right)}\]
Recombined 2 regimes into one program. Final simplification25.8
\[\leadsto \begin{array}{l}
\mathbf{if}\;D \leq -2.9238707485049054 \cdot 10^{+63}:\\
\;\;\;\;0\\
\mathbf{elif}\;D \leq 1.6115875034803501 \cdot 10^{+146}:\\
\;\;\;\;0.25 \cdot \left(\left(M \cdot \frac{h \cdot \left(D \cdot D\right)}{d}\right) \cdot \frac{M}{d}\right)\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}\]
Reproduce herbie shell --seed 2021043
(FPCore (c0 w h D d M)
:name "Henrywood and Agarwal, Equation (13)"
:precision binary64
(* (/ c0 (* 2.0 w)) (+ (/ (* c0 (* d d)) (* (* w h) (* D D))) (sqrt (- (* (/ (* c0 (* d d)) (* (* w h) (* D D))) (/ (* c0 (* d d)) (* (* w h) (* D D)))) (* M M))))))