Average Error: 13.7 → 0.2
Time: 4.3min
Precision: binary64
Cost: 20994
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
↓
\[\begin{array}{l}
\mathbf{if}\;F \leq -2.2682253394869427 \cdot 10^{+36}:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq 254769.1791808347:\\
\;\;\;\;\frac{F \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5}}{\sin B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \left(\frac{x}{F \cdot F} + \frac{1}{F \cdot F}\right)}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}↓
\begin{array}{l}
\mathbf{if}\;F \leq -2.2682253394869427 \cdot 10^{+36}:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq 254769.1791808347:\\
\;\;\;\;\frac{F \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5}}{\sin B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \left(\frac{x}{F \cdot F} + \frac{1}{F \cdot F}\right)}{\sin B} - \frac{x}{\tan B}\\
\end{array}(FPCore (F B x)
:precision binary64
(+
(- (* x (/ 1.0 (tan B))))
(* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))
↓
(FPCore (F B x)
:precision binary64
(if (<= F -2.2682253394869427e+36)
(- (/ -1.0 (sin B)) (/ x (tan B)))
(if (<= F 254769.1791808347)
(-
(/ (* F (pow (+ (+ (* F F) 2.0) (* x 2.0)) -0.5)) (sin B))
(/ x (tan B)))
(- (/ (- 1.0 (+ (/ x (* F F)) (/ 1.0 (* F F)))) (sin B)) (/ x (tan B))))))double code(double F, double B, double x) {
return -(x * (1.0 / tan(B))) + ((F / sin(B)) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
↓
double code(double F, double B, double x) {
double tmp;
if (F <= -2.2682253394869427e+36) {
tmp = (-1.0 / sin(B)) - (x / tan(B));
} else if (F <= 254769.1791808347) {
tmp = ((F * pow((((F * F) + 2.0) + (x * 2.0)), -0.5)) / sin(B)) - (x / tan(B));
} else {
tmp = ((1.0 - ((x / (F * F)) + (1.0 / (F * F)))) / sin(B)) - (x / tan(B));
}
return tmp;
}
Try it out
Enter valid numbers for all inputs
Alternatives
| Alternative 1 |
|---|
| Error | 0.2 |
|---|
| Cost | 20802 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -2.1390484231469626 \cdot 10^{+36}:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq 228986.99893373696:\\
\;\;\;\;\frac{F \cdot \sqrt{\frac{1}{F \cdot F + 2}}}{\sin B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \left(\frac{x}{F \cdot F} + \frac{1}{F \cdot F}\right)}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
| Alternative 2 |
|---|
| Error | 0.5 |
|---|
| Cost | 20802 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -1.435136797446235:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq 26.53211519579416:\\
\;\;\;\;\frac{F}{\sin B} \cdot \sqrt{\frac{1}{2 + x \cdot 2}} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \left(\frac{x}{F \cdot F} + \frac{1}{F \cdot F}\right)}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
| Alternative 3 |
|---|
| Error | 5.4 |
|---|
| Cost | 14979 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -73.36809345229936:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq -1.2402944923380242 \cdot 10^{-127}:\\
\;\;\;\;{\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5} \cdot \frac{F}{\sin B} - \frac{x}{B}\\
\mathbf{elif}\;F \leq 283.8050133319312:\\
\;\;\;\;{\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5} \cdot \frac{F}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \left(\frac{x}{F \cdot F} + \frac{1}{F \cdot F}\right)}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
| Alternative 4 |
|---|
| Error | 5.4 |
|---|
| Cost | 14915 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -75.80811335455446:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq -1.2402944923380242 \cdot 10^{-127}:\\
\;\;\;\;{\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5} \cdot \frac{F}{\sin B} - \frac{x}{B}\\
\mathbf{elif}\;F \leq 6486.398982731933:\\
\;\;\;\;{\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5} \cdot \frac{F}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
| Alternative 5 |
|---|
| Error | 7.0 |
|---|
| Cost | 15236 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -75.80811335455446:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq -1.2008151000659857 \cdot 10^{-127}:\\
\;\;\;\;{\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5} \cdot \frac{F}{\sin B} - \frac{x}{B}\\
\mathbf{elif}\;F \leq 7.080216094282791 \cdot 10^{-187}:\\
\;\;\;\;\frac{-x}{\sin B} \cdot \cos B\\
\mathbf{elif}\;F \leq 541788.5644028311:\\
\;\;\;\;\frac{F \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5}}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
| Alternative 6 |
|---|
| Error | 7.0 |
|---|
| Cost | 15236 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -75.80811335455446:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq -1.2402944923380242 \cdot 10^{-127}:\\
\;\;\;\;\frac{F \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5}}{\sin B} - \frac{x}{B}\\
\mathbf{elif}\;F \leq 3.3863620014432923 \cdot 10^{-180}:\\
\;\;\;\;\frac{-x}{\sin B} \cdot \cos B\\
\mathbf{elif}\;F \leq 987277.5500405453:\\
\;\;\;\;\frac{F \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5}}{\sin B} - \frac{x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
| Alternative 7 |
|---|
| Error | 10.9 |
|---|
| Cost | 13890 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -6.95601292148594 \cdot 10^{-38}:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq 3.438733885708423 \cdot 10^{-26}:\\
\;\;\;\;\frac{-x}{\sin B} \cdot \cos B\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
| Alternative 8 |
|---|
| Error | 21.5 |
|---|
| Cost | 13569 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -2.1242530184207155 \cdot 10^{-32}:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\sin B} \cdot \cos B\\
\end{array}\]
| Alternative 9 |
|---|
| Error | 26.6 |
|---|
| Cost | 13826 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -9.525976295326883 \cdot 10^{+91}:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{B}\\
\mathbf{elif}\;F \leq -9.399891388730018 \cdot 10^{-36}:\\
\;\;\;\;\frac{-1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\sin B} \cdot \cos B\\
\end{array}\]
| Alternative 10 |
|---|
| Error | 31.0 |
|---|
| Cost | 7176 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.7656457365202159 \cdot 10^{-12} \lor \neg \left(x \leq 1.6959097733192 \cdot 10^{-110}\right):\\
\;\;\;\;\frac{-1}{B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\sin B}\\
\end{array}\]
| Alternative 11 |
|---|
| Error | 42.6 |
|---|
| Cost | 6913 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -6735.992858857284:\\
\;\;\;\;\frac{-1}{\sin B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{-B}\\
\end{array}\]
| Alternative 12 |
|---|
| Error | 44.9 |
|---|
| Cost | 641 |
|---|
\[\begin{array}{l}
\mathbf{if}\;F \leq -3.0404691183763064 \cdot 10^{-39}:\\
\;\;\;\;\frac{-1 - x}{B}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{-B}\\
\end{array}\]
| Alternative 13 |
|---|
| Error | 48.7 |
|---|
| Cost | 849 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -3.689161297552655 \cdot 10^{-115} \lor \neg \left(x \leq -8.814364352337864 \cdot 10^{-157} \lor \neg \left(x \leq -1.1318218994911311 \cdot 10^{-242}\right) \land x \leq 2.3385530704709698 \cdot 10^{-135}\right):\\
\;\;\;\;\frac{x}{-B}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{B}\\
\end{array}\]
| Alternative 14 |
|---|
| Error | 57.3 |
|---|
| Cost | 192 |
|---|
\[\frac{-1}{B}\]
| Alternative 15 |
|---|
| Error | 60.8 |
|---|
| Cost | 64 |
|---|
\[1\]
Error

Derivation
- Split input into 3 regimes
if F < -2.2682253394869427e36
Initial program 26.6
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
Simplified26.6
\[\leadsto \color{blue}{\frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5} - \frac{x}{\tan B}}\]
Taylor expanded around -inf 0.2
\[\leadsto \color{blue}{\frac{-1}{\sin B}} - \frac{x}{\tan B}\]
Simplified0.2
\[\leadsto \color{blue}{\frac{-1}{\sin B} - \frac{x}{\tan B}}\]
if -2.2682253394869427e36 < F < 254769.179180834704
Initial program 0.5
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
Simplified0.4
\[\leadsto \color{blue}{\frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5} - \frac{x}{\tan B}}\]
- Using strategy
rm Applied associate-*l/_binary640.3
\[\leadsto \color{blue}{\frac{F \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5}}{\sin B}} - \frac{x}{\tan B}\]
Simplified0.3
\[\leadsto \frac{\color{blue}{F \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{-0.5}}}{\sin B} - \frac{x}{\tan B}\]
Simplified0.3
\[\leadsto \color{blue}{\frac{F \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{-0.5}}{\sin B} - \frac{x}{\tan B}}\]
if 254769.179180834704 < F
Initial program 25.0
\[\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}\]
Simplified24.9
\[\leadsto \color{blue}{\frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5} - \frac{x}{\tan B}}\]
- Using strategy
rm Applied associate-*l/_binary6419.2
\[\leadsto \color{blue}{\frac{F \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5}}{\sin B}} - \frac{x}{\tan B}\]
Simplified19.2
\[\leadsto \frac{\color{blue}{F \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{-0.5}}}{\sin B} - \frac{x}{\tan B}\]
Taylor expanded around inf 0.2
\[\leadsto \frac{\color{blue}{1 - \left(\frac{x}{{F}^{2}} + \frac{1}{{F}^{2}}\right)}}{\sin B} - \frac{x}{\tan B}\]
Simplified0.2
\[\leadsto \frac{\color{blue}{1 - \left(\frac{x}{F \cdot F} + \frac{1}{F \cdot F}\right)}}{\sin B} - \frac{x}{\tan B}\]
Simplified0.2
\[\leadsto \color{blue}{\frac{1 - \left(\frac{x}{F \cdot F} + \frac{1}{F \cdot F}\right)}{\sin B} - \frac{x}{\tan B}}\]
- Recombined 3 regimes into one program.
Final simplification0.2
\[\leadsto \begin{array}{l}
\mathbf{if}\;F \leq -2.2682253394869427 \cdot 10^{+36}:\\
\;\;\;\;\frac{-1}{\sin B} - \frac{x}{\tan B}\\
\mathbf{elif}\;F \leq 254769.1791808347:\\
\;\;\;\;\frac{F \cdot {\left(\left(F \cdot F + 2\right) + x \cdot 2\right)}^{-0.5}}{\sin B} - \frac{x}{\tan B}\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - \left(\frac{x}{F \cdot F} + \frac{1}{F \cdot F}\right)}{\sin B} - \frac{x}{\tan B}\\
\end{array}\]
Reproduce
herbie shell --seed 2021014
(FPCore (F B x)
:name "VandenBroeck and Keller, Equation (23)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))