Average Error: 7.3 → 0.5
Time: 38.0s
Precision: 64
Internal precision: 128
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;y \le -1.3435121576273773 \cdot 10^{-33}:\\
\;\;\;\;\frac{\cosh x \cdot \frac{y}{z}}{x}\\
\mathbf{if}\;y \le 8.378170858467427 \cdot 10^{-66}:\\
\;\;\;\;\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cosh x \cdot \frac{y}{z}}{x}\\
\end{array}\]
Target
| Original | 7.3 |
| Comparison | 0.4 |
| Herbie | 0.5 |
\[ \begin{array}{l}
\mathbf{if}\;y \lt -4.618902267687042 \cdot 10^{-52}:\\
\;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\
\mathbf{if}\;y \lt 1.038530535935153 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\
\end{array} \]
Derivation
- Split input into 2 regimes.
-
if y < -1.3435121576273773e-33 or 8.378170858467427e-66 < y
Initial program 16.1
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
- Using strategy
rm
Applied div-inv 16.2
\[\leadsto \color{blue}{\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}}\]
- Using strategy
rm
Applied associate-*r/ 16.2
\[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x}} \cdot \frac{1}{z}\]
Applied associate-*l/ 0.9
\[\leadsto \color{blue}{\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{z}}{x}}\]
Applied simplify 0.8
\[\leadsto \frac{\color{blue}{\cosh x \cdot \frac{y}{z}}}{x}\]
if -1.3435121576273773e-33 < y < 8.378170858467427e-66
Initial program 0.2
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
- Using strategy
rm
Applied div-inv 0.4
\[\leadsto \color{blue}{\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1647583559 3318508030 3110287135 1484814768 2025052434 1353056123)'
(FPCore (x y z)
:name "Linear.Quaternion:$ctan from linear-1.19.1.3"
:target
(if (< y -4.618902267687042e-52) (* (/ (/ y z) x) (cosh x)) (if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))
(/ (* (cosh x) (/ y x)) z))