Average Error: 7.9 → 1.1
Time: 3.4s
Precision: 64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.4738653069367457 \cdot 10^{56}:\\ \;\;\;\;\frac{\frac{1}{2} \cdot \left(e^{-1 \cdot x} + e^{x}\right)}{z \cdot x} \cdot y\\ \mathbf{elif}\;z \le 5.00638161210447719 \cdot 10^{-8}:\\ \;\;\;\;\frac{\frac{y}{x} + \frac{1}{2} \cdot \left(x \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \left(x \cdot \frac{y}{z}\right) + \frac{y}{x \cdot z}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;z \le -4.4738653069367457 \cdot 10^{56}:\\
\;\;\;\;\frac{\frac{1}{2} \cdot \left(e^{-1 \cdot x} + e^{x}\right)}{z \cdot x} \cdot y\\

\mathbf{elif}\;z \le 5.00638161210447719 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{y}{x} + \frac{1}{2} \cdot \left(x \cdot y\right)}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \left(x \cdot \frac{y}{z}\right) + \frac{y}{x \cdot 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 <= -4.473865306936746e+56)) {
		temp = (((0.5 * (exp((-1.0 * x)) + exp(x))) / (z * x)) * y);
	} else {
		double temp_1;
		if ((z <= 5.006381612104477e-08)) {
			temp_1 = (((y / x) + (0.5 * (x * y))) / z);
		} else {
			temp_1 = ((0.5 * (x * (y / z))) + (y / (x * z)));
		}
		temp = temp_1;
	}
	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.5
Herbie1.1
\[\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 3 regimes
  2. if z < -4.473865306936746e+56

    1. Initial program 13.8

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Taylor expanded around inf 0.4

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

      \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot \left(e^{-1 \cdot x} + e^{x}\right)}{\frac{z \cdot x}{y}}}\]
    4. Using strategy rm
    5. Applied associate-/r/0.4

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

    if -4.473865306936746e+56 < z < 5.006381612104477e-08

    1. Initial program 0.8

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Taylor expanded around 0 1.8

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

    if 5.006381612104477e-08 < z

    1. Initial program 11.6

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Taylor expanded around 0 1.0

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{x \cdot y}{z} + \frac{y}{x \cdot z}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity1.0

      \[\leadsto \frac{1}{2} \cdot \frac{x \cdot y}{\color{blue}{1 \cdot z}} + \frac{y}{x \cdot z}\]
    5. Applied times-frac1.0

      \[\leadsto \frac{1}{2} \cdot \color{blue}{\left(\frac{x}{1} \cdot \frac{y}{z}\right)} + \frac{y}{x \cdot z}\]
    6. Simplified1.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.4738653069367457 \cdot 10^{56}:\\ \;\;\;\;\frac{\frac{1}{2} \cdot \left(e^{-1 \cdot x} + e^{x}\right)}{z \cdot x} \cdot y\\ \mathbf{elif}\;z \le 5.00638161210447719 \cdot 10^{-8}:\\ \;\;\;\;\frac{\frac{y}{x} + \frac{1}{2} \cdot \left(x \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \left(x \cdot \frac{y}{z}\right) + \frac{y}{x \cdot z}\\ \end{array}\]

Reproduce

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