Average Error: 7.7 → 0.6
Time: 4.6s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -0.06013142179743951:\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(x \cdot 2\right)}\\ \mathbf{elif}\;z \leq 3.797577207409332 \cdot 10^{+78}:\\ \;\;\;\;\frac{1}{x \cdot \frac{z}{y \cdot \cosh x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(x \cdot 2\right)}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -0.06013142179743951:\\
\;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(x \cdot 2\right)}\\

\mathbf{elif}\;z \leq 3.797577207409332 \cdot 10^{+78}:\\
\;\;\;\;\frac{1}{x \cdot \frac{z}{y \cdot \cosh x}}\\

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

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

Original7.7
Target0.5
Herbie0.6
\[\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 z < -0.060131421797439508 or 3.7975772074093323e78 < z

    1. Initial program 12.6

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

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

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

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

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

    if -0.060131421797439508 < z < 3.7975772074093323e78

    1. Initial program 1.1

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

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

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

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

      \[\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 clear-num_binary6416.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -0.06013142179743951:\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(x \cdot 2\right)}\\ \mathbf{elif}\;z \leq 3.797577207409332 \cdot 10^{+78}:\\ \;\;\;\;\frac{1}{x \cdot \frac{z}{y \cdot \cosh x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(x \cdot 2\right)}\\ \end{array}\]

Reproduce

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