Average Error: 7.9 → 0.6
Time: 4.0s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq -5.822213703640512 \cdot 10^{-73} \lor \neg \left(\frac{\cosh x \cdot \frac{y}{x}}{z} \leq 4.771431572403543 \cdot 10^{-47}\right):\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{z}}{x}\\ \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}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq -5.822213703640512 \cdot 10^{-73} \lor \neg \left(\frac{\cosh x \cdot \frac{y}{x}}{z} \leq 4.771431572403543 \cdot 10^{-47}\right):\\
\;\;\;\;\frac{\cosh x \cdot \frac{y}{z}}{x}\\

\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 (or (<= (/ (* (cosh x) (/ y x)) z) -5.822213703640512e-73)
         (not (<= (/ (* (cosh x) (/ y x)) z) 4.771431572403543e-47)))
   (/ (* (cosh x) (/ y z)) x)
   (/ (* (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)) / z) <= -5.822213703640512e-73) || !(((cosh(x) * (y / x)) / z) <= 4.771431572403543e-47)) {
		tmp = (cosh(x) * (y / z)) / x;
	} 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.9
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 (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < -5.8222137036405124e-73 or 4.77143157240354318e-47 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 11.6

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

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

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

      \[\leadsto \frac{\cosh x \cdot y}{\color{blue}{x \cdot z}}\]
    6. Using strategy rm
    7. Applied times-frac_binary640.9

      \[\leadsto \color{blue}{\frac{\cosh x}{x} \cdot \frac{y}{z}}\]
    8. Using strategy rm
    9. Applied associate-*l/_binary640.8

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

    if -5.8222137036405124e-73 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 4.77143157240354318e-47

    1. Initial program 0.2

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\cosh x \cdot \frac{y}{x}}{z} \leq -5.822213703640512 \cdot 10^{-73} \lor \neg \left(\frac{\cosh x \cdot \frac{y}{x}}{z} \leq 4.771431572403543 \cdot 10^{-47}\right):\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\ \end{array}\]

Reproduce

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