Average Error: 7.9 → 0.3
Time: 4.4s
Precision: 64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \le -9.4004414364335926 \cdot 10^{274}:\\ \;\;\;\;\frac{e^{x} + e^{-x}}{\frac{z \cdot \left(2 \cdot x\right)}{y}}\\ \mathbf{elif}\;\cosh x \cdot \frac{y}{x} \le 2.1678956117950275 \cdot 10^{239}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{2} \cdot \frac{\frac{1}{z}}{x}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{y}{x} \le -9.4004414364335926 \cdot 10^{274}:\\
\;\;\;\;\frac{e^{x} + e^{-x}}{\frac{z \cdot \left(2 \cdot x\right)}{y}}\\

\mathbf{elif}\;\cosh x \cdot \frac{y}{x} \le 2.1678956117950275 \cdot 10^{239}:\\
\;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\

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

\end{array}
double code(double x, double y, double z) {
	return ((cosh(x) * (y / x)) / z);
}
double code(double x, double y, double z) {
	double VAR;
	if (((cosh(x) * (y / x)) <= -9.400441436433593e+274)) {
		VAR = ((exp(x) + exp(-x)) / ((z * (2.0 * x)) / y));
	} else {
		double VAR_1;
		if (((cosh(x) * (y / x)) <= 2.1678956117950275e+239)) {
			VAR_1 = ((cosh(x) * (y / x)) / z);
		} else {
			VAR_1 = ((((exp(x) + exp(-x)) * y) / 2.0) * ((1.0 / z) / x));
		}
		VAR = VAR_1;
	}
	return VAR;
}

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.9
Target0.4
Herbie0.3
\[\begin{array}{l} \mathbf{if}\;y \lt -4.618902267687042 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{elif}\;y \lt 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 (* (cosh x) (/ y x)) < -9.400441436433593e+274

    1. Initial program 47.7

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

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

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

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

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

    if -9.400441436433593e+274 < (* (cosh x) (/ y x)) < 2.1678956117950275e+239

    1. Initial program 0.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]

    if 2.1678956117950275e+239 < (* (cosh x) (/ y x))

    1. Initial program 37.7

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z}}{2 \cdot x}}\]
    8. Using strategy rm
    9. Applied div-inv0.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \le -9.4004414364335926 \cdot 10^{274}:\\ \;\;\;\;\frac{e^{x} + e^{-x}}{\frac{z \cdot \left(2 \cdot x\right)}{y}}\\ \mathbf{elif}\;\cosh x \cdot \frac{y}{x} \le 2.1678956117950275 \cdot 10^{239}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{2} \cdot \frac{\frac{1}{z}}{x}\\ \end{array}\]

Reproduce

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