Average Error: 7.2 → 0.5
Time: 7.8s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \leq -1.5319762094625696 \cdot 10^{+39}:\\ \;\;\;\;0.041666666666666664 \cdot \frac{{x}^{3} \cdot y}{z} + \left(0.5 \cdot \frac{x \cdot y}{z} + \left(0.001388888888888889 \cdot \frac{y \cdot {x}^{5}}{z} + \frac{y}{z \cdot x}\right)\right)\\ \mathbf{elif}\;z \leq 8.670599136611819 \cdot 10^{-21}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(e^{x} + e^{-x}\right)}{z \cdot x}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \leq -1.5319762094625696 \cdot 10^{+39}:\\
\;\;\;\;0.041666666666666664 \cdot \frac{{x}^{3} \cdot y}{z} + \left(0.5 \cdot \frac{x \cdot y}{z} + \left(0.001388888888888889 \cdot \frac{y \cdot {x}^{5}}{z} + \frac{y}{z \cdot x}\right)\right)\\

\mathbf{elif}\;z \leq 8.670599136611819 \cdot 10^{-21}:\\
\;\;\;\;\cosh x \cdot \frac{\frac{y}{x}}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= z -1.5319762094625696e+39)
   (+
    (* 0.041666666666666664 (/ (* (pow x 3.0) y) z))
    (+
     (* 0.5 (/ (* x y) z))
     (+ (* 0.001388888888888889 (/ (* y (pow x 5.0)) z)) (/ y (* z x)))))
   (if (<= z 8.670599136611819e-21)
     (* (cosh x) (/ (/ y x) z))
     (* 0.5 (/ (* y (+ (exp x) (exp (- x)))) (* z x))))))
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.5319762094625696e+39) {
		tmp = (0.041666666666666664 * ((pow(x, 3.0) * y) / z)) + ((0.5 * ((x * y) / z)) + ((0.001388888888888889 * ((y * pow(x, 5.0)) / z)) + (y / (z * x))));
	} else if (z <= 8.670599136611819e-21) {
		tmp = cosh(x) * ((y / x) / z);
	} else {
		tmp = 0.5 * ((y * (exp(x) + exp(-x))) / (z * x));
	}
	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.2
Target0.4
Herbie0.5
\[\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.5319762094625696e39

    1. Initial program 11.3

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Taylor expanded around 0 0.8

      \[\leadsto \color{blue}{0.041666666666666664 \cdot \frac{{x}^{3} \cdot y}{z} + \left(0.5 \cdot \frac{x \cdot y}{z} + \left(0.001388888888888889 \cdot \frac{{x}^{5} \cdot y}{z} + \frac{y}{x \cdot z}\right)\right)}\]

    if -1.5319762094625696e39 < z < 8.67059913661181889e-21

    1. Initial program 0.5

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

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

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

    if 8.67059913661181889e-21 < z

    1. Initial program 10.9

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Taylor expanded around inf 0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.5319762094625696 \cdot 10^{+39}:\\ \;\;\;\;0.041666666666666664 \cdot \frac{{x}^{3} \cdot y}{z} + \left(0.5 \cdot \frac{x \cdot y}{z} + \left(0.001388888888888889 \cdot \frac{y \cdot {x}^{5}}{z} + \frac{y}{z \cdot x}\right)\right)\\ \mathbf{elif}\;z \leq 8.670599136611819 \cdot 10^{-21}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \frac{y \cdot \left(e^{x} + e^{-x}\right)}{z \cdot x}\\ \end{array}\]

Reproduce

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