Radioactive exchange between two surfaces

?

Percentage Accurate: 86.6% → 99.8%
Time: 4.7s
Precision: binary64
Cost: 960

?

\[{x}^{4} - {y}^{4} \]
\[\left(x \cdot x + y \cdot y\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right) \]
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
(FPCore (x y) :precision binary64 (* (+ (* x x) (* y y)) (* (- x y) (+ x y))))
double code(double x, double y) {
	return pow(x, 4.0) - pow(y, 4.0);
}
double code(double x, double y) {
	return ((x * x) + (y * y)) * ((x - y) * (x + y));
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x ** 4.0d0) - (y ** 4.0d0)
end function
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = ((x * x) + (y * y)) * ((x - y) * (x + y))
end function
public static double code(double x, double y) {
	return Math.pow(x, 4.0) - Math.pow(y, 4.0);
}
public static double code(double x, double y) {
	return ((x * x) + (y * y)) * ((x - y) * (x + y));
}
def code(x, y):
	return math.pow(x, 4.0) - math.pow(y, 4.0)
def code(x, y):
	return ((x * x) + (y * y)) * ((x - y) * (x + y))
function code(x, y)
	return Float64((x ^ 4.0) - (y ^ 4.0))
end
function code(x, y)
	return Float64(Float64(Float64(x * x) + Float64(y * y)) * Float64(Float64(x - y) * Float64(x + y)))
end
function tmp = code(x, y)
	tmp = (x ^ 4.0) - (y ^ 4.0);
end
function tmp = code(x, y)
	tmp = ((x * x) + (y * y)) * ((x - y) * (x + y));
end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
{x}^{4} - {y}^{4}
\left(x \cdot x + y \cdot y\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right)

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 5 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each of Herbie's proposed alternatives. Up and to the right is better. Each dot represents an alternative program; the red square represents the initial program.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 82.0%

    \[{x}^{4} - {y}^{4} \]
  2. Applied egg-rr91.2%

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

    [Start]82.0

    \[ {x}^{4} - {y}^{4} \]

    sqr-pow [=>]81.9

    \[ \color{blue}{{x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)}} - {y}^{4} \]

    sqr-pow [=>]81.8

    \[ {x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\left(\frac{4}{2}\right)} - \color{blue}{{y}^{\left(\frac{4}{2}\right)} \cdot {y}^{\left(\frac{4}{2}\right)}} \]

    difference-of-squares [=>]91.2

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

    metadata-eval [=>]91.2

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

    pow2 [<=]91.2

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

    metadata-eval [=>]91.2

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

    pow2 [<=]91.2

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

    metadata-eval [=>]91.2

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

    pow2 [<=]91.2

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

    metadata-eval [=>]91.2

    \[ \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - {y}^{\color{blue}{2}}\right) \]

    pow2 [<=]91.2

    \[ \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
  3. Applied egg-rr99.8%

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

    [Start]91.2

    \[ \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right) \]

    difference-of-squares [=>]99.8

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

    *-commutative [=>]99.8

    \[ \left(x \cdot x + y \cdot y\right) \cdot \color{blue}{\left(\left(x - y\right) \cdot \left(x + y\right)\right)} \]
  4. Final simplification99.8%

    \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \left(\left(x - y\right) \cdot \left(x + y\right)\right) \]

Alternatives

Alternative 1
Accuracy81.6%
Cost1298
\[\begin{array}{l} t_0 := x \cdot x + y \cdot y\\ \mathbf{if}\;x \leq -2.1 \cdot 10^{+26} \lor \neg \left(x \leq -1.7 \cdot 10^{-32} \lor \neg \left(x \leq -8.5 \cdot 10^{-49}\right) \land x \leq 1250000000000\right):\\ \;\;\;\;\left(x \cdot x\right) \cdot t_0\\ \mathbf{else}:\\ \;\;\;\;t_0 \cdot \left(y \cdot \left(-y\right)\right)\\ \end{array} \]
Alternative 2
Accuracy69.4%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+175} \lor \neg \left(y \leq 4.5 \cdot 10^{+131}\right):\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \end{array} \]
Alternative 3
Accuracy44.5%
Cost777
\[\begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+175} \lor \neg \left(y \leq 1.3 \cdot 10^{+131}\right):\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot \left(-y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(y \cdot y\right)\\ \end{array} \]
Alternative 4
Accuracy32.2%
Cost448
\[\left(x \cdot x\right) \cdot \left(y \cdot y\right) \]

Reproduce?

herbie shell --seed 2023161 
(FPCore (x y)
  :name "Radioactive exchange between two surfaces"
  :precision binary64
  (- (pow x 4.0) (pow y 4.0)))