?

Average Error: 2.63% → 2.9%
Time: 9.2s
Precision: binary64
Cost: 7104

?

\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\left|\frac{x + 4}{y} - \frac{z}{\frac{y}{x}}\right| \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (/ z (/ y x)))))
double code(double x, double y, double z) {
	return fabs((((x + 4.0) / y) - ((x / y) * z)));
}
double code(double x, double y, double z) {
	return fabs((((x + 4.0) / y) - (z / (y / x))));
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = abs((((x + 4.0d0) / y) - ((x / y) * 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
    code = abs((((x + 4.0d0) / y) - (z / (y / x))))
end function
public static double code(double x, double y, double z) {
	return Math.abs((((x + 4.0) / y) - ((x / y) * z)));
}
public static double code(double x, double y, double z) {
	return Math.abs((((x + 4.0) / y) - (z / (y / x))));
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - (z / (y / x))))
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(Float64(x / y) * z)))
end
function code(x, y, z)
	return abs(Float64(Float64(Float64(x + 4.0) / y) - Float64(z / Float64(y / x))))
end
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) / y) - ((x / y) * z)));
end
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) / y) - (z / (y / x))));
end
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_, y_, z_] := N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision] - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\left|\frac{x + 4}{y} - \frac{z}{\frac{y}{x}}\right|

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 2.63

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Simplified2.9

    \[\leadsto \color{blue}{\left|\frac{x + 4}{y} - \frac{z}{\frac{y}{x}}\right|} \]
    Proof

    [Start]2.63

    \[ \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]

    *-lft-identity [<=]2.63

    \[ \color{blue}{1 \cdot \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|} \]

    metadata-eval [<=]2.63

    \[ \color{blue}{\left|-1\right|} \cdot \left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]

    fabs-sub [=>]2.63

    \[ \left|-1\right| \cdot \color{blue}{\left|\frac{x}{y} \cdot z - \frac{x + 4}{y}\right|} \]

    fabs-mul [<=]2.63

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

    neg-mul-1 [<=]2.63

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

    sub0-neg [<=]2.63

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

    associate-+l- [<=]2.63

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

    neg-sub0 [<=]2.63

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

    +-commutative [<=]2.63

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

    sub-neg [<=]2.63

    \[ \left|\color{blue}{\frac{x + 4}{y} - \frac{x}{y} \cdot z}\right| \]

    associate-*l/ [=>]5.56

    \[ \left|\frac{x + 4}{y} - \color{blue}{\frac{x \cdot z}{y}}\right| \]

    *-commutative [=>]5.56

    \[ \left|\frac{x + 4}{y} - \frac{\color{blue}{z \cdot x}}{y}\right| \]

    associate-/l* [=>]2.9

    \[ \left|\frac{x + 4}{y} - \color{blue}{\frac{z}{\frac{y}{x}}}\right| \]
  3. Final simplification2.9

    \[\leadsto \left|\frac{x + 4}{y} - \frac{z}{\frac{y}{x}}\right| \]

Alternatives

Alternative 1
Error19.85%
Cost7248
\[\begin{array}{l} t_0 := \left|\frac{z}{\frac{y}{x}}\right|\\ t_1 := \left|\frac{x + 4}{y}\right|\\ \mathbf{if}\;z \leq -9.6 \cdot 10^{+203}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -5.2 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.7 \cdot 10^{+32}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+116}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error14.43%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -3000 \lor \neg \left(x \leq 8.2 \cdot 10^{-7}\right):\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \end{array} \]
Alternative 3
Error2.91%
Cost7108
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+21}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]
Alternative 4
Error2.63%
Cost7104
\[\left|\frac{x + 4}{y} - z \cdot \frac{x}{y}\right| \]
Alternative 5
Error32.06%
Cost6988
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1.75 \cdot 10^{+145}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2200:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error30.16%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -10.5 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]
Alternative 7
Error51.71%
Cost6592
\[\left|\frac{4}{y}\right| \]

Error

Reproduce?

herbie shell --seed 2023121 
(FPCore (x y z)
  :name "fabs fraction 1"
  :precision binary64
  (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))