?

Average Error: 8.2 → 0.7
Time: 11.3s
Precision: binary64
Cost: 7112

?

\[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
\[\begin{array}{l} t_0 := \frac{y}{z \cdot x}\\ \mathbf{if}\;z \leq -3.35 \cdot 10^{+19}:\\ \;\;\;\;\cosh x \cdot t_0\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+47}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ y (* z x))))
   (if (<= z -3.35e+19)
     (* (cosh x) t_0)
     (if (<= z 7e+47) (/ (* (cosh x) (/ y x)) z) t_0))))
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 = y / (z * x);
	double tmp;
	if (z <= -3.35e+19) {
		tmp = cosh(x) * t_0;
	} else if (z <= 7e+47) {
		tmp = (cosh(x) * (y / x)) / z;
	} else {
		tmp = t_0;
	}
	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 = y / (z * x)
    if (z <= (-3.35d+19)) then
        tmp = cosh(x) * t_0
    else if (z <= 7d+47) then
        tmp = (cosh(x) * (y / x)) / z
    else
        tmp = t_0
    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 = y / (z * x);
	double tmp;
	if (z <= -3.35e+19) {
		tmp = Math.cosh(x) * t_0;
	} else if (z <= 7e+47) {
		tmp = (Math.cosh(x) * (y / x)) / z;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
def code(x, y, z):
	t_0 = y / (z * x)
	tmp = 0
	if z <= -3.35e+19:
		tmp = math.cosh(x) * t_0
	elif z <= 7e+47:
		tmp = (math.cosh(x) * (y / x)) / z
	else:
		tmp = t_0
	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(y / Float64(z * x))
	tmp = 0.0
	if (z <= -3.35e+19)
		tmp = Float64(cosh(x) * t_0);
	elseif (z <= 7e+47)
		tmp = Float64(Float64(cosh(x) * Float64(y / x)) / z);
	else
		tmp = t_0;
	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 = y / (z * x);
	tmp = 0.0;
	if (z <= -3.35e+19)
		tmp = cosh(x) * t_0;
	elseif (z <= 7e+47)
		tmp = (cosh(x) * (y / x)) / z;
	else
		tmp = t_0;
	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[(y / N[(z * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.35e+19], N[(N[Cosh[x], $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[z, 7e+47], N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
t_0 := \frac{y}{z \cdot x}\\
\mathbf{if}\;z \leq -3.35 \cdot 10^{+19}:\\
\;\;\;\;\cosh x \cdot t_0\\

\mathbf{elif}\;z \leq 7 \cdot 10^{+47}:\\
\;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original8.2
Target0.4
Herbie0.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 z < -3.35e19

    1. Initial program 13.5

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

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

      [Start]13.5

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

      associate-*r/ [<=]13.5

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

      associate-/r* [<=]0.3

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

    if -3.35e19 < z < 7.00000000000000031e47

    1. Initial program 0.7

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

    if 7.00000000000000031e47 < z

    1. Initial program 13.5

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

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

      [Start]13.5

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

      associate-*r/ [=>]13.5

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

      associate-/r* [<=]0.3

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

      times-frac [=>]11.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -3.35 \cdot 10^{+19}:\\ \;\;\;\;\cosh x \cdot \frac{y}{z \cdot x}\\ \mathbf{elif}\;z \leq 7 \cdot 10^{+47}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \end{array} \]

Alternatives

Alternative 1
Error1.2
Cost6980
\[\begin{array}{l} t_0 := \frac{y}{z \cdot x}\\ \mathbf{if}\;z \leq -26000:\\ \;\;\;\;\cosh x \cdot t_0\\ \mathbf{elif}\;z \leq 1.25 \cdot 10^{+46}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}} + \frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.5
Cost1096
\[\begin{array}{l} \mathbf{if}\;z \leq -1.45 \cdot 10^{+45}:\\ \;\;\;\;\frac{y}{\frac{z}{x \cdot 0.5 + \frac{1}{x}}}\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{+43}:\\ \;\;\;\;0.5 \cdot \frac{y}{\frac{z}{x}} + \frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \end{array} \]
Alternative 3
Error1.6
Cost836
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{+15}:\\ \;\;\;\;\frac{y}{\frac{z}{x \cdot 0.5 + \frac{1}{x}}}\\ \mathbf{elif}\;z \leq 1.18 \cdot 10^{+45}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \end{array} \]
Alternative 4
Error1.6
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+20} \lor \neg \left(z \leq 1.85 \cdot 10^{+43}\right):\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \end{array} \]
Alternative 5
Error8.4
Cost320
\[\frac{y}{z \cdot x} \]

Error

Reproduce?

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