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

\mathbf{elif}\;y \le 1.8559816678073198 \cdot 10^{-9}:\\
\;\;\;\;\frac{\frac{y}{x}}{\frac{z}{\cosh x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\left(e^{x} + e^{-x}\right) \cdot \left(-y\right)}{z}}{-2 \cdot 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 ((y <= -1.7239256270070378e-25)) {
		VAR = ((((pow(exp(x), 3.0) + pow(exp(-x), 3.0)) * -y) / ((exp(x) * exp(x)) + ((exp(-x) * exp(-x)) - (exp(x) * exp(-x))))) / ((-2.0 * x) * z));
	} else {
		double VAR_1;
		if ((y <= 1.8559816678073198e-09)) {
			VAR_1 = ((y / x) / (z / cosh(x)));
		} else {
			VAR_1 = ((((exp(x) + exp(-x)) * -y) / z) / (-2.0 * x));
		}
		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 frac-2neg19.0

      \[\leadsto \frac{\cosh x \cdot \color{blue}{\frac{-y}{-x}}}{z}\]
    4. Applied cosh-def19.0

      \[\leadsto \frac{\color{blue}{\frac{e^{x} + e^{-x}}{2}} \cdot \frac{-y}{-x}}{z}\]
    5. Applied frac-times19.0

      \[\leadsto \frac{\color{blue}{\frac{\left(e^{x} + e^{-x}\right) \cdot \left(-y\right)}{2 \cdot \left(-x\right)}}}{z}\]
    6. Applied associate-/l/0.4

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

      \[\leadsto \frac{\left(e^{x} + e^{-x}\right) \cdot \left(-y\right)}{\color{blue}{\left(-2 \cdot x\right) \cdot z}}\]
    8. Using strategy rm
    9. Applied flip3-+0.5

      \[\leadsto \frac{\color{blue}{\frac{{\left(e^{x}\right)}^{3} + {\left(e^{-x}\right)}^{3}}{e^{x} \cdot e^{x} + \left(e^{-x} \cdot e^{-x} - e^{x} \cdot e^{-x}\right)}} \cdot \left(-y\right)}{\left(-2 \cdot x\right) \cdot z}\]
    10. Applied associate-*l/0.6

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

    if -1.7239256270070378e-25 < y < 1.8559816678073198e-09

    1. Initial program 0.3

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

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

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

    if 1.8559816678073198e-09 < y

    1. Initial program 21.6

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied frac-2neg21.6

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

      \[\leadsto \frac{\color{blue}{\frac{e^{x} + e^{-x}}{2}} \cdot \frac{-y}{-x}}{z}\]
    5. Applied frac-times21.6

      \[\leadsto \frac{\color{blue}{\frac{\left(e^{x} + e^{-x}\right) \cdot \left(-y\right)}{2 \cdot \left(-x\right)}}}{z}\]
    6. Applied associate-/l/0.3

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

      \[\leadsto \frac{\left(e^{x} + e^{-x}\right) \cdot \left(-y\right)}{\color{blue}{\left(-2 \cdot x\right) \cdot z}}\]
    8. Using strategy rm
    9. Applied *-commutative0.3

      \[\leadsto \frac{\left(e^{x} + e^{-x}\right) \cdot \left(-y\right)}{\color{blue}{z \cdot \left(-2 \cdot x\right)}}\]
    10. Applied associate-/r*0.3

      \[\leadsto \color{blue}{\frac{\frac{\left(e^{x} + e^{-x}\right) \cdot \left(-y\right)}{z}}{-2 \cdot x}}\]
  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{\frac{\left({\left(e^{x}\right)}^{3} + {\left(e^{-x}\right)}^{3}\right) \cdot \left(-y\right)}{e^{x} \cdot e^{x} + \left(e^{-x} \cdot e^{-x} - e^{x} \cdot e^{-x}\right)}}{\left(-2 \cdot x\right) \cdot z}\\ \mathbf{elif}\;y \le 1.8559816678073198 \cdot 10^{-9}:\\ \;\;\;\;\frac{\frac{y}{x}}{\frac{z}{\cosh x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\left(e^{x} + e^{-x}\right) \cdot \left(-y\right)}{z}}{-2 \cdot x}\\ \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))