?

Average Accuracy: 88.0% → 97.7%
Time: 9.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}\\ t_1 := \frac{\frac{y}{z}}{x}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{-126}:\\ \;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot 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 -1e-35)
     t_1
     (if (<= t_0 2e-126) (* y (/ (cosh x) (* x z))) (* (cosh x) 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 <= -1e-35) {
		tmp = t_1;
	} else if (t_0 <= 2e-126) {
		tmp = y * (cosh(x) / (x * z));
	} else {
		tmp = cosh(x) * 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 <= (-1d-35)) then
        tmp = t_1
    else if (t_0 <= 2d-126) then
        tmp = y * (cosh(x) / (x * z))
    else
        tmp = cosh(x) * 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 <= -1e-35) {
		tmp = t_1;
	} else if (t_0 <= 2e-126) {
		tmp = y * (Math.cosh(x) / (x * z));
	} else {
		tmp = Math.cosh(x) * 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 <= -1e-35:
		tmp = t_1
	elif t_0 <= 2e-126:
		tmp = y * (math.cosh(x) / (x * z))
	else:
		tmp = math.cosh(x) * 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 <= -1e-35)
		tmp = t_1;
	elseif (t_0 <= 2e-126)
		tmp = Float64(y * Float64(cosh(x) / Float64(x * z)));
	else
		tmp = Float64(cosh(x) * 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 <= -1e-35)
		tmp = t_1;
	elseif (t_0 <= 2e-126)
		tmp = y * (cosh(x) / (x * z));
	else
		tmp = cosh(x) * 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, -1e-35], t$95$1, If[LessEqual[t$95$0, 2e-126], N[(y * N[(N[Cosh[x], $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cosh[x], $MachinePrecision] * t$95$1), $MachinePrecision]]]]]
\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 -1 \cdot 10^{-35}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{-126}:\\
\;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\

\mathbf{else}:\\
\;\;\;\;\cosh x \cdot t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original88.0%
Target99.3%
Herbie97.7%
\[\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) < -1.00000000000000001e-35

    1. Initial program 81.1%

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

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

      [Start]81.1

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

      associate-/l* [=>]81.0

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

      associate-/r/ [=>]99.0

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

      \[\leadsto \color{blue}{\frac{y}{z \cdot x}} \]
    4. Simplified97.5%

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

      [Start]83.0

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

      associate-/r* [=>]97.5

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

    if -1.00000000000000001e-35 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 1.9999999999999999e-126

    1. Initial program 99.7%

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

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

      [Start]99.7

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

      associate-*r/ [=>]99.7

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

      associate-/l/ [=>]99.6

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

      associate-*l/ [<=]99.5

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

      *-commutative [=>]99.5

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

      *-commutative [=>]99.5

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

    if 1.9999999999999999e-126 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 84.9%

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

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

      [Start]84.9

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

      associate-*r/ [<=]84.9

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

      associate-/l/ [=>]85.8

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

      associate-/r* [=>]96.5

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

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

Alternatives

Alternative 1
Accuracy98.4%
Cost6980
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{-20}:\\ \;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\ \mathbf{elif}\;y \leq 10^{+19}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 2
Accuracy97.2%
Cost969
\[\begin{array}{l} \mathbf{if}\;z \leq -5.8 \cdot 10^{+63} \lor \neg \left(z \leq 1.5 \cdot 10^{+65}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\ \end{array} \]
Alternative 3
Accuracy97.5%
Cost968
\[\begin{array}{l} t_0 := \frac{y}{x \cdot z}\\ \mathbf{if}\;z \leq -1.7 \cdot 10^{+60}:\\ \;\;\;\;t_0 + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{+58}:\\ \;\;\;\;\frac{\frac{y}{x} + 0.5 \cdot \left(x \cdot y\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Accuracy97.0%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+67} \lor \neg \left(z \leq 2.05 \cdot 10^{+52}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 5
Accuracy87.6%
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce?

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