Average Error: 7.8 → 0.3
Time: 6.3s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
\[\begin{array}{l} t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{if}\;t_0 \leq -5.557433224784573 \cdot 10^{+193} \lor \neg \left(t_0 \leq 8.756943765838428 \cdot 10^{+79}\right):\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
\mathbf{if}\;t_0 \leq -5.557433224784573 \cdot 10^{+193} \lor \neg \left(t_0 \leq 8.756943765838428 \cdot 10^{+79}\right):\\
\;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* (cosh x) (/ y x)) z)))
   (if (or (<= t_0 -5.557433224784573e+193)
           (not (<= t_0 8.756943765838428e+79)))
     (* (cosh x) (/ (/ y z) x))
     t_0)))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
double code(double x, double y, double z) {
	double t_0 = (cosh(x) * (y / x)) / z;
	double tmp;
	if ((t_0 <= -5.557433224784573e+193) || !(t_0 <= 8.756943765838428e+79)) {
		tmp = cosh(x) * ((y / z) / x);
	} else {
		tmp = t_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.8
Target0.5
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.038530535935153 \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 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -5.557433224784573e193 or 8.756943765838428e79 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 20.7

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Applied *-un-lft-identity_binary6420.7

      \[\leadsto \frac{\cosh x \cdot \frac{y}{x}}{\color{blue}{1 \cdot z}} \]
    3. Applied times-frac_binary6420.6

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

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

      \[\leadsto \cosh x \cdot \color{blue}{\frac{y}{z \cdot x}} \]
    6. Applied associate-/r*_binary640.3

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

    if -5.557433224784573e193 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 8.756943765838428e79

    1. Initial program 0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq -5.557433224784573 \cdot 10^{+193} \lor \neg \left(\frac{\cosh x \cdot \frac{y}{x}}{z} \leq 8.756943765838428 \cdot 10^{+79}\right):\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \end{array} \]

Reproduce

herbie shell --seed 2021280 
(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.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))

  (/ (* (cosh x) (/ y x)) z))