Average Error: 7.8 → 0.4
Time: 3.8s
Precision: 64
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;y \le -1.72392562700703779 \cdot 10^{-25}:\\ \;\;\;\;\frac{\sqrt{\cosh x} \cdot \left(\sqrt{\cosh x} \cdot y\right)}{z \cdot x}\\ \mathbf{elif}\;y \le 9.213608132896887 \cdot 10^{26}:\\ \;\;\;\;\frac{\left(\frac{1}{2} \cdot \left(e^{-1 \cdot x} + e^{x}\right)\right) \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cosh x}{1}}{\frac{x}{\frac{y}{z}}}\\ \end{array}\]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;y \le -1.72392562700703779 \cdot 10^{-25}:\\
\;\;\;\;\frac{\sqrt{\cosh x} \cdot \left(\sqrt{\cosh x} \cdot y\right)}{z \cdot x}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\cosh x}{1}}{\frac{x}{\frac{y}{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 VAR;
	if ((y <= -1.7239256270070378e-25)) {
		VAR = ((sqrt(cosh(x)) * (sqrt(cosh(x)) * y)) / (z * x));
	} else {
		double VAR_1;
		if ((y <= 9.213608132896887e+26)) {
			VAR_1 = (((0.5 * (exp((-1.0 * x)) + exp(x))) * (y / x)) / z);
		} else {
			VAR_1 = ((cosh(x) / 1.0) / (x / (y / z)));
		}
		VAR = VAR_1;
	}
	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.8
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 3 regimes
  2. if y < -1.7239256270070378e-25

    1. Initial program 19.0

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

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

      \[\leadsto \color{blue}{\frac{\cosh x \cdot y}{z \cdot x}}\]
    5. Using strategy rm
    6. Applied add-sqr-sqrt0.4

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

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

    if -1.7239256270070378e-25 < y < 9.213608132896887e+26

    1. Initial program 0.3

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

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

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

    if 9.213608132896887e+26 < y

    1. Initial program 25.7

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

      \[\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}}\]
    5. Using strategy rm
    6. Applied associate-/r*0.3

      \[\leadsto \color{blue}{\frac{\frac{\cosh x \cdot y}{z}}{x}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity0.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -1.72392562700703779 \cdot 10^{-25}:\\ \;\;\;\;\frac{\sqrt{\cosh x} \cdot \left(\sqrt{\cosh x} \cdot y\right)}{z \cdot x}\\ \mathbf{elif}\;y \le 9.213608132896887 \cdot 10^{26}:\\ \;\;\;\;\frac{\left(\frac{1}{2} \cdot \left(e^{-1 \cdot x} + e^{x}\right)\right) \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\cosh x}{1}}{\frac{x}{\frac{y}{z}}}\\ \end{array}\]

Reproduce

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