?

Average Accuracy: 88.2% → 99.3%
Time: 11.9s
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}\\ t_1 := \frac{\frac{y}{z}}{x}\\ \mathbf{if}\;t_0 \leq -2000:\\ \;\;\;\;\cosh x \cdot t_1\\ \mathbf{elif}\;t_0 \leq 10^{+126}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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)) (t_1 (/ (/ y z) x)))
   (if (<= t_0 -2000.0) (* (cosh x) t_1) (if (<= t_0 1e+126) t_0 t_1))))
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 t_1 = (y / z) / x;
	double tmp;
	if (t_0 <= -2000.0) {
		tmp = cosh(x) * t_1;
	} else if (t_0 <= 1e+126) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (cosh(x) * (y / x)) / z
    t_1 = (y / z) / x
    if (t_0 <= (-2000.0d0)) then
        tmp = cosh(x) * t_1
    else if (t_0 <= 1d+126) then
        tmp = t_0
    else
        tmp = t_1
    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 t_0 = (Math.cosh(x) * (y / x)) / z;
	double t_1 = (y / z) / x;
	double tmp;
	if (t_0 <= -2000.0) {
		tmp = Math.cosh(x) * t_1;
	} else if (t_0 <= 1e+126) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	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
	t_1 = (y / z) / x
	tmp = 0
	if t_0 <= -2000.0:
		tmp = math.cosh(x) * t_1
	elif t_0 <= 1e+126:
		tmp = t_0
	else:
		tmp = t_1
	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)
	t_1 = Float64(Float64(y / z) / x)
	tmp = 0.0
	if (t_0 <= -2000.0)
		tmp = Float64(cosh(x) * t_1);
	elseif (t_0 <= 1e+126)
		tmp = t_0;
	else
		tmp = t_1;
	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;
	t_1 = (y / z) / x;
	tmp = 0.0;
	if (t_0 <= -2000.0)
		tmp = cosh(x) * t_1;
	elseif (t_0 <= 1e+126)
		tmp = t_0;
	else
		tmp = t_1;
	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]}, Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[t$95$0, -2000.0], N[(N[Cosh[x], $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t$95$0, 1e+126], t$95$0, t$95$1]]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \frac{\cosh x \cdot \frac{y}{x}}{z}\\
t_1 := \frac{\frac{y}{z}}{x}\\
\mathbf{if}\;t_0 \leq -2000:\\
\;\;\;\;\cosh x \cdot t_1\\

\mathbf{elif}\;t_0 \leq 10^{+126}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original88.2%
Target99.4%
Herbie99.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) < -2e3

    1. Initial program 79.3%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified99.6%

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

      [Start]79.3

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

      associate-*r/ [<=]79.4

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

      associate-/l/ [=>]80.6

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

      associate-/r* [=>]99.6

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

    if -2e3 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 9.99999999999999925e125

    1. Initial program 99.6%

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

    if 9.99999999999999925e125 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 70.0%

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified99.2%

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

      [Start]70.0

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

      associate-*r/ [=>]70.0

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

      associate-/r* [<=]76.7

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

      times-frac [=>]99.2

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

      \[\leadsto \color{blue}{\frac{1}{x}} \cdot \frac{y}{z} \]
    4. Applied egg-rr98.0%

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

      [Start]97.7

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

      associate-*l/ [=>]98.0

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

      *-un-lft-identity [<=]98.0

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

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

Alternatives

Alternative 1
Accuracy98.7%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{-15} \lor \neg \left(z \leq 2.7 \cdot 10^{-73}\right):\\ \;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \end{array} \]
Alternative 2
Accuracy99.4%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -6.8 \cdot 10^{+33} \lor \neg \left(z \leq 5.8 \cdot 10^{-57}\right):\\ \;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 3
Accuracy98.4%
Cost1097
\[\begin{array}{l} \mathbf{if}\;z \leq -1.62 \cdot 10^{-13} \lor \neg \left(z \leq 8 \cdot 10^{-39}\right):\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \end{array} \]
Alternative 4
Accuracy98.4%
Cost1096
\[\begin{array}{l} t_0 := \frac{y}{x \cdot z}\\ \mathbf{if}\;z \leq -2 \cdot 10^{-13}:\\ \;\;\;\;t_0 + \left(y \cdot 0.5\right) \cdot \left(x \cdot \frac{1}{z}\right)\\ \mathbf{elif}\;z \leq 8.9 \cdot 10^{-38}:\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0 + 0.5 \cdot \frac{x \cdot y}{z}\\ \end{array} \]
Alternative 5
Accuracy98.1%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+34} \lor \neg \left(z \leq 9.2 \cdot 10^{+28}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \end{array} \]
Alternative 6
Accuracy97.4%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -3.5 \cdot 10^{-81}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-24}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{x \cdot z}{y}}\\ \end{array} \]
Alternative 7
Accuracy97.5%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -3 \cdot 10^{-77} \lor \neg \left(y \leq 10^{-14}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 8
Accuracy97.3%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{-77}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-67}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 9
Accuracy87.3%
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce?

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