Average Error: 7.5 → 1.4
Time: 5.6s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \leq -2.1664839211293362 \cdot 10^{+74}:\\ \;\;\;\;\frac{y}{x \cdot z} \cdot \cosh x\\ \mathbf{elif}\;y \leq 1.9232029565270297 \cdot 10^{-141}:\\ \;\;\;\;\frac{\frac{y \cdot \left(e^{x} + e^{-x}\right)}{x \cdot 2}}{z}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\frac{y}{x \cdot z} \cdot \left(e^{x} + e^{-x}\right)\right)\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -2.1664839211293362 \cdot 10^{+74}:\\
\;\;\;\;\frac{y}{x \cdot z} \cdot \cosh x\\

\mathbf{elif}\;y \leq 1.9232029565270297 \cdot 10^{-141}:\\
\;\;\;\;\frac{\frac{y \cdot \left(e^{x} + e^{-x}\right)}{x \cdot 2}}{z}\\

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

\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= y -2.1664839211293362e+74)
   (* (/ y (* x z)) (cosh x))
   (if (<= y 1.9232029565270297e-141)
     (/ (/ (* y (+ (exp x) (exp (- x)))) (* x 2.0)) z)
     (* 0.5 (* (/ y (* x z)) (+ (exp x) (exp (- 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 (y <= -2.1664839211293362e+74) {
		tmp = (y / (x * z)) * cosh(x);
	} else if (y <= 1.9232029565270297e-141) {
		tmp = ((y * (exp(x) + exp(-x))) / (x * 2.0)) / z;
	} else {
		tmp = 0.5 * ((y / (x * z)) * (exp(x) + exp(-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.5
Target0.5
Herbie1.4
\[\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 y < -2.1664839211293362e74

    1. Initial program 28.6

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

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

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

      \[\leadsto \frac{1}{\color{blue}{1 \cdot \frac{z}{\frac{y}{x} \cdot \cosh x}}}\]
    7. Applied add-sqr-sqrt_binary6428.7

      \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{1 \cdot \frac{z}{\frac{y}{x} \cdot \cosh x}}\]
    8. Applied times-frac_binary6428.7

      \[\leadsto \color{blue}{\frac{\sqrt{1}}{1} \cdot \frac{\sqrt{1}}{\frac{z}{\frac{y}{x} \cdot \cosh x}}}\]
    9. Simplified28.7

      \[\leadsto \color{blue}{1} \cdot \frac{\sqrt{1}}{\frac{z}{\frac{y}{x} \cdot \cosh x}}\]
    10. Simplified0.3

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

    if -2.1664839211293362e74 < y < 1.9232029565270297e-141

    1. Initial program 0.9

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

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

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

      \[\leadsto \frac{\color{blue}{\left(y \cdot \cosh x\right)} \cdot \frac{1}{x}}{z}\]
    6. Using strategy rm
    7. Applied cosh-def_binary641.0

      \[\leadsto \frac{\left(y \cdot \color{blue}{\frac{e^{x} + e^{-x}}{2}}\right) \cdot \frac{1}{x}}{z}\]
    8. Applied associate-*r/_binary641.0

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

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

    if 1.9232029565270297e-141 < y

    1. Initial program 11.6

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

      \[\leadsto \color{blue}{\frac{0.5 \cdot \left(e^{x} \cdot y\right) + 0.5 \cdot \left(e^{-x} \cdot y\right)}{x \cdot z}}\]
    3. Simplified2.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -2.1664839211293362 \cdot 10^{+74}:\\ \;\;\;\;\frac{y}{x \cdot z} \cdot \cosh x\\ \mathbf{elif}\;y \leq 1.9232029565270297 \cdot 10^{-141}:\\ \;\;\;\;\frac{\frac{y \cdot \left(e^{x} + e^{-x}\right)}{x \cdot 2}}{z}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\frac{y}{x \cdot z} \cdot \left(e^{x} + e^{-x}\right)\right)\\ \end{array}\]

Alternatives

Reproduce

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