?

Average Accuracy: 97.5% → 99.6%
Time: 13.0s
Precision: binary64
Cost: 7241

?

\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} \mathbf{if}\;x \leq -3.55 \cdot 10^{+64} \lor \neg \left(x \leq 1.15 \cdot 10^{+20}\right):\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\ \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -3.55e+64) (not (<= x 1.15e+20)))
   (fabs (/ (- 1.0 z) (/ y x)))
   (fabs (/ (- (+ 4.0 x) (* 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) {
	double tmp;
	if ((x <= -3.55e+64) || !(x <= 1.15e+20)) {
		tmp = fabs(((1.0 - z) / (y / x)));
	} else {
		tmp = fabs((((4.0 + x) - (x * z)) / y));
	}
	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 = 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
    real(8) :: tmp
    if ((x <= (-3.55d+64)) .or. (.not. (x <= 1.15d+20))) then
        tmp = abs(((1.0d0 - z) / (y / x)))
    else
        tmp = abs((((4.0d0 + x) - (x * z)) / y))
    end if
    code = tmp
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) {
	double tmp;
	if ((x <= -3.55e+64) || !(x <= 1.15e+20)) {
		tmp = Math.abs(((1.0 - z) / (y / x)));
	} else {
		tmp = Math.abs((((4.0 + x) - (x * z)) / y));
	}
	return tmp;
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
def code(x, y, z):
	tmp = 0
	if (x <= -3.55e+64) or not (x <= 1.15e+20):
		tmp = math.fabs(((1.0 - z) / (y / x)))
	else:
		tmp = math.fabs((((4.0 + x) - (x * z)) / y))
	return tmp
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)
	tmp = 0.0
	if ((x <= -3.55e+64) || !(x <= 1.15e+20))
		tmp = abs(Float64(Float64(1.0 - z) / Float64(y / x)));
	else
		tmp = abs(Float64(Float64(Float64(4.0 + x) - Float64(x * z)) / y));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = abs((((x + 4.0) / y) - ((x / y) * z)));
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((x <= -3.55e+64) || ~((x <= 1.15e+20)))
		tmp = abs(((1.0 - z) / (y / x)));
	else
		tmp = abs((((4.0 + x) - (x * z)) / y));
	end
	tmp_2 = tmp;
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_] := If[Or[LessEqual[x, -3.55e+64], N[Not[LessEqual[x, 1.15e+20]], $MachinePrecision]], N[Abs[N[(N[(1.0 - z), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[(4.0 + x), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
\mathbf{if}\;x \leq -3.55 \cdot 10^{+64} \lor \neg \left(x \leq 1.15 \cdot 10^{+20}\right):\\
\;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if x < -3.55000000000000029e64 or 1.15e20 < x

    1. Initial program 99.8%

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

      \[\leadsto \color{blue}{\left|\frac{x - \mathsf{fma}\left(x, z, -4\right)}{y}\right|} \]
      Proof

      [Start]99.8

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

      fabs-neg [<=]99.8

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

      sub-neg [=>]99.8

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

      distribute-neg-in [=>]99.8

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

      sub-neg [<=]99.8

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

      distribute-neg-frac [=>]99.8

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

      associate-*l/ [=>]84.2

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

      distribute-neg-frac [=>]84.2

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

      neg-mul-1 [=>]84.2

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

      associate-*l/ [<=]83.9

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

      neg-mul-1 [=>]83.9

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

      associate-*l/ [<=]83.9

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

      distribute-lft-out-- [=>]83.9

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

      fabs-mul [=>]83.9

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

      fabs-sub [=>]83.9

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

      fabs-mul [<=]83.9

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

      associate-*l/ [=>]84.2

      \[ \left|\color{blue}{\frac{-1 \cdot \left(x \cdot z - \left(x + 4\right)\right)}{y}}\right| \]
    3. Taylor expanded in x around inf 84.2%

      \[\leadsto \left|\color{blue}{\frac{\left(1 - z\right) \cdot x}{y}}\right| \]
    4. Simplified99.6%

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

      [Start]84.2

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

      associate-/l* [=>]99.6

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

    if -3.55000000000000029e64 < x < 1.15e20

    1. Initial program 96.5%

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

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

      [Start]96.5

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

      associate-*l/ [=>]99.6

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

      sub-div [=>]99.6

      \[ \left|\color{blue}{\frac{\left(x + 4\right) - x \cdot z}{y}}\right| \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.55 \cdot 10^{+64} \lor \neg \left(x \leq 1.15 \cdot 10^{+20}\right):\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(4 + x\right) - x \cdot z}{y}\right|\\ \end{array} \]

Alternatives

Alternative 1
Accuracy81.5%
Cost7250
\[\begin{array}{l} \mathbf{if}\;z \leq -8.5 \cdot 10^{+178} \lor \neg \left(z \leq -1.3 \cdot 10^{+144} \lor \neg \left(z \leq -1.4 \cdot 10^{+45}\right) \land z \leq 28000000\right):\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \]
Alternative 2
Accuracy98.4%
Cost7241
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y} - \frac{x \cdot z}{y}\right|\\ \end{array} \]
Alternative 3
Accuracy97.5%
Cost7232
\[\left|\left(\frac{4}{y} + \frac{x}{y}\right) - \frac{x}{y} \cdot z\right| \]
Alternative 4
Accuracy84.9%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -6.9 \cdot 10^{-31} \lor \neg \left(x \leq 2.5 \cdot 10^{+20}\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{-4 - x}{y}\right|\\ \end{array} \]
Alternative 5
Accuracy84.9%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -2.75 \cdot 10^{-31} \lor \neg \left(x \leq 2.5 \cdot 10^{+20}\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\ \end{array} \]
Alternative 6
Accuracy85.1%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -3.1 \cdot 10^{-37} \lor \neg \left(x \leq 210000\right):\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y} + \frac{x}{y}\right|\\ \end{array} \]
Alternative 7
Accuracy98.4%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 3.8\right):\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4 - x \cdot z}{y}\right|\\ \end{array} \]
Alternative 8
Accuracy97.5%
Cost7104
\[\left|\frac{4}{y} + \frac{x}{y} \cdot \left(1 - z\right)\right| \]
Alternative 9
Accuracy97.5%
Cost7104
\[\left|\frac{x}{y} \cdot z - \frac{4 + x}{y}\right| \]
Alternative 10
Accuracy69.1%
Cost6988
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -2.85 \cdot 10^{+110}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -6.9 \cdot 10^{-31}:\\ \;\;\;\;\left|x \cdot \frac{z}{y}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Accuracy68.8%
Cost6988
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -2.55 \cdot 10^{+113}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-37}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Accuracy68.8%
Cost6988
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -7.2 \cdot 10^{+111}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-37}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 13
Accuracy70.2%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -1.55 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{4}{y}\right|\\ \end{array} \]
Alternative 14
Accuracy48.8%
Cost6592
\[\left|\frac{4}{y}\right| \]

Error

Reproduce?

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