(FPCore (x) :precision binary64 (sqrt (* 2.0 (pow x 2.0))))
(FPCore (x) :precision binary64 (hypot x x))
double code(double x) {
return sqrt((2.0 * pow(x, 2.0)));
}
double code(double x) {
return hypot(x, x);
}
public static double code(double x) {
return Math.sqrt((2.0 * Math.pow(x, 2.0)));
}
public static double code(double x) {
return Math.hypot(x, x);
}
def code(x): return math.sqrt((2.0 * math.pow(x, 2.0)))
def code(x): return math.hypot(x, x)
function code(x) return sqrt(Float64(2.0 * (x ^ 2.0))) end
function code(x) return hypot(x, x) end
function tmp = code(x) tmp = sqrt((2.0 * (x ^ 2.0))); end
function tmp = code(x) tmp = hypot(x, x); end
code[x_] := N[Sqrt[N[(2.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := N[Sqrt[x ^ 2 + x ^ 2], $MachinePrecision]
\sqrt{2 \cdot {x}^{2}}
\mathsf{hypot}\left(x, x\right)
Results
Initial program 54.0%
Simplified54.0%
[Start]54.0 | \[ \sqrt{2 \cdot {x}^{2}}
\] |
|---|---|
unpow2 [=>]54.0 | \[ \sqrt{2 \cdot \color{blue}{\left(x \cdot x\right)}}
\] |
Taylor expanded in x around -inf 50.4%
Simplified50.4%
[Start]50.4 | \[ -1 \cdot \left(\sqrt{2} \cdot x\right)
\] |
|---|---|
mul-1-neg [=>]50.4 | \[ \color{blue}{-\sqrt{2} \cdot x}
\] |
distribute-rgt-neg-in [=>]50.4 | \[ \color{blue}{\sqrt{2} \cdot \left(-x\right)}
\] |
Applied egg-rr30.2%
[Start]50.4 | \[ \sqrt{2} \cdot \left(-x\right)
\] |
|---|---|
expm1-log1p-u [=>]48.2 | \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\sqrt{2} \cdot \left(-x\right)\right)\right)}
\] |
expm1-udef [=>]25.2 | \[ \color{blue}{e^{\mathsf{log1p}\left(\sqrt{2} \cdot \left(-x\right)\right)} - 1}
\] |
log1p-udef [=>]25.2 | \[ e^{\color{blue}{\log \left(1 + \sqrt{2} \cdot \left(-x\right)\right)}} - 1
\] |
add-exp-log [<=]27.4 | \[ \color{blue}{\left(1 + \sqrt{2} \cdot \left(-x\right)\right)} - 1
\] |
add-sqr-sqrt [=>]25.8 | \[ \left(1 + \sqrt{2} \cdot \color{blue}{\left(\sqrt{-x} \cdot \sqrt{-x}\right)}\right) - 1
\] |
sqrt-unprod [=>]31.9 | \[ \left(1 + \sqrt{2} \cdot \color{blue}{\sqrt{\left(-x\right) \cdot \left(-x\right)}}\right) - 1
\] |
sqr-neg [=>]31.9 | \[ \left(1 + \sqrt{2} \cdot \sqrt{\color{blue}{x \cdot x}}\right) - 1
\] |
sqrt-unprod [<=]28.7 | \[ \left(1 + \sqrt{2} \cdot \color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)}\right) - 1
\] |
add-sqr-sqrt [<=]30.2 | \[ \left(1 + \sqrt{2} \cdot \color{blue}{x}\right) - 1
\] |
Simplified100.0%
[Start]30.2 | \[ \left(1 + \sqrt{2} \cdot x\right) - 1
\] |
|---|---|
+-commutative [=>]30.2 | \[ \color{blue}{\left(\sqrt{2} \cdot x + 1\right)} - 1
\] |
associate--l+ [=>]51.1 | \[ \color{blue}{\sqrt{2} \cdot x + \left(1 - 1\right)}
\] |
metadata-eval [=>]51.1 | \[ \sqrt{2} \cdot x + \color{blue}{0}
\] |
+-rgt-identity [=>]51.1 | \[ \color{blue}{\sqrt{2} \cdot x}
\] |
unpow1 [<=]51.1 | \[ \color{blue}{{\left(\sqrt{2} \cdot x\right)}^{1}}
\] |
sqr-pow [=>]49.8 | \[ \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.8 | \[ \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 [<=]53.8 | \[ \color{blue}{\sqrt{\left(\sqrt{2} \cdot x\right) \cdot \left(\sqrt{2} \cdot x\right)}}
\] |
*-commutative [=>]53.8 | \[ \sqrt{\color{blue}{\left(x \cdot \sqrt{2}\right)} \cdot \left(\sqrt{2} \cdot x\right)}
\] |
associate-*l* [=>]53.7 | \[ \sqrt{\color{blue}{x \cdot \left(\sqrt{2} \cdot \left(\sqrt{2} \cdot x\right)\right)}}
\] |
*-commutative [=>]53.7 | \[ \sqrt{x \cdot \left(\sqrt{2} \cdot \color{blue}{\left(x \cdot \sqrt{2}\right)}\right)}
\] |
rem-log-exp [<=]53.7 | \[ \sqrt{x \cdot \left(\sqrt{2} \cdot \left(x \cdot \color{blue}{\log \left(e^{\sqrt{2}}\right)}\right)\right)}
\] |
log-pow [<=]7.5 | \[ \sqrt{x \cdot \left(\sqrt{2} \cdot \color{blue}{\log \left({\left(e^{\sqrt{2}}\right)}^{x}\right)}\right)}
\] |
sqr-pow [=>]7.4 | \[ \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 [=>]7.8 | \[ \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 [=>]7.8 | \[ \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)}}
\] |
Final simplification100.0%
herbie shell --seed 2023160
(FPCore (x)
:name "sqrt D (should all be same)"
:precision binary64
(sqrt (* 2.0 (pow x 2.0))))