?

Average Accuracy: 87.3% → 99.2%
Time: 11.6s
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 -5 \cdot 10^{+280}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{elif}\;t_0 \leq 10^{+202}:\\ \;\;\;\;\frac{t_0}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{1}{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 -5e+280)
     (/ y (* x z))
     (if (<= t_0 1e+202) (/ t_0 z) (* y (/ 1.0 (* 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 <= -5e+280) {
		tmp = y / (x * z);
	} else if (t_0 <= 1e+202) {
		tmp = t_0 / z;
	} else {
		tmp = y * (1.0 / (x * z));
	}
	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) :: tmp
    t_0 = cosh(x) * (y / x)
    if (t_0 <= (-5d+280)) then
        tmp = y / (x * z)
    else if (t_0 <= 1d+202) then
        tmp = t_0 / z
    else
        tmp = y * (1.0d0 / (x * z))
    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);
	double tmp;
	if (t_0 <= -5e+280) {
		tmp = y / (x * z);
	} else if (t_0 <= 1e+202) {
		tmp = t_0 / z;
	} else {
		tmp = y * (1.0 / (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 <= -5e+280:
		tmp = y / (x * z)
	elif t_0 <= 1e+202:
		tmp = t_0 / z
	else:
		tmp = y * (1.0 / (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 <= -5e+280)
		tmp = Float64(y / Float64(x * z));
	elseif (t_0 <= 1e+202)
		tmp = Float64(t_0 / z);
	else
		tmp = Float64(y * Float64(1.0 / 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 <= -5e+280)
		tmp = y / (x * z);
	elseif (t_0 <= 1e+202)
		tmp = t_0 / z;
	else
		tmp = y * (1.0 / (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, -5e+280], N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+202], N[(t$95$0 / z), $MachinePrecision], N[(y * N[(1.0 / N[(x * z), $MachinePrecision]), $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 -5 \cdot 10^{+280}:\\
\;\;\;\;\frac{y}{x \cdot z}\\

\mathbf{elif}\;t_0 \leq 10^{+202}:\\
\;\;\;\;\frac{t_0}{z}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original87.3%
Target99.2%
Herbie99.2%
\[\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)) < -5.0000000000000002e280

    1. Initial program 18.0%

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

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

      [Start]18.0

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

      associate-*r/ [=>]18.0

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

      associate-/l/ [=>]99.0

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

      associate-*l/ [<=]99.0

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

      *-commutative [=>]99.0

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

      *-commutative [=>]99.0

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

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

    if -5.0000000000000002e280 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 9.999999999999999e201

    1. Initial program 99.6%

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

    if 9.999999999999999e201 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 53.9%

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

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

      [Start]53.9

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

      associate-*r/ [=>]53.8

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

      associate-/l/ [=>]98.3

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

      associate-*l/ [<=]98.1

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

      *-commutative [=>]98.1

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

      *-commutative [=>]98.1

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

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

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

Alternatives

Alternative 1
Accuracy98.6%
Cost7113
\[\begin{array}{l} \mathbf{if}\;y \leq -4000000000 \lor \neg \left(y \leq 3.15 \cdot 10^{+38}\right):\\ \;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\ \end{array} \]
Alternative 2
Accuracy99.4%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -2.45 \cdot 10^{-13} \lor \neg \left(z \leq 2000\right):\\ \;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 3
Accuracy98.0%
Cost1097
\[\begin{array}{l} \mathbf{if}\;y \leq -4000000000 \lor \neg \left(y \leq 1.5 \cdot 10^{+41}\right):\\ \;\;\;\;y \cdot \left(\frac{1}{x \cdot z} + 0.5 \cdot \frac{x}{z}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\ \end{array} \]
Alternative 4
Accuracy97.6%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -5.1 \cdot 10^{+38} \lor \neg \left(z \leq 5 \cdot 10^{-40}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(\frac{1}{x} + x \cdot 0.5\right)}{z}\\ \end{array} \]
Alternative 5
Accuracy97.7%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+38} \lor \neg \left(z \leq 7 \cdot 10^{+26}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\ \end{array} \]
Alternative 6
Accuracy97.7%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -1.35 \cdot 10^{+70} \lor \neg \left(y \leq 1.02 \cdot 10^{+36}\right):\\ \;\;\;\;\frac{\frac{1}{x} - x \cdot -0.5}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\ \end{array} \]
Alternative 7
Accuracy97.4%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+38} \lor \neg \left(z \leq 5 \cdot 10^{-40}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 8
Accuracy97.1%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;y \leq 1.36 \cdot 10^{-84}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 9
Accuracy87.2%
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce?

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