?

Average Accuracy: 51.8% → 100.0%
Time: 2.4s
Precision: binary64
Cost: 6528

?

\[\sqrt{\left(2 \cdot x\right) \cdot x} \]
\[\mathsf{hypot}\left(x, x\right) \]
(FPCore (x) :precision binary64 (sqrt (* (* 2.0 x) x)))
(FPCore (x) :precision binary64 (hypot x x))
double code(double x) {
	return sqrt(((2.0 * x) * x));
}
double code(double x) {
	return hypot(x, x);
}
public static double code(double x) {
	return Math.sqrt(((2.0 * x) * x));
}
public static double code(double x) {
	return Math.hypot(x, x);
}
def code(x):
	return math.sqrt(((2.0 * x) * x))
def code(x):
	return math.hypot(x, x)
function code(x)
	return sqrt(Float64(Float64(2.0 * x) * x))
end
function code(x)
	return hypot(x, x)
end
function tmp = code(x)
	tmp = sqrt(((2.0 * x) * x));
end
function tmp = code(x)
	tmp = hypot(x, x);
end
code[x_] := N[Sqrt[N[(N[(2.0 * x), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]
code[x_] := N[Sqrt[x ^ 2 + x ^ 2], $MachinePrecision]
\sqrt{\left(2 \cdot x\right) \cdot x}
\mathsf{hypot}\left(x, x\right)

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 51.8%

    \[\sqrt{\left(2 \cdot x\right) \cdot x} \]
  2. Taylor expanded in x around -inf 50.7%

    \[\leadsto \color{blue}{-1 \cdot \left(\sqrt{2} \cdot x\right)} \]
  3. Simplified50.7%

    \[\leadsto \color{blue}{\sqrt{2} \cdot \left(-x\right)} \]
    Proof

    [Start]50.7

    \[ -1 \cdot \left(\sqrt{2} \cdot x\right) \]

    mul-1-neg [=>]50.7

    \[ \color{blue}{-\sqrt{2} \cdot x} \]

    distribute-rgt-neg-in [=>]50.7

    \[ \color{blue}{\sqrt{2} \cdot \left(-x\right)} \]
  4. Applied egg-rr28.6%

    \[\leadsto \color{blue}{\left(1 + \sqrt{2} \cdot x\right) - 1} \]
    Proof

    [Start]50.7

    \[ \sqrt{2} \cdot \left(-x\right) \]

    expm1-log1p-u [=>]48.5

    \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{2} \cdot \left(-x\right)\right)\right)} \]

    expm1-udef [=>]26.4

    \[ \color{blue}{e^{\mathsf{log1p}\left(\sqrt{2} \cdot \left(-x\right)\right)} - 1} \]

    log1p-udef [=>]26.4

    \[ e^{\color{blue}{\log \left(1 + \sqrt{2} \cdot \left(-x\right)\right)}} - 1 \]

    add-exp-log [<=]28.7

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

    add-sqr-sqrt [=>]27.1

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

    sqrt-unprod [=>]29.1

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

    sqr-neg [=>]29.1

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

    sqrt-unprod [<=]27.1

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

    add-sqr-sqrt [<=]28.6

    \[ \left(1 + \sqrt{2} \cdot \color{blue}{x}\right) - 1 \]
  5. Simplified100.0%

    \[\leadsto \color{blue}{\mathsf{hypot}\left(x, x\right)} \]
    Proof

    [Start]28.6

    \[ \left(1 + \sqrt{2} \cdot x\right) - 1 \]

    +-commutative [=>]28.6

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

    associate--l+ [=>]50.9

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

    metadata-eval [=>]50.9

    \[ \sqrt{2} \cdot x + \color{blue}{0} \]

    +-rgt-identity [=>]50.9

    \[ \color{blue}{\sqrt{2} \cdot x} \]

    unpow1 [<=]50.9

    \[ \color{blue}{{\left(\sqrt{2} \cdot x\right)}^{1}} \]

    sqr-pow [=>]49.6

    \[ \color{blue}{{\left(\sqrt{2} \cdot x\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\sqrt{2} \cdot x\right)}^{\left(\frac{1}{2}\right)}} \]

    fabs-sqr [<=]49.6

    \[ \color{blue}{\left|{\left(\sqrt{2} \cdot x\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\sqrt{2} \cdot x\right)}^{\left(\frac{1}{2}\right)}\right|} \]

    sqr-pow [<=]99.3

    \[ \left|\color{blue}{{\left(\sqrt{2} \cdot x\right)}^{1}}\right| \]

    unpow1 [=>]99.3

    \[ \left|\color{blue}{\sqrt{2} \cdot x}\right| \]

    rem-sqrt-square [<=]51.5

    \[ \color{blue}{\sqrt{\left(\sqrt{2} \cdot x\right) \cdot \left(\sqrt{2} \cdot x\right)}} \]

    *-commutative [=>]51.5

    \[ \sqrt{\color{blue}{\left(x \cdot \sqrt{2}\right)} \cdot \left(\sqrt{2} \cdot x\right)} \]

    associate-*l* [=>]51.5

    \[ \sqrt{\color{blue}{x \cdot \left(\sqrt{2} \cdot \left(\sqrt{2} \cdot x\right)\right)}} \]

    *-commutative [=>]51.5

    \[ \sqrt{x \cdot \left(\sqrt{2} \cdot \color{blue}{\left(x \cdot \sqrt{2}\right)}\right)} \]

    rem-log-exp [<=]51.5

    \[ \sqrt{x \cdot \left(\sqrt{2} \cdot \left(x \cdot \color{blue}{\log \left(e^{\sqrt{2}}\right)}\right)\right)} \]

    log-pow [<=]4.5

    \[ \sqrt{x \cdot \left(\sqrt{2} \cdot \color{blue}{\log \left({\left(e^{\sqrt{2}}\right)}^{x}\right)}\right)} \]

    sqr-pow [=>]4.5

    \[ \sqrt{x \cdot \left(\sqrt{2} \cdot \log \color{blue}{\left({\left(e^{\sqrt{2}}\right)}^{\left(\frac{x}{2}\right)} \cdot {\left(e^{\sqrt{2}}\right)}^{\left(\frac{x}{2}\right)}\right)}\right)} \]

    log-prod [=>]4.5

    \[ \sqrt{x \cdot \left(\sqrt{2} \cdot \color{blue}{\left(\log \left({\left(e^{\sqrt{2}}\right)}^{\left(\frac{x}{2}\right)}\right) + \log \left({\left(e^{\sqrt{2}}\right)}^{\left(\frac{x}{2}\right)}\right)\right)}\right)} \]

    distribute-lft-in [=>]4.5

    \[ \sqrt{x \cdot \color{blue}{\left(\sqrt{2} \cdot \log \left({\left(e^{\sqrt{2}}\right)}^{\left(\frac{x}{2}\right)}\right) + \sqrt{2} \cdot \log \left({\left(e^{\sqrt{2}}\right)}^{\left(\frac{x}{2}\right)}\right)\right)}} \]
  6. Final simplification100.0%

    \[\leadsto \mathsf{hypot}\left(x, x\right) \]

Reproduce?

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