?

Average Error: 13.1 → 0.3
Time: 6.6s
Precision: binary64
Cost: 2513

?

\[\frac{x \cdot \left(y + z\right)}{z} \]
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;t_0 \leq -1 \cdot 10^{+56} \lor \neg \left(t_0 \leq 5 \cdot 10^{-49}\right) \land t_0 \leq 2 \cdot 10^{+299}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (+ y z)) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x (+ y z)) z)))
   (if (<= t_0 (- INFINITY))
     (/ x (/ z (+ y z)))
     (if (or (<= t_0 -1e+56) (and (not (<= t_0 5e-49)) (<= t_0 2e+299)))
       t_0
       (+ x (* x (/ y z)))))))
double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
double code(double x, double y, double z) {
	double t_0 = (x * (y + z)) / z;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = x / (z / (y + z));
	} else if ((t_0 <= -1e+56) || (!(t_0 <= 5e-49) && (t_0 <= 2e+299))) {
		tmp = t_0;
	} else {
		tmp = x + (x * (y / z));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return (x * (y + z)) / z;
}
public static double code(double x, double y, double z) {
	double t_0 = (x * (y + z)) / z;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = x / (z / (y + z));
	} else if ((t_0 <= -1e+56) || (!(t_0 <= 5e-49) && (t_0 <= 2e+299))) {
		tmp = t_0;
	} else {
		tmp = x + (x * (y / z));
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y + z)) / z
def code(x, y, z):
	t_0 = (x * (y + z)) / z
	tmp = 0
	if t_0 <= -math.inf:
		tmp = x / (z / (y + z))
	elif (t_0 <= -1e+56) or (not (t_0 <= 5e-49) and (t_0 <= 2e+299)):
		tmp = t_0
	else:
		tmp = x + (x * (y / z))
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y + z)) / z)
end
function code(x, y, z)
	t_0 = Float64(Float64(x * Float64(y + z)) / z)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(x / Float64(z / Float64(y + z)));
	elseif ((t_0 <= -1e+56) || (!(t_0 <= 5e-49) && (t_0 <= 2e+299)))
		tmp = t_0;
	else
		tmp = Float64(x + Float64(x * Float64(y / z)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y + z)) / z;
end
function tmp_2 = code(x, y, z)
	t_0 = (x * (y + z)) / z;
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = x / (z / (y + z));
	elseif ((t_0 <= -1e+56) || (~((t_0 <= 5e-49)) && (t_0 <= 2e+299)))
		tmp = t_0;
	else
		tmp = x + (x * (y / z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(x / N[(z / N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -1e+56], And[N[Not[LessEqual[t$95$0, 5e-49]], $MachinePrecision], LessEqual[t$95$0, 2e+299]]], t$95$0, N[(x + N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot \left(y + z\right)}{z}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y + z\right)}{z}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{x}{\frac{z}{y + z}}\\

\mathbf{elif}\;t_0 \leq -1 \cdot 10^{+56} \lor \neg \left(t_0 \leq 5 \cdot 10^{-49}\right) \land t_0 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original13.1
Target3.2
Herbie0.3
\[\frac{x}{\frac{z}{y + z}} \]

Derivation?

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 x (+.f64 y z)) z) < -inf.0

    1. Initial program 64.0

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Simplified0.1

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

      [Start]64.0

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

      associate-/l* [=>]0.1

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

    if -inf.0 < (/.f64 (*.f64 x (+.f64 y z)) z) < -1.00000000000000009e56 or 4.9999999999999999e-49 < (/.f64 (*.f64 x (+.f64 y z)) z) < 2.0000000000000001e299

    1. Initial program 0.2

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

    if -1.00000000000000009e56 < (/.f64 (*.f64 x (+.f64 y z)) z) < 4.9999999999999999e-49 or 2.0000000000000001e299 < (/.f64 (*.f64 x (+.f64 y z)) z)

    1. Initial program 15.5

      \[\frac{x \cdot \left(y + z\right)}{z} \]
    2. Simplified0.3

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

      [Start]15.5

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

      associate-*r/ [<=]0.3

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

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

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

      [Start]15.5

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

      associate-*l/ [<=]0.3

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

      *-lft-identity [<=]0.3

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

      associate-*r/ [=>]0.3

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

      associate-*l/ [<=]0.4

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

      distribute-lft-in [=>]0.4

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

      lft-mult-inverse [=>]0.3

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

      distribute-rgt1-in [<=]0.3

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

      associate-*l/ [=>]0.3

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

      *-lft-identity [=>]0.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y + z\right)}{z} \leq -\infty:\\ \;\;\;\;\frac{x}{\frac{z}{y + z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y + z\right)}{z} \leq -1 \cdot 10^{+56} \lor \neg \left(\frac{x \cdot \left(y + z\right)}{z} \leq 5 \cdot 10^{-49}\right) \land \frac{x \cdot \left(y + z\right)}{z} \leq 2 \cdot 10^{+299}:\\ \;\;\;\;\frac{x \cdot \left(y + z\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error4.3
Cost1241
\[\begin{array}{l} t_0 := x \cdot \frac{y + z}{z}\\ t_1 := y \cdot \frac{x}{z}\\ \mathbf{if}\;z \leq -2.25 \cdot 10^{-208}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{-242}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -9.2 \cdot 10^{-299}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 5.1 \cdot 10^{-244}:\\ \;\;\;\;\frac{x \cdot y}{z}\\ \mathbf{elif}\;z \leq 2.55 \cdot 10^{-160} \lor \neg \left(z \leq 6.5 \cdot 10^{-111}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error3.9
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{+14} \lor \neg \left(y \leq 6.1 \cdot 10^{+91}\right):\\ \;\;\;\;\left(y + z\right) \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array} \]
Alternative 3
Error1.8
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-8} \lor \neg \left(y \leq 2 \cdot 10^{+89}\right):\\ \;\;\;\;x + y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y + z}{z}\\ \end{array} \]
Alternative 4
Error1.8
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-7} \lor \neg \left(y \leq 2 \cdot 10^{+89}\right):\\ \;\;\;\;x + y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x + x \cdot \frac{y}{z}\\ \end{array} \]
Alternative 5
Error18.4
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+33} \lor \neg \left(y \leq 8.8 \cdot 10^{+139}\right):\\ \;\;\;\;y \cdot \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error25.0
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023031 
(FPCore (x y z)
  :name "Numeric.SpecFunctions:choose from math-functions-0.1.5.2"
  :precision binary64

  :herbie-target
  (/ x (/ z (+ y z)))

  (/ (* x (+ y z)) z))