Average Error: 48.3 → 7.6
Time: 29.2s
Precision: binary64
Cost: 20552
\[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\ell \leq -1.9288477212394867 \cdot 10^{+98} \lor \neg \left(\ell \leq 5.655539911333164 \cdot 10^{+206}\right):\\
\;\;\;\;2 \cdot \left(\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right) \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\ell \cdot \left(\frac{\ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)\right)\\
\end{array}\]
\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)}↓
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.9288477212394867 \cdot 10^{+98} \lor \neg \left(\ell \leq 5.655539911333164 \cdot 10^{+206}\right):\\
\;\;\;\;2 \cdot \left(\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right) \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\ell \cdot \left(\frac{\ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)\right)\\
\end{array}(FPCore (t l k)
:precision binary64
(/
2.0
(*
(* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k))
(- (+ 1.0 (pow (/ k t) 2.0)) 1.0))))
↓
(FPCore (t l k)
:precision binary64
(if (or (<= l -1.9288477212394867e+98) (not (<= l 5.655539911333164e+206)))
(* 2.0 (* (* (/ l k) (/ l k)) (/ (cos k) (* t (pow (sin k) 2.0)))))
(* 2.0 (* l (* (/ l k) (/ (cos k) (* k (* t (pow (sin k) 2.0)))))))))
double code(double t, double l, double k) {
return 2.0 / ((((pow(t, 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + pow((k / t), 2.0)) - 1.0));
}
↓
double code(double t, double l, double k) {
double tmp;
if ((l <= -1.9288477212394867e+98) || !(l <= 5.655539911333164e+206)) {
tmp = 2.0 * (((l / k) * (l / k)) * (cos(k) / (t * pow(sin(k), 2.0))));
} else {
tmp = 2.0 * (l * ((l / k) * (cos(k) / (k * (t * pow(sin(k), 2.0))))));
}
return tmp;
}
Try it out
Enter valid numbers for all inputs
Alternatives
| Alternative 1 |
|---|
| Error | 6.8 |
|---|
| Cost | 40129 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\ell \cdot \ell \leq 3.603875151524802 \cdot 10^{+196}:\\
\;\;\;\;2 \cdot \left(\frac{\ell}{\sqrt[3]{k} \cdot \sqrt[3]{k}} \cdot \left(\frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)} \cdot \frac{\ell}{\sqrt[3]{k}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right) \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)\\
\end{array}\]
| Alternative 2 |
|---|
| Error | 7.6 |
|---|
| Cost | 20808 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\ell \cdot \ell \leq 1.1539497427612818 \cdot 10^{-248} \lor \neg \left(\ell \cdot \ell \leq 4.081322563393444 \cdot 10^{+196}\right):\\
\;\;\;\;2 \cdot \left(\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right) \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)} \cdot \left(\ell \cdot \frac{\ell}{k}\right)\right)\\
\end{array}\]
| Alternative 3 |
|---|
| Error | 12.6 |
|---|
| Cost | 20552 |
|---|
\[\begin{array}{l}
\mathbf{if}\;k \leq -3.6547036640213393 \cdot 10^{-07} \lor \neg \left(k \leq -6.122936130232856 \cdot 10^{-54}\right):\\
\;\;\;\;2 \cdot \left(\frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)} \cdot \left(\ell \cdot \frac{\ell}{k}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{{k}^{4}}{\frac{\ell}{\frac{t}{\ell}}}}\\
\end{array}\]
| Alternative 4 |
|---|
| Error | 12.5 |
|---|
| Cost | 20552 |
|---|
\[\begin{array}{l}
\mathbf{if}\;k \leq -1.1852346881225905 \cdot 10^{-05} \lor \neg \left(k \leq -7.063681446027815 \cdot 10^{-56}\right):\\
\;\;\;\;2 \cdot \left(\frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)} \cdot \frac{\ell}{\frac{k}{\ell}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{{k}^{4}}{\frac{\ell}{\frac{t}{\ell}}}}\\
\end{array}\]
| Alternative 5 |
|---|
| Error | 17.5 |
|---|
| Cost | 20552 |
|---|
\[\begin{array}{l}
\mathbf{if}\;k \leq -9.151404920080495 \cdot 10^{-06} \lor \neg \left(k \leq -1.3436020588189278 \cdot 10^{-52}\right):\\
\;\;\;\;2 \cdot \frac{\cos k \cdot \frac{\ell \cdot \ell}{k}}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{{k}^{4}}{\frac{\ell}{\frac{t}{\ell}}}}\\
\end{array}\]
| Alternative 6 |
|---|
| Error | 28.8 |
|---|
| Cost | 14786 |
|---|
\[\begin{array}{l}
\mathbf{if}\;t \leq -8.783101688769685 \cdot 10^{+89}:\\
\;\;\;\;2 \cdot \left(\frac{\ell \cdot \ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot \left(k \cdot k\right)\right)}\right)\\
\mathbf{elif}\;t \leq 2.167343341657803 \cdot 10^{-157}:\\
\;\;\;\;\frac{2}{\frac{{k}^{4}}{\frac{\ell}{\frac{t}{\ell}}} + 0.16666666666666666 \cdot \frac{{k}^{6}}{\frac{\ell}{\frac{t}{\ell}}}}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{\cos k \cdot \left(\ell \cdot \ell\right)}{k \cdot \left(k \cdot \left(k \cdot \left(k \cdot t\right)\right)\right)}\\
\end{array}\]
| Alternative 7 |
|---|
| Error | 28.7 |
|---|
| Cost | 8130 |
|---|
\[\begin{array}{l}
\mathbf{if}\;t \leq -3.575766571680626 \cdot 10^{-125}:\\
\;\;\;\;2 \cdot \left(\frac{\ell \cdot \ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot \left(k \cdot k\right)\right)}\right)\\
\mathbf{elif}\;t \leq 9.479879216596787 \cdot 10^{-157}:\\
\;\;\;\;\frac{2}{\frac{{k}^{4}}{\frac{\ell}{\frac{t}{\ell}}}}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{\cos k \cdot \left(\ell \cdot \ell\right)}{k \cdot \left(k \cdot \left(k \cdot \left(k \cdot t\right)\right)\right)}\\
\end{array}\]
| Alternative 8 |
|---|
| Error | 28.3 |
|---|
| Cost | 7816 |
|---|
\[\begin{array}{l}
\mathbf{if}\;t \leq -2.4575930907319535 \cdot 10^{-127} \lor \neg \left(t \leq 7.777500190582001 \cdot 10^{-156}\right):\\
\;\;\;\;2 \cdot \left(\frac{\ell \cdot \ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot \left(k \cdot k\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{{k}^{4}}{\frac{\ell}{\frac{t}{\ell}}}}\\
\end{array}\]
| Alternative 9 |
|---|
| Error | 28.8 |
|---|
| Cost | 7624 |
|---|
\[\begin{array}{l}
\mathbf{if}\;k \leq -1.3852239520341363 \cdot 10^{-58} \lor \neg \left(k \leq 3.1551806453450644 \cdot 10^{-78}\right):\\
\;\;\;\;\frac{2}{\frac{{k}^{4}}{\frac{\ell}{\frac{t}{\ell}}}}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\frac{\ell \cdot \ell}{k} \cdot \frac{1}{t \cdot {k}^{3}}\right)\\
\end{array}\]
| Alternative 10 |
|---|
| Error | 29.9 |
|---|
| Cost | 7040 |
|---|
\[\frac{2}{\frac{{k}^{4}}{\frac{\ell}{\frac{t}{\ell}}}}\]
| Alternative 11 |
|---|
| Error | 31.4 |
|---|
| Cost | 7040 |
|---|
\[2 \cdot \frac{\ell \cdot \ell}{t \cdot {k}^{4}}\]
| Alternative 12 |
|---|
| Error | 34.1 |
|---|
| Cost | 64 |
|---|
\[0\]
| Alternative 13 |
|---|
| Error | 61.9 |
|---|
| Cost | 64 |
|---|
\[1\]
Error

Derivation
- Split input into 2 regimes
if l < -1.92884772123948671e98 or 5.6555399113331643e206 < l
Initial program 61.2
\[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)}\]
Simplified59.6
\[\leadsto \color{blue}{\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot {\left(\frac{k}{t}\right)}^{2}}}\]
Taylor expanded around 0 55.5
\[\leadsto \color{blue}{2 \cdot \frac{\cos k \cdot {\ell}^{2}}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}}\]
Simplified55.5
\[\leadsto \color{blue}{2 \cdot \frac{\left(\ell \cdot \ell\right) \cdot \cos k}{\left(k \cdot k\right) \cdot \left(t \cdot {\sin k}^{2}\right)}}\]
- Using strategy
rm Applied associate-*l*_binary64_36053.8
\[\leadsto 2 \cdot \frac{\left(\ell \cdot \ell\right) \cdot \cos k}{\color{blue}{k \cdot \left(k \cdot \left(t \cdot {\sin k}^{2}\right)\right)}}\]
- Using strategy
rm Applied times-frac_binary64_42551.0
\[\leadsto 2 \cdot \color{blue}{\left(\frac{\ell \cdot \ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)}\]
- Using strategy
rm Applied *-un-lft-identity_binary64_41951.0
\[\leadsto 2 \cdot \left(\frac{\ell \cdot \ell}{k} \cdot \frac{\color{blue}{1 \cdot \cos k}}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)\]
Applied times-frac_binary64_42551.0
\[\leadsto 2 \cdot \left(\frac{\ell \cdot \ell}{k} \cdot \color{blue}{\left(\frac{1}{k} \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)}\right)\]
Applied associate-*r*_binary64_35950.5
\[\leadsto 2 \cdot \color{blue}{\left(\left(\frac{\ell \cdot \ell}{k} \cdot \frac{1}{k}\right) \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)}\]
Simplified9.0
\[\leadsto 2 \cdot \left(\color{blue}{\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right)} \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)\]
Simplified9.0
\[\leadsto \color{blue}{2 \cdot \left(\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right) \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)}\]
if -1.92884772123948671e98 < l < 5.6555399113331643e206
Initial program 45.9
\[\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)}\]
Simplified36.8
\[\leadsto \color{blue}{\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot {\left(\frac{k}{t}\right)}^{2}}}\]
Taylor expanded around 0 16.1
\[\leadsto \color{blue}{2 \cdot \frac{\cos k \cdot {\ell}^{2}}{{k}^{2} \cdot \left(t \cdot {\sin k}^{2}\right)}}\]
Simplified16.1
\[\leadsto \color{blue}{2 \cdot \frac{\left(\ell \cdot \ell\right) \cdot \cos k}{\left(k \cdot k\right) \cdot \left(t \cdot {\sin k}^{2}\right)}}\]
- Using strategy
rm Applied associate-*l*_binary64_36013.9
\[\leadsto 2 \cdot \frac{\left(\ell \cdot \ell\right) \cdot \cos k}{\color{blue}{k \cdot \left(k \cdot \left(t \cdot {\sin k}^{2}\right)\right)}}\]
- Using strategy
rm Applied times-frac_binary64_42511.9
\[\leadsto 2 \cdot \color{blue}{\left(\frac{\ell \cdot \ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)}\]
- Using strategy
rm Applied *-un-lft-identity_binary64_41911.9
\[\leadsto 2 \cdot \left(\frac{\ell \cdot \ell}{\color{blue}{1 \cdot k}} \cdot \frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)\]
Applied times-frac_binary64_4259.5
\[\leadsto 2 \cdot \left(\color{blue}{\left(\frac{\ell}{1} \cdot \frac{\ell}{k}\right)} \cdot \frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)\]
Applied associate-*l*_binary64_3607.3
\[\leadsto 2 \cdot \color{blue}{\left(\frac{\ell}{1} \cdot \left(\frac{\ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)\right)}\]
Simplified7.3
\[\leadsto 2 \cdot \left(\frac{\ell}{1} \cdot \color{blue}{\left(\frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)} \cdot \frac{\ell}{k}\right)}\right)\]
Simplified7.3
\[\leadsto \color{blue}{2 \cdot \left(\ell \cdot \left(\frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)} \cdot \frac{\ell}{k}\right)\right)}\]
- Recombined 2 regimes into one program.
Final simplification7.6
\[\leadsto \begin{array}{l}
\mathbf{if}\;\ell \leq -1.9288477212394867 \cdot 10^{+98} \lor \neg \left(\ell \leq 5.655539911333164 \cdot 10^{+206}\right):\\
\;\;\;\;2 \cdot \left(\left(\frac{\ell}{k} \cdot \frac{\ell}{k}\right) \cdot \frac{\cos k}{t \cdot {\sin k}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\ell \cdot \left(\frac{\ell}{k} \cdot \frac{\cos k}{k \cdot \left(t \cdot {\sin k}^{2}\right)}\right)\right)\\
\end{array}\]
Reproduce
herbie shell --seed 2021044
(FPCore (t l k)
:name "Toniolo and Linder, Equation (10-)"
:precision binary64
(/ 2.0 (* (* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k)) (- (+ 1.0 (pow (/ k t) 2.0)) 1.0))))