Average Error: 2.8 → 1.7
Time: 17.0s
Precision: 64
Internal precision: 128
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;z \le -1.82015982480053 \cdot 10^{+26}:\\
\;\;\;\;\frac{\frac{x}{z}}{\frac{1}{\frac{\sin y}{y}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{\frac{\sin y}{y}}}\\
\end{array}\]
Target
| Original | 2.8 |
| Comparison | 0.3 |
| Herbie | 1.7 |
\[ \begin{array}{l}
\mathbf{if}\;z \lt -4.2173720203427147 \cdot 10^{-29}:\\
\;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\
\mathbf{if}\;z \lt 4.446702369113811 \cdot 10^{+64}:\\
\;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if z < -1.82015982480053e+26
Initial program 0.1
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
- Using strategy
rm
Applied associate-/l* 6.6
\[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}}\]
- Using strategy
rm
Applied div-inv 6.6
\[\leadsto \frac{x}{\color{blue}{z \cdot \frac{1}{\frac{\sin y}{y}}}}\]
Applied associate-/r* 0.1
\[\leadsto \color{blue}{\frac{\frac{x}{z}}{\frac{1}{\frac{\sin y}{y}}}}\]
if -1.82015982480053e+26 < z
Initial program 3.7
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
- Using strategy
rm
Applied associate-/l* 2.2
\[\leadsto \color{blue}{\frac{x}{\frac{z}{\frac{\sin y}{y}}}}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1440918070 1407420733 2964682725 2621594647 4044970290 104752456)'
(FPCore (x y z)
:name "Linear.Quaternion:$ctanh from linear-1.19.1.3"
:target
(if (< z -4.2173720203427147e-29) (/ (* x (/ 1 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1 (/ y (sin y)))) z)))
(/ (* x (/ (sin y) y)) z))