Average Error: 9.4 → 1.2
Time: 4.5s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
\[\begin{array}{l} t_0 := \cosh x \cdot y\\ \mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -\infty:\\ \;\;\;\;\frac{\frac{t_0}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{z}\\ \end{array} \]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \cosh x \cdot y\\
\mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -\infty:\\
\;\;\;\;\frac{\frac{t_0}{z}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t_0}{x}}{z}\\


\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (cosh x) y)))
   (if (<= (* (cosh x) (/ y x)) (- INFINITY))
     (/ (/ t_0 z) x)
     (/ (/ t_0 x) z))))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
double code(double x, double y, double z) {
	double t_0 = cosh(x) * y;
	double tmp;
	if ((cosh(x) * (y / x)) <= -((double) INFINITY)) {
		tmp = (t_0 / z) / x;
	} else {
		tmp = (t_0 / x) / z;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.4
Target1.8
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{elif}\;y < 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

  1. Split input into 2 regimes
  2. if (*.f64 (cosh.f64 x) (/.f64 y x)) < -inf.0

    1. Initial program 4.7

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Applied div-inv_binary644.7

      \[\leadsto \color{blue}{\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}} \]
    3. Applied associate-*r/_binary644.7

      \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{x}} \cdot \frac{1}{z} \]
    4. Applied associate-*l/_binary640.0

      \[\leadsto \color{blue}{\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{z}}{x}} \]
    5. Simplified0.0

      \[\leadsto \frac{\color{blue}{\frac{y \cdot \cosh x}{z}}}{x} \]

    if -inf.0 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 10.9

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Applied associate-*r/_binary641.6

      \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -\infty:\\ \;\;\;\;\frac{\frac{\cosh x \cdot y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\ \end{array} \]

Reproduce

herbie shell --seed 2022068 
(FPCore (x y z)
  :name "Linear.Quaternion:$ctan from linear-1.19.1.3"
  :precision binary64

  :herbie-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))