Average Error: 7.9 → 0.4
Time: 3.3s
Precision: 64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -147933744.31255263 \lor \neg \left(z \le 5673807207157.2168\right):\\ \;\;\;\;\cosh x \cdot \left(y \cdot \frac{1}{x \cdot z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z} \cdot \mathsf{fma}\left(e^{x}, \frac{1}{2}, \frac{\frac{1}{2}}{e^{x}}\right)}{x}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -147933744.31255263 \lor \neg \left(z \le 5673807207157.2168\right):\\
\;\;\;\;\cosh x \cdot \left(y \cdot \frac{1}{x \cdot z}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z} \cdot \mathsf{fma}\left(e^{x}, \frac{1}{2}, \frac{\frac{1}{2}}{e^{x}}\right)}{x}\\

\end{array}
double code(double x, double y, double z) {
	return ((cosh(x) * (y / x)) / z);
}
double code(double x, double y, double z) {
	double temp;
	if (((z <= -147933744.31255263) || !(z <= 5673807207157.217))) {
		temp = (cosh(x) * (y * (1.0 / (x * z))));
	} else {
		temp = (((y / z) * fma(exp(x), 0.5, (0.5 / exp(x)))) / x);
	}
	return temp;
}

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.9
Target0.4
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 < -147933744.31255263 or 5673807207157.217 < z

    1. Initial program 12.5

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

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

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

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

      \[\leadsto \cosh x \cdot \color{blue}{\frac{y}{x \cdot z}}\]
    7. Using strategy rm
    8. Applied div-inv0.4

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

    if -147933744.31255263 < z < 5673807207157.217

    1. Initial program 0.4

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

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

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

      \[\leadsto \color{blue}{\cosh x} \cdot \frac{\frac{y}{x}}{z}\]
    6. Simplified18.4

      \[\leadsto \cosh x \cdot \color{blue}{\frac{y}{x \cdot z}}\]
    7. Taylor expanded around inf 18.4

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

      \[\leadsto \color{blue}{\frac{\frac{y}{z} \cdot \mathsf{fma}\left(e^{x}, \frac{1}{2}, \frac{\frac{1}{2}}{e^{x}}\right)}{x}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -147933744.31255263 \lor \neg \left(z \le 5673807207157.2168\right):\\ \;\;\;\;\cosh x \cdot \left(y \cdot \frac{1}{x \cdot z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z} \cdot \mathsf{fma}\left(e^{x}, \frac{1}{2}, \frac{\frac{1}{2}}{e^{x}}\right)}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 2020056 +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))