?

Average Accuracy: 97.7% → 99.5%
Time: 9.6s
Precision: binary64
Cost: 7241

?

\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+50} \lor \neg \left(x \leq 3.3 \cdot 10^{+74}\right):\\ \;\;\;\;\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} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= x -3.6e+50) (not (<= x 3.3e+74)))
   (fabs (* (/ x y) (- 1.0 z)))
   (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) {
	double tmp;
	if ((x <= -3.6e+50) || !(x <= 3.3e+74)) {
		tmp = fabs(((x / y) * (1.0 - z)));
	} else {
		tmp = fabs((((x + 4.0) - (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.6d+50)) .or. (.not. (x <= 3.3d+74))) then
        tmp = abs(((x / y) * (1.0d0 - z)))
    else
        tmp = abs((((x + 4.0d0) - (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.6e+50) || !(x <= 3.3e+74)) {
		tmp = Math.abs(((x / y) * (1.0 - z)));
	} else {
		tmp = Math.abs((((x + 4.0) - (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.6e+50) or not (x <= 3.3e+74):
		tmp = math.fabs(((x / y) * (1.0 - z)))
	else:
		tmp = math.fabs((((x + 4.0) - (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.6e+50) || !(x <= 3.3e+74))
		tmp = abs(Float64(Float64(x / y) * Float64(1.0 - z)));
	else
		tmp = abs(Float64(Float64(Float64(x + 4.0) - 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.6e+50) || ~((x <= 3.3e+74)))
		tmp = abs(((x / y) * (1.0 - z)));
	else
		tmp = abs((((x + 4.0) - (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.6e+50], N[Not[LessEqual[x, 3.3e+74]], $MachinePrecision]], N[Abs[N[(N[(x / y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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|
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+50} \lor \neg \left(x \leq 3.3 \cdot 10^{+74}\right):\\
\;\;\;\;\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}

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.59999999999999986e50 or 3.3000000000000002e74 < x

    1. Initial program 99.8%

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

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

      [Start]99.8

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

      *-lft-identity [<=]99.8

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

      metadata-eval [<=]99.8

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

      fabs-sub [=>]99.8

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

      fabs-mul [<=]99.8

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

      neg-mul-1 [<=]99.8

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

      sub0-neg [<=]99.8

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

      associate-+l- [<=]99.8

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

      neg-sub0 [<=]99.8

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

      +-commutative [<=]99.8

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

      sub-neg [<=]99.8

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

      associate-*l/ [=>]82.7

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

      *-commutative [=>]82.7

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

      associate-/l* [=>]99.8

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

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

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

      [Start]99.6

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

      *-commutative [=>]99.6

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

      sub-neg [=>]99.6

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

      mul-1-neg [<=]99.6

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

      +-commutative [=>]99.6

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

      associate-*r/ [=>]99.6

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

      neg-mul-1 [<=]99.6

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

      remove-double-neg [<=]99.6

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

      distribute-rgt-in [=>]99.6

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

      neg-mul-1 [=>]99.6

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

      remove-double-neg [=>]99.6

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

      associate-*r/ [<=]99.6

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

      associate-*r* [<=]99.6

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

      associate-*l/ [=>]82.5

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

      associate-*l/ [=>]82.7

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

      associate-*r/ [<=]82.7

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

      *-lft-identity [=>]82.7

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

      associate-*r/ [<=]99.8

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

      associate-*r* [=>]99.8

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

      neg-mul-1 [<=]99.8

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

      distribute-lft1-in [=>]99.8

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

    if -3.59999999999999986e50 < x < 3.3000000000000002e74

    1. Initial program 96.9%

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

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

      [Start]96.9

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

      associate-*l/ [=>]99.3

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

      sub-div [=>]99.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.6 \cdot 10^{+50} \lor \neg \left(x \leq 3.3 \cdot 10^{+74}\right):\\ \;\;\;\;\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} \]

Alternatives

Alternative 1
Accuracy69.3%
Cost7380
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ t_1 := \left|\frac{x}{y} \cdot z\right|\\ \mathbf{if}\;x \leq -1.05 \cdot 10^{+87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{+70}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.52:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-30}:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{+78}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Accuracy69.3%
Cost7380
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1.05 \cdot 10^{+87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -2.15 \cdot 10^{+70}:\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;x \leq -1.52:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-30}:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{elif}\;x \leq 5.7 \cdot 10^{+79}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Accuracy85.1%
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-24} \lor \neg \left(x \leq 6.6 \cdot 10^{-60}\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \end{array} \]
Alternative 4
Accuracy85.2%
Cost7112
\[\begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{-25}:\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-60}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \end{array} \]
Alternative 5
Accuracy85.2%
Cost7112
\[\begin{array}{l} \mathbf{if}\;x \leq -4.9 \cdot 10^{-26}:\\ \;\;\;\;\left|\frac{x}{y} \cdot \left(1 - z\right)\right|\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{-60}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{1 - z}{\frac{y}{x}}\right|\\ \end{array} \]
Alternative 6
Accuracy97.7%
Cost7104
\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
Alternative 7
Accuracy81.9%
Cost6984
\[\begin{array}{l} \mathbf{if}\;z \leq -3.35 \cdot 10^{+65}:\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;z \leq 8.5 \cdot 10^{+150}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \end{array} \]
Alternative 8
Accuracy70.1%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -1.52 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \end{array} \]
Alternative 9
Accuracy48.8%
Cost6592
\[\frac{4}{\left|y\right|} \]

Error

Reproduce?

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