Average Error: 7.6 → 0.5
Time: 3.4s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -5.8237894250236384 \cdot 10^{+256} \lor \neg \left(\cosh x \cdot \frac{y}{x} \leq 7.777588006988912 \cdot 10^{+175}\right):\\ \;\;\;\;\frac{\frac{y \cdot \left(e^{x} + e^{-x}\right)}{z}}{x \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -5.8237894250236384 \cdot 10^{+256} \lor \neg \left(\cosh x \cdot \frac{y}{x} \leq 7.777588006988912 \cdot 10^{+175}\right):\\
\;\;\;\;\frac{\frac{y \cdot \left(e^{x} + e^{-x}\right)}{z}}{x \cdot 2}\\

\mathbf{else}:\\
\;\;\;\;\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= (* (cosh x) (/ y x)) -5.8237894250236384e+256)
         (not (<= (* (cosh x) (/ y x)) 7.777588006988912e+175)))
   (/ (/ (* y (+ (exp x) (exp (- x)))) z) (* x 2.0))
   (* (* (cosh x) (/ y x)) (/ 1.0 z))))
double code(double x, double y, double z) {
	return (((double) (((double) cosh(x)) * (y / x))) / z);
}
double code(double x, double y, double z) {
	double tmp;
	if (((((double) (((double) cosh(x)) * (y / x))) <= -5.8237894250236384e+256) || !(((double) (((double) cosh(x)) * (y / x))) <= 7.777588006988912e+175))) {
		tmp = ((((double) (y * ((double) (((double) exp(x)) + ((double) exp(((double) -(x)))))))) / z) / ((double) (x * 2.0)));
	} else {
		tmp = ((double) (((double) (((double) cosh(x)) * (y / x))) * (1.0 / 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.6
Target0.4
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 2 regimes
  2. if (*.f64 (cosh.f64 x) (/.f64 y x)) < -5.82378942502363837e256 or 7.77758800698891167e175 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 30.9

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

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

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

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

      \[\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 add-sqr-sqrt_binary642.0

      \[\leadsto \frac{\color{blue}{\left(\sqrt{e^{x} + e^{-x}} \cdot \sqrt{e^{x} + e^{-x}}\right)} \cdot y}{z \cdot \left(x \cdot 2\right)}\]
    9. Applied associate-*l*_binary641.7

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

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

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

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

    if -5.82378942502363837e256 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 7.77758800698891167e175

    1. Initial program 0.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -5.8237894250236384 \cdot 10^{+256} \lor \neg \left(\cosh x \cdot \frac{y}{x} \leq 7.777588006988912 \cdot 10^{+175}\right):\\ \;\;\;\;\frac{\frac{y \cdot \left(e^{x} + e^{-x}\right)}{z}}{x \cdot 2}\\ \mathbf{else}:\\ \;\;\;\;\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}\\ \end{array}\]

Reproduce

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