Average Error: 7.5 → 0.3
Time: 3.6s
Precision: 64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -9.689094535544859 \lor \neg \left(z \le 4.3133036925259257 \cdot 10^{-14}\right):\\ \;\;\;\;\frac{\cosh x \cdot y}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cosh x \cdot y}{z}}{x}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -9.689094535544859 \lor \neg \left(z \le 4.3133036925259257 \cdot 10^{-14}\right):\\
\;\;\;\;\frac{\cosh x \cdot y}{z \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cosh x \cdot y}{z}}{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 VAR;
	if (((z <= -9.689094535544859) || !(z <= 4.313303692525926e-14))) {
		VAR = ((cosh(x) * y) / (z * x));
	} else {
		VAR = (((cosh(x) * y) / z) / x);
	}
	return VAR;
}

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.5
Herbie0.3
\[\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 < -9.689094535544859 or 4.313303692525926e-14 < z

    1. Initial program 11.2

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

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

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

    if -9.689094535544859 < z < 4.313303692525926e-14

    1. Initial program 0.3

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

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

      \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{z \cdot x}}\]
    5. Using strategy rm
    6. Applied associate-/r*0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -9.689094535544859 \lor \neg \left(z \le 4.3133036925259257 \cdot 10^{-14}\right):\\ \;\;\;\;\frac{\cosh x \cdot y}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cosh x \cdot y}{z}}{x}\\ \end{array}\]

Reproduce

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