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

\mathbf{elif}\;t_0 \leq 10^{-6}:\\
\;\;\;\;\frac{\cosh x \cdot y}{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

Original7.5
Target0.4
Herbie0.9
\[\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) < -9.9999999999999996e86

    1. Initial program 16.0

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

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

      [Start]16.0

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

      associate-*l/ [<=]15.9

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

      times-frac [<=]14.2

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

      associate-*l/ [<=]15.2

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

      *-commutative [=>]15.2

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

      \[\leadsto \color{blue}{\frac{1}{z \cdot x}} \cdot y \]
    4. Applied egg-rr1.4

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

    if -9.9999999999999996e86 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z) < 9.99999999999999955e-7

    1. Initial program 0.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified0.9

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

      [Start]0.2

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

      associate-*r/ [=>]0.2

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

      associate-/l/ [=>]0.9

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

    if 9.99999999999999955e-7 < (/.f64 (*.f64 (cosh.f64 x) (/.f64 y x)) z)

    1. Initial program 13.0

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Simplified0.4

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

      [Start]13.0

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

      associate-*r/ [<=]13.0

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

      associate-/l/ [=>]11.9

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

      associate-/r* [=>]0.4

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

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

Alternatives

Alternative 1
Error1.1
Cost7113
\[\begin{array}{l} \mathbf{if}\;z \leq -1.32 \cdot 10^{+98} \lor \neg \left(z \leq 4.3 \cdot 10^{+20}\right):\\ \;\;\;\;\frac{y \cdot \left(1 + 0.5 \cdot \left(x \cdot x\right)\right)}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 2
Error0.9
Cost7112
\[\begin{array}{l} \mathbf{if}\;z \leq -1.32 \cdot 10^{+98}:\\ \;\;\;\;y \cdot \frac{\cosh x}{x \cdot z}\\ \mathbf{elif}\;z \leq 5 \cdot 10^{+14}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot \left(1 + 0.5 \cdot \left(x \cdot x\right)\right)}{x \cdot z}\\ \end{array} \]
Alternative 3
Error1.2
Cost1097
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{+14} \lor \neg \left(y \leq 2 \cdot 10^{-20}\right):\\ \;\;\;\;\frac{y \cdot \left(1 + 0.5 \cdot \left(x \cdot x\right)\right)}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \end{array} \]
Alternative 4
Error1.4
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -0.26 \lor \neg \left(y \leq 1.95 \cdot 10^{-16}\right):\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 5
Error1.5
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -0.43 \lor \neg \left(y \leq 2.3 \cdot 10^{+62}\right):\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \end{array} \]
Alternative 6
Error1.6
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -920000000000 \lor \neg \left(y \leq 5.2 \cdot 10^{-20}\right):\\ \;\;\;\;\frac{y}{x \cdot z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 7
Error1.6
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -0.1 \lor \neg \left(y \leq 5.2 \cdot 10^{-21}\right):\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 8
Error8.4
Cost320
\[\frac{y}{x \cdot z} \]

Error

Reproduce

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