?

Average Error: 10.1 → 0.2
Time: 13.3s
Precision: binary64
Cost: 1864

?

\[\frac{x + y \cdot \left(z - x\right)}{z} \]
\[\begin{array}{l} t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;y \cdot \frac{z - x}{z}\\ \mathbf{elif}\;t_0 \leq 4 \cdot 10^{+302}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (+ x (* y (- z x))) z)))
   (if (<= t_0 (- INFINITY))
     (* y (/ (- z x) z))
     (if (<= t_0 4e+302) t_0 (/ y (/ z (- z x)))))))
double code(double x, double y, double z) {
	return (x + (y * (z - x))) / z;
}
double code(double x, double y, double z) {
	double t_0 = (x + (y * (z - x))) / z;
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = y * ((z - x) / z);
	} else if (t_0 <= 4e+302) {
		tmp = t_0;
	} else {
		tmp = y / (z / (z - x));
	}
	return tmp;
}
public static double code(double x, double y, double z) {
	return (x + (y * (z - x))) / z;
}
public static double code(double x, double y, double z) {
	double t_0 = (x + (y * (z - x))) / z;
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = y * ((z - x) / z);
	} else if (t_0 <= 4e+302) {
		tmp = t_0;
	} else {
		tmp = y / (z / (z - x));
	}
	return tmp;
}
def code(x, y, z):
	return (x + (y * (z - x))) / z
def code(x, y, z):
	t_0 = (x + (y * (z - x))) / z
	tmp = 0
	if t_0 <= -math.inf:
		tmp = y * ((z - x) / z)
	elif t_0 <= 4e+302:
		tmp = t_0
	else:
		tmp = y / (z / (z - x))
	return tmp
function code(x, y, z)
	return Float64(Float64(x + Float64(y * Float64(z - x))) / z)
end
function code(x, y, z)
	t_0 = Float64(Float64(x + Float64(y * Float64(z - x))) / z)
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = Float64(y * Float64(Float64(z - x) / z));
	elseif (t_0 <= 4e+302)
		tmp = t_0;
	else
		tmp = Float64(y / Float64(z / Float64(z - x)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x + (y * (z - x))) / z;
end
function tmp_2 = code(x, y, z)
	t_0 = (x + (y * (z - x))) / z;
	tmp = 0.0;
	if (t_0 <= -Inf)
		tmp = y * ((z - x) / z);
	elseif (t_0 <= 4e+302)
		tmp = t_0;
	else
		tmp = y / (z / (z - x));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+302], t$95$0, N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\frac{x + y \cdot \left(z - x\right)}{z}
\begin{array}{l}
t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\

\mathbf{elif}\;t_0 \leq 4 \cdot 10^{+302}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original10.1
Target0.0
Herbie0.2
\[\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}} \]

Derivation?

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

    1. Initial program 64.0

      \[\frac{x + y \cdot \left(z - x\right)}{z} \]
    2. Taylor expanded in y around inf 64.0

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

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

      [Start]64.0

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

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

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

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

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

    if -inf.0 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 4.0000000000000003e302

    1. Initial program 0.1

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

    if 4.0000000000000003e302 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z)

    1. Initial program 61.4

      \[\frac{x + y \cdot \left(z - x\right)}{z} \]
    2. Taylor expanded in y around inf 62.5

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - x\right)}{z}} \]
    3. Simplified1.2

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

      [Start]62.5

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + y \cdot \left(z - x\right)}{z} \leq -\infty:\\ \;\;\;\;y \cdot \frac{z - x}{z}\\ \mathbf{elif}\;\frac{x + y \cdot \left(z - x\right)}{z} \leq 4 \cdot 10^{+302}:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \end{array} \]

Alternatives

Alternative 1
Error21.0
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \cdot 10^{-81}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 1.2 \cdot 10^{-212}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{-159}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.35 \cdot 10^{-23}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 2
Error7.9
Cost712
\[\begin{array}{l} t_0 := x \cdot \frac{1 - y}{z}\\ \mathbf{if}\;x \leq -3.6 \cdot 10^{+139}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{+129}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.9
Cost712
\[\begin{array}{l} t_0 := y \cdot \frac{z - x}{z}\\ \mathbf{if}\;y \leq -16500000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.065:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.9
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -16500000000000:\\ \;\;\;\;y \cdot \frac{z - x}{z}\\ \mathbf{elif}\;y \leq 0.065:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \end{array} \]
Alternative 5
Error1.8
Cost708
\[\begin{array}{l} \mathbf{if}\;y \leq -8.2 \cdot 10^{+15}:\\ \;\;\;\;y \cdot \frac{z - x}{z}\\ \mathbf{else}:\\ \;\;\;\;y + x \cdot \frac{1 - y}{z}\\ \end{array} \]
Alternative 6
Error9.1
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq 2.6 \cdot 10^{+20}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 3.05 \cdot 10^{+39}:\\ \;\;\;\;x \cdot \frac{y}{-z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 7
Error9.1
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq 1.35 \cdot 10^{+22}:\\ \;\;\;\;y + \frac{x}{z}\\ \mathbf{elif}\;y \leq 7.6 \cdot 10^{+39}:\\ \;\;\;\;\frac{-x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 8
Error8.8
Cost320
\[y + \frac{x}{z} \]
Alternative 9
Error31.4
Cost64
\[y \]

Error

Reproduce?

herbie shell --seed 2023064 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
  :precision binary64

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

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