?

Average Error: 12.41% → 1.2%
Time: 12.2s
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^{+130}:\\ \;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+283}:\\ \;\;\;\;\frac{t_0}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5 + \frac{1}{x}}{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+130)
     (/ (* (cosh x) y) (* x z))
     (if (<= t_0 2e+283) (/ t_0 z) (* y (/ (+ (* x 0.5) (/ 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+130) {
		tmp = (cosh(x) * y) / (x * z);
	} else if (t_0 <= 2e+283) {
		tmp = t_0 / z;
	} else {
		tmp = y * (((x * 0.5) + (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+130)) then
        tmp = (cosh(x) * y) / (x * z)
    else if (t_0 <= 2d+283) then
        tmp = t_0 / z
    else
        tmp = y * (((x * 0.5d0) + (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+130) {
		tmp = (Math.cosh(x) * y) / (x * z);
	} else if (t_0 <= 2e+283) {
		tmp = t_0 / z;
	} else {
		tmp = y * (((x * 0.5) + (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+130:
		tmp = (math.cosh(x) * y) / (x * z)
	elif t_0 <= 2e+283:
		tmp = t_0 / z
	else:
		tmp = y * (((x * 0.5) + (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+130)
		tmp = Float64(Float64(cosh(x) * y) / Float64(x * z));
	elseif (t_0 <= 2e+283)
		tmp = Float64(t_0 / z);
	else
		tmp = Float64(y * Float64(Float64(Float64(x * 0.5) + Float64(1.0 / 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+130)
		tmp = (cosh(x) * y) / (x * z);
	elseif (t_0 <= 2e+283)
		tmp = t_0 / z;
	else
		tmp = y * (((x * 0.5) + (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+130], N[(N[(N[Cosh[x], $MachinePrecision] * y), $MachinePrecision] / N[(x * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+283], N[(t$95$0 / z), $MachinePrecision], N[(y * N[(N[(N[(x * 0.5), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision] / z), $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^{+130}:\\
\;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\

\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+283}:\\
\;\;\;\;\frac{t_0}{z}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.41%
Target0.69%
Herbie1.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)) < -4.9999999999999996e130

    1. Initial program 32.17

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified4.03

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

      [Start]32.17

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

      associate-*r/ [=>]32.17

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

      associate-/l/ [=>]4.03

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

    if -4.9999999999999996e130 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 1.99999999999999991e283

    1. Initial program 0.39

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

    if 1.99999999999999991e283 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 80.74

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified1.11

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

      [Start]80.74

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

      associate-*l/ [<=]80.43

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

      times-frac [<=]1.29

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

      associate-*l/ [<=]1.11

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

      *-commutative [=>]1.11

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

      \[\leadsto \color{blue}{\left(\frac{1}{z \cdot x} + 0.5 \cdot \frac{x}{z}\right)} \cdot y \]
    4. Simplified1.58

      \[\leadsto \color{blue}{\left(\frac{0.5 \cdot x}{z} + \frac{1}{z \cdot x}\right)} \cdot y \]
      Proof

      [Start]1.58

      \[ \left(\frac{1}{z \cdot x} + 0.5 \cdot \frac{x}{z}\right) \cdot y \]

      +-commutative [=>]1.58

      \[ \color{blue}{\left(0.5 \cdot \frac{x}{z} + \frac{1}{z \cdot x}\right)} \cdot y \]

      associate-*r/ [=>]1.58

      \[ \left(\color{blue}{\frac{0.5 \cdot x}{z}} + \frac{1}{z \cdot x}\right) \cdot y \]
    5. Taylor expanded in z around 0 1.58

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

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

Alternatives

Alternative 1
Error1.86%
Cost7112
\[\begin{array}{l} t_0 := x \cdot 0.5 + \frac{1}{x}\\ \mathbf{if}\;y \leq -200000000:\\ \;\;\;\;t_0 \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 4 \cdot 10^{-66}:\\ \;\;\;\;\frac{y \cdot t_0}{z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 2
Error1.78%
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -122000:\\ \;\;\;\;\left(x \cdot 0.5 + \frac{1}{x}\right) \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+96}:\\ \;\;\;\;\frac{y}{x} \cdot \frac{\cosh x}{z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 3
Error1.19%
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -0.022:\\ \;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\ \mathbf{elif}\;z \leq 5.7 \cdot 10^{+41}:\\ \;\;\;\;\frac{y}{x} \cdot \frac{\cosh x}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5 + \frac{1}{x}}{z}\\ \end{array} \]
Alternative 4
Error2.04%
Cost1096
\[\begin{array}{l} t_0 := 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{if}\;z \leq -2 \cdot 10^{-11}:\\ \;\;\;\;\frac{y}{x \cdot z} + t_0\\ \mathbf{elif}\;z \leq 8 \cdot 10^{+18}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} + t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{x \cdot 0.5 + \frac{1}{x}}{z}\\ \end{array} \]
Alternative 5
Error2.56%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -3 \lor \neg \left(y \leq 4 \cdot 10^{-66}\right):\\ \;\;\;\;\left(x \cdot 0.5 + \frac{1}{x}\right) \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 6
Error2.45%
Cost969
\[\begin{array}{l} t_0 := x \cdot 0.5 + \frac{1}{x}\\ \mathbf{if}\;z \leq -2.35 \cdot 10^{+80} \lor \neg \left(z \leq 5\right):\\ \;\;\;\;y \cdot \frac{t_0}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \frac{y}{z}\\ \end{array} \]
Alternative 7
Error2.34%
Cost969
\[\begin{array}{l} t_0 := x \cdot 0.5 + \frac{1}{x}\\ \mathbf{if}\;y \leq -60000000 \lor \neg \left(y \leq 4 \cdot 10^{-66}\right):\\ \;\;\;\;t_0 \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot t_0}{z}\\ \end{array} \]
Alternative 8
Error2.3%
Cost968
\[\begin{array}{l} t_0 := x \cdot 0.5 + \frac{1}{x}\\ \mathbf{if}\;z \leq -7.6 \cdot 10^{+18}:\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+40}:\\ \;\;\;\;\frac{y \cdot t_0}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{t_0}{z}\\ \end{array} \]
Alternative 9
Error3.6%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{+30} \lor \neg \left(z \leq 3.4 \cdot 10^{+91}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 10
Error3.42%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -0.42 \lor \neg \left(y \leq 4.2 \cdot 10^{+96}\right):\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 11
Error3.44%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -3300:\\ \;\;\;\;\frac{1}{x} \cdot \frac{y}{z}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+96}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 12
Error13.81%
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce?

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