?

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

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.04%
Target0.71%
Herbie1.84%
\[\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)) < -9.9999999999999993e167

    1. Initial program 37.55

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified2.49

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

      [Start]37.55

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

      associate-*r/ [=>]37.55

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

      associate-/l/ [=>]2.49

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

      \[\leadsto \color{blue}{\frac{y}{z \cdot x}} \]
    4. Simplified3.19

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

      [Start]3.51

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

      associate-/r* [=>]3.19

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

    if -9.9999999999999993e167 < (*.f64 (cosh.f64 x) (/.f64 y x)) < 1.9999999999999999e99

    1. Initial program 0.4

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

    if 1.9999999999999999e99 < (*.f64 (cosh.f64 x) (/.f64 y x))

    1. Initial program 27.04

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified5.05

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

      [Start]27.04

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

      associate-*l/ [<=]27.2

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

      times-frac [<=]4.28

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

      associate-*l/ [<=]5.05

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

      *-commutative [=>]5.05

      \[ \frac{\cosh x}{\color{blue}{x \cdot z}} \cdot y \]
    3. Applied egg-rr69.24

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{\cosh x}{x \cdot z}\right)} - 1\right)} \cdot y \]
    4. Simplified5.07

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

      [Start]69.24

      \[ \left(e^{\mathsf{log1p}\left(\frac{\cosh x}{x \cdot z}\right)} - 1\right) \cdot y \]

      expm1-def [=>]33.47

      \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{\cosh x}{x \cdot z}\right)\right)} \cdot y \]

      expm1-log1p [=>]5.05

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

      associate-/r* [=>]5.07

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

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

Alternatives

Alternative 1
Error2.89%
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -14000000 \lor \neg \left(z \leq 6.5 \cdot 10^{+170}\right):\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 2
Error2.93%
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -40000000000:\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{+174}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\ \end{array} \]
Alternative 3
Error2.82%
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -500000000:\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \mathbf{elif}\;z \leq 6.5 \cdot 10^{+170}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\frac{\cosh x}{x}}{z}\\ \end{array} \]
Alternative 4
Error2.33%
Cost7112
\[\begin{array}{l} t_0 := \frac{\frac{y}{z}}{x}\\ \mathbf{if}\;y \leq -2.5 \cdot 10^{-97}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.65 \cdot 10^{-68}:\\ \;\;\;\;\frac{\cosh x}{\frac{z}{\frac{y}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot t_0\\ \end{array} \]
Alternative 5
Error2.58%
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -2.5 \cdot 10^{-97}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{-80}:\\ \;\;\;\;\frac{\cosh x}{\frac{z}{\frac{y}{x}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cosh x \cdot y}{x \cdot z}\\ \end{array} \]
Alternative 6
Error2.8%
Cost1096
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-91}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-81}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x \cdot y}{z}\\ \end{array} \]
Alternative 7
Error2.76%
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-91}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-58}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \end{array} \]
Alternative 8
Error2.56%
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-91}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-58}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \end{array} \]
Alternative 9
Error3.76%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -4.6 \cdot 10^{-35} \lor \neg \left(z \leq 4.4 \cdot 10^{-148}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 10
Error3.2%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-91}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-80}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{x \cdot z}\\ \end{array} \]
Alternative 11
Error13.07%
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce?

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