?

Average Error: 7.7 → 0.6
Time: 17.7s
Precision: binary64
Cost: 7112

?

\[\frac{\cosh x \cdot \frac{y}{x}}{z} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+20}:\\ \;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+53}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} + x \cdot \left(0.5 \cdot \frac{y}{z}\right)\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* (cosh x) (/ y x)) z))
(FPCore (x y z)
 :precision binary64
 (if (<= y -3.3e+20)
   (* (cosh x) (/ y (* x z)))
   (if (<= y 1.05e+53)
     (/ (* (cosh x) (/ y x)) z)
     (+ (/ (/ y z) x) (* x (* 0.5 (/ y z)))))))
double code(double x, double y, double z) {
	return (cosh(x) * (y / x)) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if (y <= -3.3e+20) {
		tmp = cosh(x) * (y / (x * z));
	} else if (y <= 1.05e+53) {
		tmp = (cosh(x) * (y / x)) / z;
	} else {
		tmp = ((y / z) / x) + (x * (0.5 * (y / 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) :: tmp
    if (y <= (-3.3d+20)) then
        tmp = cosh(x) * (y / (x * z))
    else if (y <= 1.05d+53) then
        tmp = (cosh(x) * (y / x)) / z
    else
        tmp = ((y / z) / x) + (x * (0.5d0 * (y / 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 tmp;
	if (y <= -3.3e+20) {
		tmp = Math.cosh(x) * (y / (x * z));
	} else if (y <= 1.05e+53) {
		tmp = (Math.cosh(x) * (y / x)) / z;
	} else {
		tmp = ((y / z) / x) + (x * (0.5 * (y / z)));
	}
	return tmp;
}
def code(x, y, z):
	return (math.cosh(x) * (y / x)) / z
def code(x, y, z):
	tmp = 0
	if y <= -3.3e+20:
		tmp = math.cosh(x) * (y / (x * z))
	elif y <= 1.05e+53:
		tmp = (math.cosh(x) * (y / x)) / z
	else:
		tmp = ((y / z) / x) + (x * (0.5 * (y / z)))
	return tmp
function code(x, y, z)
	return Float64(Float64(cosh(x) * Float64(y / x)) / z)
end
function code(x, y, z)
	tmp = 0.0
	if (y <= -3.3e+20)
		tmp = Float64(cosh(x) * Float64(y / Float64(x * z)));
	elseif (y <= 1.05e+53)
		tmp = Float64(Float64(cosh(x) * Float64(y / x)) / z);
	else
		tmp = Float64(Float64(Float64(y / z) / x) + Float64(x * Float64(0.5 * Float64(y / 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)
	tmp = 0.0;
	if (y <= -3.3e+20)
		tmp = cosh(x) * (y / (x * z));
	elseif (y <= 1.05e+53)
		tmp = (cosh(x) * (y / x)) / z;
	else
		tmp = ((y / z) / x) + (x * (0.5 * (y / 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_] := If[LessEqual[y, -3.3e+20], N[(N[Cosh[x], $MachinePrecision] * N[(y / N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e+53], N[(N[(N[Cosh[x], $MachinePrecision] * N[(y / x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(N[(y / z), $MachinePrecision] / x), $MachinePrecision] + N[(x * N[(0.5 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{\cosh x \cdot \frac{y}{x}}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -3.3 \cdot 10^{+20}:\\
\;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{y}{z}}{x} + x \cdot \left(0.5 \cdot \frac{y}{z}\right)\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.7
Target0.5
Herbie0.6
\[\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 y < -3.3e20

    1. Initial program 22.9

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

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

      [Start]22.9

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

      rational.json-simplify-2 [=>]22.9

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

      rational.json-simplify-49 [=>]22.8

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

      rational.json-simplify-47 [=>]0.3

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

    if -3.3e20 < y < 1.0500000000000001e53

    1. Initial program 0.6

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

    if 1.0500000000000001e53 < y

    1. Initial program 27.6

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

      \[\leadsto \frac{\color{blue}{\frac{y}{x} + 0.5 \cdot \left(y \cdot x\right)}}{z} \]
    3. Simplified28.6

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

      [Start]28.6

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

      rational.json-simplify-43 [=>]28.6

      \[ \frac{\frac{y}{x} + \color{blue}{y \cdot \left(x \cdot 0.5\right)}}{z} \]
    4. Applied egg-rr1.5

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

      \[\leadsto \color{blue}{\frac{y}{z \cdot x} + 0.5 \cdot \frac{y \cdot x}{z}} \]
    6. Simplified1.4

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

      [Start]1.4

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

      rational.json-simplify-46 [=>]1.4

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

      rational.json-simplify-49 [=>]1.4

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

      rational.json-simplify-43 [=>]1.4

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

      rational.json-simplify-2 [=>]1.4

      \[ \frac{\frac{y}{z}}{x} + x \cdot \color{blue}{\left(0.5 \cdot \frac{y}{z}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{+20}:\\ \;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+53}:\\ \;\;\;\;\frac{\cosh x \cdot \frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} + x \cdot \left(0.5 \cdot \frac{y}{z}\right)\\ \end{array} \]

Alternatives

Alternative 1
Error1.1
Cost7112
\[\begin{array}{l} t_0 := \cosh x \cdot \frac{y}{x \cdot z}\\ \mathbf{if}\;z \leq -3.1 \cdot 10^{-113}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-47}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.7
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{-7}:\\ \;\;\;\;\cosh x \cdot \frac{y}{x \cdot z}\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{+53}:\\ \;\;\;\;\frac{y}{x} \cdot \frac{\cosh x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} + x \cdot \left(0.5 \cdot \frac{y}{z}\right)\\ \end{array} \]
Alternative 3
Error0.7
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{\cosh x}{z}}{x} \cdot y\\ \mathbf{elif}\;y \leq 10^{-43}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\cosh x \cdot \frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 4
Error1.5
Cost1096
\[\begin{array}{l} t_0 := \frac{y}{x \cdot z} + 0.5 \cdot \frac{x}{\frac{z}{y}}\\ \mathbf{if}\;z \leq -3.5 \cdot 10^{-112}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-12}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.2
Cost1096
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{y}{x \cdot z} + 0.5 \cdot \frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+53}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} + x \cdot \left(0.5 \cdot \frac{y}{z}\right)\\ \end{array} \]
Alternative 6
Error1.3
Cost968
\[\begin{array}{l} t_0 := \frac{y}{z \cdot x}\\ \mathbf{if}\;z \leq -7 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 10^{-7}:\\ \;\;\;\;\frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error1.1
Cost968
\[\begin{array}{l} t_0 := \frac{y}{z} \cdot \left(x \cdot 0.5 + \frac{1}{x}\right)\\ \mathbf{if}\;y \leq -1 \cdot 10^{-5}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{+14}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error1.2
Cost968
\[\begin{array}{l} \mathbf{if}\;z \leq -4 \cdot 10^{+18}:\\ \;\;\;\;\left(\frac{\frac{1}{x}}{z} + 0.5 \cdot \frac{x}{z}\right) \cdot y\\ \mathbf{elif}\;z \leq 5.6 \cdot 10^{-8}:\\ \;\;\;\;\frac{\frac{y}{x} + y \cdot \left(x \cdot 0.5\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \end{array} \]
Alternative 9
Error1.8
Cost584
\[\begin{array}{l} t_0 := \frac{y}{z \cdot x}\\ \mathbf{if}\;z \leq -4.1 \cdot 10^{-91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 10^{-14}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error1.6
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{+21}:\\ \;\;\;\;\frac{y}{z \cdot x}\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+53}:\\ \;\;\;\;\frac{\frac{y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x}\\ \end{array} \]
Alternative 11
Error7.9
Cost320
\[\frac{y}{z \cdot x} \]

Error

Reproduce?

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