Average Error: 8.1 → 0.4
Time: 4.6s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -9.905533536424995 \cdot 10^{+35}:\\ \;\;\;\;\frac{y \cdot \left(e^{x} + e^{-x}\right)}{z \cdot \left(x \cdot 2\right)}\\ \mathbf{elif}\;y \leq 741420780451993:\\ \;\;\;\;\frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\cosh x}\right) \cdot \left(\sqrt[3]{\cosh x} \cdot \frac{y}{x}\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \frac{e^{x} + e^{-x}}{z}}{x \cdot 2}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -9.905533536424995 \cdot 10^{+35}:\\
\;\;\;\;\frac{y \cdot \left(e^{x} + e^{-x}\right)}{z \cdot \left(x \cdot 2\right)}\\

\mathbf{elif}\;y \leq 741420780451993:\\
\;\;\;\;\frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\cosh x}\right) \cdot \left(\sqrt[3]{\cosh x} \cdot \frac{y}{x}\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \frac{e^{x} + e^{-x}}{z}}{x \cdot 2}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= y -9.905533536424995e+35)
   (/ (* y (+ (exp x) (exp (- x)))) (* z (* x 2.0)))
   (if (<= y 741420780451993.0)
     (/ (* (* (cbrt (cosh x)) (cbrt (cosh x))) (* (cbrt (cosh x)) (/ y x))) z)
     (/ (* y (/ (+ (exp x) (exp (- x))) z)) (* x 2.0)))))
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 <= -9.905533536424995e+35) {
		tmp = (y * (exp(x) + exp(-x))) / (z * (x * 2.0));
	} else if (y <= 741420780451993.0) {
		tmp = ((cbrt(cosh(x)) * cbrt(cosh(x))) * (cbrt(cosh(x)) * (y / x))) / z;
	} else {
		tmp = (y * ((exp(x) + exp(-x)) / z)) / (x * 2.0);
	}
	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

Original8.1
Target0.4
Herbie0.4
\[\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 < -9.90553353642499542e35

    1. Initial program 26.4

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied cosh-def_binary64_1542526.4

      \[\leadsto \frac{\color{blue}{\frac{e^{x} + e^{-x}}{2}} \cdot \frac{y}{x}}{z}\]
    4. Applied frac-times_binary64_1525226.4

      \[\leadsto \frac{\color{blue}{\frac{\left(e^{x} + e^{-x}\right) \cdot y}{2 \cdot x}}}{z}\]
    5. Applied associate-/l/_binary64_151910.5

      \[\leadsto \color{blue}{\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(2 \cdot x\right)}}\]
    6. Simplified0.5

      \[\leadsto \frac{\left(e^{x} + e^{-x}\right) \cdot y}{\color{blue}{z \cdot \left(x \cdot 2\right)}}\]

    if -9.90553353642499542e35 < y < 741420780451993

    1. Initial program 0.3

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt_binary64_152740.4

      \[\leadsto \frac{\color{blue}{\left(\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\cosh x}\right) \cdot \sqrt[3]{\cosh x}\right)} \cdot \frac{y}{x}}{z}\]
    4. Applied associate-*l*_binary64_151850.4

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

      \[\leadsto \frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\cosh x}\right) \cdot \color{blue}{\left(\frac{y}{x} \cdot \sqrt[3]{\cosh x}\right)}}{z}\]

    if 741420780451993 < y

    1. Initial program 23.3

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied cosh-def_binary64_1542523.3

      \[\leadsto \frac{\color{blue}{\frac{e^{x} + e^{-x}}{2}} \cdot \frac{y}{x}}{z}\]
    4. Applied frac-times_binary64_1525223.3

      \[\leadsto \frac{\color{blue}{\frac{\left(e^{x} + e^{-x}\right) \cdot y}{2 \cdot x}}}{z}\]
    5. Applied associate-/l/_binary64_151910.4

      \[\leadsto \color{blue}{\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(2 \cdot x\right)}}\]
    6. Simplified0.4

      \[\leadsto \frac{\left(e^{x} + e^{-x}\right) \cdot y}{\color{blue}{z \cdot \left(x \cdot 2\right)}}\]
    7. Using strategy rm
    8. Applied associate-/r*_binary64_151880.4

      \[\leadsto \color{blue}{\frac{\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z}}{x \cdot 2}}\]
    9. Simplified0.4

      \[\leadsto \frac{\color{blue}{\frac{e^{x} + e^{-x}}{z} \cdot y}}{x \cdot 2}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -9.905533536424995 \cdot 10^{+35}:\\ \;\;\;\;\frac{y \cdot \left(e^{x} + e^{-x}\right)}{z \cdot \left(x \cdot 2\right)}\\ \mathbf{elif}\;y \leq 741420780451993:\\ \;\;\;\;\frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\cosh x}\right) \cdot \left(\sqrt[3]{\cosh x} \cdot \frac{y}{x}\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \frac{e^{x} + e^{-x}}{z}}{x \cdot 2}\\ \end{array}\]

Reproduce

herbie shell --seed 2020277 
(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))