math.sqrt on complex, imaginary part, im greater than 0 branch

Percentage Accurate: 41.4% → 86.5%
Time: 3.2s
Alternatives: 7
Speedup: 1.7×

Specification

?
\[im > 0\]
\[\begin{array}{l} \\ 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \end{array} \]
(FPCore (re im)
 :precision binary64
 (* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))
double code(double re, double im) {
	return 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = 0.5d0 * sqrt((2.0d0 * (sqrt(((re * re) + (im * im))) - re)))
end function
public static double code(double re, double im) {
	return 0.5 * Math.sqrt((2.0 * (Math.sqrt(((re * re) + (im * im))) - re)));
}
def code(re, im):
	return 0.5 * math.sqrt((2.0 * (math.sqrt(((re * re) + (im * im))) - re)))
function code(re, im)
	return Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(re * re) + Float64(im * im))) - re))))
end
function tmp = code(re, im)
	tmp = 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re)));
end
code[re_, im_] := N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}
\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.

Accuracy vs Speed?

Herbie found 7 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: 41.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \end{array} \]
(FPCore (re im)
 :precision binary64
 (* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))
double code(double re, double im) {
	return 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(re, im)
use fmin_fmax_functions
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = 0.5d0 * sqrt((2.0d0 * (sqrt(((re * re) + (im * im))) - re)))
end function
public static double code(double re, double im) {
	return 0.5 * Math.sqrt((2.0 * (Math.sqrt(((re * re) + (im * im))) - re)));
}
def code(re, im):
	return 0.5 * math.sqrt((2.0 * (math.sqrt(((re * re) + (im * im))) - re)))
function code(re, im)
	return Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(Float64(Float64(re * re) + Float64(im * im))) - re))))
end
function tmp = code(re, im)
	tmp = 0.5 * sqrt((2.0 * (sqrt(((re * re) + (im * im))) - re)));
end
code[re_, im_] := N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}
\end{array}

Alternative 1: 86.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq 3.2 \cdot 10^{+125}:\\ \;\;\;\;\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(im \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \sqrt{2}\right) \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re 3.2e+125)
   (* (sqrt (* (- (hypot im re) re) 2.0)) 0.5)
   (* (* (* (* im (sqrt 0.5)) (sqrt (/ 1.0 re))) (sqrt 2.0)) 0.5)))
double code(double re, double im) {
	double tmp;
	if (re <= 3.2e+125) {
		tmp = sqrt(((hypot(im, re) - re) * 2.0)) * 0.5;
	} else {
		tmp = (((im * sqrt(0.5)) * sqrt((1.0 / re))) * sqrt(2.0)) * 0.5;
	}
	return tmp;
}
public static double code(double re, double im) {
	double tmp;
	if (re <= 3.2e+125) {
		tmp = Math.sqrt(((Math.hypot(im, re) - re) * 2.0)) * 0.5;
	} else {
		tmp = (((im * Math.sqrt(0.5)) * Math.sqrt((1.0 / re))) * Math.sqrt(2.0)) * 0.5;
	}
	return tmp;
}
def code(re, im):
	tmp = 0
	if re <= 3.2e+125:
		tmp = math.sqrt(((math.hypot(im, re) - re) * 2.0)) * 0.5
	else:
		tmp = (((im * math.sqrt(0.5)) * math.sqrt((1.0 / re))) * math.sqrt(2.0)) * 0.5
	return tmp
function code(re, im)
	tmp = 0.0
	if (re <= 3.2e+125)
		tmp = Float64(sqrt(Float64(Float64(hypot(im, re) - re) * 2.0)) * 0.5);
	else
		tmp = Float64(Float64(Float64(Float64(im * sqrt(0.5)) * sqrt(Float64(1.0 / re))) * sqrt(2.0)) * 0.5);
	end
	return tmp
end
function tmp_2 = code(re, im)
	tmp = 0.0;
	if (re <= 3.2e+125)
		tmp = sqrt(((hypot(im, re) - re) * 2.0)) * 0.5;
	else
		tmp = (((im * sqrt(0.5)) * sqrt((1.0 / re))) * sqrt(2.0)) * 0.5;
	end
	tmp_2 = tmp;
end
code[re_, im_] := If[LessEqual[re, 3.2e+125], N[(N[Sqrt[N[(N[(N[Sqrt[im ^ 2 + re ^ 2], $MachinePrecision] - re), $MachinePrecision] * 2.0), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(im * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.2 \cdot 10^{+125}:\\
\;\;\;\;\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\left(im \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \sqrt{2}\right) \cdot 0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if re < 3.19999999999999983e125

    1. Initial program 47.7%

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot \frac{1}{2}} \]
      3. lower-*.f6447.7

        \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot 0.5} \]
      4. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \cdot \frac{1}{2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot \frac{1}{2} \]
      6. lower-*.f6447.7

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot 0.5 \]
      7. lift-sqrt.f64N/A

        \[\leadsto \sqrt{\left(\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      8. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      9. +-commutativeN/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im + re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      10. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      11. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{im \cdot im + \color{blue}{re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      12. lower-hypot.f6487.0

        \[\leadsto \sqrt{\left(\color{blue}{\mathsf{hypot}\left(im, re\right)} - re\right) \cdot 2} \cdot 0.5 \]
    3. Applied rewrites87.0%

      \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5} \]

    if 3.19999999999999983e125 < re

    1. Initial program 5.0%

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot \frac{1}{2}} \]
      3. lower-*.f645.0

        \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot 0.5} \]
      4. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \cdot \frac{1}{2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot \frac{1}{2} \]
      6. lower-*.f645.0

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot 0.5 \]
      7. lift-sqrt.f64N/A

        \[\leadsto \sqrt{\left(\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      8. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      9. +-commutativeN/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im + re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      10. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      11. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{im \cdot im + \color{blue}{re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      12. lower-hypot.f6435.2

        \[\leadsto \sqrt{\left(\color{blue}{\mathsf{hypot}\left(im, re\right)} - re\right) \cdot 2} \cdot 0.5 \]
    3. Applied rewrites35.2%

      \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5} \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
      3. sqrt-prodN/A

        \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(im, re\right) - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
      4. lift-hypot.f64N/A

        \[\leadsto \left(\sqrt{\color{blue}{\sqrt{im \cdot im + re \cdot re}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      5. lift-*.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{{re}^{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      7. exp-to-powN/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      8. lift-log.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re} \cdot 2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      9. lift-*.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      10. lift-exp.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      11. +-commutativeN/A

        \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      12. lift-+.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \left(\sqrt{\color{blue}{\sqrt{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      14. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\sqrt{\sqrt{e^{\log re \cdot 2} + im \cdot im} - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
    5. Applied rewrites35.2%

      \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(re, im\right) - re} \cdot \sqrt{2}\right)} \cdot 0.5 \]
    6. Step-by-step derivation
      1. lift-hypot.f64N/A

        \[\leadsto \left(\sqrt{\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{re \cdot re + \color{blue}{im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      3. lift-fma.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      4. pow1/2N/A

        \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      5. unpow1N/A

        \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{1}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      6. sqr-powN/A

        \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      7. metadata-evalN/A

        \[\leadsto \left(\sqrt{{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      8. pow1/2N/A

        \[\leadsto \left(\sqrt{{\left(\color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      9. lift-fma.f64N/A

        \[\leadsto \left(\sqrt{{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      10. lift-*.f64N/A

        \[\leadsto \left(\sqrt{{\left(\sqrt{re \cdot re + \color{blue}{im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      11. lift-hypot.f64N/A

        \[\leadsto \left(\sqrt{{\left(\color{blue}{\mathsf{hypot}\left(re, im\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      12. metadata-evalN/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      13. pow1/2N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      14. lift-fma.f64N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{\color{blue}{re \cdot re + im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      15. lift-*.f64N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{re \cdot re + \color{blue}{im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      16. lift-hypot.f64N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      17. pow-prod-downN/A

        \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      18. lift-pow.f64N/A

        \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      19. lift-pow.f64N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      20. pow2N/A

        \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      21. lower-pow.f6427.7

        \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{0.5}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
    7. Applied rewrites27.7%

      \[\leadsto \left(\sqrt{\color{blue}{{\left(\sqrt{\mathsf{hypot}\left(im, re\right)}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
    8. Taylor expanded in re around inf

      \[\leadsto \left(\color{blue}{\left(\left(im \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{re}}\right)} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

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

        \[\leadsto \left(\left(\left(im \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\color{blue}{\frac{1}{re}}}\right) \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      3. lower-sqrt.f64N/A

        \[\leadsto \left(\left(\left(im \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{\color{blue}{re}}}\right) \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      4. lower-sqrt.f64N/A

        \[\leadsto \left(\left(\left(im \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      5. lower-/.f6483.4

        \[\leadsto \left(\left(\left(im \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \sqrt{2}\right) \cdot 0.5 \]
    10. Applied rewrites83.4%

      \[\leadsto \left(\color{blue}{\left(\left(im \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{1}{re}}\right)} \cdot \sqrt{2}\right) \cdot 0.5 \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 77.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -1.05 \cdot 10^{+126}:\\ \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\ \mathbf{elif}\;re \leq -7.5 \cdot 10^{-79}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)} - re\right)}\\ \mathbf{elif}\;re \leq 1.3 \cdot 10^{-104}:\\ \;\;\;\;\left(\sqrt{im - re} \cdot \sqrt{2}\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\left(im \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \sqrt{2}\right) \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (re im)
 :precision binary64
 (if (<= re -1.05e+126)
   (* 0.5 (sqrt (* -4.0 re)))
   (if (<= re -7.5e-79)
     (* 0.5 (sqrt (* 2.0 (- (sqrt (fma re re (* im im))) re))))
     (if (<= re 1.3e-104)
       (* (* (sqrt (- im re)) (sqrt 2.0)) 0.5)
       (* (* (* (* im (sqrt 0.5)) (sqrt (/ 1.0 re))) (sqrt 2.0)) 0.5)))))
double code(double re, double im) {
	double tmp;
	if (re <= -1.05e+126) {
		tmp = 0.5 * sqrt((-4.0 * re));
	} else if (re <= -7.5e-79) {
		tmp = 0.5 * sqrt((2.0 * (sqrt(fma(re, re, (im * im))) - re)));
	} else if (re <= 1.3e-104) {
		tmp = (sqrt((im - re)) * sqrt(2.0)) * 0.5;
	} else {
		tmp = (((im * sqrt(0.5)) * sqrt((1.0 / re))) * sqrt(2.0)) * 0.5;
	}
	return tmp;
}
function code(re, im)
	tmp = 0.0
	if (re <= -1.05e+126)
		tmp = Float64(0.5 * sqrt(Float64(-4.0 * re)));
	elseif (re <= -7.5e-79)
		tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(fma(re, re, Float64(im * im))) - re))));
	elseif (re <= 1.3e-104)
		tmp = Float64(Float64(sqrt(Float64(im - re)) * sqrt(2.0)) * 0.5);
	else
		tmp = Float64(Float64(Float64(Float64(im * sqrt(0.5)) * sqrt(Float64(1.0 / re))) * sqrt(2.0)) * 0.5);
	end
	return tmp
end
code[re_, im_] := If[LessEqual[re, -1.05e+126], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, -7.5e-79], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(re * re + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.3e-104], N[(N[(N[Sqrt[N[(im - re), $MachinePrecision]], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(im * N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.05 \cdot 10^{+126}:\\
\;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\

\mathbf{elif}\;re \leq -7.5 \cdot 10^{-79}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)} - re\right)}\\

\mathbf{elif}\;re \leq 1.3 \cdot 10^{-104}:\\
\;\;\;\;\left(\sqrt{im - re} \cdot \sqrt{2}\right) \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;\left(\left(\left(im \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \sqrt{2}\right) \cdot 0.5\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if re < -1.05e126

    1. Initial program 14.8%

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
      3. lower-fma.f6414.8

        \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
    3. Applied rewrites14.8%

      \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
    4. Step-by-step derivation
      1. lift-fma.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
      2. pow2N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{{re}^{2}} + im \cdot im} - re\right)} \]
      3. exp-to-powN/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
      4. lift-log.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re} \cdot 2} + im \cdot im} - re\right)} \]
      5. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re \cdot 2}} + im \cdot im} - re\right)} \]
      6. lift-exp.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
      7. flip3-+N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
      8. lower-/.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
    5. Applied rewrites0.0%

      \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, re \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{re \cdot re}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      2. rem-exp-logN/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      3. lift-log.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      4. rem-exp-logN/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot \color{blue}{e^{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      5. lift-log.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot e^{\color{blue}{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      6. exp-lft-sqr-revN/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      7. lower-exp.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      8. lower-*.f640.0

        \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
    7. Applied rewrites0.0%

      \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
    8. Taylor expanded in re around -inf

      \[\leadsto \frac{1}{2} \cdot \sqrt{\color{blue}{-4 \cdot re}} \]
    9. Step-by-step derivation
      1. lower-*.f6486.3

        \[\leadsto 0.5 \cdot \sqrt{-4 \cdot \color{blue}{re}} \]
    10. Applied rewrites86.3%

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{-4 \cdot re}} \]

    if -1.05e126 < re < -7.49999999999999969e-79

    1. Initial program 76.8%

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
      3. lower-fma.f6476.8

        \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
    3. Applied rewrites76.8%

      \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]

    if -7.49999999999999969e-79 < re < 1.30000000000000001e-104

    1. Initial program 57.2%

      \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
    2. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot \frac{1}{2}} \]
      3. lower-*.f6457.2

        \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot 0.5} \]
      4. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \cdot \frac{1}{2} \]
      5. *-commutativeN/A

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot \frac{1}{2} \]
      6. lower-*.f6457.2

        \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot 0.5 \]
      7. lift-sqrt.f64N/A

        \[\leadsto \sqrt{\left(\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      8. lift-+.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      9. +-commutativeN/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im + re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      10. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      11. lift-*.f64N/A

        \[\leadsto \sqrt{\left(\sqrt{im \cdot im + \color{blue}{re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
      12. lower-hypot.f6493.3

        \[\leadsto \sqrt{\left(\color{blue}{\mathsf{hypot}\left(im, re\right)} - re\right) \cdot 2} \cdot 0.5 \]
    3. Applied rewrites93.3%

      \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5} \]
    4. Step-by-step derivation
      1. lift-sqrt.f64N/A

        \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
      2. lift-*.f64N/A

        \[\leadsto \sqrt{\color{blue}{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
      3. sqrt-prodN/A

        \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(im, re\right) - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
      4. lift-hypot.f64N/A

        \[\leadsto \left(\sqrt{\color{blue}{\sqrt{im \cdot im + re \cdot re}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      5. lift-*.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      6. pow2N/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{{re}^{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      7. exp-to-powN/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      8. lift-log.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re} \cdot 2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      9. lift-*.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      10. lift-exp.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      11. +-commutativeN/A

        \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      12. lift-+.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      13. lift-sqrt.f64N/A

        \[\leadsto \left(\sqrt{\color{blue}{\sqrt{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      14. lower-*.f64N/A

        \[\leadsto \color{blue}{\left(\sqrt{\sqrt{e^{\log re \cdot 2} + im \cdot im} - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
    5. Applied rewrites92.7%

      \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(re, im\right) - re} \cdot \sqrt{2}\right)} \cdot 0.5 \]
    6. Step-by-step derivation
      1. lift-hypot.f64N/A

        \[\leadsto \left(\sqrt{\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{re \cdot re + \color{blue}{im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      3. lift-fma.f64N/A

        \[\leadsto \left(\sqrt{\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      4. pow1/2N/A

        \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      5. unpow1N/A

        \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{1}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      6. sqr-powN/A

        \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      7. metadata-evalN/A

        \[\leadsto \left(\sqrt{{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      8. pow1/2N/A

        \[\leadsto \left(\sqrt{{\left(\color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      9. lift-fma.f64N/A

        \[\leadsto \left(\sqrt{{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      10. lift-*.f64N/A

        \[\leadsto \left(\sqrt{{\left(\sqrt{re \cdot re + \color{blue}{im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      11. lift-hypot.f64N/A

        \[\leadsto \left(\sqrt{{\left(\color{blue}{\mathsf{hypot}\left(re, im\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      12. metadata-evalN/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      13. pow1/2N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      14. lift-fma.f64N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{\color{blue}{re \cdot re + im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      15. lift-*.f64N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{re \cdot re + \color{blue}{im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      16. lift-hypot.f64N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      17. pow-prod-downN/A

        \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      18. lift-pow.f64N/A

        \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      19. lift-pow.f64N/A

        \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      20. pow2N/A

        \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      21. lower-pow.f6492.6

        \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{0.5}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
    7. Applied rewrites92.6%

      \[\leadsto \left(\sqrt{\color{blue}{{\left(\sqrt{\mathsf{hypot}\left(im, re\right)}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
    8. Taylor expanded in re around 0

      \[\leadsto \left(\sqrt{\color{blue}{im} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
    9. Step-by-step derivation
      1. Applied rewrites83.1%

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

      if 1.30000000000000001e-104 < re

      1. Initial program 18.9%

        \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot \frac{1}{2}} \]
        3. lower-*.f6418.9

          \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot 0.5} \]
        4. lift-*.f64N/A

          \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \cdot \frac{1}{2} \]
        5. *-commutativeN/A

          \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot \frac{1}{2} \]
        6. lower-*.f6418.9

          \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot 0.5 \]
        7. lift-sqrt.f64N/A

          \[\leadsto \sqrt{\left(\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        8. lift-+.f64N/A

          \[\leadsto \sqrt{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        9. +-commutativeN/A

          \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im + re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        10. lift-*.f64N/A

          \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        11. lift-*.f64N/A

          \[\leadsto \sqrt{\left(\sqrt{im \cdot im + \color{blue}{re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        12. lower-hypot.f6445.0

          \[\leadsto \sqrt{\left(\color{blue}{\mathsf{hypot}\left(im, re\right)} - re\right) \cdot 2} \cdot 0.5 \]
      3. Applied rewrites45.0%

        \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5} \]
      4. Step-by-step derivation
        1. lift-sqrt.f64N/A

          \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
        2. lift-*.f64N/A

          \[\leadsto \sqrt{\color{blue}{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
        3. sqrt-prodN/A

          \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(im, re\right) - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
        4. lift-hypot.f64N/A

          \[\leadsto \left(\sqrt{\color{blue}{\sqrt{im \cdot im + re \cdot re}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        5. lift-*.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        6. pow2N/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{{re}^{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        7. exp-to-powN/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        8. lift-log.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re} \cdot 2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        9. lift-*.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        10. lift-exp.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        11. +-commutativeN/A

          \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        12. lift-+.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        13. lift-sqrt.f64N/A

          \[\leadsto \left(\sqrt{\color{blue}{\sqrt{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        14. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\sqrt{\sqrt{e^{\log re \cdot 2} + im \cdot im} - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
      5. Applied rewrites44.8%

        \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(re, im\right) - re} \cdot \sqrt{2}\right)} \cdot 0.5 \]
      6. Step-by-step derivation
        1. lift-hypot.f64N/A

          \[\leadsto \left(\sqrt{\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        2. lift-*.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{re \cdot re + \color{blue}{im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        3. lift-fma.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        4. pow1/2N/A

          \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        5. unpow1N/A

          \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{1}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        6. sqr-powN/A

          \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        7. metadata-evalN/A

          \[\leadsto \left(\sqrt{{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        8. pow1/2N/A

          \[\leadsto \left(\sqrt{{\left(\color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        9. lift-fma.f64N/A

          \[\leadsto \left(\sqrt{{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        10. lift-*.f64N/A

          \[\leadsto \left(\sqrt{{\left(\sqrt{re \cdot re + \color{blue}{im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        11. lift-hypot.f64N/A

          \[\leadsto \left(\sqrt{{\left(\color{blue}{\mathsf{hypot}\left(re, im\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        12. metadata-evalN/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        13. pow1/2N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        14. lift-fma.f64N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{\color{blue}{re \cdot re + im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        15. lift-*.f64N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{re \cdot re + \color{blue}{im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        16. lift-hypot.f64N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        17. pow-prod-downN/A

          \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        18. lift-pow.f64N/A

          \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        19. lift-pow.f64N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        20. pow2N/A

          \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        21. lower-pow.f6440.7

          \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{0.5}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
      7. Applied rewrites40.7%

        \[\leadsto \left(\sqrt{\color{blue}{{\left(\sqrt{\mathsf{hypot}\left(im, re\right)}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
      8. Taylor expanded in re around inf

        \[\leadsto \left(\color{blue}{\left(\left(im \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{re}}\right)} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      9. Step-by-step derivation
        1. lower-*.f64N/A

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

          \[\leadsto \left(\left(\left(im \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\color{blue}{\frac{1}{re}}}\right) \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        3. lower-sqrt.f64N/A

          \[\leadsto \left(\left(\left(im \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{\color{blue}{re}}}\right) \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        4. lower-sqrt.f64N/A

          \[\leadsto \left(\left(\left(im \cdot \sqrt{\frac{1}{2}}\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        5. lower-/.f6467.5

          \[\leadsto \left(\left(\left(im \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \sqrt{2}\right) \cdot 0.5 \]
      10. Applied rewrites67.5%

        \[\leadsto \left(\color{blue}{\left(\left(im \cdot \sqrt{0.5}\right) \cdot \sqrt{\frac{1}{re}}\right)} \cdot \sqrt{2}\right) \cdot 0.5 \]
    10. Recombined 4 regimes into one program.
    11. Add Preprocessing

    Alternative 3: 77.2% accurate, 0.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -1.05 \cdot 10^{+126}:\\ \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\ \mathbf{elif}\;re \leq -7.5 \cdot 10^{-79}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)} - re\right)}\\ \mathbf{elif}\;re \leq 1.3 \cdot 10^{-104}:\\ \;\;\;\;\left(\sqrt{im - re} \cdot \sqrt{2}\right) \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\left(\left(im \cdot \left(\sqrt{0.5} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot 0.5\\ \end{array} \end{array} \]
    (FPCore (re im)
     :precision binary64
     (if (<= re -1.05e+126)
       (* 0.5 (sqrt (* -4.0 re)))
       (if (<= re -7.5e-79)
         (* 0.5 (sqrt (* 2.0 (- (sqrt (fma re re (* im im))) re))))
         (if (<= re 1.3e-104)
           (* (* (sqrt (- im re)) (sqrt 2.0)) 0.5)
           (* (* (* im (* (sqrt 0.5) (sqrt 2.0))) (sqrt (/ 1.0 re))) 0.5)))))
    double code(double re, double im) {
    	double tmp;
    	if (re <= -1.05e+126) {
    		tmp = 0.5 * sqrt((-4.0 * re));
    	} else if (re <= -7.5e-79) {
    		tmp = 0.5 * sqrt((2.0 * (sqrt(fma(re, re, (im * im))) - re)));
    	} else if (re <= 1.3e-104) {
    		tmp = (sqrt((im - re)) * sqrt(2.0)) * 0.5;
    	} else {
    		tmp = ((im * (sqrt(0.5) * sqrt(2.0))) * sqrt((1.0 / re))) * 0.5;
    	}
    	return tmp;
    }
    
    function code(re, im)
    	tmp = 0.0
    	if (re <= -1.05e+126)
    		tmp = Float64(0.5 * sqrt(Float64(-4.0 * re)));
    	elseif (re <= -7.5e-79)
    		tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(fma(re, re, Float64(im * im))) - re))));
    	elseif (re <= 1.3e-104)
    		tmp = Float64(Float64(sqrt(Float64(im - re)) * sqrt(2.0)) * 0.5);
    	else
    		tmp = Float64(Float64(Float64(im * Float64(sqrt(0.5) * sqrt(2.0))) * sqrt(Float64(1.0 / re))) * 0.5);
    	end
    	return tmp
    end
    
    code[re_, im_] := If[LessEqual[re, -1.05e+126], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, -7.5e-79], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(re * re + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.3e-104], N[(N[(N[Sqrt[N[(im - re), $MachinePrecision]], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(im * N[(N[Sqrt[0.5], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 / re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;re \leq -1.05 \cdot 10^{+126}:\\
    \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
    
    \mathbf{elif}\;re \leq -7.5 \cdot 10^{-79}:\\
    \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)} - re\right)}\\
    
    \mathbf{elif}\;re \leq 1.3 \cdot 10^{-104}:\\
    \;\;\;\;\left(\sqrt{im - re} \cdot \sqrt{2}\right) \cdot 0.5\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(\left(im \cdot \left(\sqrt{0.5} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot 0.5\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 4 regimes
    2. if re < -1.05e126

      1. Initial program 14.8%

        \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
      2. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
        3. lower-fma.f6414.8

          \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
      3. Applied rewrites14.8%

        \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
      4. Step-by-step derivation
        1. lift-fma.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
        2. pow2N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{{re}^{2}} + im \cdot im} - re\right)} \]
        3. exp-to-powN/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
        4. lift-log.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re} \cdot 2} + im \cdot im} - re\right)} \]
        5. lift-*.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re \cdot 2}} + im \cdot im} - re\right)} \]
        6. lift-exp.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
        7. flip3-+N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
        8. lower-/.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
      5. Applied rewrites0.0%

        \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, re \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
      6. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{re \cdot re}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        2. rem-exp-logN/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        3. lift-log.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        4. rem-exp-logN/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot \color{blue}{e^{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        5. lift-log.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot e^{\color{blue}{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        6. exp-lft-sqr-revN/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        7. lower-exp.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        8. lower-*.f640.0

          \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      7. Applied rewrites0.0%

        \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
      8. Taylor expanded in re around -inf

        \[\leadsto \frac{1}{2} \cdot \sqrt{\color{blue}{-4 \cdot re}} \]
      9. Step-by-step derivation
        1. lower-*.f6486.3

          \[\leadsto 0.5 \cdot \sqrt{-4 \cdot \color{blue}{re}} \]
      10. Applied rewrites86.3%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{-4 \cdot re}} \]

      if -1.05e126 < re < -7.49999999999999969e-79

      1. Initial program 76.8%

        \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
      2. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
        3. lower-fma.f6476.8

          \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
      3. Applied rewrites76.8%

        \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]

      if -7.49999999999999969e-79 < re < 1.30000000000000001e-104

      1. Initial program 57.2%

        \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
      2. Step-by-step derivation
        1. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \]
        2. *-commutativeN/A

          \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot \frac{1}{2}} \]
        3. lower-*.f6457.2

          \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot 0.5} \]
        4. lift-*.f64N/A

          \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \cdot \frac{1}{2} \]
        5. *-commutativeN/A

          \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot \frac{1}{2} \]
        6. lower-*.f6457.2

          \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot 0.5 \]
        7. lift-sqrt.f64N/A

          \[\leadsto \sqrt{\left(\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        8. lift-+.f64N/A

          \[\leadsto \sqrt{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        9. +-commutativeN/A

          \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im + re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        10. lift-*.f64N/A

          \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        11. lift-*.f64N/A

          \[\leadsto \sqrt{\left(\sqrt{im \cdot im + \color{blue}{re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
        12. lower-hypot.f6493.3

          \[\leadsto \sqrt{\left(\color{blue}{\mathsf{hypot}\left(im, re\right)} - re\right) \cdot 2} \cdot 0.5 \]
      3. Applied rewrites93.3%

        \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5} \]
      4. Step-by-step derivation
        1. lift-sqrt.f64N/A

          \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
        2. lift-*.f64N/A

          \[\leadsto \sqrt{\color{blue}{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
        3. sqrt-prodN/A

          \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(im, re\right) - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
        4. lift-hypot.f64N/A

          \[\leadsto \left(\sqrt{\color{blue}{\sqrt{im \cdot im + re \cdot re}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        5. lift-*.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        6. pow2N/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{{re}^{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        7. exp-to-powN/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        8. lift-log.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re} \cdot 2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        9. lift-*.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        10. lift-exp.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        11. +-commutativeN/A

          \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        12. lift-+.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        13. lift-sqrt.f64N/A

          \[\leadsto \left(\sqrt{\color{blue}{\sqrt{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        14. lower-*.f64N/A

          \[\leadsto \color{blue}{\left(\sqrt{\sqrt{e^{\log re \cdot 2} + im \cdot im} - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
      5. Applied rewrites92.7%

        \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(re, im\right) - re} \cdot \sqrt{2}\right)} \cdot 0.5 \]
      6. Step-by-step derivation
        1. lift-hypot.f64N/A

          \[\leadsto \left(\sqrt{\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        2. lift-*.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{re \cdot re + \color{blue}{im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        3. lift-fma.f64N/A

          \[\leadsto \left(\sqrt{\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        4. pow1/2N/A

          \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        5. unpow1N/A

          \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{1}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        6. sqr-powN/A

          \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        7. metadata-evalN/A

          \[\leadsto \left(\sqrt{{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        8. pow1/2N/A

          \[\leadsto \left(\sqrt{{\left(\color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        9. lift-fma.f64N/A

          \[\leadsto \left(\sqrt{{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        10. lift-*.f64N/A

          \[\leadsto \left(\sqrt{{\left(\sqrt{re \cdot re + \color{blue}{im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        11. lift-hypot.f64N/A

          \[\leadsto \left(\sqrt{{\left(\color{blue}{\mathsf{hypot}\left(re, im\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        12. metadata-evalN/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        13. pow1/2N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        14. lift-fma.f64N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{\color{blue}{re \cdot re + im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        15. lift-*.f64N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{re \cdot re + \color{blue}{im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        16. lift-hypot.f64N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        17. pow-prod-downN/A

          \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        18. lift-pow.f64N/A

          \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        19. lift-pow.f64N/A

          \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        20. pow2N/A

          \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        21. lower-pow.f6492.6

          \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{0.5}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
      7. Applied rewrites92.6%

        \[\leadsto \left(\sqrt{\color{blue}{{\left(\sqrt{\mathsf{hypot}\left(im, re\right)}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
      8. Taylor expanded in re around 0

        \[\leadsto \left(\sqrt{\color{blue}{im} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
      9. Step-by-step derivation
        1. Applied rewrites83.1%

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

        if 1.30000000000000001e-104 < re

        1. Initial program 18.9%

          \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \]
          2. *-commutativeN/A

            \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot \frac{1}{2}} \]
          3. lower-*.f6418.9

            \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot 0.5} \]
          4. lift-*.f64N/A

            \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \cdot \frac{1}{2} \]
          5. *-commutativeN/A

            \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot \frac{1}{2} \]
          6. lower-*.f6418.9

            \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot 0.5 \]
          7. lift-sqrt.f64N/A

            \[\leadsto \sqrt{\left(\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          8. lift-+.f64N/A

            \[\leadsto \sqrt{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          9. +-commutativeN/A

            \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im + re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          10. lift-*.f64N/A

            \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          11. lift-*.f64N/A

            \[\leadsto \sqrt{\left(\sqrt{im \cdot im + \color{blue}{re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          12. lower-hypot.f6445.0

            \[\leadsto \sqrt{\left(\color{blue}{\mathsf{hypot}\left(im, re\right)} - re\right) \cdot 2} \cdot 0.5 \]
        3. Applied rewrites45.0%

          \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5} \]
        4. Step-by-step derivation
          1. lift-sqrt.f64N/A

            \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
          2. lift-*.f64N/A

            \[\leadsto \sqrt{\color{blue}{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
          3. sqrt-prodN/A

            \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(im, re\right) - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
          4. lift-hypot.f64N/A

            \[\leadsto \left(\sqrt{\color{blue}{\sqrt{im \cdot im + re \cdot re}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          5. lift-*.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          6. pow2N/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{{re}^{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          7. exp-to-powN/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          8. lift-log.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re} \cdot 2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          9. lift-*.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          10. lift-exp.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          11. +-commutativeN/A

            \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          12. lift-+.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          13. lift-sqrt.f64N/A

            \[\leadsto \left(\sqrt{\color{blue}{\sqrt{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          14. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(\sqrt{\sqrt{e^{\log re \cdot 2} + im \cdot im} - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
        5. Applied rewrites44.8%

          \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(re, im\right) - re} \cdot \sqrt{2}\right)} \cdot 0.5 \]
        6. Step-by-step derivation
          1. lift-hypot.f64N/A

            \[\leadsto \left(\sqrt{\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          2. lift-*.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{re \cdot re + \color{blue}{im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          3. lift-fma.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          4. pow1/2N/A

            \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          5. unpow1N/A

            \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{1}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          6. sqr-powN/A

            \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          7. metadata-evalN/A

            \[\leadsto \left(\sqrt{{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          8. pow1/2N/A

            \[\leadsto \left(\sqrt{{\left(\color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          9. lift-fma.f64N/A

            \[\leadsto \left(\sqrt{{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          10. lift-*.f64N/A

            \[\leadsto \left(\sqrt{{\left(\sqrt{re \cdot re + \color{blue}{im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          11. lift-hypot.f64N/A

            \[\leadsto \left(\sqrt{{\left(\color{blue}{\mathsf{hypot}\left(re, im\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          12. metadata-evalN/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          13. pow1/2N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          14. lift-fma.f64N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{\color{blue}{re \cdot re + im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          15. lift-*.f64N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{re \cdot re + \color{blue}{im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          16. lift-hypot.f64N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          17. pow-prod-downN/A

            \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          18. lift-pow.f64N/A

            \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          19. lift-pow.f64N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          20. pow2N/A

            \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          21. lower-pow.f6440.7

            \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{0.5}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
        7. Applied rewrites40.7%

          \[\leadsto \left(\sqrt{\color{blue}{{\left(\sqrt{\mathsf{hypot}\left(im, re\right)}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
        8. Taylor expanded in re around inf

          \[\leadsto \color{blue}{\left(\left(im \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{re}}\right)} \cdot \frac{1}{2} \]
        9. Step-by-step derivation
          1. lower-*.f64N/A

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

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

            \[\leadsto \left(\left(im \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{\color{blue}{re}}}\right) \cdot \frac{1}{2} \]
          4. lower-sqrt.f64N/A

            \[\leadsto \left(\left(im \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \frac{1}{2} \]
          5. lower-sqrt.f64N/A

            \[\leadsto \left(\left(im \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \frac{1}{2} \]
          6. lower-sqrt.f64N/A

            \[\leadsto \left(\left(im \cdot \left(\sqrt{\frac{1}{2}} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot \frac{1}{2} \]
          7. lower-/.f6467.1

            \[\leadsto \left(\left(im \cdot \left(\sqrt{0.5} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{re}}\right) \cdot 0.5 \]
        10. Applied rewrites67.1%

          \[\leadsto \color{blue}{\left(\left(im \cdot \left(\sqrt{0.5} \cdot \sqrt{2}\right)\right) \cdot \sqrt{\frac{1}{re}}\right)} \cdot 0.5 \]
      10. Recombined 4 regimes into one program.
      11. Add Preprocessing

      Alternative 4: 66.7% accurate, 0.8× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -1.05 \cdot 10^{+126}:\\ \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\ \mathbf{elif}\;re \leq -7.5 \cdot 10^{-79}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)} - re\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{im} \cdot \sqrt{2}\right) \cdot 0.5\\ \end{array} \end{array} \]
      (FPCore (re im)
       :precision binary64
       (if (<= re -1.05e+126)
         (* 0.5 (sqrt (* -4.0 re)))
         (if (<= re -7.5e-79)
           (* 0.5 (sqrt (* 2.0 (- (sqrt (fma re re (* im im))) re))))
           (* (* (sqrt im) (sqrt 2.0)) 0.5))))
      double code(double re, double im) {
      	double tmp;
      	if (re <= -1.05e+126) {
      		tmp = 0.5 * sqrt((-4.0 * re));
      	} else if (re <= -7.5e-79) {
      		tmp = 0.5 * sqrt((2.0 * (sqrt(fma(re, re, (im * im))) - re)));
      	} else {
      		tmp = (sqrt(im) * sqrt(2.0)) * 0.5;
      	}
      	return tmp;
      }
      
      function code(re, im)
      	tmp = 0.0
      	if (re <= -1.05e+126)
      		tmp = Float64(0.5 * sqrt(Float64(-4.0 * re)));
      	elseif (re <= -7.5e-79)
      		tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(fma(re, re, Float64(im * im))) - re))));
      	else
      		tmp = Float64(Float64(sqrt(im) * sqrt(2.0)) * 0.5);
      	end
      	return tmp
      end
      
      code[re_, im_] := If[LessEqual[re, -1.05e+126], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, -7.5e-79], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[N[(re * re + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[im], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;re \leq -1.05 \cdot 10^{+126}:\\
      \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
      
      \mathbf{elif}\;re \leq -7.5 \cdot 10^{-79}:\\
      \;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)} - re\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;\left(\sqrt{im} \cdot \sqrt{2}\right) \cdot 0.5\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if re < -1.05e126

        1. Initial program 14.8%

          \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
        2. Step-by-step derivation
          1. lift-+.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
          3. lower-fma.f6414.8

            \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
        3. Applied rewrites14.8%

          \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
        4. Step-by-step derivation
          1. lift-fma.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
          2. pow2N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{{re}^{2}} + im \cdot im} - re\right)} \]
          3. exp-to-powN/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
          4. lift-log.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re} \cdot 2} + im \cdot im} - re\right)} \]
          5. lift-*.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re \cdot 2}} + im \cdot im} - re\right)} \]
          6. lift-exp.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
          7. flip3-+N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
          8. lower-/.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
        5. Applied rewrites0.0%

          \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, re \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
        6. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{re \cdot re}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          2. rem-exp-logN/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          3. lift-log.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          4. rem-exp-logN/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot \color{blue}{e^{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          5. lift-log.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot e^{\color{blue}{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          6. exp-lft-sqr-revN/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          7. lower-exp.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          8. lower-*.f640.0

            \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        7. Applied rewrites0.0%

          \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
        8. Taylor expanded in re around -inf

          \[\leadsto \frac{1}{2} \cdot \sqrt{\color{blue}{-4 \cdot re}} \]
        9. Step-by-step derivation
          1. lower-*.f6486.3

            \[\leadsto 0.5 \cdot \sqrt{-4 \cdot \color{blue}{re}} \]
        10. Applied rewrites86.3%

          \[\leadsto 0.5 \cdot \sqrt{\color{blue}{-4 \cdot re}} \]

        if -1.05e126 < re < -7.49999999999999969e-79

        1. Initial program 76.8%

          \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
        2. Step-by-step derivation
          1. lift-+.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
          3. lower-fma.f6476.8

            \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
        3. Applied rewrites76.8%

          \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]

        if -7.49999999999999969e-79 < re

        1. Initial program 38.5%

          \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
        2. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \]
          2. *-commutativeN/A

            \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot \frac{1}{2}} \]
          3. lower-*.f6438.5

            \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot 0.5} \]
          4. lift-*.f64N/A

            \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \cdot \frac{1}{2} \]
          5. *-commutativeN/A

            \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot \frac{1}{2} \]
          6. lower-*.f6438.5

            \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot 0.5 \]
          7. lift-sqrt.f64N/A

            \[\leadsto \sqrt{\left(\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          8. lift-+.f64N/A

            \[\leadsto \sqrt{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          9. +-commutativeN/A

            \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im + re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          10. lift-*.f64N/A

            \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          11. lift-*.f64N/A

            \[\leadsto \sqrt{\left(\sqrt{im \cdot im + \color{blue}{re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
          12. lower-hypot.f6469.7

            \[\leadsto \sqrt{\left(\color{blue}{\mathsf{hypot}\left(im, re\right)} - re\right) \cdot 2} \cdot 0.5 \]
        3. Applied rewrites69.7%

          \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5} \]
        4. Step-by-step derivation
          1. lift-sqrt.f64N/A

            \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
          2. lift-*.f64N/A

            \[\leadsto \sqrt{\color{blue}{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
          3. sqrt-prodN/A

            \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(im, re\right) - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
          4. lift-hypot.f64N/A

            \[\leadsto \left(\sqrt{\color{blue}{\sqrt{im \cdot im + re \cdot re}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          5. lift-*.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          6. pow2N/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{{re}^{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          7. exp-to-powN/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          8. lift-log.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re} \cdot 2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          9. lift-*.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          10. lift-exp.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          11. +-commutativeN/A

            \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          12. lift-+.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          13. lift-sqrt.f64N/A

            \[\leadsto \left(\sqrt{\color{blue}{\sqrt{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          14. lower-*.f64N/A

            \[\leadsto \color{blue}{\left(\sqrt{\sqrt{e^{\log re \cdot 2} + im \cdot im} - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
        5. Applied rewrites69.3%

          \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(re, im\right) - re} \cdot \sqrt{2}\right)} \cdot 0.5 \]
        6. Step-by-step derivation
          1. lift-hypot.f64N/A

            \[\leadsto \left(\sqrt{\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          2. lift-*.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{re \cdot re + \color{blue}{im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          3. lift-fma.f64N/A

            \[\leadsto \left(\sqrt{\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          4. pow1/2N/A

            \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          5. unpow1N/A

            \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{1}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          6. sqr-powN/A

            \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          7. metadata-evalN/A

            \[\leadsto \left(\sqrt{{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          8. pow1/2N/A

            \[\leadsto \left(\sqrt{{\left(\color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          9. lift-fma.f64N/A

            \[\leadsto \left(\sqrt{{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          10. lift-*.f64N/A

            \[\leadsto \left(\sqrt{{\left(\sqrt{re \cdot re + \color{blue}{im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          11. lift-hypot.f64N/A

            \[\leadsto \left(\sqrt{{\left(\color{blue}{\mathsf{hypot}\left(re, im\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          12. metadata-evalN/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          13. pow1/2N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          14. lift-fma.f64N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{\color{blue}{re \cdot re + im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          15. lift-*.f64N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{re \cdot re + \color{blue}{im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          16. lift-hypot.f64N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          17. pow-prod-downN/A

            \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          18. lift-pow.f64N/A

            \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          19. lift-pow.f64N/A

            \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          20. pow2N/A

            \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          21. lower-pow.f6467.3

            \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{0.5}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
        7. Applied rewrites67.3%

          \[\leadsto \left(\sqrt{\color{blue}{{\left(\sqrt{\mathsf{hypot}\left(im, re\right)}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
        8. Taylor expanded in re around 0

          \[\leadsto \left(\sqrt{\color{blue}{im}} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
        9. Step-by-step derivation
          1. Applied rewrites59.9%

            \[\leadsto \left(\sqrt{\color{blue}{im}} \cdot \sqrt{2}\right) \cdot 0.5 \]
        10. Recombined 3 regimes into one program.
        11. Add Preprocessing

        Alternative 5: 64.2% accurate, 1.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -2.4 \cdot 10^{-46}:\\ \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt{im} \cdot \sqrt{2}\right) \cdot 0.5\\ \end{array} \end{array} \]
        (FPCore (re im)
         :precision binary64
         (if (<= re -2.4e-46)
           (* 0.5 (sqrt (* -4.0 re)))
           (* (* (sqrt im) (sqrt 2.0)) 0.5)))
        double code(double re, double im) {
        	double tmp;
        	if (re <= -2.4e-46) {
        		tmp = 0.5 * sqrt((-4.0 * re));
        	} else {
        		tmp = (sqrt(im) * sqrt(2.0)) * 0.5;
        	}
        	return tmp;
        }
        
        module fmin_fmax_functions
            implicit none
            private
            public fmax
            public fmin
        
            interface fmax
                module procedure fmax88
                module procedure fmax44
                module procedure fmax84
                module procedure fmax48
            end interface
            interface fmin
                module procedure fmin88
                module procedure fmin44
                module procedure fmin84
                module procedure fmin48
            end interface
        contains
            real(8) function fmax88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(4) function fmax44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, max(x, y), y /= y), x /= x)
            end function
            real(8) function fmax84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmax48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
            end function
            real(8) function fmin88(x, y) result (res)
                real(8), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(4) function fmin44(x, y) result (res)
                real(4), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(y, merge(x, min(x, y), y /= y), x /= x)
            end function
            real(8) function fmin84(x, y) result(res)
                real(8), intent (in) :: x
                real(4), intent (in) :: y
                res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
            end function
            real(8) function fmin48(x, y) result(res)
                real(4), intent (in) :: x
                real(8), intent (in) :: y
                res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
            end function
        end module
        
        real(8) function code(re, im)
        use fmin_fmax_functions
            real(8), intent (in) :: re
            real(8), intent (in) :: im
            real(8) :: tmp
            if (re <= (-2.4d-46)) then
                tmp = 0.5d0 * sqrt(((-4.0d0) * re))
            else
                tmp = (sqrt(im) * sqrt(2.0d0)) * 0.5d0
            end if
            code = tmp
        end function
        
        public static double code(double re, double im) {
        	double tmp;
        	if (re <= -2.4e-46) {
        		tmp = 0.5 * Math.sqrt((-4.0 * re));
        	} else {
        		tmp = (Math.sqrt(im) * Math.sqrt(2.0)) * 0.5;
        	}
        	return tmp;
        }
        
        def code(re, im):
        	tmp = 0
        	if re <= -2.4e-46:
        		tmp = 0.5 * math.sqrt((-4.0 * re))
        	else:
        		tmp = (math.sqrt(im) * math.sqrt(2.0)) * 0.5
        	return tmp
        
        function code(re, im)
        	tmp = 0.0
        	if (re <= -2.4e-46)
        		tmp = Float64(0.5 * sqrt(Float64(-4.0 * re)));
        	else
        		tmp = Float64(Float64(sqrt(im) * sqrt(2.0)) * 0.5);
        	end
        	return tmp
        end
        
        function tmp_2 = code(re, im)
        	tmp = 0.0;
        	if (re <= -2.4e-46)
        		tmp = 0.5 * sqrt((-4.0 * re));
        	else
        		tmp = (sqrt(im) * sqrt(2.0)) * 0.5;
        	end
        	tmp_2 = tmp;
        end
        
        code[re_, im_] := If[LessEqual[re, -2.4e-46], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[im], $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;re \leq -2.4 \cdot 10^{-46}:\\
        \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
        
        \mathbf{else}:\\
        \;\;\;\;\left(\sqrt{im} \cdot \sqrt{2}\right) \cdot 0.5\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if re < -2.40000000000000013e-46

          1. Initial program 45.1%

            \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
          2. Step-by-step derivation
            1. lift-+.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
            2. lift-*.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
            3. lower-fma.f6445.1

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
          3. Applied rewrites45.1%

            \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
          4. Step-by-step derivation
            1. lift-fma.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
            2. pow2N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{{re}^{2}} + im \cdot im} - re\right)} \]
            3. exp-to-powN/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
            4. lift-log.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re} \cdot 2} + im \cdot im} - re\right)} \]
            5. lift-*.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re \cdot 2}} + im \cdot im} - re\right)} \]
            6. lift-exp.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
            7. flip3-+N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
            8. lower-/.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
          5. Applied rewrites16.9%

            \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, re \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
          6. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{re \cdot re}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            2. rem-exp-logN/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            3. lift-log.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            4. rem-exp-logN/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot \color{blue}{e^{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            5. lift-log.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot e^{\color{blue}{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            6. exp-lft-sqr-revN/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            7. lower-exp.f64N/A

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            8. lower-*.f640.0

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          7. Applied rewrites0.0%

            \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
          8. Taylor expanded in re around -inf

            \[\leadsto \frac{1}{2} \cdot \sqrt{\color{blue}{-4 \cdot re}} \]
          9. Step-by-step derivation
            1. lower-*.f6474.8

              \[\leadsto 0.5 \cdot \sqrt{-4 \cdot \color{blue}{re}} \]
          10. Applied rewrites74.8%

            \[\leadsto 0.5 \cdot \sqrt{\color{blue}{-4 \cdot re}} \]

          if -2.40000000000000013e-46 < re

          1. Initial program 39.9%

            \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
          2. Step-by-step derivation
            1. lift-*.f64N/A

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \]
            2. *-commutativeN/A

              \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot \frac{1}{2}} \]
            3. lower-*.f6439.9

              \[\leadsto \color{blue}{\sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \cdot 0.5} \]
            4. lift-*.f64N/A

              \[\leadsto \sqrt{\color{blue}{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)}} \cdot \frac{1}{2} \]
            5. *-commutativeN/A

              \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot \frac{1}{2} \]
            6. lower-*.f6439.9

              \[\leadsto \sqrt{\color{blue}{\left(\sqrt{re \cdot re + im \cdot im} - re\right) \cdot 2}} \cdot 0.5 \]
            7. lift-sqrt.f64N/A

              \[\leadsto \sqrt{\left(\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
            8. lift-+.f64N/A

              \[\leadsto \sqrt{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
            9. +-commutativeN/A

              \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im + re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
            10. lift-*.f64N/A

              \[\leadsto \sqrt{\left(\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re\right) \cdot 2} \cdot \frac{1}{2} \]
            11. lift-*.f64N/A

              \[\leadsto \sqrt{\left(\sqrt{im \cdot im + \color{blue}{re \cdot re}} - re\right) \cdot 2} \cdot \frac{1}{2} \]
            12. lower-hypot.f6470.9

              \[\leadsto \sqrt{\left(\color{blue}{\mathsf{hypot}\left(im, re\right)} - re\right) \cdot 2} \cdot 0.5 \]
          3. Applied rewrites70.9%

            \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2} \cdot 0.5} \]
          4. Step-by-step derivation
            1. lift-sqrt.f64N/A

              \[\leadsto \color{blue}{\sqrt{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
            2. lift-*.f64N/A

              \[\leadsto \sqrt{\color{blue}{\left(\mathsf{hypot}\left(im, re\right) - re\right) \cdot 2}} \cdot \frac{1}{2} \]
            3. sqrt-prodN/A

              \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(im, re\right) - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
            4. lift-hypot.f64N/A

              \[\leadsto \left(\sqrt{\color{blue}{\sqrt{im \cdot im + re \cdot re}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            5. lift-*.f64N/A

              \[\leadsto \left(\sqrt{\sqrt{\color{blue}{im \cdot im} + re \cdot re} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            6. pow2N/A

              \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{{re}^{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            7. exp-to-powN/A

              \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            8. lift-log.f64N/A

              \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re} \cdot 2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            9. lift-*.f64N/A

              \[\leadsto \left(\sqrt{\sqrt{im \cdot im + e^{\color{blue}{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            10. lift-exp.f64N/A

              \[\leadsto \left(\sqrt{\sqrt{im \cdot im + \color{blue}{e^{\log re \cdot 2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            11. +-commutativeN/A

              \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            12. lift-+.f64N/A

              \[\leadsto \left(\sqrt{\sqrt{\color{blue}{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            13. lift-sqrt.f64N/A

              \[\leadsto \left(\sqrt{\color{blue}{\sqrt{e^{\log re \cdot 2} + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            14. lower-*.f64N/A

              \[\leadsto \color{blue}{\left(\sqrt{\sqrt{e^{\log re \cdot 2} + im \cdot im} - re} \cdot \sqrt{2}\right)} \cdot \frac{1}{2} \]
          5. Applied rewrites70.5%

            \[\leadsto \color{blue}{\left(\sqrt{\mathsf{hypot}\left(re, im\right) - re} \cdot \sqrt{2}\right)} \cdot 0.5 \]
          6. Step-by-step derivation
            1. lift-hypot.f64N/A

              \[\leadsto \left(\sqrt{\color{blue}{\sqrt{re \cdot re + im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            2. lift-*.f64N/A

              \[\leadsto \left(\sqrt{\sqrt{re \cdot re + \color{blue}{im \cdot im}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            3. lift-fma.f64N/A

              \[\leadsto \left(\sqrt{\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            4. pow1/2N/A

              \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            5. unpow1N/A

              \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{1}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            6. sqr-powN/A

              \[\leadsto \left(\sqrt{{\color{blue}{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            7. metadata-evalN/A

              \[\leadsto \left(\sqrt{{\left({\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            8. pow1/2N/A

              \[\leadsto \left(\sqrt{{\left(\color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            9. lift-fma.f64N/A

              \[\leadsto \left(\sqrt{{\left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            10. lift-*.f64N/A

              \[\leadsto \left(\sqrt{{\left(\sqrt{re \cdot re + \color{blue}{im \cdot im}} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            11. lift-hypot.f64N/A

              \[\leadsto \left(\sqrt{{\left(\color{blue}{\mathsf{hypot}\left(re, im\right)} \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\left(\frac{1}{2}\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            12. metadata-evalN/A

              \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot {\left(\mathsf{fma}\left(re, re, im \cdot im\right)\right)}^{\color{blue}{\frac{1}{2}}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            13. pow1/2N/A

              \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            14. lift-fma.f64N/A

              \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{\color{blue}{re \cdot re + im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            15. lift-*.f64N/A

              \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \sqrt{re \cdot re + \color{blue}{im \cdot im}}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            16. lift-hypot.f64N/A

              \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right) \cdot \color{blue}{\mathsf{hypot}\left(re, im\right)}\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            17. pow-prod-downN/A

              \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            18. lift-pow.f64N/A

              \[\leadsto \left(\sqrt{\color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} \cdot {\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            19. lift-pow.f64N/A

              \[\leadsto \left(\sqrt{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}} \cdot \color{blue}{{\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            20. pow2N/A

              \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{\frac{1}{2}}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
            21. lower-pow.f6468.5

              \[\leadsto \left(\sqrt{\color{blue}{{\left({\left(\mathsf{hypot}\left(re, im\right)\right)}^{0.5}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
          7. Applied rewrites68.5%

            \[\leadsto \left(\sqrt{\color{blue}{{\left(\sqrt{\mathsf{hypot}\left(im, re\right)}\right)}^{2}} - re} \cdot \sqrt{2}\right) \cdot 0.5 \]
          8. Taylor expanded in re around 0

            \[\leadsto \left(\sqrt{\color{blue}{im}} \cdot \sqrt{2}\right) \cdot \frac{1}{2} \]
          9. Step-by-step derivation
            1. Applied rewrites59.9%

              \[\leadsto \left(\sqrt{\color{blue}{im}} \cdot \sqrt{2}\right) \cdot 0.5 \]
          10. Recombined 2 regimes into one program.
          11. Add Preprocessing

          Alternative 6: 64.5% accurate, 1.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;re \leq -2.4 \cdot 10^{-46}:\\ \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{2 \cdot im}\\ \end{array} \end{array} \]
          (FPCore (re im)
           :precision binary64
           (if (<= re -2.4e-46) (* 0.5 (sqrt (* -4.0 re))) (* 0.5 (sqrt (* 2.0 im)))))
          double code(double re, double im) {
          	double tmp;
          	if (re <= -2.4e-46) {
          		tmp = 0.5 * sqrt((-4.0 * re));
          	} else {
          		tmp = 0.5 * sqrt((2.0 * im));
          	}
          	return tmp;
          }
          
          module fmin_fmax_functions
              implicit none
              private
              public fmax
              public fmin
          
              interface fmax
                  module procedure fmax88
                  module procedure fmax44
                  module procedure fmax84
                  module procedure fmax48
              end interface
              interface fmin
                  module procedure fmin88
                  module procedure fmin44
                  module procedure fmin84
                  module procedure fmin48
              end interface
          contains
              real(8) function fmax88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(4) function fmax44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
              end function
              real(8) function fmax84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmax48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
              end function
              real(8) function fmin88(x, y) result (res)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(4) function fmin44(x, y) result (res)
                  real(4), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
              end function
              real(8) function fmin84(x, y) result(res)
                  real(8), intent (in) :: x
                  real(4), intent (in) :: y
                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
              end function
              real(8) function fmin48(x, y) result(res)
                  real(4), intent (in) :: x
                  real(8), intent (in) :: y
                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
              end function
          end module
          
          real(8) function code(re, im)
          use fmin_fmax_functions
              real(8), intent (in) :: re
              real(8), intent (in) :: im
              real(8) :: tmp
              if (re <= (-2.4d-46)) then
                  tmp = 0.5d0 * sqrt(((-4.0d0) * re))
              else
                  tmp = 0.5d0 * sqrt((2.0d0 * im))
              end if
              code = tmp
          end function
          
          public static double code(double re, double im) {
          	double tmp;
          	if (re <= -2.4e-46) {
          		tmp = 0.5 * Math.sqrt((-4.0 * re));
          	} else {
          		tmp = 0.5 * Math.sqrt((2.0 * im));
          	}
          	return tmp;
          }
          
          def code(re, im):
          	tmp = 0
          	if re <= -2.4e-46:
          		tmp = 0.5 * math.sqrt((-4.0 * re))
          	else:
          		tmp = 0.5 * math.sqrt((2.0 * im))
          	return tmp
          
          function code(re, im)
          	tmp = 0.0
          	if (re <= -2.4e-46)
          		tmp = Float64(0.5 * sqrt(Float64(-4.0 * re)));
          	else
          		tmp = Float64(0.5 * sqrt(Float64(2.0 * im)));
          	end
          	return tmp
          end
          
          function tmp_2 = code(re, im)
          	tmp = 0.0;
          	if (re <= -2.4e-46)
          		tmp = 0.5 * sqrt((-4.0 * re));
          	else
          		tmp = 0.5 * sqrt((2.0 * im));
          	end
          	tmp_2 = tmp;
          end
          
          code[re_, im_] := If[LessEqual[re, -2.4e-46], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(2.0 * im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;re \leq -2.4 \cdot 10^{-46}:\\
          \;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
          
          \mathbf{else}:\\
          \;\;\;\;0.5 \cdot \sqrt{2 \cdot im}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if re < -2.40000000000000013e-46

            1. Initial program 45.1%

              \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
            2. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
              2. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
              3. lower-fma.f6445.1

                \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
            3. Applied rewrites45.1%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
            4. Step-by-step derivation
              1. lift-fma.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
              2. pow2N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{{re}^{2}} + im \cdot im} - re\right)} \]
              3. exp-to-powN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              4. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re} \cdot 2} + im \cdot im} - re\right)} \]
              5. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              6. lift-exp.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              7. flip3-+N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
              8. lower-/.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
            5. Applied rewrites16.9%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, re \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
            6. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{re \cdot re}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              2. rem-exp-logN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              3. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              4. rem-exp-logN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot \color{blue}{e^{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              5. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot e^{\color{blue}{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              6. exp-lft-sqr-revN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              7. lower-exp.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              8. lower-*.f640.0

                \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            7. Applied rewrites0.0%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            8. Taylor expanded in re around -inf

              \[\leadsto \frac{1}{2} \cdot \sqrt{\color{blue}{-4 \cdot re}} \]
            9. Step-by-step derivation
              1. lower-*.f6474.8

                \[\leadsto 0.5 \cdot \sqrt{-4 \cdot \color{blue}{re}} \]
            10. Applied rewrites74.8%

              \[\leadsto 0.5 \cdot \sqrt{\color{blue}{-4 \cdot re}} \]

            if -2.40000000000000013e-46 < re

            1. Initial program 39.9%

              \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
            2. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
              2. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
              3. lower-fma.f6439.9

                \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
            3. Applied rewrites39.9%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
            4. Step-by-step derivation
              1. lift-fma.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
              2. pow2N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{{re}^{2}} + im \cdot im} - re\right)} \]
              3. exp-to-powN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              4. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re} \cdot 2} + im \cdot im} - re\right)} \]
              5. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              6. lift-exp.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              7. flip3-+N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
              8. lower-/.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
            5. Applied rewrites12.1%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, re \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
            6. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{re \cdot re}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              2. rem-exp-logN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              3. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              4. rem-exp-logN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot \color{blue}{e^{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              5. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot e^{\color{blue}{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              6. exp-lft-sqr-revN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              7. lower-exp.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              8. lower-*.f646.1

                \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            7. Applied rewrites6.1%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            8. Taylor expanded in re around 0

              \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \color{blue}{im}} \]
            9. Step-by-step derivation
              1. Applied rewrites60.2%

                \[\leadsto 0.5 \cdot \sqrt{2 \cdot \color{blue}{im}} \]
            10. Recombined 2 regimes into one program.
            11. Add Preprocessing

            Alternative 7: 27.4% accurate, 2.2× speedup?

            \[\begin{array}{l} \\ 0.5 \cdot \sqrt{-4 \cdot re} \end{array} \]
            (FPCore (re im) :precision binary64 (* 0.5 (sqrt (* -4.0 re))))
            double code(double re, double im) {
            	return 0.5 * sqrt((-4.0 * re));
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(re, im)
            use fmin_fmax_functions
                real(8), intent (in) :: re
                real(8), intent (in) :: im
                code = 0.5d0 * sqrt(((-4.0d0) * re))
            end function
            
            public static double code(double re, double im) {
            	return 0.5 * Math.sqrt((-4.0 * re));
            }
            
            def code(re, im):
            	return 0.5 * math.sqrt((-4.0 * re))
            
            function code(re, im)
            	return Float64(0.5 * sqrt(Float64(-4.0 * re)))
            end
            
            function tmp = code(re, im)
            	tmp = 0.5 * sqrt((-4.0 * re));
            end
            
            code[re_, im_] := N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            0.5 \cdot \sqrt{-4 \cdot re}
            \end{array}
            
            Derivation
            1. Initial program 41.4%

              \[0.5 \cdot \sqrt{2 \cdot \left(\sqrt{re \cdot re + im \cdot im} - re\right)} \]
            2. Step-by-step derivation
              1. lift-+.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
              2. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re} + im \cdot im} - re\right)} \]
              3. lower-fma.f6441.4

                \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
            3. Applied rewrites41.4%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\mathsf{fma}\left(re, re, im \cdot im\right)}} - re\right)} \]
            4. Step-by-step derivation
              1. lift-fma.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{re \cdot re + im \cdot im}} - re\right)} \]
              2. pow2N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{{re}^{2}} + im \cdot im} - re\right)} \]
              3. exp-to-powN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              4. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re} \cdot 2} + im \cdot im} - re\right)} \]
              5. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{e^{\color{blue}{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              6. lift-exp.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{e^{\log re \cdot 2}} + im \cdot im} - re\right)} \]
              7. flip3-+N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
              8. lower-/.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(e^{\log re \cdot 2}\right)}^{3} + {\left(im \cdot im\right)}^{3}}{e^{\log re \cdot 2} \cdot e^{\log re \cdot 2} + \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right) - e^{\log re \cdot 2} \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
            5. Applied rewrites13.5%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\color{blue}{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, re \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}}} - re\right)} \]
            6. Step-by-step derivation
              1. lift-*.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{re \cdot re}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              2. rem-exp-logN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              3. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re}} \cdot re, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              4. rem-exp-logN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot \color{blue}{e^{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              5. lift-log.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\log re} \cdot e^{\color{blue}{\log re}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              6. exp-lft-sqr-revN/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              7. lower-exp.f64N/A

                \[\leadsto \frac{1}{2} \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
              8. lower-*.f644.4

                \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, e^{\color{blue}{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            7. Applied rewrites4.4%

              \[\leadsto 0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\frac{{\left(re \cdot re\right)}^{3} + {\left(im \cdot im\right)}^{3}}{\mathsf{fma}\left(re \cdot re, \color{blue}{e^{\log re \cdot 2}}, \left(im \cdot im\right) \cdot \left(im \cdot im\right) - \left(re \cdot re\right) \cdot \left(im \cdot im\right)\right)}} - re\right)} \]
            8. Taylor expanded in re around -inf

              \[\leadsto \frac{1}{2} \cdot \sqrt{\color{blue}{-4 \cdot re}} \]
            9. Step-by-step derivation
              1. lower-*.f6427.4

                \[\leadsto 0.5 \cdot \sqrt{-4 \cdot \color{blue}{re}} \]
            10. Applied rewrites27.4%

              \[\leadsto 0.5 \cdot \sqrt{\color{blue}{-4 \cdot re}} \]
            11. Add Preprocessing

            Reproduce

            ?
            herbie shell --seed 2025108 
            (FPCore (re im)
              :name "math.sqrt on complex, imaginary part, im greater than 0 branch"
              :precision binary64
              :pre (> im 0.0)
              (* 0.5 (sqrt (* 2.0 (- (sqrt (+ (* re re) (* im im))) re)))))