Average Error: 8.1 → 0.4
Time: 4.0s
Precision: 64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -2.1502193184218725 \cdot 10^{-38} \lor \neg \left(z \le 1.53959680102203708 \cdot 10^{-41}\right):\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(2 \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{\cosh x \cdot \frac{y}{x}}}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -2.1502193184218725 \cdot 10^{-38} \lor \neg \left(z \le 1.53959680102203708 \cdot 10^{-41}\right):\\
\;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(2 \cdot x\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{z}{\cosh x \cdot \frac{y}{x}}}\\

\end{array}
double f(double x, double y, double z) {
        double r489294 = x;
        double r489295 = cosh(r489294);
        double r489296 = y;
        double r489297 = r489296 / r489294;
        double r489298 = r489295 * r489297;
        double r489299 = z;
        double r489300 = r489298 / r489299;
        return r489300;
}

double f(double x, double y, double z) {
        double r489301 = z;
        double r489302 = -2.1502193184218725e-38;
        bool r489303 = r489301 <= r489302;
        double r489304 = 1.539596801022037e-41;
        bool r489305 = r489301 <= r489304;
        double r489306 = !r489305;
        bool r489307 = r489303 || r489306;
        double r489308 = x;
        double r489309 = exp(r489308);
        double r489310 = -r489308;
        double r489311 = exp(r489310);
        double r489312 = r489309 + r489311;
        double r489313 = y;
        double r489314 = r489312 * r489313;
        double r489315 = 2.0;
        double r489316 = r489315 * r489308;
        double r489317 = r489301 * r489316;
        double r489318 = r489314 / r489317;
        double r489319 = 1.0;
        double r489320 = cosh(r489308);
        double r489321 = r489313 / r489308;
        double r489322 = r489320 * r489321;
        double r489323 = r489301 / r489322;
        double r489324 = r489319 / r489323;
        double r489325 = r489307 ? r489318 : r489324;
        return r489325;
}

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

Original8.1
Target0.5
Herbie0.4
\[\begin{array}{l} \mathbf{if}\;y \lt -4.618902267687042 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{elif}\;y \lt 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 z < -2.1502193184218725e-38 or 1.539596801022037e-41 < z

    1. Initial program 11.2

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

      \[\leadsto \frac{\color{blue}{\frac{e^{x} + e^{-x}}{2}} \cdot \frac{y}{x}}{z}\]
    4. Applied frac-times11.2

      \[\leadsto \frac{\color{blue}{\frac{\left(e^{x} + e^{-x}\right) \cdot y}{2 \cdot x}}}{z}\]
    5. Applied associate-/l/0.5

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

    if -2.1502193184218725e-38 < z < 1.539596801022037e-41

    1. Initial program 0.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -2.1502193184218725 \cdot 10^{-38} \lor \neg \left(z \le 1.53959680102203708 \cdot 10^{-41}\right):\\ \;\;\;\;\frac{\left(e^{x} + e^{-x}\right) \cdot y}{z \cdot \left(2 \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{z}{\cosh x \cdot \frac{y}{x}}}\\ \end{array}\]

Reproduce

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