Average Error: 7.6 → 0.9
Time: 4.9s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.3836237899484027 \cdot 10^{-81}:\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(x \cdot 2\right)}\\ \mathbf{elif}\;z \leq 7.710689966732358 \cdot 10^{+68}:\\ \;\;\;\;\frac{1}{\frac{z}{\cosh x \cdot \frac{y}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \left(y \cdot \frac{\frac{1}{x}}{z}\right)\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -1.3836237899484027 \cdot 10^{-81}:\\
\;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(x \cdot 2\right)}\\

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

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.3836237899484027e-81)
   (/ (* (+ (exp x) (exp (- x))) y) (* z (* x 2.0)))
   (if (<= z 7.710689966732358e+68)
     (/ 1.0 (/ z (* (cosh x) (/ y x))))
     (* (cosh x) (* y (/ (/ 1.0 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 (z <= -1.3836237899484027e-81) {
		tmp = ((exp(x) + exp(-x)) * y) / (z * (x * 2.0));
	} else if (z <= 7.710689966732358e+68) {
		tmp = 1.0 / (z / (cosh(x) * (y / x)));
	} else {
		tmp = cosh(x) * (y * ((1.0 / 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.6
Target0.4
Herbie0.9
\[\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 z < -1.38362378994840266e-81

    1. Initial program 10.0

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

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

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

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

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

    if -1.38362378994840266e-81 < z < 7.710689966732358e68

    1. Initial program 1.1

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

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

    if 7.710689966732358e68 < z

    1. Initial program 13.1

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

      \[\leadsto \frac{\cosh x \cdot \frac{y}{x}}{\color{blue}{1 \cdot z}}\]
    4. Applied times-frac_binary64_1487713.1

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

      \[\leadsto \color{blue}{\cosh x} \cdot \frac{\frac{y}{x}}{z}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity_binary64_1487113.1

      \[\leadsto \cosh x \cdot \frac{\frac{y}{x}}{\color{blue}{1 \cdot z}}\]
    8. Applied div-inv_binary64_1486813.2

      \[\leadsto \cosh x \cdot \frac{\color{blue}{y \cdot \frac{1}{x}}}{1 \cdot z}\]
    9. Applied times-frac_binary64_148770.5

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

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

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

Reproduce

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