Average Error: 8.1 → 0.4
Time: 4.3s
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 r465207 = x;
        double r465208 = cosh(r465207);
        double r465209 = y;
        double r465210 = r465209 / r465207;
        double r465211 = r465208 * r465210;
        double r465212 = z;
        double r465213 = r465211 / r465212;
        return r465213;
}

double f(double x, double y, double z) {
        double r465214 = z;
        double r465215 = -2.1502193184218725e-38;
        bool r465216 = r465214 <= r465215;
        double r465217 = 1.539596801022037e-41;
        bool r465218 = r465214 <= r465217;
        double r465219 = !r465218;
        bool r465220 = r465216 || r465219;
        double r465221 = x;
        double r465222 = exp(r465221);
        double r465223 = -r465221;
        double r465224 = exp(r465223);
        double r465225 = r465222 + r465224;
        double r465226 = y;
        double r465227 = r465225 * r465226;
        double r465228 = 2.0;
        double r465229 = r465228 * r465221;
        double r465230 = r465214 * r465229;
        double r465231 = r465227 / r465230;
        double r465232 = 1.0;
        double r465233 = cosh(r465221);
        double r465234 = r465226 / r465221;
        double r465235 = r465233 * r465234;
        double r465236 = r465214 / r465235;
        double r465237 = r465232 / r465236;
        double r465238 = r465220 ? r465231 : r465237;
        return r465238;
}

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 +o rules:numerics
(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))