Radioactive exchange between two surfaces

?

Percentage Accurate: 85.5% → 94.7%
Time: 4.2s
Precision: binary64
Cost: 1092

?

\[{x}^{4} - {y}^{4} \]
\[\begin{array}{l} t_0 := x \cdot x + y \cdot y\\ \mathbf{if}\;x \leq 5.8 \cdot 10^{+145}:\\ \;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot t_0\\ \end{array} \]
(FPCore (x y) :precision binary64 (- (pow x 4.0) (pow y 4.0)))
(FPCore (x y)
 :precision binary64
 (let* ((t_0 (+ (* x x) (* y y))))
   (if (<= x 5.8e+145) (* t_0 (- (* x x) (* y y))) (* (* x x) t_0))))
double code(double x, double y) {
	return pow(x, 4.0) - pow(y, 4.0);
}
double code(double x, double y) {
	double t_0 = (x * x) + (y * y);
	double tmp;
	if (x <= 5.8e+145) {
		tmp = t_0 * ((x * x) - (y * y));
	} else {
		tmp = (x * x) * t_0;
	}
	return tmp;
}
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
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x * x) + (y * y)
    if (x <= 5.8d+145) then
        tmp = t_0 * ((x * x) - (y * y))
    else
        tmp = (x * x) * t_0
    end if
    code = tmp
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) {
	double t_0 = (x * x) + (y * y);
	double tmp;
	if (x <= 5.8e+145) {
		tmp = t_0 * ((x * x) - (y * y));
	} else {
		tmp = (x * x) * t_0;
	}
	return tmp;
}
def code(x, y):
	return math.pow(x, 4.0) - math.pow(y, 4.0)
def code(x, y):
	t_0 = (x * x) + (y * y)
	tmp = 0
	if x <= 5.8e+145:
		tmp = t_0 * ((x * x) - (y * y))
	else:
		tmp = (x * x) * t_0
	return tmp
function code(x, y)
	return Float64((x ^ 4.0) - (y ^ 4.0))
end
function code(x, y)
	t_0 = Float64(Float64(x * x) + Float64(y * y))
	tmp = 0.0
	if (x <= 5.8e+145)
		tmp = Float64(t_0 * Float64(Float64(x * x) - Float64(y * y)));
	else
		tmp = Float64(Float64(x * x) * t_0);
	end
	return tmp
end
function tmp = code(x, y)
	tmp = (x ^ 4.0) - (y ^ 4.0);
end
function tmp_2 = code(x, y)
	t_0 = (x * x) + (y * y);
	tmp = 0.0;
	if (x <= 5.8e+145)
		tmp = t_0 * ((x * x) - (y * y));
	else
		tmp = (x * x) * t_0;
	end
	tmp_2 = tmp;
end
code[x_, y_] := N[(N[Power[x, 4.0], $MachinePrecision] - N[Power[y, 4.0], $MachinePrecision]), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5.8e+145], N[(t$95$0 * N[(N[(x * x), $MachinePrecision] - N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision]]]
{x}^{4} - {y}^{4}
\begin{array}{l}
t_0 := x \cdot x + y \cdot y\\
\mathbf{if}\;x \leq 5.8 \cdot 10^{+145}:\\
\;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot t_0\\


\end{array}

Local Percentage Accuracy vs ?

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 alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if x < 5.8000000000000001e145

    1. Initial program 90.3%

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

      \[\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]90.3%

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

      sqr-pow [=>]90.1%

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

      sqr-pow [=>]90.0%

      \[ {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 [=>]98.3%

      \[ \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 [=>]98.3%

      \[ \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 [<=]98.3%

      \[ \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 [=>]98.3%

      \[ \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 [<=]98.3%

      \[ \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 [=>]98.3%

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

      pow2 [<=]98.3%

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

      metadata-eval [=>]98.3%

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

      pow2 [<=]98.3%

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

    if 5.8000000000000001e145 < x

    1. Initial program 65.0%

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

      \[\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]65.0%

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

      sqr-pow [=>]65.0%

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

      sqr-pow [=>]65.0%

      \[ {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 [=>]75.0%

      \[ \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 [=>]75.0%

      \[ \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 [<=]75.0%

      \[ \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 [=>]75.0%

      \[ \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 [<=]75.0%

      \[ \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 [=>]75.0%

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

      pow2 [<=]75.0%

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

      metadata-eval [=>]75.0%

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

      pow2 [<=]75.0%

      \[ \left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - \color{blue}{y \cdot y}\right) \]
    3. Taylor expanded in x around inf 87.5%

      \[\leadsto \left(x \cdot x + y \cdot y\right) \cdot \color{blue}{{x}^{2}} \]
    4. Simplified87.5%

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

      [Start]87.5%

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

      unpow2 [=>]87.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.8 \cdot 10^{+145}:\\ \;\;\;\;\left(x \cdot x + y \cdot y\right) \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy94.7%
Cost1092
\[\begin{array}{l} t_0 := x \cdot x + y \cdot y\\ \mathbf{if}\;x \leq 5.8 \cdot 10^{+145}:\\ \;\;\;\;t_0 \cdot \left(x \cdot x - y \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot t_0\\ \end{array} \]
Alternative 2
Accuracy79.3%
Cost1033
\[\begin{array}{l} \mathbf{if}\;y \leq -1.95 \cdot 10^{+109} \lor \neg \left(y \leq 1.05 \cdot 10^{-57}\right):\\ \;\;\;\;\left(y \cdot y\right) \cdot \left(y \cdot \left(-y\right) - x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot x\right) \cdot \left(x \cdot x + y \cdot y\right)\\ \end{array} \]
Alternative 3
Accuracy69.0%
Cost969
\[\begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{+110} \lor \neg \left(y \leq 1.22 \cdot 10^{+126}\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 4
Accuracy44.6%
Cost777
\[\begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{+109} \lor \neg \left(y \leq 1.25 \cdot 10^{+126}\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 5
Accuracy33.3%
Cost448
\[\left(x \cdot x\right) \cdot \left(y \cdot y\right) \]

Reproduce?

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