?

Average Error: 7.7 → 0.4
Time: 8.7s
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^{+237}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{elif}\;t_0 \leq 2 \cdot 10^{+283}:\\ \;\;\;\;\frac{t_0}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{\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+237)
     (/ y (* z x))
     (if (<= t_0 2e+283) (/ t_0 z) (* y (/ (/ 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+237) {
		tmp = y / (z * x);
	} else if (t_0 <= 2e+283) {
		tmp = t_0 / z;
	} else {
		tmp = y * ((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+237)) then
        tmp = y / (z * x)
    else if (t_0 <= 2d+283) then
        tmp = t_0 / z
    else
        tmp = y * ((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+237) {
		tmp = y / (z * x);
	} else if (t_0 <= 2e+283) {
		tmp = t_0 / z;
	} else {
		tmp = y * ((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+237:
		tmp = y / (z * x)
	elif t_0 <= 2e+283:
		tmp = t_0 / z
	else:
		tmp = y * ((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+237)
		tmp = Float64(y / Float64(z * x));
	elseif (t_0 <= 2e+283)
		tmp = Float64(t_0 / z);
	else
		tmp = Float64(y * Float64(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+237)
		tmp = y / (z * x);
	elseif (t_0 <= 2e+283)
		tmp = t_0 / z;
	else
		tmp = y * ((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+237], N[(y / N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+283], N[(t$95$0 / z), $MachinePrecision], N[(y * N[(N[(1.0 / 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 -5 \cdot 10^{+237}:\\
\;\;\;\;\frac{y}{z \cdot x}\\

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

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.7
Target0.5
Herbie0.4
\[\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)) < -5.0000000000000002e237

    1. Initial program 36.8

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

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

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

    1. Initial program 0.3

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

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

    1. Initial program 51.8

      \[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
    2. Taylor expanded in x around 0 0.8

      \[\leadsto \color{blue}{\frac{y}{z \cdot x} + 0.5 \cdot \frac{y \cdot x}{z}} \]
    3. Taylor expanded in y around 0 0.9

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

      \[\leadsto y \cdot \color{blue}{\frac{0.5 \cdot x + \frac{1}{x}}{z}} \]
    5. Taylor expanded in x around 0 0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \leq -5 \cdot 10^{+237}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \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{\frac{1}{x}}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error2.0
Cost1096
\[\begin{array}{l} t_0 := \frac{y}{z \cdot x} + 0.5 \cdot \frac{y \cdot x}{z}\\ \mathbf{if}\;z \leq -6 \cdot 10^{-28}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-148}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.5
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-27}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{elif}\;y \leq 6 \cdot 10^{-54}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{0.5 \cdot x + \frac{1}{x}}{z}\\ \end{array} \]
Alternative 3
Error1.3
Cost968
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-23}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{-54}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;y \cdot \frac{0.5 \cdot x + \frac{1}{x}}{z}\\ \end{array} \]
Alternative 4
Error2.4
Cost584
\[\begin{array}{l} t_0 := \frac{y}{z \cdot x}\\ \mathbf{if}\;z \leq -1.85 \cdot 10^{-33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-148}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error8.4
Cost320
\[\frac{y}{z \cdot x} \]

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))