?

Average Accuracy: 91.9% → 96.2%
Time: 10.2s
Precision: binary64
Cost: 6976

?

\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\left|\frac{\left(x + 4\right) - x \cdot z}{y}\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) (* x z)) y)))
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) - (x * z)) / y));
}
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) - (x * z)) / y))
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) - (x * z)) / y));
}
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) - (x * z)) / y))
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) - Float64(x * z)) / y))
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) - (x * z)) / y));
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] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 90.9%

    \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  2. Applied egg-rr97.3%

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

    [Start]90.9

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

    associate-*l/ [=>]92.6

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

    sub-div [=>]97.3

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

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

Alternatives

Alternative 1
Accuracy69.2%
Cost7512
\[\begin{array}{l} t_0 := \left|x \cdot \frac{z}{y}\right|\\ t_1 := \left|z \cdot \frac{x}{y}\right|\\ t_2 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1.7 \cdot 10^{+185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.4 \cdot 10^{+103}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2 \cdot 10^{-52}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-17}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{+165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{+282}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Accuracy68.0%
Cost7380
\[\begin{array}{l} t_0 := \left|x \cdot \frac{z}{y}\right|\\ t_1 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -2.15 \cdot 10^{+185}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-53}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-19}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{+161}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy86.8%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -6.2 \cdot 10^{-53} \lor \neg \left(x \leq 1.4 \cdot 10^{-17}\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \]
Alternative 4
Accuracy85.8%
Cost6984
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{+39}:\\ \;\;\;\;\left|z \cdot \frac{x}{y}\right|\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+77}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \end{array} \]
Alternative 5
Accuracy69.3%
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 6
Accuracy40.0%
Cost6592
\[\left|\frac{4}{y}\right| \]

Error

Reproduce?

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