Average Error: 9.8 → 2.2
Time: 7.7s
Precision: binary64
\[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
\[\begin{array}{l} \mathbf{if}\;x \leq 2.71211154208478 \cdot 10^{-288} \lor \neg \left(x \leq 7.30782984999272 \cdot 10^{-25}\right):\\ \;\;\;\;\frac{0.5 \cdot \frac{y \cdot \left(e^{x} + \frac{1}{e^{x}}\right)}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \frac{\cosh x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\frac{1}{x}}{\sqrt[3]{z}}\\ \end{array} \]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;x \leq 2.71211154208478 \cdot 10^{-288} \lor \neg \left(x \leq 7.30782984999272 \cdot 10^{-25}\right):\\
\;\;\;\;\frac{0.5 \cdot \frac{y \cdot \left(e^{x} + \frac{1}{e^{x}}\right)}{x}}{z}\\

\mathbf{else}:\\
\;\;\;\;\left(y \cdot \frac{\cosh x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\frac{1}{x}}{\sqrt[3]{z}}\\


\end{array}
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= x 2.71211154208478e-288) (not (<= x 7.30782984999272e-25)))
   (/ (* 0.5 (/ (* y (+ (exp x) (/ 1.0 (exp x)))) x)) z)
   (* (* y (/ (cosh x) (* (cbrt z) (cbrt z)))) (/ (/ 1.0 x) (cbrt 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 ((x <= 2.71211154208478e-288) || !(x <= 7.30782984999272e-25)) {
		tmp = (0.5 * ((y * (exp(x) + (1.0 / exp(x)))) / x)) / z;
	} else {
		tmp = (y * (cosh(x) / (cbrt(z) * cbrt(z)))) * ((1.0 / x) / cbrt(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

Original9.8
Target1.8
Herbie2.2
\[\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 x < 2.71211154208477987e-288 or 7.3078298499927198e-25 < x

    1. Initial program 10.8

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

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

    if 2.71211154208477987e-288 < x < 7.3078298499927198e-25

    1. Initial program 5.9

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Applied associate-*r/_binary645.9

      \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z} \]
    3. Applied add-cube-cbrt_binary646.6

      \[\leadsto \frac{\frac{\cosh x \cdot y}{x}}{\color{blue}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}}} \]
    4. Applied div-inv_binary646.6

      \[\leadsto \frac{\color{blue}{\left(\cosh x \cdot y\right) \cdot \frac{1}{x}}}{\left(\sqrt[3]{z} \cdot \sqrt[3]{z}\right) \cdot \sqrt[3]{z}} \]
    5. Applied times-frac_binary644.3

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

      \[\leadsto \color{blue}{\left(\frac{\cosh x}{\sqrt[3]{z} \cdot \sqrt[3]{z}} \cdot y\right)} \cdot \frac{\frac{1}{x}}{\sqrt[3]{z}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.71211154208478 \cdot 10^{-288} \lor \neg \left(x \leq 7.30782984999272 \cdot 10^{-25}\right):\\ \;\;\;\;\frac{0.5 \cdot \frac{y \cdot \left(e^{x} + \frac{1}{e^{x}}\right)}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot \frac{\cosh x}{\sqrt[3]{z} \cdot \sqrt[3]{z}}\right) \cdot \frac{\frac{1}{x}}{\sqrt[3]{z}}\\ \end{array} \]

Reproduce

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