Average Error: 7.7 → 0.3
Time: 9.0s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -3.927886336883088 \cdot 10^{+282}:\\ \;\;\;\;\left(\cosh x \cdot y\right) \cdot \frac{1}{x \cdot z}\\ \mathbf{elif}\;\cosh x \cdot \frac{y}{x} \leq 1.1771731479509362 \cdot 10^{+257}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -3.927886336883088 \cdot 10^{+282}:\\
\;\;\;\;\left(\cosh x \cdot y\right) \cdot \frac{1}{x \cdot z}\\

\mathbf{elif}\;\cosh x \cdot \frac{y}{x} \leq 1.1771731479509362 \cdot 10^{+257}:\\
\;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= (* (cosh x) (/ y x)) -3.927886336883088e+282)
   (* (* (cosh x) y) (/ 1.0 (* x z)))
   (if (<= (* (cosh x) (/ y x)) 1.1771731479509362e+257)
     (/ (* (cosh x) (/ y x)) z)
     (/ (* (cosh x) y) (* 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 ((cosh(x) * (y / x)) <= -3.927886336883088e+282) {
		tmp = (cosh(x) * y) * (1.0 / (x * z));
	} else if ((cosh(x) * (y / x)) <= 1.1771731479509362e+257) {
		tmp = (cosh(x) * (y / x)) / z;
	} else {
		tmp = (cosh(x) * y) / (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.7
Target0.4
Herbie0.3
\[\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 (*.f64 (cosh.f64 x) (/.f64 y x)) < -3.927886336883088e282

    1. Initial program 51.1

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

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

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

      \[\leadsto \color{blue}{\cosh x} \cdot \frac{\frac{y}{x}}{z}\]
    6. Simplified0.6

      \[\leadsto \cosh x \cdot \color{blue}{\frac{y}{x \cdot z}}\]
    7. Using strategy rm
    8. Applied div-inv_binary64_113280.7

      \[\leadsto \cosh x \cdot \color{blue}{\left(y \cdot \frac{1}{x \cdot z}\right)}\]
    9. Applied associate-*r*_binary64_112710.8

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

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

    if -3.927886336883088e282 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 1.1771731479509362e257

    1. Initial program 0.2

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

    if 1.1771731479509362e257 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 42.5

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied associate-*r/_binary64_1127342.5

      \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z}\]
    4. Applied associate-/l/_binary64_112780.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -3.927886336883088 \cdot 10^{+282}:\\ \;\;\;\;\left(\cosh x \cdot y\right) \cdot \frac{1}{x \cdot z}\\ \mathbf{elif}\;\cosh x \cdot \frac{y}{x} \leq 1.1771731479509362 \cdot 10^{+257}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\ \end{array}\]

Reproduce

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