?

Average Error: 1.6 → 0.4
Time: 8.4s
Precision: binary64
Cost: 8648

?

\[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
\[\begin{array}{l} t_0 := \frac{x + 4}{y}\\ t_1 := t_0 - \frac{x}{y} \cdot z\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{+78}:\\ \;\;\;\;\left|t_0 - \frac{z}{\frac{y}{x}}\right|\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+81}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|t_1\right|\\ \end{array} \]
(FPCore (x y z) :precision binary64 (fabs (- (/ (+ x 4.0) y) (* (/ x y) z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (+ x 4.0) y)) (t_1 (- t_0 (* (/ x y) z))))
   (if (<= t_1 -2e+78)
     (fabs (- t_0 (/ z (/ y x))))
     (if (<= t_1 5e+81) (fabs (/ (- (+ x 4.0) (* x z)) y)) (fabs t_1)))))
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 t_0 = (x + 4.0) / y;
	double t_1 = t_0 - ((x / y) * z);
	double tmp;
	if (t_1 <= -2e+78) {
		tmp = fabs((t_0 - (z / (y / x))));
	} else if (t_1 <= 5e+81) {
		tmp = fabs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = fabs(t_1);
	}
	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) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x + 4.0d0) / y
    t_1 = t_0 - ((x / y) * z)
    if (t_1 <= (-2d+78)) then
        tmp = abs((t_0 - (z / (y / x))))
    else if (t_1 <= 5d+81) then
        tmp = abs((((x + 4.0d0) - (x * z)) / y))
    else
        tmp = abs(t_1)
    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 t_0 = (x + 4.0) / y;
	double t_1 = t_0 - ((x / y) * z);
	double tmp;
	if (t_1 <= -2e+78) {
		tmp = Math.abs((t_0 - (z / (y / x))));
	} else if (t_1 <= 5e+81) {
		tmp = Math.abs((((x + 4.0) - (x * z)) / y));
	} else {
		tmp = Math.abs(t_1);
	}
	return tmp;
}
def code(x, y, z):
	return math.fabs((((x + 4.0) / y) - ((x / y) * z)))
def code(x, y, z):
	t_0 = (x + 4.0) / y
	t_1 = t_0 - ((x / y) * z)
	tmp = 0
	if t_1 <= -2e+78:
		tmp = math.fabs((t_0 - (z / (y / x))))
	elif t_1 <= 5e+81:
		tmp = math.fabs((((x + 4.0) - (x * z)) / y))
	else:
		tmp = math.fabs(t_1)
	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)
	t_0 = Float64(Float64(x + 4.0) / y)
	t_1 = Float64(t_0 - Float64(Float64(x / y) * z))
	tmp = 0.0
	if (t_1 <= -2e+78)
		tmp = abs(Float64(t_0 - Float64(z / Float64(y / x))));
	elseif (t_1 <= 5e+81)
		tmp = abs(Float64(Float64(Float64(x + 4.0) - Float64(x * z)) / y));
	else
		tmp = abs(t_1);
	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)
	t_0 = (x + 4.0) / y;
	t_1 = t_0 - ((x / y) * z);
	tmp = 0.0;
	if (t_1 <= -2e+78)
		tmp = abs((t_0 - (z / (y / x))));
	elseif (t_1 <= 5e+81)
		tmp = abs((((x + 4.0) - (x * z)) / y));
	else
		tmp = abs(t_1);
	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_] := Block[{t$95$0 = N[(N[(x + 4.0), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(N[(x / y), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+78], N[Abs[N[(t$95$0 - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$1, 5e+81], N[Abs[N[(N[(N[(x + 4.0), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision], N[Abs[t$95$1], $MachinePrecision]]]]]
\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right|
\begin{array}{l}
t_0 := \frac{x + 4}{y}\\
t_1 := t_0 - \frac{x}{y} \cdot z\\
\mathbf{if}\;t_1 \leq -2 \cdot 10^{+78}:\\
\;\;\;\;\left|t_0 - \frac{z}{\frac{y}{x}}\right|\\

\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+81}:\\
\;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\

\mathbf{else}:\\
\;\;\;\;\left|t_1\right|\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

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

    1. Initial program 0.1

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

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

      [Start]0.1

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

      *-lft-identity [<=]0.1

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

      metadata-eval [<=]0.1

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

      fabs-sub [=>]0.1

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

      fabs-mul [<=]0.1

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

      neg-mul-1 [<=]0.1

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

      sub0-neg [<=]0.1

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

      associate-+l- [<=]0.1

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

      neg-sub0 [<=]0.1

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

      +-commutative [<=]0.1

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

      sub-neg [<=]0.1

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

      associate-*l/ [=>]6.8

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

      *-commutative [=>]6.8

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

      associate-/l* [=>]0.1

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

    if -2.00000000000000002e78 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z)) < 4.9999999999999998e81

    1. Initial program 2.9

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
    2. Taylor expanded in x around 0 0.3

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

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

      [Start]0.3

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

      *-commutative [=>]0.3

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

      sub-neg [=>]0.3

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

      mul-1-neg [<=]0.3

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

      distribute-rgt-in [=>]0.3

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

      *-commutative [<=]0.3

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

      associate-*r* [<=]0.3

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

      associate-*l/ [=>]0.8

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

      mul-1-neg [=>]0.8

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

      *-commutative [=>]0.8

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

      associate-*l/ [<=]2.9

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

      distribute-rgt-neg-out [<=]2.9

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

      associate-+r+ [=>]2.9

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

      +-commutative [<=]2.9

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

      distribute-rgt-in [<=]2.9

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

      associate-*l/ [=>]2.9

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

      *-lft-identity [=>]2.9

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

      distribute-rgt-neg-out [=>]2.9

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

    if 4.9999999999999998e81 < (-.f64 (/.f64 (+.f64 x 4) y) (*.f64 (/.f64 x y) z))

    1. Initial program 0.1

      \[\left|\frac{x + 4}{y} - \frac{x}{y} \cdot z\right| \]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.4

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

Alternatives

Alternative 1
Error0.4
Cost8649
\[\begin{array}{l} t_0 := \frac{x + 4}{y} - \frac{x}{y} \cdot z\\ \mathbf{if}\;t_0 \leq -2 \cdot 10^{+78} \lor \neg \left(t_0 \leq 5 \cdot 10^{+81}\right):\\ \;\;\;\;\left|t_0\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]
Alternative 2
Error19.8
Cost7381
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ t_1 := \left|\frac{x}{y} \cdot z\right|\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+83}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{+214} \lor \neg \left(x \leq 2.25 \cdot 10^{+257}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error19.8
Cost7381
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -1 \cdot 10^{+84}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-29}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+214} \lor \neg \left(x \leq 3.05 \cdot 10^{+254}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \end{array} \]
Alternative 4
Error19.9
Cost7381
\[\begin{array}{l} t_0 := \left|\frac{x}{y}\right|\\ \mathbf{if}\;x \leq -7.5 \cdot 10^{+83}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-29}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \mathbf{elif}\;x \leq 4:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{+196} \lor \neg \left(x \leq 3.05 \cdot 10^{+254}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{z}{\frac{y}{x}}\right|\\ \end{array} \]
Alternative 5
Error0.4
Cost7241
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{+66} \lor \neg \left(x \leq 1.02 \cdot 10^{+74}\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{\left(x + 4\right) - x \cdot z}{y}\right|\\ \end{array} \]
Alternative 6
Error9.3
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{-29} \lor \neg \left(x \leq 0.0001\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \end{array} \]
Alternative 7
Error9.3
Cost7113
\[\begin{array}{l} \mathbf{if}\;x \leq -2.8 \cdot 10^{-29} \lor \neg \left(x \leq 0.00017\right):\\ \;\;\;\;\left|x \cdot \frac{1 - z}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{y} + \frac{4}{y}\right|\\ \end{array} \]
Alternative 8
Error11.3
Cost6984
\[\begin{array}{l} \mathbf{if}\;z \leq -6.4 \cdot 10^{+71}:\\ \;\;\;\;\left|\frac{x}{y} \cdot z\right|\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{+117}:\\ \;\;\;\;\left|\frac{x + 4}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\left|\frac{x}{\frac{y}{z}}\right|\\ \end{array} \]
Alternative 9
Error19.0
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -10.5 \lor \neg \left(x \leq 4\right):\\ \;\;\;\;\left|\frac{x}{y}\right|\\ \mathbf{else}:\\ \;\;\;\;\frac{4}{\left|y\right|}\\ \end{array} \]
Alternative 10
Error32.9
Cost6592
\[\frac{4}{\left|y\right|} \]

Error

Reproduce?

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