math.log/1 on complex, real part

Percentage Accurate: 52.3% → 99.6%
Time: 6.6s
Alternatives: 7
Speedup: 1.2×

Specification

?
\[\begin{array}{l} \\ \log \left(\sqrt{re \cdot re + im \cdot im}\right) \end{array} \]
(FPCore (re im) :precision binary64 (log (sqrt (+ (* re re) (* im im)))))
double code(double re, double im) {
	return log(sqrt(((re * re) + (im * im))));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = log(sqrt(((re * re) + (im * im))))
end function
public static double code(double re, double im) {
	return Math.log(Math.sqrt(((re * re) + (im * im))));
}
def code(re, im):
	return math.log(math.sqrt(((re * re) + (im * im))))
function code(re, im)
	return log(sqrt(Float64(Float64(re * re) + Float64(im * im))))
end
function tmp = code(re, im)
	tmp = log(sqrt(((re * re) + (im * im))));
end
code[re_, im_] := N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\log \left(\sqrt{re \cdot re + im \cdot im}\right)
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

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

\[\begin{array}{l} \\ \log \left(\sqrt{re \cdot re + im \cdot im}\right) \end{array} \]
(FPCore (re im) :precision binary64 (log (sqrt (+ (* re re) (* im im)))))
double code(double re, double im) {
	return log(sqrt(((re * re) + (im * im))));
}
real(8) function code(re, im)
    real(8), intent (in) :: re
    real(8), intent (in) :: im
    code = log(sqrt(((re * re) + (im * im))))
end function
public static double code(double re, double im) {
	return Math.log(Math.sqrt(((re * re) + (im * im))));
}
def code(re, im):
	return math.log(math.sqrt(((re * re) + (im * im))))
function code(re, im)
	return log(sqrt(Float64(Float64(re * re) + Float64(im * im))))
end
function tmp = code(re, im)
	tmp = log(sqrt(((re * re) + (im * im))));
end
code[re_, im_] := N[Log[N[Sqrt[N[(N[(re * re), $MachinePrecision] + N[(im * im), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\log \left(\sqrt{re \cdot re + im \cdot im}\right)
\end{array}

Alternative 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} im_m = \left|im\right| \\ re_m = \left|re\right| \\ [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\ \\ \log \left(\mathsf{fma}\left(\frac{re\_m}{im\_m}, 0.5 \cdot re\_m, im\_m\right)\right) \end{array} \]
im_m = (fabs.f64 im)
re_m = (fabs.f64 re)
NOTE: re_m and im_m should be sorted in increasing order before calling this function.
(FPCore (re_m im_m)
 :precision binary64
 (log (fma (/ re_m im_m) (* 0.5 re_m) im_m)))
im_m = fabs(im);
re_m = fabs(re);
assert(re_m < im_m);
double code(double re_m, double im_m) {
	return log(fma((re_m / im_m), (0.5 * re_m), im_m));
}
im_m = abs(im)
re_m = abs(re)
re_m, im_m = sort([re_m, im_m])
function code(re_m, im_m)
	return log(fma(Float64(re_m / im_m), Float64(0.5 * re_m), im_m))
end
im_m = N[Abs[im], $MachinePrecision]
re_m = N[Abs[re], $MachinePrecision]
NOTE: re_m and im_m should be sorted in increasing order before calling this function.
code[re$95$m_, im$95$m_] := N[Log[N[(N[(re$95$m / im$95$m), $MachinePrecision] * N[(0.5 * re$95$m), $MachinePrecision] + im$95$m), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
im_m = \left|im\right|
\\
re_m = \left|re\right|
\\
[re_m, im_m] = \mathsf{sort}([re_m, im_m])\\
\\
\log \left(\mathsf{fma}\left(\frac{re\_m}{im\_m}, 0.5 \cdot re\_m, im\_m\right)\right)
\end{array}
Derivation
  1. Initial program 57.9%

    \[\log \left(\sqrt{re \cdot re + im \cdot im}\right) \]
  2. Add Preprocessing
  3. Taylor expanded in re around 0

    \[\leadsto \log \color{blue}{\left(im + \frac{1}{2} \cdot \frac{{re}^{2}}{im}\right)} \]
  4. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \log \color{blue}{\left(\frac{1}{2} \cdot \frac{{re}^{2}}{im} + im\right)} \]
    2. associate-*r/N/A

      \[\leadsto \log \left(\color{blue}{\frac{\frac{1}{2} \cdot {re}^{2}}{im}} + im\right) \]
    3. associate-*l/N/A

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

      \[\leadsto \log \left(\frac{\color{blue}{\frac{1}{2} \cdot 1}}{im} \cdot {re}^{2} + im\right) \]
    5. associate-*r/N/A

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

      \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{1}{2} \cdot \frac{1}{im}, {re}^{2}, im\right)\right)} \]
    7. associate-*r/N/A

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

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

      \[\leadsto \log \left(\mathsf{fma}\left(\color{blue}{\frac{\frac{1}{2}}{im}}, {re}^{2}, im\right)\right) \]
    10. unpow2N/A

      \[\leadsto \log \left(\mathsf{fma}\left(\frac{\frac{1}{2}}{im}, \color{blue}{re \cdot re}, im\right)\right) \]
    11. lower-*.f6429.4

      \[\leadsto \log \left(\mathsf{fma}\left(\frac{0.5}{im}, \color{blue}{re \cdot re}, im\right)\right) \]
  5. Applied rewrites29.4%

    \[\leadsto \log \color{blue}{\left(\mathsf{fma}\left(\frac{0.5}{im}, re \cdot re, im\right)\right)} \]
  6. Step-by-step derivation
    1. Applied rewrites30.7%

      \[\leadsto \log \left(\mathsf{fma}\left(\frac{re}{im}, \color{blue}{0.5 \cdot re}, im\right)\right) \]
    2. Add Preprocessing

    Alternative 2: 99.2% accurate, 1.2× speedup?

    \[\begin{array}{l} im_m = \left|im\right| \\ re_m = \left|re\right| \\ [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\ \\ \log im\_m \end{array} \]
    im_m = (fabs.f64 im)
    re_m = (fabs.f64 re)
    NOTE: re_m and im_m should be sorted in increasing order before calling this function.
    (FPCore (re_m im_m) :precision binary64 (log im_m))
    im_m = fabs(im);
    re_m = fabs(re);
    assert(re_m < im_m);
    double code(double re_m, double im_m) {
    	return log(im_m);
    }
    
    im_m = abs(im)
    re_m = abs(re)
    NOTE: re_m and im_m should be sorted in increasing order before calling this function.
    real(8) function code(re_m, im_m)
        real(8), intent (in) :: re_m
        real(8), intent (in) :: im_m
        code = log(im_m)
    end function
    
    im_m = Math.abs(im);
    re_m = Math.abs(re);
    assert re_m < im_m;
    public static double code(double re_m, double im_m) {
    	return Math.log(im_m);
    }
    
    im_m = math.fabs(im)
    re_m = math.fabs(re)
    [re_m, im_m] = sort([re_m, im_m])
    def code(re_m, im_m):
    	return math.log(im_m)
    
    im_m = abs(im)
    re_m = abs(re)
    re_m, im_m = sort([re_m, im_m])
    function code(re_m, im_m)
    	return log(im_m)
    end
    
    im_m = abs(im);
    re_m = abs(re);
    re_m, im_m = num2cell(sort([re_m, im_m])){:}
    function tmp = code(re_m, im_m)
    	tmp = log(im_m);
    end
    
    im_m = N[Abs[im], $MachinePrecision]
    re_m = N[Abs[re], $MachinePrecision]
    NOTE: re_m and im_m should be sorted in increasing order before calling this function.
    code[re$95$m_, im$95$m_] := N[Log[im$95$m], $MachinePrecision]
    
    \begin{array}{l}
    im_m = \left|im\right|
    \\
    re_m = \left|re\right|
    \\
    [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\
    \\
    \log im\_m
    \end{array}
    
    Derivation
    1. Initial program 57.9%

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0

      \[\leadsto \color{blue}{\log im} \]
    4. Step-by-step derivation
      1. lower-log.f6430.4

        \[\leadsto \color{blue}{\log im} \]
    5. Applied rewrites30.4%

      \[\leadsto \color{blue}{\log im} \]
    6. Add Preprocessing

    Alternative 3: 3.5% accurate, 2.5× speedup?

    \[\begin{array}{l} im_m = \left|im\right| \\ re_m = \left|re\right| \\ [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\ \\ \frac{0.5}{im\_m} \cdot \frac{1}{\frac{\frac{im\_m}{re\_m}}{re\_m}} \end{array} \]
    im_m = (fabs.f64 im)
    re_m = (fabs.f64 re)
    NOTE: re_m and im_m should be sorted in increasing order before calling this function.
    (FPCore (re_m im_m)
     :precision binary64
     (* (/ 0.5 im_m) (/ 1.0 (/ (/ im_m re_m) re_m))))
    im_m = fabs(im);
    re_m = fabs(re);
    assert(re_m < im_m);
    double code(double re_m, double im_m) {
    	return (0.5 / im_m) * (1.0 / ((im_m / re_m) / re_m));
    }
    
    im_m = abs(im)
    re_m = abs(re)
    NOTE: re_m and im_m should be sorted in increasing order before calling this function.
    real(8) function code(re_m, im_m)
        real(8), intent (in) :: re_m
        real(8), intent (in) :: im_m
        code = (0.5d0 / im_m) * (1.0d0 / ((im_m / re_m) / re_m))
    end function
    
    im_m = Math.abs(im);
    re_m = Math.abs(re);
    assert re_m < im_m;
    public static double code(double re_m, double im_m) {
    	return (0.5 / im_m) * (1.0 / ((im_m / re_m) / re_m));
    }
    
    im_m = math.fabs(im)
    re_m = math.fabs(re)
    [re_m, im_m] = sort([re_m, im_m])
    def code(re_m, im_m):
    	return (0.5 / im_m) * (1.0 / ((im_m / re_m) / re_m))
    
    im_m = abs(im)
    re_m = abs(re)
    re_m, im_m = sort([re_m, im_m])
    function code(re_m, im_m)
    	return Float64(Float64(0.5 / im_m) * Float64(1.0 / Float64(Float64(im_m / re_m) / re_m)))
    end
    
    im_m = abs(im);
    re_m = abs(re);
    re_m, im_m = num2cell(sort([re_m, im_m])){:}
    function tmp = code(re_m, im_m)
    	tmp = (0.5 / im_m) * (1.0 / ((im_m / re_m) / re_m));
    end
    
    im_m = N[Abs[im], $MachinePrecision]
    re_m = N[Abs[re], $MachinePrecision]
    NOTE: re_m and im_m should be sorted in increasing order before calling this function.
    code[re$95$m_, im$95$m_] := N[(N[(0.5 / im$95$m), $MachinePrecision] * N[(1.0 / N[(N[(im$95$m / re$95$m), $MachinePrecision] / re$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    im_m = \left|im\right|
    \\
    re_m = \left|re\right|
    \\
    [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\
    \\
    \frac{0.5}{im\_m} \cdot \frac{1}{\frac{\frac{im\_m}{re\_m}}{re\_m}}
    \end{array}
    
    Derivation
    1. Initial program 57.9%

      \[\log \left(\sqrt{re \cdot re + im \cdot im}\right) \]
    2. Add Preprocessing
    3. Taylor expanded in re around 0

      \[\leadsto \color{blue}{\log im + \frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}}} \]
    4. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}} + \log im} \]
      2. associate-*r/N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot {re}^{2}}{{im}^{2}}} + \log im \]
      3. associate-*l/N/A

        \[\leadsto \color{blue}{\frac{\frac{1}{2}}{{im}^{2}} \cdot {re}^{2}} + \log im \]
      4. metadata-evalN/A

        \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot 1}}{{im}^{2}} \cdot {re}^{2} + \log im \]
      5. associate-*r/N/A

        \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{{im}^{2}}\right)} \cdot {re}^{2} + \log im \]
      6. unpow2N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(re \cdot \color{blue}{\left(\frac{1}{{im}^{2}} \cdot \frac{1}{2}\right)}, re, \log im\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(re \cdot \frac{1}{{im}^{2}}\right) \cdot \frac{1}{2}}, re, \log im\right) \]
      12. associate-/l*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re \cdot 1}{{im}^{2}}} \cdot \frac{1}{2}, re, \log im\right) \]
      13. *-rgt-identityN/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re}{{im}^{2}} \cdot \frac{1}{2}}, re, \log im\right) \]
      15. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{re}{\color{blue}{im \cdot im}} \cdot \frac{1}{2}, re, \log im\right) \]
      16. associate-/r*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
      17. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
      18. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\frac{re}{im}}}{im} \cdot \frac{1}{2}, re, \log im\right) \]
      19. lower-log.f6429.1

        \[\leadsto \mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \color{blue}{\log im}\right) \]
    5. Applied rewrites29.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \log im\right)} \]
    6. Taylor expanded in re around inf

      \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{{re}^{2}}{{im}^{2}}} \]
    7. Step-by-step derivation
      1. Applied rewrites3.3%

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

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

            \[\leadsto \frac{1}{\frac{\frac{im}{re}}{re}} \cdot \frac{0.5}{im} \]
          2. Final simplification3.3%

            \[\leadsto \frac{0.5}{im} \cdot \frac{1}{\frac{\frac{im}{re}}{re}} \]
          3. Add Preprocessing

          Alternative 4: 3.5% accurate, 3.8× speedup?

          \[\begin{array}{l} im_m = \left|im\right| \\ re_m = \left|re\right| \\ [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\ \\ \left(\frac{re\_m}{im\_m} \cdot re\_m\right) \cdot \frac{0.5}{im\_m} \end{array} \]
          im_m = (fabs.f64 im)
          re_m = (fabs.f64 re)
          NOTE: re_m and im_m should be sorted in increasing order before calling this function.
          (FPCore (re_m im_m)
           :precision binary64
           (* (* (/ re_m im_m) re_m) (/ 0.5 im_m)))
          im_m = fabs(im);
          re_m = fabs(re);
          assert(re_m < im_m);
          double code(double re_m, double im_m) {
          	return ((re_m / im_m) * re_m) * (0.5 / im_m);
          }
          
          im_m = abs(im)
          re_m = abs(re)
          NOTE: re_m and im_m should be sorted in increasing order before calling this function.
          real(8) function code(re_m, im_m)
              real(8), intent (in) :: re_m
              real(8), intent (in) :: im_m
              code = ((re_m / im_m) * re_m) * (0.5d0 / im_m)
          end function
          
          im_m = Math.abs(im);
          re_m = Math.abs(re);
          assert re_m < im_m;
          public static double code(double re_m, double im_m) {
          	return ((re_m / im_m) * re_m) * (0.5 / im_m);
          }
          
          im_m = math.fabs(im)
          re_m = math.fabs(re)
          [re_m, im_m] = sort([re_m, im_m])
          def code(re_m, im_m):
          	return ((re_m / im_m) * re_m) * (0.5 / im_m)
          
          im_m = abs(im)
          re_m = abs(re)
          re_m, im_m = sort([re_m, im_m])
          function code(re_m, im_m)
          	return Float64(Float64(Float64(re_m / im_m) * re_m) * Float64(0.5 / im_m))
          end
          
          im_m = abs(im);
          re_m = abs(re);
          re_m, im_m = num2cell(sort([re_m, im_m])){:}
          function tmp = code(re_m, im_m)
          	tmp = ((re_m / im_m) * re_m) * (0.5 / im_m);
          end
          
          im_m = N[Abs[im], $MachinePrecision]
          re_m = N[Abs[re], $MachinePrecision]
          NOTE: re_m and im_m should be sorted in increasing order before calling this function.
          code[re$95$m_, im$95$m_] := N[(N[(N[(re$95$m / im$95$m), $MachinePrecision] * re$95$m), $MachinePrecision] * N[(0.5 / im$95$m), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          im_m = \left|im\right|
          \\
          re_m = \left|re\right|
          \\
          [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\
          \\
          \left(\frac{re\_m}{im\_m} \cdot re\_m\right) \cdot \frac{0.5}{im\_m}
          \end{array}
          
          Derivation
          1. Initial program 57.9%

            \[\log \left(\sqrt{re \cdot re + im \cdot im}\right) \]
          2. Add Preprocessing
          3. Taylor expanded in re around 0

            \[\leadsto \color{blue}{\log im + \frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}}} \]
          4. Step-by-step derivation
            1. +-commutativeN/A

              \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}} + \log im} \]
            2. associate-*r/N/A

              \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot {re}^{2}}{{im}^{2}}} + \log im \]
            3. associate-*l/N/A

              \[\leadsto \color{blue}{\frac{\frac{1}{2}}{{im}^{2}} \cdot {re}^{2}} + \log im \]
            4. metadata-evalN/A

              \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot 1}}{{im}^{2}} \cdot {re}^{2} + \log im \]
            5. associate-*r/N/A

              \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{{im}^{2}}\right)} \cdot {re}^{2} + \log im \]
            6. unpow2N/A

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

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

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

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

              \[\leadsto \mathsf{fma}\left(re \cdot \color{blue}{\left(\frac{1}{{im}^{2}} \cdot \frac{1}{2}\right)}, re, \log im\right) \]
            11. associate-*r*N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\left(re \cdot \frac{1}{{im}^{2}}\right) \cdot \frac{1}{2}}, re, \log im\right) \]
            12. associate-/l*N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re \cdot 1}{{im}^{2}}} \cdot \frac{1}{2}, re, \log im\right) \]
            13. *-rgt-identityN/A

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

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re}{{im}^{2}} \cdot \frac{1}{2}}, re, \log im\right) \]
            15. unpow2N/A

              \[\leadsto \mathsf{fma}\left(\frac{re}{\color{blue}{im \cdot im}} \cdot \frac{1}{2}, re, \log im\right) \]
            16. associate-/r*N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
            17. lower-/.f64N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
            18. lower-/.f64N/A

              \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\frac{re}{im}}}{im} \cdot \frac{1}{2}, re, \log im\right) \]
            19. lower-log.f6429.1

              \[\leadsto \mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \color{blue}{\log im}\right) \]
          5. Applied rewrites29.1%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \log im\right)} \]
          6. Taylor expanded in re around inf

            \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{{re}^{2}}{{im}^{2}}} \]
          7. Step-by-step derivation
            1. Applied rewrites3.3%

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

                \[\leadsto \left(\frac{re}{im} \cdot re\right) \cdot \frac{0.5}{\color{blue}{im}} \]
              2. Add Preprocessing

              Alternative 5: 3.5% accurate, 3.8× speedup?

              \[\begin{array}{l} im_m = \left|im\right| \\ re_m = \left|re\right| \\ [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\ \\ \left(\frac{0.5}{im\_m} \cdot re\_m\right) \cdot \frac{re\_m}{im\_m} \end{array} \]
              im_m = (fabs.f64 im)
              re_m = (fabs.f64 re)
              NOTE: re_m and im_m should be sorted in increasing order before calling this function.
              (FPCore (re_m im_m)
               :precision binary64
               (* (* (/ 0.5 im_m) re_m) (/ re_m im_m)))
              im_m = fabs(im);
              re_m = fabs(re);
              assert(re_m < im_m);
              double code(double re_m, double im_m) {
              	return ((0.5 / im_m) * re_m) * (re_m / im_m);
              }
              
              im_m = abs(im)
              re_m = abs(re)
              NOTE: re_m and im_m should be sorted in increasing order before calling this function.
              real(8) function code(re_m, im_m)
                  real(8), intent (in) :: re_m
                  real(8), intent (in) :: im_m
                  code = ((0.5d0 / im_m) * re_m) * (re_m / im_m)
              end function
              
              im_m = Math.abs(im);
              re_m = Math.abs(re);
              assert re_m < im_m;
              public static double code(double re_m, double im_m) {
              	return ((0.5 / im_m) * re_m) * (re_m / im_m);
              }
              
              im_m = math.fabs(im)
              re_m = math.fabs(re)
              [re_m, im_m] = sort([re_m, im_m])
              def code(re_m, im_m):
              	return ((0.5 / im_m) * re_m) * (re_m / im_m)
              
              im_m = abs(im)
              re_m = abs(re)
              re_m, im_m = sort([re_m, im_m])
              function code(re_m, im_m)
              	return Float64(Float64(Float64(0.5 / im_m) * re_m) * Float64(re_m / im_m))
              end
              
              im_m = abs(im);
              re_m = abs(re);
              re_m, im_m = num2cell(sort([re_m, im_m])){:}
              function tmp = code(re_m, im_m)
              	tmp = ((0.5 / im_m) * re_m) * (re_m / im_m);
              end
              
              im_m = N[Abs[im], $MachinePrecision]
              re_m = N[Abs[re], $MachinePrecision]
              NOTE: re_m and im_m should be sorted in increasing order before calling this function.
              code[re$95$m_, im$95$m_] := N[(N[(N[(0.5 / im$95$m), $MachinePrecision] * re$95$m), $MachinePrecision] * N[(re$95$m / im$95$m), $MachinePrecision]), $MachinePrecision]
              
              \begin{array}{l}
              im_m = \left|im\right|
              \\
              re_m = \left|re\right|
              \\
              [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\
              \\
              \left(\frac{0.5}{im\_m} \cdot re\_m\right) \cdot \frac{re\_m}{im\_m}
              \end{array}
              
              Derivation
              1. Initial program 57.9%

                \[\log \left(\sqrt{re \cdot re + im \cdot im}\right) \]
              2. Add Preprocessing
              3. Taylor expanded in re around 0

                \[\leadsto \color{blue}{\log im + \frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}}} \]
              4. Step-by-step derivation
                1. +-commutativeN/A

                  \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}} + \log im} \]
                2. associate-*r/N/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot {re}^{2}}{{im}^{2}}} + \log im \]
                3. associate-*l/N/A

                  \[\leadsto \color{blue}{\frac{\frac{1}{2}}{{im}^{2}} \cdot {re}^{2}} + \log im \]
                4. metadata-evalN/A

                  \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot 1}}{{im}^{2}} \cdot {re}^{2} + \log im \]
                5. associate-*r/N/A

                  \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{{im}^{2}}\right)} \cdot {re}^{2} + \log im \]
                6. unpow2N/A

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

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

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

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

                  \[\leadsto \mathsf{fma}\left(re \cdot \color{blue}{\left(\frac{1}{{im}^{2}} \cdot \frac{1}{2}\right)}, re, \log im\right) \]
                11. associate-*r*N/A

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\left(re \cdot \frac{1}{{im}^{2}}\right) \cdot \frac{1}{2}}, re, \log im\right) \]
                12. associate-/l*N/A

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re \cdot 1}{{im}^{2}}} \cdot \frac{1}{2}, re, \log im\right) \]
                13. *-rgt-identityN/A

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

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re}{{im}^{2}} \cdot \frac{1}{2}}, re, \log im\right) \]
                15. unpow2N/A

                  \[\leadsto \mathsf{fma}\left(\frac{re}{\color{blue}{im \cdot im}} \cdot \frac{1}{2}, re, \log im\right) \]
                16. associate-/r*N/A

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
                17. lower-/.f64N/A

                  \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
                18. lower-/.f64N/A

                  \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\frac{re}{im}}}{im} \cdot \frac{1}{2}, re, \log im\right) \]
                19. lower-log.f6429.1

                  \[\leadsto \mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \color{blue}{\log im}\right) \]
              5. Applied rewrites29.1%

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \log im\right)} \]
              6. Taylor expanded in re around inf

                \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{{re}^{2}}{{im}^{2}}} \]
              7. Step-by-step derivation
                1. Applied rewrites3.3%

                  \[\leadsto \left(\frac{re}{im} \cdot 0.5\right) \cdot \color{blue}{\frac{re}{im}} \]
                2. Taylor expanded in re around inf

                  \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{{re}^{2}}{{im}^{2}}} \]
                3. Step-by-step derivation
                  1. Applied rewrites3.3%

                    \[\leadsto \left(\frac{0.5}{im} \cdot re\right) \cdot \color{blue}{\frac{re}{im}} \]
                  2. Add Preprocessing

                  Alternative 6: 3.1% accurate, 4.6× speedup?

                  \[\begin{array}{l} im_m = \left|im\right| \\ re_m = \left|re\right| \\ [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\ \\ \frac{re\_m}{im\_m \cdot im\_m} \cdot \left(0.5 \cdot re\_m\right) \end{array} \]
                  im_m = (fabs.f64 im)
                  re_m = (fabs.f64 re)
                  NOTE: re_m and im_m should be sorted in increasing order before calling this function.
                  (FPCore (re_m im_m)
                   :precision binary64
                   (* (/ re_m (* im_m im_m)) (* 0.5 re_m)))
                  im_m = fabs(im);
                  re_m = fabs(re);
                  assert(re_m < im_m);
                  double code(double re_m, double im_m) {
                  	return (re_m / (im_m * im_m)) * (0.5 * re_m);
                  }
                  
                  im_m = abs(im)
                  re_m = abs(re)
                  NOTE: re_m and im_m should be sorted in increasing order before calling this function.
                  real(8) function code(re_m, im_m)
                      real(8), intent (in) :: re_m
                      real(8), intent (in) :: im_m
                      code = (re_m / (im_m * im_m)) * (0.5d0 * re_m)
                  end function
                  
                  im_m = Math.abs(im);
                  re_m = Math.abs(re);
                  assert re_m < im_m;
                  public static double code(double re_m, double im_m) {
                  	return (re_m / (im_m * im_m)) * (0.5 * re_m);
                  }
                  
                  im_m = math.fabs(im)
                  re_m = math.fabs(re)
                  [re_m, im_m] = sort([re_m, im_m])
                  def code(re_m, im_m):
                  	return (re_m / (im_m * im_m)) * (0.5 * re_m)
                  
                  im_m = abs(im)
                  re_m = abs(re)
                  re_m, im_m = sort([re_m, im_m])
                  function code(re_m, im_m)
                  	return Float64(Float64(re_m / Float64(im_m * im_m)) * Float64(0.5 * re_m))
                  end
                  
                  im_m = abs(im);
                  re_m = abs(re);
                  re_m, im_m = num2cell(sort([re_m, im_m])){:}
                  function tmp = code(re_m, im_m)
                  	tmp = (re_m / (im_m * im_m)) * (0.5 * re_m);
                  end
                  
                  im_m = N[Abs[im], $MachinePrecision]
                  re_m = N[Abs[re], $MachinePrecision]
                  NOTE: re_m and im_m should be sorted in increasing order before calling this function.
                  code[re$95$m_, im$95$m_] := N[(N[(re$95$m / N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] * N[(0.5 * re$95$m), $MachinePrecision]), $MachinePrecision]
                  
                  \begin{array}{l}
                  im_m = \left|im\right|
                  \\
                  re_m = \left|re\right|
                  \\
                  [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\
                  \\
                  \frac{re\_m}{im\_m \cdot im\_m} \cdot \left(0.5 \cdot re\_m\right)
                  \end{array}
                  
                  Derivation
                  1. Initial program 57.9%

                    \[\log \left(\sqrt{re \cdot re + im \cdot im}\right) \]
                  2. Add Preprocessing
                  3. Taylor expanded in re around 0

                    \[\leadsto \color{blue}{\log im + \frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}}} \]
                  4. Step-by-step derivation
                    1. +-commutativeN/A

                      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}} + \log im} \]
                    2. associate-*r/N/A

                      \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot {re}^{2}}{{im}^{2}}} + \log im \]
                    3. associate-*l/N/A

                      \[\leadsto \color{blue}{\frac{\frac{1}{2}}{{im}^{2}} \cdot {re}^{2}} + \log im \]
                    4. metadata-evalN/A

                      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot 1}}{{im}^{2}} \cdot {re}^{2} + \log im \]
                    5. associate-*r/N/A

                      \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{{im}^{2}}\right)} \cdot {re}^{2} + \log im \]
                    6. unpow2N/A

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

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

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

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

                      \[\leadsto \mathsf{fma}\left(re \cdot \color{blue}{\left(\frac{1}{{im}^{2}} \cdot \frac{1}{2}\right)}, re, \log im\right) \]
                    11. associate-*r*N/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\left(re \cdot \frac{1}{{im}^{2}}\right) \cdot \frac{1}{2}}, re, \log im\right) \]
                    12. associate-/l*N/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re \cdot 1}{{im}^{2}}} \cdot \frac{1}{2}, re, \log im\right) \]
                    13. *-rgt-identityN/A

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

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re}{{im}^{2}} \cdot \frac{1}{2}}, re, \log im\right) \]
                    15. unpow2N/A

                      \[\leadsto \mathsf{fma}\left(\frac{re}{\color{blue}{im \cdot im}} \cdot \frac{1}{2}, re, \log im\right) \]
                    16. associate-/r*N/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
                    17. lower-/.f64N/A

                      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
                    18. lower-/.f64N/A

                      \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\frac{re}{im}}}{im} \cdot \frac{1}{2}, re, \log im\right) \]
                    19. lower-log.f6429.1

                      \[\leadsto \mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \color{blue}{\log im}\right) \]
                  5. Applied rewrites29.1%

                    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \log im\right)} \]
                  6. Taylor expanded in re around inf

                    \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{{re}^{2}}{{im}^{2}}} \]
                  7. Step-by-step derivation
                    1. Applied rewrites3.3%

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

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

                          \[\leadsto \frac{re}{im \cdot im} \cdot \left(0.5 \cdot re\right) \]
                        2. Add Preprocessing

                        Alternative 7: 2.9% accurate, 4.6× speedup?

                        \[\begin{array}{l} im_m = \left|im\right| \\ re_m = \left|re\right| \\ [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\ \\ \frac{0.5}{im\_m \cdot im\_m} \cdot \left(re\_m \cdot re\_m\right) \end{array} \]
                        im_m = (fabs.f64 im)
                        re_m = (fabs.f64 re)
                        NOTE: re_m and im_m should be sorted in increasing order before calling this function.
                        (FPCore (re_m im_m)
                         :precision binary64
                         (* (/ 0.5 (* im_m im_m)) (* re_m re_m)))
                        im_m = fabs(im);
                        re_m = fabs(re);
                        assert(re_m < im_m);
                        double code(double re_m, double im_m) {
                        	return (0.5 / (im_m * im_m)) * (re_m * re_m);
                        }
                        
                        im_m = abs(im)
                        re_m = abs(re)
                        NOTE: re_m and im_m should be sorted in increasing order before calling this function.
                        real(8) function code(re_m, im_m)
                            real(8), intent (in) :: re_m
                            real(8), intent (in) :: im_m
                            code = (0.5d0 / (im_m * im_m)) * (re_m * re_m)
                        end function
                        
                        im_m = Math.abs(im);
                        re_m = Math.abs(re);
                        assert re_m < im_m;
                        public static double code(double re_m, double im_m) {
                        	return (0.5 / (im_m * im_m)) * (re_m * re_m);
                        }
                        
                        im_m = math.fabs(im)
                        re_m = math.fabs(re)
                        [re_m, im_m] = sort([re_m, im_m])
                        def code(re_m, im_m):
                        	return (0.5 / (im_m * im_m)) * (re_m * re_m)
                        
                        im_m = abs(im)
                        re_m = abs(re)
                        re_m, im_m = sort([re_m, im_m])
                        function code(re_m, im_m)
                        	return Float64(Float64(0.5 / Float64(im_m * im_m)) * Float64(re_m * re_m))
                        end
                        
                        im_m = abs(im);
                        re_m = abs(re);
                        re_m, im_m = num2cell(sort([re_m, im_m])){:}
                        function tmp = code(re_m, im_m)
                        	tmp = (0.5 / (im_m * im_m)) * (re_m * re_m);
                        end
                        
                        im_m = N[Abs[im], $MachinePrecision]
                        re_m = N[Abs[re], $MachinePrecision]
                        NOTE: re_m and im_m should be sorted in increasing order before calling this function.
                        code[re$95$m_, im$95$m_] := N[(N[(0.5 / N[(im$95$m * im$95$m), $MachinePrecision]), $MachinePrecision] * N[(re$95$m * re$95$m), $MachinePrecision]), $MachinePrecision]
                        
                        \begin{array}{l}
                        im_m = \left|im\right|
                        \\
                        re_m = \left|re\right|
                        \\
                        [re_m, im_m] = \mathsf{sort}([re_m, im_m])\\
                        \\
                        \frac{0.5}{im\_m \cdot im\_m} \cdot \left(re\_m \cdot re\_m\right)
                        \end{array}
                        
                        Derivation
                        1. Initial program 57.9%

                          \[\log \left(\sqrt{re \cdot re + im \cdot im}\right) \]
                        2. Add Preprocessing
                        3. Taylor expanded in re around 0

                          \[\leadsto \color{blue}{\log im + \frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}}} \]
                        4. Step-by-step derivation
                          1. +-commutativeN/A

                            \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{{re}^{2}}{{im}^{2}} + \log im} \]
                          2. associate-*r/N/A

                            \[\leadsto \color{blue}{\frac{\frac{1}{2} \cdot {re}^{2}}{{im}^{2}}} + \log im \]
                          3. associate-*l/N/A

                            \[\leadsto \color{blue}{\frac{\frac{1}{2}}{{im}^{2}} \cdot {re}^{2}} + \log im \]
                          4. metadata-evalN/A

                            \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot 1}}{{im}^{2}} \cdot {re}^{2} + \log im \]
                          5. associate-*r/N/A

                            \[\leadsto \color{blue}{\left(\frac{1}{2} \cdot \frac{1}{{im}^{2}}\right)} \cdot {re}^{2} + \log im \]
                          6. unpow2N/A

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

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

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

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

                            \[\leadsto \mathsf{fma}\left(re \cdot \color{blue}{\left(\frac{1}{{im}^{2}} \cdot \frac{1}{2}\right)}, re, \log im\right) \]
                          11. associate-*r*N/A

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\left(re \cdot \frac{1}{{im}^{2}}\right) \cdot \frac{1}{2}}, re, \log im\right) \]
                          12. associate-/l*N/A

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re \cdot 1}{{im}^{2}}} \cdot \frac{1}{2}, re, \log im\right) \]
                          13. *-rgt-identityN/A

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

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{re}{{im}^{2}} \cdot \frac{1}{2}}, re, \log im\right) \]
                          15. unpow2N/A

                            \[\leadsto \mathsf{fma}\left(\frac{re}{\color{blue}{im \cdot im}} \cdot \frac{1}{2}, re, \log im\right) \]
                          16. associate-/r*N/A

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
                          17. lower-/.f64N/A

                            \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{\frac{re}{im}}{im}} \cdot \frac{1}{2}, re, \log im\right) \]
                          18. lower-/.f64N/A

                            \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\frac{re}{im}}}{im} \cdot \frac{1}{2}, re, \log im\right) \]
                          19. lower-log.f6429.1

                            \[\leadsto \mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \color{blue}{\log im}\right) \]
                        5. Applied rewrites29.1%

                          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\frac{re}{im}}{im} \cdot 0.5, re, \log im\right)} \]
                        6. Taylor expanded in re around inf

                          \[\leadsto \frac{1}{2} \cdot \color{blue}{\frac{{re}^{2}}{{im}^{2}}} \]
                        7. Step-by-step derivation
                          1. Applied rewrites3.3%

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

                              \[\leadsto \left(re \cdot re\right) \cdot \frac{0.5}{\color{blue}{im \cdot im}} \]
                            2. Final simplification2.9%

                              \[\leadsto \frac{0.5}{im \cdot im} \cdot \left(re \cdot re\right) \]
                            3. Add Preprocessing

                            Reproduce

                            ?
                            herbie shell --seed 2024249 
                            (FPCore (re im)
                              :name "math.log/1 on complex, real part"
                              :precision binary64
                              (log (sqrt (+ (* re re) (* im im)))))