sqrt D (should all be same)

Percentage Accurate: 53.9% → 99.5%
Time: 14.4s
Alternatives: 8
Speedup: 4.9×

Specification

?
\[\begin{array}{l} \\ \sqrt{2 \cdot {x}^{2}} \end{array} \]
(FPCore (x) :precision binary64 (sqrt (* 2.0 (pow x 2.0))))
double code(double x) {
	return sqrt((2.0 * pow(x, 2.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt((2.0d0 * (x ** 2.0d0)))
end function
public static double code(double x) {
	return Math.sqrt((2.0 * Math.pow(x, 2.0)));
}
def code(x):
	return math.sqrt((2.0 * math.pow(x, 2.0)))
function code(x)
	return sqrt(Float64(2.0 * (x ^ 2.0)))
end
function tmp = code(x)
	tmp = sqrt((2.0 * (x ^ 2.0)));
end
code[x_] := N[Sqrt[N[(2.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{2 \cdot {x}^{2}}
\end{array}

Sampling outcomes in binary64 precision:

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.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
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.

Initial Program: 53.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{2 \cdot {x}^{2}} \end{array} \]
(FPCore (x) :precision binary64 (sqrt (* 2.0 (pow x 2.0))))
double code(double x) {
	return sqrt((2.0 * pow(x, 2.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt((2.0d0 * (x ** 2.0d0)))
end function
public static double code(double x) {
	return Math.sqrt((2.0 * Math.pow(x, 2.0)));
}
def code(x):
	return math.sqrt((2.0 * math.pow(x, 2.0)))
function code(x)
	return sqrt(Float64(2.0 * (x ^ 2.0)))
end
function tmp = code(x)
	tmp = sqrt((2.0 * (x ^ 2.0)));
end
code[x_] := N[Sqrt[N[(2.0 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{2 \cdot {x}^{2}}
\end{array}

Alternative 1: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\left(-{16}^{0.03125}\right) \cdot \left({64}^{0.0625} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{0.75} \cdot {\left(4 \cdot x\right)}^{0.25}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2e-310)
   (* (- (pow 16.0 0.03125)) (* (pow 64.0 0.0625) x))
   (* (pow x 0.75) (pow (* 4.0 x) 0.25))))
double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = -pow(16.0, 0.03125) * (pow(64.0, 0.0625) * x);
	} else {
		tmp = pow(x, 0.75) * pow((4.0 * x), 0.25);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2d-310)) then
        tmp = -(16.0d0 ** 0.03125d0) * ((64.0d0 ** 0.0625d0) * x)
    else
        tmp = (x ** 0.75d0) * ((4.0d0 * x) ** 0.25d0)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = -Math.pow(16.0, 0.03125) * (Math.pow(64.0, 0.0625) * x);
	} else {
		tmp = Math.pow(x, 0.75) * Math.pow((4.0 * x), 0.25);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2e-310:
		tmp = -math.pow(16.0, 0.03125) * (math.pow(64.0, 0.0625) * x)
	else:
		tmp = math.pow(x, 0.75) * math.pow((4.0 * x), 0.25)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2e-310)
		tmp = Float64(Float64(-(16.0 ^ 0.03125)) * Float64((64.0 ^ 0.0625) * x));
	else
		tmp = Float64((x ^ 0.75) * (Float64(4.0 * x) ^ 0.25));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2e-310)
		tmp = -(16.0 ^ 0.03125) * ((64.0 ^ 0.0625) * x);
	else
		tmp = (x ^ 0.75) * ((4.0 * x) ^ 0.25);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2e-310], N[((-N[Power[16.0, 0.03125], $MachinePrecision]) * N[(N[Power[64.0, 0.0625], $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 0.75], $MachinePrecision] * N[Power[N[(4.0 * x), $MachinePrecision], 0.25], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(-{16}^{0.03125}\right) \cdot \left({64}^{0.0625} \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;{x}^{0.75} \cdot {\left(4 \cdot x\right)}^{0.25}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.999999999999994e-310

    1. Initial program 56.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites2.1%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 + x\right)} \]
      3. flip-+N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 - x}} \]
      4. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{-x}} \]
      6. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{-x}\right)} \]
      7. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left(-x\right)}^{-1}}\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\color{blue}{\left(2 \cdot \frac{-1}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}\right) \]
      10. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left({\left(-x\right)}^{2}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right) \]
      11. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      13. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      14. sqr-negN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(x \cdot x\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      15. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left({x}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      16. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{x}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}\right) \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
      18. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\color{blue}{-1}}\right) \]
      19. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{\frac{1}{x}}\right) \]
      20. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{\color{blue}{0 + x}}\right) \]
      21. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 + x}} \]
      22. flip--N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 - x\right)} \]
      23. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left({4}^{0.125} \cdot x\right) \cdot \left(-{4}^{0.125}\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({4}^{\frac{1}{8}} \cdot x\right) \cdot \left(-{4}^{\frac{1}{8}}\right)} \]
      2. lift-neg.f64N/A

        \[\leadsto \left({4}^{\frac{1}{8}} \cdot x\right) \cdot \color{blue}{\left(\mathsf{neg}\left({4}^{\frac{1}{8}}\right)\right)} \]
      3. lift-pow.f64N/A

        \[\leadsto \left({4}^{\frac{1}{8}} \cdot x\right) \cdot \left(\mathsf{neg}\left(\color{blue}{{4}^{\frac{1}{8}}}\right)\right) \]
      4. sqr-powN/A

        \[\leadsto \left({4}^{\frac{1}{8}} \cdot x\right) \cdot \left(\mathsf{neg}\left(\color{blue}{{4}^{\left(\frac{\frac{1}{8}}{2}\right)} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}}\right)\right) \]
      5. distribute-rgt-neg-inN/A

        \[\leadsto \left({4}^{\frac{1}{8}} \cdot x\right) \cdot \color{blue}{\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)} \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right)\right)} \]
      6. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left({4}^{\frac{1}{8}} \cdot x\right) \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right)} \]
      7. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\left({4}^{\frac{1}{8}} \cdot x\right) \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right)} \]
      8. lift-*.f64N/A

        \[\leadsto \left(\color{blue}{\left({4}^{\frac{1}{8}} \cdot x\right)} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      9. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(x \cdot {4}^{\frac{1}{8}}\right)} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      10. associate-*l*N/A

        \[\leadsto \color{blue}{\left(x \cdot \left({4}^{\frac{1}{8}} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right)} \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(x \cdot \left({4}^{\frac{1}{8}} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right)} \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      12. lift-pow.f64N/A

        \[\leadsto \left(x \cdot \left(\color{blue}{{4}^{\frac{1}{8}}} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      13. sqr-powN/A

        \[\leadsto \left(x \cdot \left(\color{blue}{\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      14. pow-prod-downN/A

        \[\leadsto \left(x \cdot \left(\color{blue}{{\left(4 \cdot 4\right)}^{\left(\frac{\frac{1}{8}}{2}\right)}} \cdot {4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      15. pow-prod-downN/A

        \[\leadsto \left(x \cdot \color{blue}{{\left(\left(4 \cdot 4\right) \cdot 4\right)}^{\left(\frac{\frac{1}{8}}{2}\right)}}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      16. lower-pow.f64N/A

        \[\leadsto \left(x \cdot \color{blue}{{\left(\left(4 \cdot 4\right) \cdot 4\right)}^{\left(\frac{\frac{1}{8}}{2}\right)}}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      17. metadata-evalN/A

        \[\leadsto \left(x \cdot {\left(\color{blue}{16} \cdot 4\right)}^{\left(\frac{\frac{1}{8}}{2}\right)}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      18. metadata-evalN/A

        \[\leadsto \left(x \cdot {\color{blue}{64}}^{\left(\frac{\frac{1}{8}}{2}\right)}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      19. metadata-evalN/A

        \[\leadsto \left(x \cdot {64}^{\color{blue}{\frac{1}{16}}}\right) \cdot \left(\mathsf{neg}\left({4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)\right) \]
      20. lower-neg.f64N/A

        \[\leadsto \left(x \cdot {64}^{\frac{1}{16}}\right) \cdot \color{blue}{\left(-{4}^{\left(\frac{\frac{1}{8}}{2}\right)}\right)} \]
      21. sqr-powN/A

        \[\leadsto \left(x \cdot {64}^{\frac{1}{16}}\right) \cdot \left(-\color{blue}{{4}^{\left(\frac{\frac{\frac{1}{8}}{2}}{2}\right)} \cdot {4}^{\left(\frac{\frac{\frac{1}{8}}{2}}{2}\right)}}\right) \]
      22. pow-prod-downN/A

        \[\leadsto \left(x \cdot {64}^{\frac{1}{16}}\right) \cdot \left(-\color{blue}{{\left(4 \cdot 4\right)}^{\left(\frac{\frac{\frac{1}{8}}{2}}{2}\right)}}\right) \]
    7. Applied rewrites99.6%

      \[\leadsto \color{blue}{\left(x \cdot {64}^{0.0625}\right) \cdot \left(-{16}^{0.03125}\right)} \]

    if -1.999999999999994e-310 < x

    1. Initial program 52.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 + x\right)} \]
      3. flip-+N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 - x}} \]
      4. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{-x}} \]
      6. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{-x}\right)} \]
      7. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left(-x\right)}^{-1}}\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\color{blue}{\left(2 \cdot \frac{-1}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}\right) \]
      10. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left({\left(-x\right)}^{2}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right) \]
      11. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      13. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      14. sqr-negN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(x \cdot x\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      15. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left({x}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      16. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{x}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}\right) \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
      18. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\color{blue}{-1}}\right) \]
      19. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{\frac{1}{x}}\right) \]
      20. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{\color{blue}{0 + x}}\right) \]
      21. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 + x}} \]
      22. flip--N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 - x\right)} \]
      23. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
    5. Applied rewrites2.4%

      \[\leadsto \color{blue}{\left({4}^{0.125} \cdot x\right) \cdot \left(-{4}^{0.125}\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({4}^{\frac{1}{8}} \cdot x\right) \cdot \left(-{4}^{\frac{1}{8}}\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({4}^{\frac{1}{8}} \cdot x\right)} \cdot \left(-{4}^{\frac{1}{8}}\right) \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{{4}^{\frac{1}{8}} \cdot \left(x \cdot \left(-{4}^{\frac{1}{8}}\right)\right)} \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{\left(x \cdot \left(-{4}^{\frac{1}{8}}\right)\right) \cdot {4}^{\frac{1}{8}}} \]
      5. lift-neg.f64N/A

        \[\leadsto \left(x \cdot \color{blue}{\left(\mathsf{neg}\left({4}^{\frac{1}{8}}\right)\right)}\right) \cdot {4}^{\frac{1}{8}} \]
      6. neg-mul-1N/A

        \[\leadsto \left(x \cdot \color{blue}{\left(-1 \cdot {4}^{\frac{1}{8}}\right)}\right) \cdot {4}^{\frac{1}{8}} \]
      7. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot -1\right) \cdot {4}^{\frac{1}{8}}\right)} \cdot {4}^{\frac{1}{8}} \]
      8. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(-1 \cdot x\right)} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      9. metadata-evalN/A

        \[\leadsto \left(\left(\color{blue}{\frac{-1}{1}} \cdot x\right) \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      10. associate-/r/N/A

        \[\leadsto \left(\color{blue}{\frac{-1}{\frac{1}{x}}} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      11. unpow-1N/A

        \[\leadsto \left(\frac{-1}{\color{blue}{{x}^{-1}}} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      12. lift-pow.f64N/A

        \[\leadsto \left(\frac{-1}{\color{blue}{{x}^{-1}}} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      13. lift-/.f64N/A

        \[\leadsto \left(\color{blue}{\frac{-1}{{x}^{-1}}} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      14. associate-*l*N/A

        \[\leadsto \color{blue}{\frac{-1}{{x}^{-1}} \cdot \left({4}^{\frac{1}{8}} \cdot {4}^{\frac{1}{8}}\right)} \]
    7. Applied rewrites99.5%

      \[\leadsto \color{blue}{{\left(x \cdot 4\right)}^{0.25} \cdot {x}^{0.75}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\left(-{16}^{0.03125}\right) \cdot \left({64}^{0.0625} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{0.75} \cdot {\left(4 \cdot x\right)}^{0.25}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 99.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{0.75} \cdot {\left(4 \cdot x\right)}^{0.25}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2e-310)
   (/ (* -2.0 x) (sqrt 2.0))
   (* (pow x 0.75) (pow (* 4.0 x) 0.25))))
double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = (-2.0 * x) / sqrt(2.0);
	} else {
		tmp = pow(x, 0.75) * pow((4.0 * x), 0.25);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2d-310)) then
        tmp = ((-2.0d0) * x) / sqrt(2.0d0)
    else
        tmp = (x ** 0.75d0) * ((4.0d0 * x) ** 0.25d0)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = (-2.0 * x) / Math.sqrt(2.0);
	} else {
		tmp = Math.pow(x, 0.75) * Math.pow((4.0 * x), 0.25);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2e-310:
		tmp = (-2.0 * x) / math.sqrt(2.0)
	else:
		tmp = math.pow(x, 0.75) * math.pow((4.0 * x), 0.25)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2e-310)
		tmp = Float64(Float64(-2.0 * x) / sqrt(2.0));
	else
		tmp = Float64((x ^ 0.75) * (Float64(4.0 * x) ^ 0.25));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2e-310)
		tmp = (-2.0 * x) / sqrt(2.0);
	else
		tmp = (x ^ 0.75) * ((4.0 * x) ^ 0.25);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2e-310], N[(N[(-2.0 * x), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 0.75], $MachinePrecision] * N[Power[N[(4.0 * x), $MachinePrecision], 0.25], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\

\mathbf{else}:\\
\;\;\;\;{x}^{0.75} \cdot {\left(4 \cdot x\right)}^{0.25}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.999999999999994e-310

    1. Initial program 56.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites2.1%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 + x\right)} \]
      3. flip-+N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 - x}} \]
      4. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{-x}} \]
      6. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{-x}\right)} \]
      7. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left(-x\right)}^{-1}}\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\color{blue}{\left(2 \cdot \frac{-1}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}\right) \]
      10. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left({\left(-x\right)}^{2}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right) \]
      11. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      13. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      14. sqr-negN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(x \cdot x\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      15. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left({x}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      16. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{x}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}\right) \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
      18. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\color{blue}{-1}}\right) \]
      19. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{\frac{1}{x}}\right) \]
      20. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{\color{blue}{0 + x}}\right) \]
      21. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 + x}} \]
      22. flip--N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 - x\right)} \]
      23. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left({4}^{0.125} \cdot x\right) \cdot \left(-{4}^{0.125}\right)} \]
    6. Applied rewrites55.9%

      \[\leadsto \color{blue}{\frac{0 - \left(x \cdot x\right) \cdot 2}{\sqrt{2} \cdot x}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{0 - \left(x \cdot x\right) \cdot 2}{\sqrt{2} \cdot x}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{0 - \left(x \cdot x\right) \cdot 2}{\color{blue}{\sqrt{2} \cdot x}} \]
      3. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\frac{0 - \left(x \cdot x\right) \cdot 2}{x}}{\sqrt{2}}} \]
      4. lift--.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{0 - \left(x \cdot x\right) \cdot 2}}{x}}{\sqrt{2}} \]
      5. sub0-negN/A

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{neg}\left(\left(x \cdot x\right) \cdot 2\right)}}{x}}{\sqrt{2}} \]
      6. distribute-frac-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\frac{\left(x \cdot x\right) \cdot 2}{x}\right)}}{\sqrt{2}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{\left(x \cdot x\right) \cdot 2}}{x}\right)}{\sqrt{2}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{\left(x \cdot x\right)} \cdot 2}{x}\right)}{\sqrt{2}} \]
      9. associate-*l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{x \cdot \left(x \cdot 2\right)}}{x}\right)}{\sqrt{2}} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{x \cdot \frac{x \cdot 2}{x}}\right)}{\sqrt{2}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \frac{\color{blue}{2 \cdot x}}{x}\right)}{\sqrt{2}} \]
      12. associate-/l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \color{blue}{\left(2 \cdot \frac{x}{x}\right)}\right)}{\sqrt{2}} \]
      13. *-inversesN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \left(2 \cdot \color{blue}{1}\right)\right)}{\sqrt{2}} \]
      14. metadata-evalN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \color{blue}{2}\right)}{\sqrt{2}} \]
      15. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x \cdot 2\right)}{\sqrt{2}}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{2 \cdot x}\right)}{\sqrt{2}} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot x}}{\sqrt{2}} \]
      18. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot x}}{\sqrt{2}} \]
      19. metadata-eval99.4

        \[\leadsto \frac{\color{blue}{-2} \cdot x}{\sqrt{2}} \]
    8. Applied rewrites99.4%

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

    if -1.999999999999994e-310 < x

    1. Initial program 52.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 + x\right)} \]
      3. flip-+N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 - x}} \]
      4. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{-x}} \]
      6. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{-x}\right)} \]
      7. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left(-x\right)}^{-1}}\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\color{blue}{\left(2 \cdot \frac{-1}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}\right) \]
      10. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left({\left(-x\right)}^{2}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right) \]
      11. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      13. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      14. sqr-negN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(x \cdot x\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      15. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left({x}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      16. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{x}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}\right) \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
      18. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\color{blue}{-1}}\right) \]
      19. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{\frac{1}{x}}\right) \]
      20. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{\color{blue}{0 + x}}\right) \]
      21. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 + x}} \]
      22. flip--N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 - x\right)} \]
      23. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
    5. Applied rewrites2.4%

      \[\leadsto \color{blue}{\left({4}^{0.125} \cdot x\right) \cdot \left(-{4}^{0.125}\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({4}^{\frac{1}{8}} \cdot x\right) \cdot \left(-{4}^{\frac{1}{8}}\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \color{blue}{\left({4}^{\frac{1}{8}} \cdot x\right)} \cdot \left(-{4}^{\frac{1}{8}}\right) \]
      3. associate-*l*N/A

        \[\leadsto \color{blue}{{4}^{\frac{1}{8}} \cdot \left(x \cdot \left(-{4}^{\frac{1}{8}}\right)\right)} \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{\left(x \cdot \left(-{4}^{\frac{1}{8}}\right)\right) \cdot {4}^{\frac{1}{8}}} \]
      5. lift-neg.f64N/A

        \[\leadsto \left(x \cdot \color{blue}{\left(\mathsf{neg}\left({4}^{\frac{1}{8}}\right)\right)}\right) \cdot {4}^{\frac{1}{8}} \]
      6. neg-mul-1N/A

        \[\leadsto \left(x \cdot \color{blue}{\left(-1 \cdot {4}^{\frac{1}{8}}\right)}\right) \cdot {4}^{\frac{1}{8}} \]
      7. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\left(x \cdot -1\right) \cdot {4}^{\frac{1}{8}}\right)} \cdot {4}^{\frac{1}{8}} \]
      8. *-commutativeN/A

        \[\leadsto \left(\color{blue}{\left(-1 \cdot x\right)} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      9. metadata-evalN/A

        \[\leadsto \left(\left(\color{blue}{\frac{-1}{1}} \cdot x\right) \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      10. associate-/r/N/A

        \[\leadsto \left(\color{blue}{\frac{-1}{\frac{1}{x}}} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      11. unpow-1N/A

        \[\leadsto \left(\frac{-1}{\color{blue}{{x}^{-1}}} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      12. lift-pow.f64N/A

        \[\leadsto \left(\frac{-1}{\color{blue}{{x}^{-1}}} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      13. lift-/.f64N/A

        \[\leadsto \left(\color{blue}{\frac{-1}{{x}^{-1}}} \cdot {4}^{\frac{1}{8}}\right) \cdot {4}^{\frac{1}{8}} \]
      14. associate-*l*N/A

        \[\leadsto \color{blue}{\frac{-1}{{x}^{-1}} \cdot \left({4}^{\frac{1}{8}} \cdot {4}^{\frac{1}{8}}\right)} \]
    7. Applied rewrites99.5%

      \[\leadsto \color{blue}{{\left(x \cdot 4\right)}^{0.25} \cdot {x}^{0.75}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{0.75} \cdot {\left(4 \cdot x\right)}^{0.25}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{2 \cdot x}}{{x}^{-0.5}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2e-310)
   (/ (* -2.0 x) (sqrt 2.0))
   (/ (sqrt (* 2.0 x)) (pow x -0.5))))
double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = (-2.0 * x) / sqrt(2.0);
	} else {
		tmp = sqrt((2.0 * x)) / pow(x, -0.5);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2d-310)) then
        tmp = ((-2.0d0) * x) / sqrt(2.0d0)
    else
        tmp = sqrt((2.0d0 * x)) / (x ** (-0.5d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = (-2.0 * x) / Math.sqrt(2.0);
	} else {
		tmp = Math.sqrt((2.0 * x)) / Math.pow(x, -0.5);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2e-310:
		tmp = (-2.0 * x) / math.sqrt(2.0)
	else:
		tmp = math.sqrt((2.0 * x)) / math.pow(x, -0.5)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2e-310)
		tmp = Float64(Float64(-2.0 * x) / sqrt(2.0));
	else
		tmp = Float64(sqrt(Float64(2.0 * x)) / (x ^ -0.5));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2e-310)
		tmp = (-2.0 * x) / sqrt(2.0);
	else
		tmp = sqrt((2.0 * x)) / (x ^ -0.5);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2e-310], N[(N[(-2.0 * x), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] / N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt{2 \cdot x}}{{x}^{-0.5}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.999999999999994e-310

    1. Initial program 56.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites2.1%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 + x\right)} \]
      3. flip-+N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 - x}} \]
      4. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{-x}} \]
      6. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{-x}\right)} \]
      7. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left(-x\right)}^{-1}}\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\color{blue}{\left(2 \cdot \frac{-1}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}\right) \]
      10. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left({\left(-x\right)}^{2}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right) \]
      11. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      13. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      14. sqr-negN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(x \cdot x\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      15. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left({x}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      16. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{x}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}\right) \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
      18. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\color{blue}{-1}}\right) \]
      19. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{\frac{1}{x}}\right) \]
      20. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{\color{blue}{0 + x}}\right) \]
      21. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 + x}} \]
      22. flip--N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 - x\right)} \]
      23. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left({4}^{0.125} \cdot x\right) \cdot \left(-{4}^{0.125}\right)} \]
    6. Applied rewrites55.9%

      \[\leadsto \color{blue}{\frac{0 - \left(x \cdot x\right) \cdot 2}{\sqrt{2} \cdot x}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{0 - \left(x \cdot x\right) \cdot 2}{\sqrt{2} \cdot x}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{0 - \left(x \cdot x\right) \cdot 2}{\color{blue}{\sqrt{2} \cdot x}} \]
      3. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\frac{0 - \left(x \cdot x\right) \cdot 2}{x}}{\sqrt{2}}} \]
      4. lift--.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{0 - \left(x \cdot x\right) \cdot 2}}{x}}{\sqrt{2}} \]
      5. sub0-negN/A

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{neg}\left(\left(x \cdot x\right) \cdot 2\right)}}{x}}{\sqrt{2}} \]
      6. distribute-frac-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\frac{\left(x \cdot x\right) \cdot 2}{x}\right)}}{\sqrt{2}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{\left(x \cdot x\right) \cdot 2}}{x}\right)}{\sqrt{2}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{\left(x \cdot x\right)} \cdot 2}{x}\right)}{\sqrt{2}} \]
      9. associate-*l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{x \cdot \left(x \cdot 2\right)}}{x}\right)}{\sqrt{2}} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{x \cdot \frac{x \cdot 2}{x}}\right)}{\sqrt{2}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \frac{\color{blue}{2 \cdot x}}{x}\right)}{\sqrt{2}} \]
      12. associate-/l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \color{blue}{\left(2 \cdot \frac{x}{x}\right)}\right)}{\sqrt{2}} \]
      13. *-inversesN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \left(2 \cdot \color{blue}{1}\right)\right)}{\sqrt{2}} \]
      14. metadata-evalN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \color{blue}{2}\right)}{\sqrt{2}} \]
      15. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x \cdot 2\right)}{\sqrt{2}}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{2 \cdot x}\right)}{\sqrt{2}} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot x}}{\sqrt{2}} \]
      18. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot x}}{\sqrt{2}} \]
      19. metadata-eval99.4

        \[\leadsto \frac{\color{blue}{-2} \cdot x}{\sqrt{2}} \]
    8. Applied rewrites99.4%

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

    if -1.999999999999994e-310 < x

    1. Initial program 52.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 + x\right)} \]
      3. flip-+N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 - x}} \]
      4. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{-x}} \]
      6. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{-x}\right)} \]
      7. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left(-x\right)}^{-1}}\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\color{blue}{\left(2 \cdot \frac{-1}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}\right) \]
      10. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left({\left(-x\right)}^{2}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right) \]
      11. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      13. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      14. sqr-negN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(x \cdot x\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      15. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left({x}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      16. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{x}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}\right) \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
      18. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\color{blue}{-1}}\right) \]
      19. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{\frac{1}{x}}\right) \]
      20. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{\color{blue}{0 + x}}\right) \]
      21. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 + x}} \]
      22. flip--N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 - x\right)} \]
      23. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
    5. Applied rewrites2.4%

      \[\leadsto \color{blue}{\left({4}^{0.125} \cdot x\right) \cdot \left(-{4}^{0.125}\right)} \]
    6. Applied rewrites99.4%

      \[\leadsto \color{blue}{\frac{\sqrt{2 \cdot x}}{{x}^{-0.5}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 99.4% accurate, 3.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \sqrt{2 \cdot x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2e-310) (/ (* -2.0 x) (sqrt 2.0)) (* (sqrt x) (sqrt (* 2.0 x)))))
double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = (-2.0 * x) / sqrt(2.0);
	} else {
		tmp = sqrt(x) * sqrt((2.0 * x));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2d-310)) then
        tmp = ((-2.0d0) * x) / sqrt(2.0d0)
    else
        tmp = sqrt(x) * sqrt((2.0d0 * x))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = (-2.0 * x) / Math.sqrt(2.0);
	} else {
		tmp = Math.sqrt(x) * Math.sqrt((2.0 * x));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2e-310:
		tmp = (-2.0 * x) / math.sqrt(2.0)
	else:
		tmp = math.sqrt(x) * math.sqrt((2.0 * x))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2e-310)
		tmp = Float64(Float64(-2.0 * x) / sqrt(2.0));
	else
		tmp = Float64(sqrt(x) * sqrt(Float64(2.0 * x)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2e-310)
		tmp = (-2.0 * x) / sqrt(2.0);
	else
		tmp = sqrt(x) * sqrt((2.0 * x));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2e-310], N[(N[(-2.0 * x), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[x], $MachinePrecision] * N[Sqrt[N[(2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \sqrt{2 \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.999999999999994e-310

    1. Initial program 56.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites2.1%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 + x\right)} \]
      3. flip-+N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 - x}} \]
      4. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{-x}} \]
      6. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{-x}\right)} \]
      7. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left(-x\right)}^{-1}}\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\color{blue}{\left(2 \cdot \frac{-1}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}\right) \]
      10. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left({\left(-x\right)}^{2}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right) \]
      11. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      13. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      14. sqr-negN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(x \cdot x\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      15. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left({x}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      16. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{x}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}\right) \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
      18. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\color{blue}{-1}}\right) \]
      19. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{\frac{1}{x}}\right) \]
      20. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{\color{blue}{0 + x}}\right) \]
      21. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 + x}} \]
      22. flip--N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 - x\right)} \]
      23. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left({4}^{0.125} \cdot x\right) \cdot \left(-{4}^{0.125}\right)} \]
    6. Applied rewrites55.9%

      \[\leadsto \color{blue}{\frac{0 - \left(x \cdot x\right) \cdot 2}{\sqrt{2} \cdot x}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{0 - \left(x \cdot x\right) \cdot 2}{\sqrt{2} \cdot x}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{0 - \left(x \cdot x\right) \cdot 2}{\color{blue}{\sqrt{2} \cdot x}} \]
      3. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\frac{0 - \left(x \cdot x\right) \cdot 2}{x}}{\sqrt{2}}} \]
      4. lift--.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{0 - \left(x \cdot x\right) \cdot 2}}{x}}{\sqrt{2}} \]
      5. sub0-negN/A

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{neg}\left(\left(x \cdot x\right) \cdot 2\right)}}{x}}{\sqrt{2}} \]
      6. distribute-frac-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\frac{\left(x \cdot x\right) \cdot 2}{x}\right)}}{\sqrt{2}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{\left(x \cdot x\right) \cdot 2}}{x}\right)}{\sqrt{2}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{\left(x \cdot x\right)} \cdot 2}{x}\right)}{\sqrt{2}} \]
      9. associate-*l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{x \cdot \left(x \cdot 2\right)}}{x}\right)}{\sqrt{2}} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{x \cdot \frac{x \cdot 2}{x}}\right)}{\sqrt{2}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \frac{\color{blue}{2 \cdot x}}{x}\right)}{\sqrt{2}} \]
      12. associate-/l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \color{blue}{\left(2 \cdot \frac{x}{x}\right)}\right)}{\sqrt{2}} \]
      13. *-inversesN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \left(2 \cdot \color{blue}{1}\right)\right)}{\sqrt{2}} \]
      14. metadata-evalN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \color{blue}{2}\right)}{\sqrt{2}} \]
      15. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x \cdot 2\right)}{\sqrt{2}}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{2 \cdot x}\right)}{\sqrt{2}} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot x}}{\sqrt{2}} \]
      18. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot x}}{\sqrt{2}} \]
      19. metadata-eval99.4

        \[\leadsto \frac{\color{blue}{-2} \cdot x}{\sqrt{2}} \]
    8. Applied rewrites99.4%

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

    if -1.999999999999994e-310 < x

    1. Initial program 52.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. unpow1N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{{x}^{1}} \]
      3. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot {x}^{\color{blue}{\left(\frac{2}{2}\right)}} \]
      4. sqr-powN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left({x}^{\left(\frac{\frac{2}{2}}{2}\right)} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)}\right)} \]
      5. associate-*r*N/A

        \[\leadsto \color{blue}{\left(\sqrt{2} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)}} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \left(\color{blue}{\sqrt{2}} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      7. pow1/2N/A

        \[\leadsto \left(\color{blue}{{2}^{\frac{1}{2}}} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)}\right) \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      8. metadata-evalN/A

        \[\leadsto \left({2}^{\frac{1}{2}} \cdot {x}^{\left(\frac{\color{blue}{1}}{2}\right)}\right) \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      9. metadata-evalN/A

        \[\leadsto \left({2}^{\frac{1}{2}} \cdot {x}^{\color{blue}{\frac{1}{2}}}\right) \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      10. unpow-prod-downN/A

        \[\leadsto \color{blue}{{\left(2 \cdot x\right)}^{\frac{1}{2}}} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \color{blue}{{\left(2 \cdot x\right)}^{\frac{1}{2}} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)}} \]
      12. pow1/2N/A

        \[\leadsto \color{blue}{\sqrt{2 \cdot x}} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      13. lower-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{2 \cdot x}} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      14. *-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{x \cdot 2}} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      15. lower-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{x \cdot 2}} \cdot {x}^{\left(\frac{\frac{2}{2}}{2}\right)} \]
      16. metadata-evalN/A

        \[\leadsto \sqrt{x \cdot 2} \cdot {x}^{\left(\frac{\color{blue}{1}}{2}\right)} \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{x \cdot 2} \cdot {x}^{\color{blue}{\frac{1}{2}}} \]
      18. pow1/2N/A

        \[\leadsto \sqrt{x \cdot 2} \cdot \color{blue}{\sqrt{x}} \]
      19. lower-sqrt.f6499.4

        \[\leadsto \sqrt{x \cdot 2} \cdot \color{blue}{\sqrt{x}} \]
    5. Applied rewrites99.4%

      \[\leadsto \color{blue}{\sqrt{x \cdot 2} \cdot \sqrt{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \sqrt{2 \cdot x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 99.3% accurate, 3.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot x\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2e-310) (/ (* -2.0 x) (sqrt 2.0)) (* (sqrt 2.0) x)))
double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = (-2.0 * x) / sqrt(2.0);
	} else {
		tmp = sqrt(2.0) * x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2d-310)) then
        tmp = ((-2.0d0) * x) / sqrt(2.0d0)
    else
        tmp = sqrt(2.0d0) * x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = (-2.0 * x) / Math.sqrt(2.0);
	} else {
		tmp = Math.sqrt(2.0) * x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2e-310:
		tmp = (-2.0 * x) / math.sqrt(2.0)
	else:
		tmp = math.sqrt(2.0) * x
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2e-310)
		tmp = Float64(Float64(-2.0 * x) / sqrt(2.0));
	else
		tmp = Float64(sqrt(2.0) * x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2e-310)
		tmp = (-2.0 * x) / sqrt(2.0);
	else
		tmp = sqrt(2.0) * x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2e-310], N[(N[(-2.0 * x), $MachinePrecision] / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-2 \cdot x}{\sqrt{2}}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.999999999999994e-310

    1. Initial program 56.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites2.1%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
    4. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
      2. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 + x\right)} \]
      3. flip-+N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 - x}} \]
      4. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{\mathsf{neg}\left(x\right)}} \]
      5. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \frac{0 \cdot 0 - x \cdot x}{\color{blue}{-x}} \]
      6. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{-x}\right)} \]
      7. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left(-x\right)}^{-1}}\right) \]
      8. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\color{blue}{\left(2 \cdot \frac{-1}{2}\right)}}\right) \]
      9. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(-x\right)}^{\left(2 \cdot \color{blue}{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right)}\right) \]
      10. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{\left({\left(-x\right)}^{2}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}\right) \]
      11. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(\left(-x\right) \cdot \left(-x\right)\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      12. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \left(-x\right)\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      13. lift-neg.f64N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\left(\left(\mathsf{neg}\left(x\right)\right) \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)}\right)}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      14. sqr-negN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left(x \cdot x\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      15. pow2N/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {\color{blue}{\left({x}^{2}\right)}}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}\right) \]
      16. pow-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{{x}^{\left(2 \cdot \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)}}\right) \]
      17. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\left(2 \cdot \color{blue}{\frac{-1}{2}}\right)}\right) \]
      18. metadata-evalN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot {x}^{\color{blue}{-1}}\right) \]
      19. inv-powN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \color{blue}{\frac{1}{x}}\right) \]
      20. +-lft-identityN/A

        \[\leadsto \sqrt{2} \cdot \left(\left(0 \cdot 0 - x \cdot x\right) \cdot \frac{1}{\color{blue}{0 + x}}\right) \]
      21. div-invN/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\frac{0 \cdot 0 - x \cdot x}{0 + x}} \]
      22. flip--N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(0 - x\right)} \]
      23. neg-sub0N/A

        \[\leadsto \sqrt{2} \cdot \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
    5. Applied rewrites99.3%

      \[\leadsto \color{blue}{\left({4}^{0.125} \cdot x\right) \cdot \left(-{4}^{0.125}\right)} \]
    6. Applied rewrites55.9%

      \[\leadsto \color{blue}{\frac{0 - \left(x \cdot x\right) \cdot 2}{\sqrt{2} \cdot x}} \]
    7. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{0 - \left(x \cdot x\right) \cdot 2}{\sqrt{2} \cdot x}} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{0 - \left(x \cdot x\right) \cdot 2}{\color{blue}{\sqrt{2} \cdot x}} \]
      3. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\frac{0 - \left(x \cdot x\right) \cdot 2}{x}}{\sqrt{2}}} \]
      4. lift--.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{0 - \left(x \cdot x\right) \cdot 2}}{x}}{\sqrt{2}} \]
      5. sub0-negN/A

        \[\leadsto \frac{\frac{\color{blue}{\mathsf{neg}\left(\left(x \cdot x\right) \cdot 2\right)}}{x}}{\sqrt{2}} \]
      6. distribute-frac-negN/A

        \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\frac{\left(x \cdot x\right) \cdot 2}{x}\right)}}{\sqrt{2}} \]
      7. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{\left(x \cdot x\right) \cdot 2}}{x}\right)}{\sqrt{2}} \]
      8. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{\left(x \cdot x\right)} \cdot 2}{x}\right)}{\sqrt{2}} \]
      9. associate-*l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(\frac{\color{blue}{x \cdot \left(x \cdot 2\right)}}{x}\right)}{\sqrt{2}} \]
      10. associate-/l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{x \cdot \frac{x \cdot 2}{x}}\right)}{\sqrt{2}} \]
      11. *-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \frac{\color{blue}{2 \cdot x}}{x}\right)}{\sqrt{2}} \]
      12. associate-/l*N/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \color{blue}{\left(2 \cdot \frac{x}{x}\right)}\right)}{\sqrt{2}} \]
      13. *-inversesN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \left(2 \cdot \color{blue}{1}\right)\right)}{\sqrt{2}} \]
      14. metadata-evalN/A

        \[\leadsto \frac{\mathsf{neg}\left(x \cdot \color{blue}{2}\right)}{\sqrt{2}} \]
      15. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\mathsf{neg}\left(x \cdot 2\right)}{\sqrt{2}}} \]
      16. *-commutativeN/A

        \[\leadsto \frac{\mathsf{neg}\left(\color{blue}{2 \cdot x}\right)}{\sqrt{2}} \]
      17. distribute-lft-neg-inN/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot x}}{\sqrt{2}} \]
      18. lower-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(2\right)\right) \cdot x}}{\sqrt{2}} \]
      19. metadata-eval99.4

        \[\leadsto \frac{\color{blue}{-2} \cdot x}{\sqrt{2}} \]
    8. Applied rewrites99.4%

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

    if -1.999999999999994e-310 < x

    1. Initial program 52.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 99.3% accurate, 4.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\ \;\;\;\;\left(-x\right) \cdot \sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot x\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2e-310) (* (- x) (sqrt 2.0)) (* (sqrt 2.0) x)))
double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = -x * sqrt(2.0);
	} else {
		tmp = sqrt(2.0) * x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2d-310)) then
        tmp = -x * sqrt(2.0d0)
    else
        tmp = sqrt(2.0d0) * x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2e-310) {
		tmp = -x * Math.sqrt(2.0);
	} else {
		tmp = Math.sqrt(2.0) * x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2e-310:
		tmp = -x * math.sqrt(2.0)
	else:
		tmp = math.sqrt(2.0) * x
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2e-310)
		tmp = Float64(Float64(-x) * sqrt(2.0));
	else
		tmp = Float64(sqrt(2.0) * x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2e-310)
		tmp = -x * sqrt(2.0);
	else
		tmp = sqrt(2.0) * x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2e-310], N[((-x) * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\left(-x\right) \cdot \sqrt{2}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.999999999999994e-310

    1. Initial program 56.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1 \cdot \left(x \cdot \sqrt{2}\right)} \]
    4. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \color{blue}{\left(-1 \cdot x\right) \cdot \sqrt{2}} \]
      2. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(-1 \cdot x\right) \cdot \sqrt{2}} \]
      3. mul-1-negN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \cdot \sqrt{2} \]
      4. lower-neg.f64N/A

        \[\leadsto \color{blue}{\left(-x\right)} \cdot \sqrt{2} \]
      5. lower-sqrt.f6499.3

        \[\leadsto \left(-x\right) \cdot \color{blue}{\sqrt{2}} \]
    5. Applied rewrites99.3%

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

    if -1.999999999999994e-310 < x

    1. Initial program 52.2%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites99.3%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 52.5% accurate, 5.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-206}:\\ \;\;\;\;\sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{2} \cdot x\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -4e-206) (sqrt 2.0) (* (sqrt 2.0) x)))
double code(double x) {
	double tmp;
	if (x <= -4e-206) {
		tmp = sqrt(2.0);
	} else {
		tmp = sqrt(2.0) * x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-4d-206)) then
        tmp = sqrt(2.0d0)
    else
        tmp = sqrt(2.0d0) * x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -4e-206) {
		tmp = Math.sqrt(2.0);
	} else {
		tmp = Math.sqrt(2.0) * x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -4e-206:
		tmp = math.sqrt(2.0)
	else:
		tmp = math.sqrt(2.0) * x
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -4e-206)
		tmp = sqrt(2.0);
	else
		tmp = Float64(sqrt(2.0) * x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -4e-206)
		tmp = sqrt(2.0);
	else
		tmp = sqrt(2.0) * x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -4e-206], N[Sqrt[2.0], $MachinePrecision], N[(N[Sqrt[2.0], $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-206}:\\
\;\;\;\;\sqrt{2}\\

\mathbf{else}:\\
\;\;\;\;\sqrt{2} \cdot x\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.00000000000000011e-206

    1. Initial program 65.8%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites5.9%

      \[\leadsto \color{blue}{\sqrt{2}} \]

    if -4.00000000000000011e-206 < x

    1. Initial program 45.3%

      \[\sqrt{2 \cdot {x}^{2}} \]
    2. Add Preprocessing
    3. Applied rewrites84.9%

      \[\leadsto \color{blue}{\sqrt{2} \cdot x} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 5.4% accurate, 10.6× speedup?

\[\begin{array}{l} \\ \sqrt{2} \end{array} \]
(FPCore (x) :precision binary64 (sqrt 2.0))
double code(double x) {
	return sqrt(2.0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt(2.0d0)
end function
public static double code(double x) {
	return Math.sqrt(2.0);
}
def code(x):
	return math.sqrt(2.0)
function code(x)
	return sqrt(2.0)
end
function tmp = code(x)
	tmp = sqrt(2.0);
end
code[x_] := N[Sqrt[2.0], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{2}
\end{array}
Derivation
  1. Initial program 54.3%

    \[\sqrt{2 \cdot {x}^{2}} \]
  2. Add Preprocessing
  3. Applied rewrites5.4%

    \[\leadsto \color{blue}{\sqrt{2}} \]
  4. Add Preprocessing

Reproduce

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