Average Error: 30.2 → 0.3
Time: 16.9s
Precision: binary64
Cost: 13120
\[\sqrt{2 \cdot {x}^{2}} \]
\[\left(\left|x\right| \cdot \sqrt{0.2222222222222222}\right) \cdot 3 \]
(FPCore (x) :precision binary64 (sqrt (* 2.0 (pow x 2.0))))
(FPCore (x) :precision binary64 (* (* (fabs x) (sqrt 0.2222222222222222)) 3.0))
double code(double x) {
	return sqrt((2.0 * pow(x, 2.0)));
}
double code(double x) {
	return (fabs(x) * sqrt(0.2222222222222222)) * 3.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt((2.0d0 * (x ** 2.0d0)))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = (abs(x) * sqrt(0.2222222222222222d0)) * 3.0d0
end function
public static double code(double x) {
	return Math.sqrt((2.0 * Math.pow(x, 2.0)));
}
public static double code(double x) {
	return (Math.abs(x) * Math.sqrt(0.2222222222222222)) * 3.0;
}
def code(x):
	return math.sqrt((2.0 * math.pow(x, 2.0)))
def code(x):
	return (math.fabs(x) * math.sqrt(0.2222222222222222)) * 3.0
function code(x)
	return sqrt(Float64(2.0 * (x ^ 2.0)))
end
function code(x)
	return Float64(Float64(abs(x) * sqrt(0.2222222222222222)) * 3.0)
end
function tmp = code(x)
	tmp = sqrt((2.0 * (x ^ 2.0)));
end
function tmp = code(x)
	tmp = (abs(x) * sqrt(0.2222222222222222)) * 3.0;
end
code[x_] := N[Sqrt[N[(2.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[(N[(N[Abs[x], $MachinePrecision] * N[Sqrt[0.2222222222222222], $MachinePrecision]), $MachinePrecision] * 3.0), $MachinePrecision]
\sqrt{2 \cdot {x}^{2}}
\left(\left|x\right| \cdot \sqrt{0.2222222222222222}\right) \cdot 3

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 30.2

    \[\sqrt{2 \cdot {x}^{2}} \]
  2. Applied egg-rr0.5

    \[\leadsto \color{blue}{\frac{\left|x\right| \cdot \sqrt{2}}{3} \cdot 3} \]
  3. Applied egg-rr0.3

    \[\leadsto \color{blue}{\left(\left|x\right| \cdot \sqrt{\frac{2}{9}}\right)} \cdot 3 \]
  4. Simplified0.3

    \[\leadsto \color{blue}{\left(\left|x\right| \cdot \sqrt{0.2222222222222222}\right)} \cdot 3 \]
    Proof

Alternatives

Alternative 1
Error0.4
Cost12992
\[\left|x\right| \cdot \sqrt{2} \]
Alternative 2
Error0.4
Cost12992
\[\frac{\left|x\right|}{\sqrt{0.5}} \]
Alternative 3
Error0.4
Cost6852
\[\begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;\frac{x \cdot -2}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot x\\ \end{array} \]
Alternative 4
Error0.4
Cost6788
\[\begin{array}{l} t_0 := \sqrt{2} \cdot x\\ \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;-t_0\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error31.1
Cost6592
\[\sqrt{2} \cdot x \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x)
  :name "sqrt D (should all be same)"
  :precision binary64
  (sqrt (* 2.0 (pow x 2.0))))