?

Average Error: 7.7 → 0.3
Time: 12.4s
Precision: binary64
Cost: 20680

?

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

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+139}:\\
\;\;\;\;t_0\\

\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

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

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\frac{\cosh x}{x} \cdot \frac{y}{z}} \]
      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-/r* [<=]0.7

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

      times-frac [=>]0.8

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

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

    if -inf.0 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 2.00000000000000007e139

    1. Initial program 0.3

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

    if 2.00000000000000007e139 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 22.1

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

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

      [Start]22.1

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

      associate-*r/ [<=]22.0

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

      associate-/l/ [=>]14.5

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

      associate-/r* [=>]0.3

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

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

Alternatives

Alternative 1
Error0.4
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -1.35 \cdot 10^{+37} \lor \neg \left(z \leq 10^{+28}\right):\\ \;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 2
Error0.3
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -1.25 \cdot 10^{+39} \lor \neg \left(z \leq 470000000\right):\\ \;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 3
Error1.3
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{-83}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;y \leq 10^{-32}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 4
Error1.3
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -6 \cdot 10^{-83}:\\ \;\;\;\;\frac{y}{z} \cdot \frac{\cosh x}{x}\\ \mathbf{elif}\;y \leq 4.4 \cdot 10^{-23}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 5
Error1.3
Cost1092
\[\begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{+31}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}} + y \cdot \frac{\frac{1}{x}}{z}\\ \mathbf{elif}\;y \leq 7.8 \cdot 10^{-32}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 6
Error1.4
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -2.5 \cdot 10^{+45} \lor \neg \left(z \leq 3.6 \cdot 10^{+15}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \left(\frac{1}{x} + x \cdot 0.5\right)\\ \end{array} \]
Alternative 7
Error1.3
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -2.35 \cdot 10^{+17}:\\ \;\;\;\;\frac{y}{z} \cdot \left(\frac{1}{x} + x \cdot 0.5\right)\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-25}:\\ \;\;\;\;\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.6
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+31} \lor \neg \left(y \leq 5.5 \cdot 10^{-33}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 9
Error1.5
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -5.2 \cdot 10^{+17}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 2 \cdot 10^{-28}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 10
Error8.1
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce?

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