?

Average Error: 12.12% → 1.66%
Time: 9.4s
Precision: binary64
Cost: 7112

?

\[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{+82}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{elif}\;y \leq 5.3 \cdot 10^{+60}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= y -1.35e+82)
   (/ y (* z x))
   (if (<= y 5.3e+60) (/ (* (cosh x) (/ y x)) z) (* (cosh x) (/ (/ y z) x)))))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.35e+82) {
		tmp = y / (z * x);
	} else if (y <= 5.3e+60) {
		tmp = (cosh(x) * (y / x)) / z;
	} else {
		tmp = cosh(x) * ((y / z) / x);
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (cosh(x) * (y / x)) / z
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if (y <= (-1.35d+82)) then
        tmp = y / (z * x)
    else if (y <= 5.3d+60) then
        tmp = (cosh(x) * (y / x)) / z
    else
        tmp = cosh(x) * ((y / z) / x)
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return (Math.cosh(x) * (y / x)) / z;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (y <= -1.35e+82) {
		tmp = y / (z * x);
	} else if (y <= 5.3e+60) {
		tmp = (Math.cosh(x) * (y / x)) / z;
	} else {
		tmp = Math.cosh(x) * ((y / z) / x);
	}
	return tmp;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
def code(x, y, z):
	tmp = 0
	if y <= -1.35e+82:
		tmp = y / (z * x)
	elif y <= 5.3e+60:
		tmp = (math.cosh(x) * (y / x)) / z
	else:
		tmp = math.cosh(x) * ((y / z) / x)
	return tmp
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function code(x, y, z)
	tmp = 0.0
	if (y <= -1.35e+82)
		tmp = Float64(y / Float64(z * x));
	elseif (y <= 5.3e+60)
		tmp = Float64(Float64(cosh(x) * Float64(y / x)) / z);
	else
		tmp = Float64(cosh(x) * Float64(Float64(y / z) / x));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (cosh(x) * (y / x)) / z;
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (y <= -1.35e+82)
		tmp = y / (z * x);
	elseif (y <= 5.3e+60)
		tmp = (cosh(x) * (y / x)) / z;
	else
		tmp = cosh(x) * ((y / z) / x);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[y, -1.35e+82], N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.3e+60], N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[Cosh[x], $MachinePrecision] * N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+82}:\\
\;\;\;\;\frac{y}{z \cdot x}\\

\mathbf{elif}\;y \leq 5.3 \cdot 10^{+60}:\\
\;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\

\mathbf{else}:\\
\;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.12%
Target0.75%
Herbie1.66%
\[\begin{array}{l} \mathbf{if}\;y < -4.618902267687042 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{elif}\;y < 1.038530535935153 \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.35e82

    1. Initial program 45.29

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified45.37

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

      [Start]45.29

      \[ \frac{\cosh x \cdot \frac{y}{x}}{z} \]

      associate-/l* [=>]45.37

      \[ \color{blue}{\frac{\cosh x}{\frac{z}{\frac{y}{x}}}} \]
    3. Taylor expanded in x around 0 2.79

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

    if -1.35e82 < y < 5.2999999999999997e60

    1. Initial program 1.71

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]

    if 5.2999999999999997e60 < y

    1. Initial program 46.08

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified0.37

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

      [Start]46.08

      \[ \frac{\cosh x \cdot \frac{y}{x}}{z} \]

      associate-*r/ [<=]46.08

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

      associate-/l/ [=>]0.41

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

      associate-/r* [=>]0.37

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{+82}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{elif}\;y \leq 5.3 \cdot 10^{+60}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]

Alternatives

Alternative 1
Error1.47%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -0.0004 \lor \neg \left(z \leq 10^{+20}\right):\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x}{z \cdot \frac{x}{y}}\\ \end{array} \]
Alternative 2
Error2.71%
Cost7112
\[\begin{array}{l} t_0 := \frac{y}{z \cdot x}\\ \mathbf{if}\;z \leq -2 \cdot 10^{-25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-133}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;t_0 + 0.5 \cdot \frac{y \cdot x}{z}\\ \end{array} \]
Alternative 3
Error3.4%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -7.4 \cdot 10^{+54} \lor \neg \left(z \leq 2 \cdot 10^{+111}\right):\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}{z}\\ \end{array} \]
Alternative 4
Error3.79%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{+53} \lor \neg \left(z \leq 2 \cdot 10^{+111}\right):\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 5
Error3.23%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{+82}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{elif}\;y \leq 5.3 \cdot 10^{+60}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 6
Error13.32%
Cost320
\[\frac{y}{z \cdot x} \]

Error

Reproduce?

herbie shell --seed 2023088 
(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.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))

  (/ (* (cosh x) (/ y x)) z))