Average Error: 7.4 → 0.5
Time: 4.0s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.448772975614469 \cdot 10^{+67}:\\ \;\;\;\;\frac{\cosh x}{\frac{x}{\frac{y}{z}}}\\ \mathbf{elif}\;y \leq 2.990037073633152 \cdot 10^{-17}:\\ \;\;\;\;\frac{\frac{y \cdot \cosh x}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \cosh x}{x \cdot z}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -1.448772975614469 \cdot 10^{+67}:\\
\;\;\;\;\frac{\cosh x}{\frac{x}{\frac{y}{z}}}\\

\mathbf{elif}\;y \leq 2.990037073633152 \cdot 10^{-17}:\\
\;\;\;\;\frac{\frac{y \cdot \cosh x}{x}}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \cosh x}{x \cdot z}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.448772975614469e+67)
   (/ (cosh x) (/ x (/ y z)))
   (if (<= y 2.990037073633152e-17)
     (/ (/ (* y (cosh x)) x) z)
     (/ (* y (cosh x)) (* 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 tmp;
	if (y <= -1.448772975614469e+67) {
		tmp = cosh(x) / (x / (y / z));
	} else if (y <= 2.990037073633152e-17) {
		tmp = ((y * cosh(x)) / x) / z;
	} else {
		tmp = (y * cosh(x)) / (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

Original7.4
Target0.5
Herbie0.5
\[\begin{array}{l} \mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{elif}\;y < 1.0385305359351529 \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 3 regimes
  2. if y < -1.4487729756144689e67

    1. Initial program 29.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied associate-*r/_binary6429.2

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

      \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{z \cdot x}}\]
    5. Simplified0.4

      \[\leadsto \frac{\cosh x \cdot y}{\color{blue}{x \cdot z}}\]
    6. Using strategy rm
    7. Applied associate-/l*_binary640.4

      \[\leadsto \color{blue}{\frac{\cosh x}{\frac{x \cdot z}{y}}}\]
    8. Simplified0.4

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

    if -1.4487729756144689e67 < y < 2.9900370736331518e-17

    1. Initial program 0.6

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied associate-*r/_binary640.6

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

    if 2.9900370736331518e-17 < y

    1. Initial program 18.7

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied associate-*r/_binary6418.7

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

      \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{z \cdot x}}\]
    5. Simplified0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.448772975614469 \cdot 10^{+67}:\\ \;\;\;\;\frac{\cosh x}{\frac{x}{\frac{y}{z}}}\\ \mathbf{elif}\;y \leq 2.990037073633152 \cdot 10^{-17}:\\ \;\;\;\;\frac{\frac{y \cdot \cosh x}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \cosh x}{x \cdot z}\\ \end{array}\]

Reproduce

herbie shell --seed 2020219 
(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.0385305359351529e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))

  (/ (* (cosh x) (/ y x)) z))