?

Average Accuracy: 87.6% → 99.0%
Time: 13.0s
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 -5 \cdot 10^{-25}:\\ \;\;\;\;\frac{\frac{1}{x} + x \cdot 0.5}{\frac{z}{y}}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+221}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\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 -5e-25)
     (/ (+ (/ 1.0 x) (* x 0.5)) (/ z y))
     (if (<= t_0 2e+221) t_0 (/ (/ 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 <= -5e-25) {
		tmp = ((1.0 / x) + (x * 0.5)) / (z / y);
	} else if (t_0 <= 2e+221) {
		tmp = t_0;
	} else {
		tmp = (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) :: t_0
    real(8) :: tmp
    t_0 = (cosh(x) * (y / x)) / z
    if (t_0 <= (-5d-25)) then
        tmp = ((1.0d0 / x) + (x * 0.5d0)) / (z / y)
    else if (t_0 <= 2d+221) then
        tmp = t_0
    else
        tmp = (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 t_0 = (Math.cosh(x) * (y / x)) / z;
	double tmp;
	if (t_0 <= -5e-25) {
		tmp = ((1.0 / x) + (x * 0.5)) / (z / y);
	} else if (t_0 <= 2e+221) {
		tmp = t_0;
	} else {
		tmp = (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 <= -5e-25:
		tmp = ((1.0 / x) + (x * 0.5)) / (z / y)
	elif t_0 <= 2e+221:
		tmp = t_0
	else:
		tmp = (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 <= -5e-25)
		tmp = Float64(Float64(Float64(1.0 / x) + Float64(x * 0.5)) / Float64(z / y));
	elseif (t_0 <= 2e+221)
		tmp = t_0;
	else
		tmp = 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 <= -5e-25)
		tmp = ((1.0 / x) + (x * 0.5)) / (z / y);
	elseif (t_0 <= 2e+221)
		tmp = t_0;
	else
		tmp = (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, -5e-25], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+221], t$95$0, N[(N[(y / z), $MachinePrecision] / x), $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 -5 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{1}{x} + x \cdot 0.5}{\frac{z}{y}}\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original87.6%
Target99.3%
Herbie99.0%
\[\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) < -4.99999999999999962e-25

    1. Initial program 80.2%

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

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

      [Start]80.2

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

      associate-*r/ [=>]80.2

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

      associate-/r* [<=]83.5

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

      times-frac [=>]99.3

      \[ \color{blue}{\frac{\cosh x}{x} \cdot \frac{y}{z}} \]
    3. Applied egg-rr99.2%

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

      [Start]99.3

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

      clear-num [=>]99.1

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

      un-div-inv [=>]99.2

      \[ \color{blue}{\frac{\frac{\cosh x}{x}}{\frac{z}{y}}} \]
    4. Taylor expanded in x around 0 98.1%

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

    if -4.99999999999999962e-25 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 2.0000000000000001e221

    1. Initial program 99.6%

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

    if 2.0000000000000001e221 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 47.5%

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

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

      [Start]47.5

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

      associate-*r/ [=>]47.5

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

      associate-/r* [<=]79.8

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

      times-frac [=>]99.3

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

      \[\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.9

      \[ \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.0%

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

Alternatives

Alternative 1
Accuracy98.1%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -9.6 \cdot 10^{-115} \lor \neg \left(z \leq 1.1 \cdot 10^{-55}\right):\\ \;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} + x \cdot 0.5}{\frac{z}{y}}\\ \end{array} \]
Alternative 2
Accuracy98.6%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -7.5 \cdot 10^{-103} \lor \neg \left(z \leq 2 \cdot 10^{-59}\right):\\ \;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 3
Accuracy97.2%
Cost1097
\[\begin{array}{l} \mathbf{if}\;z \leq -9.6 \cdot 10^{-115} \lor \neg \left(z \leq 1.8 \cdot 10^{-57}\right):\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} + x \cdot 0.5}{\frac{z}{y}}\\ \end{array} \]
Alternative 4
Accuracy97.6%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -4.6 \cdot 10^{+53} \lor \neg \left(z \leq 1.42 \cdot 10^{-55}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{x} + x \cdot 0.5\right) \cdot \frac{y}{z}\\ \end{array} \]
Alternative 5
Accuracy97.0%
Cost968
\[\begin{array}{l} t_0 := \frac{1}{x} + x \cdot 0.5\\ \mathbf{if}\;z \leq -9.6 \cdot 10^{-115}:\\ \;\;\;\;\frac{y}{\frac{z}{t_0}}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-55}:\\ \;\;\;\;t_0 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 6
Accuracy97.7%
Cost968
\[\begin{array}{l} t_0 := \frac{1}{x} + x \cdot 0.5\\ \mathbf{if}\;z \leq -4.5 \cdot 10^{+53}:\\ \;\;\;\;\frac{y}{\frac{z}{t_0}}\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-55}:\\ \;\;\;\;\frac{t_0}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 7
Accuracy97.8%
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-15}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+58}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{\frac{1}{x} + x \cdot 0.5}}\\ \end{array} \]
Alternative 8
Accuracy96.6%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{-103} \lor \neg \left(z \leq 3 \cdot 10^{-61}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \frac{z}{y}}\\ \end{array} \]
Alternative 9
Accuracy96.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -4.3 \cdot 10^{-112} \lor \neg \left(z \leq 1.8 \cdot 10^{-49}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 10
Accuracy96.7%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -1.2 \cdot 10^{-103} \lor \neg \left(z \leq 2 \cdot 10^{-59}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 11
Accuracy87.2%
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce?

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