?

Average Error: 7.7 → 0.5
Time: 11.8s
Precision: binary64
Cost: 20424

?

\[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
\[\begin{array}{l} t_0 := \cosh x \cdot \frac{y}{x}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+198}:\\ \;\;\;\;\frac{t_0}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (cosh x) (/ y x))))
   (if (<= t_0 (- INFINITY))
     (/ (/ y z) x)
     (if (<= t_0 2e+198) (/ t_0 z) (/ y (* x z))))))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
double code(double x, double y, double z) {
	double t_0 = cosh(x) * (y / x);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = (y / z) / x;
	} else if (t_0 <= 2e+198) {
		tmp = t_0 / z;
	} else {
		tmp = y / (x * z);
	}
	return tmp;
}
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 t_0 = Math.cosh(x) * (y / x);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = (y / z) / x;
	} else if (t_0 <= 2e+198) {
		tmp = t_0 / z;
	} else {
		tmp = y / (x * z);
	}
	return tmp;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
def code(x, y, z):
	t_0 = math.cosh(x) * (y / x)
	tmp = 0
	if t_0 <= -math.inf:
		tmp = (y / z) / x
	elif t_0 <= 2e+198:
		tmp = t_0 / z
	else:
		tmp = y / (x * z)
	return tmp
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function code(x, y, z)
	t_0 = Float64(cosh(x) * Float64(y / x))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(Float64(y / z) / x);
	elseif (t_0 <= 2e+198)
		tmp = Float64(t_0 / z);
	else
		tmp = Float64(y / Float64(x * z));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (cosh(x) * (y / x)) / z;
end
function tmp_2 = code(x, y, z)
	t_0 = cosh(x) * (y / x);
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = (y / z) / x;
	elseif (t_0 <= 2e+198)
		tmp = t_0 / z;
	else
		tmp = y / (x * z);
	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_] := Block[{t$95$0 = N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[t$95$0, 2e+198], N[(t$95$0 / z), $MachinePrecision], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \cosh x \cdot \frac{y}{x}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{\frac{y}{z}}{x}\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+198}:\\
\;\;\;\;\frac{t_0}{z}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.7
Target0.5
Herbie0.5
\[\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 (*.f64 (cosh.f64 x) (/.f64 y x)) < -inf.0

    1. Initial program 64.0

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

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

      [Start]64.0

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

      associate-*r/ [=>]64.0

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

      associate-/l/ [=>]0.8

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

      \[\leadsto \color{blue}{\frac{y}{z \cdot x}} \]
    4. Simplified0.7

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

      [Start]0.8

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

      associate-/r* [=>]0.7

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

    if -inf.0 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 2.00000000000000004e198

    1. Initial program 0.2

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

    if 2.00000000000000004e198 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 28.7

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified1.4

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

      [Start]28.7

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

      associate-*r/ [=>]28.7

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

      associate-/r* [<=]1.3

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

      times-frac [=>]1.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -\infty:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;\cosh x \cdot \frac{y}{x} \leq 2 \cdot 10^{+198}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]

Alternatives

Alternative 1
Error0.7
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -750000 \lor \neg \left(z \leq 14500000\right):\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 2
Error0.7
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+52}:\\ \;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\ \mathbf{elif}\;z \leq 15500000:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \end{array} \]
Alternative 3
Error0.6
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -15000:\\ \;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\ \mathbf{elif}\;z \leq 14600000:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \end{array} \]
Alternative 4
Error1.8
Cost1097
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+53} \lor \neg \left(y \leq 3.6 \cdot 10^{+81}\right):\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \end{array} \]
Alternative 5
Error1.5
Cost969
\[\begin{array}{l} t_0 := x \cdot 0.5 + \frac{1}{x}\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{+52} \lor \neg \left(z \leq 1.25 \cdot 10^{-50}\right):\\ \;\;\;\;y \cdot \frac{t_0}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot t_0\\ \end{array} \]
Alternative 6
Error1.6
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{+43}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-41}:\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{1}{x \cdot z}\\ \end{array} \]
Alternative 7
Error2.1
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+91}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5 + \frac{1}{x}}{z}\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{+81}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 8
Error1.8
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{+55}:\\ \;\;\;\;y \cdot \left(\frac{x \cdot 0.5}{z} + \frac{1}{x \cdot z}\right)\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{+81}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 9
Error2.2
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+53} \lor \neg \left(y \leq 3.6 \cdot 10^{+81}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 10
Error8.1
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce?

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