Average Error: 7.5 → 0.4
Time: 3.7s
Precision: 64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -1.28840821850656701 \cdot 10^{-48} \lor \neg \left(z \le 4.15578969436787686 \cdot 10^{-38}\right):\\ \;\;\;\;\frac{\cosh x \cdot y}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{x}}{z}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -1.28840821850656701 \cdot 10^{-48} \lor \neg \left(z \le 4.15578969436787686 \cdot 10^{-38}\right):\\
\;\;\;\;\frac{\cosh x \cdot y}{z \cdot x}\\

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

\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 <= -1.288408218506567e-48) || !(z <= 4.155789694367877e-38))) {
		temp = ((cosh(x) * y) / (z * x));
	} else {
		temp = (((cosh(x) * y) * (1.0 / x)) / z);
	}
	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.5
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 < -1.288408218506567e-48 or 4.155789694367877e-38 < z

    1. Initial program 10.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied associate-*r/10.2

      \[\leadsto \frac{\color{blue}{\frac{\cosh x \cdot y}{x}}}{z}\]
    4. Applied associate-/l/0.5

      \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{z \cdot x}}\]

    if -1.288408218506567e-48 < z < 4.155789694367877e-38

    1. Initial program 0.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.28840821850656701 \cdot 10^{-48} \lor \neg \left(z \le 4.15578969436787686 \cdot 10^{-38}\right):\\ \;\;\;\;\frac{\cosh x \cdot y}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\cosh x \cdot y\right) \cdot \frac{1}{x}}{z}\\ \end{array}\]

Reproduce

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