
(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}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (re im) :precision binary64 (if (<= re 7.6e+28) (* 0.5 (sqrt (* 2.0 (- (hypot re im) re)))) (* 0.5 (/ im (sqrt re)))))
double code(double re, double im) {
double tmp;
if (re <= 7.6e+28) {
tmp = 0.5 * sqrt((2.0 * (hypot(re, im) - re)));
} else {
tmp = 0.5 * (im / sqrt(re));
}
return tmp;
}
public static double code(double re, double im) {
double tmp;
if (re <= 7.6e+28) {
tmp = 0.5 * Math.sqrt((2.0 * (Math.hypot(re, im) - re)));
} else {
tmp = 0.5 * (im / Math.sqrt(re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 7.6e+28: tmp = 0.5 * math.sqrt((2.0 * (math.hypot(re, im) - re))) else: tmp = 0.5 * (im / math.sqrt(re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 7.6e+28) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(hypot(re, im) - re)))); else tmp = Float64(0.5 * Float64(im / sqrt(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 7.6e+28) tmp = 0.5 * sqrt((2.0 * (hypot(re, im) - re))); else tmp = 0.5 * (im / sqrt(re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 7.6e+28], N[(0.5 * N[Sqrt[N[(2.0 * N[(N[Sqrt[re ^ 2 + im ^ 2], $MachinePrecision] - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im / N[Sqrt[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 7.6 \cdot 10^{+28}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\mathsf{hypot}\left(re, im\right) - re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{re}}\\
\end{array}
\end{array}
if re < 7.5999999999999998e28Initial program 56.4%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites94.0%
if 7.5999999999999998e28 < re Initial program 7.0%
Taylor expanded in re around inf
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6486.8
Applied rewrites86.8%
Applied rewrites87.4%
Final simplification92.6%
(FPCore (re im)
:precision binary64
(if (<= re -4.8e-98)
(* 0.5 (sqrt (* -4.0 re)))
(if (<= re 0.000155)
(* 0.5 (sqrt (* 2.0 (- im re))))
(* 0.5 (* (sqrt (pow re -1.0)) im)))))
double code(double re, double im) {
double tmp;
if (re <= -4.8e-98) {
tmp = 0.5 * sqrt((-4.0 * re));
} else if (re <= 0.000155) {
tmp = 0.5 * sqrt((2.0 * (im - re)));
} else {
tmp = 0.5 * (sqrt(pow(re, -1.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 <= (-4.8d-98)) then
tmp = 0.5d0 * sqrt(((-4.0d0) * re))
else if (re <= 0.000155d0) then
tmp = 0.5d0 * sqrt((2.0d0 * (im - re)))
else
tmp = 0.5d0 * (sqrt((re ** (-1.0d0))) * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -4.8e-98) {
tmp = 0.5 * Math.sqrt((-4.0 * re));
} else if (re <= 0.000155) {
tmp = 0.5 * Math.sqrt((2.0 * (im - re)));
} else {
tmp = 0.5 * (Math.sqrt(Math.pow(re, -1.0)) * im);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.8e-98: tmp = 0.5 * math.sqrt((-4.0 * re)) elif re <= 0.000155: tmp = 0.5 * math.sqrt((2.0 * (im - re))) else: tmp = 0.5 * (math.sqrt(math.pow(re, -1.0)) * im) return tmp
function code(re, im) tmp = 0.0 if (re <= -4.8e-98) tmp = Float64(0.5 * sqrt(Float64(-4.0 * re))); elseif (re <= 0.000155) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(im - re)))); else tmp = Float64(0.5 * Float64(sqrt((re ^ -1.0)) * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -4.8e-98) tmp = 0.5 * sqrt((-4.0 * re)); elseif (re <= 0.000155) tmp = 0.5 * sqrt((2.0 * (im - re))); else tmp = 0.5 * (sqrt((re ^ -1.0)) * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.8e-98], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.000155], N[(0.5 * N[Sqrt[N[(2.0 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sqrt[N[Power[re, -1.0], $MachinePrecision]], $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.8 \cdot 10^{-98}:\\
\;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
\mathbf{elif}\;re \leq 0.000155:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sqrt{{re}^{-1}} \cdot im\right)\\
\end{array}
\end{array}
if re < -4.8000000000000001e-98Initial program 49.3%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites100.0%
Taylor expanded in re around -inf
lower-*.f6476.8
Applied rewrites76.8%
if -4.8000000000000001e-98 < re < 1.55e-4Initial program 61.4%
Taylor expanded in re around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6481.0
Applied rewrites81.0%
if 1.55e-4 < re Initial program 10.5%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites33.9%
lift-sqrt.f64N/A
pow1/2N/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
Applied rewrites33.7%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f6485.3
Applied rewrites85.3%
Final simplification80.6%
(FPCore (re im)
:precision binary64
(if (<= re -1.32e+122)
(* 0.5 (sqrt (* -4.0 re)))
(if (<= re -2.95e-105)
(* 0.5 (sqrt (* 2.0 (- (sqrt (fma re re (* im im))) re))))
(if (<= re 28.0)
(* 0.5 (sqrt (+ (fma (- (/ re im) 2.0) re im) im)))
(* 0.5 (/ im (sqrt re)))))))
double code(double re, double im) {
double tmp;
if (re <= -1.32e+122) {
tmp = 0.5 * sqrt((-4.0 * re));
} else if (re <= -2.95e-105) {
tmp = 0.5 * sqrt((2.0 * (sqrt(fma(re, re, (im * im))) - re)));
} else if (re <= 28.0) {
tmp = 0.5 * sqrt((fma(((re / im) - 2.0), re, im) + im));
} else {
tmp = 0.5 * (im / sqrt(re));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (re <= -1.32e+122) tmp = Float64(0.5 * sqrt(Float64(-4.0 * re))); elseif (re <= -2.95e-105) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(sqrt(fma(re, re, Float64(im * im))) - re)))); elseif (re <= 28.0) tmp = Float64(0.5 * sqrt(Float64(fma(Float64(Float64(re / im) - 2.0), re, im) + im))); else tmp = Float64(0.5 * Float64(im / sqrt(re))); end return tmp end
code[re_, im_] := If[LessEqual[re, -1.32e+122], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, -2.95e-105], 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, 28.0], N[(0.5 * N[Sqrt[N[(N[(N[(N[(re / im), $MachinePrecision] - 2.0), $MachinePrecision] * re + im), $MachinePrecision] + im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im / N[Sqrt[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.32 \cdot 10^{+122}:\\
\;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
\mathbf{elif}\;re \leq -2.95 \cdot 10^{-105}:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(\sqrt{\mathsf{fma}\left(re, re, im \cdot im\right)} - re\right)}\\
\mathbf{elif}\;re \leq 28:\\
\;\;\;\;0.5 \cdot \sqrt{\mathsf{fma}\left(\frac{re}{im} - 2, re, im\right) + im}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{re}}\\
\end{array}
\end{array}
if re < -1.31999999999999992e122Initial program 14.0%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites100.0%
Taylor expanded in re around -inf
lower-*.f6488.1
Applied rewrites88.1%
if -1.31999999999999992e122 < re < -2.9499999999999999e-105Initial program 80.1%
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites80.1%
if -2.9499999999999999e-105 < re < 28Initial program 61.0%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites89.6%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6481.3
Applied rewrites81.3%
Applied rewrites81.3%
if 28 < re Initial program 8.1%
Taylor expanded in re around inf
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6486.2
Applied rewrites86.2%
Applied rewrites86.9%
Final simplification83.3%
(FPCore (re im)
:precision binary64
(if (<= re -4.8e-98)
(* 0.5 (sqrt (* -4.0 re)))
(if (<= re 28.0)
(* 0.5 (sqrt (+ (fma (- (/ re im) 2.0) re im) im)))
(* 0.5 (/ im (sqrt re))))))
double code(double re, double im) {
double tmp;
if (re <= -4.8e-98) {
tmp = 0.5 * sqrt((-4.0 * re));
} else if (re <= 28.0) {
tmp = 0.5 * sqrt((fma(((re / im) - 2.0), re, im) + im));
} else {
tmp = 0.5 * (im / sqrt(re));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (re <= -4.8e-98) tmp = Float64(0.5 * sqrt(Float64(-4.0 * re))); elseif (re <= 28.0) tmp = Float64(0.5 * sqrt(Float64(fma(Float64(Float64(re / im) - 2.0), re, im) + im))); else tmp = Float64(0.5 * Float64(im / sqrt(re))); end return tmp end
code[re_, im_] := If[LessEqual[re, -4.8e-98], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 28.0], N[(0.5 * N[Sqrt[N[(N[(N[(N[(re / im), $MachinePrecision] - 2.0), $MachinePrecision] * re + im), $MachinePrecision] + im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im / N[Sqrt[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.8 \cdot 10^{-98}:\\
\;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
\mathbf{elif}\;re \leq 28:\\
\;\;\;\;0.5 \cdot \sqrt{\mathsf{fma}\left(\frac{re}{im} - 2, re, im\right) + im}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{re}}\\
\end{array}
\end{array}
if re < -4.8000000000000001e-98Initial program 49.3%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites100.0%
Taylor expanded in re around -inf
lower-*.f6476.8
Applied rewrites76.8%
if -4.8000000000000001e-98 < re < 28Initial program 61.7%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites89.8%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower-*.f6480.8
Applied rewrites80.8%
Applied rewrites80.8%
if 28 < re Initial program 8.1%
Taylor expanded in re around inf
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6486.2
Applied rewrites86.2%
Applied rewrites86.9%
Final simplification80.8%
(FPCore (re im)
:precision binary64
(if (<= re -4.8e-98)
(* 0.5 (sqrt (* -4.0 re)))
(if (<= re 0.000155)
(* 0.5 (sqrt (* 2.0 (- im re))))
(* 0.5 (/ im (sqrt re))))))
double code(double re, double im) {
double tmp;
if (re <= -4.8e-98) {
tmp = 0.5 * sqrt((-4.0 * re));
} else if (re <= 0.000155) {
tmp = 0.5 * sqrt((2.0 * (im - re)));
} else {
tmp = 0.5 * (im / sqrt(re));
}
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 <= (-4.8d-98)) then
tmp = 0.5d0 * sqrt(((-4.0d0) * re))
else if (re <= 0.000155d0) then
tmp = 0.5d0 * sqrt((2.0d0 * (im - re)))
else
tmp = 0.5d0 * (im / sqrt(re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -4.8e-98) {
tmp = 0.5 * Math.sqrt((-4.0 * re));
} else if (re <= 0.000155) {
tmp = 0.5 * Math.sqrt((2.0 * (im - re)));
} else {
tmp = 0.5 * (im / Math.sqrt(re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.8e-98: tmp = 0.5 * math.sqrt((-4.0 * re)) elif re <= 0.000155: tmp = 0.5 * math.sqrt((2.0 * (im - re))) else: tmp = 0.5 * (im / math.sqrt(re)) return tmp
function code(re, im) tmp = 0.0 if (re <= -4.8e-98) tmp = Float64(0.5 * sqrt(Float64(-4.0 * re))); elseif (re <= 0.000155) tmp = Float64(0.5 * sqrt(Float64(2.0 * Float64(im - re)))); else tmp = Float64(0.5 * Float64(im / sqrt(re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -4.8e-98) tmp = 0.5 * sqrt((-4.0 * re)); elseif (re <= 0.000155) tmp = 0.5 * sqrt((2.0 * (im - re))); else tmp = 0.5 * (im / sqrt(re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.8e-98], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 0.000155], N[(0.5 * N[Sqrt[N[(2.0 * N[(im - re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(im / N[Sqrt[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.8 \cdot 10^{-98}:\\
\;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
\mathbf{elif}\;re \leq 0.000155:\\
\;\;\;\;0.5 \cdot \sqrt{2 \cdot \left(im - re\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{im}{\sqrt{re}}\\
\end{array}
\end{array}
if re < -4.8000000000000001e-98Initial program 49.3%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites100.0%
Taylor expanded in re around -inf
lower-*.f6476.8
Applied rewrites76.8%
if -4.8000000000000001e-98 < re < 1.55e-4Initial program 61.4%
Taylor expanded in re around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f6481.0
Applied rewrites81.0%
if 1.55e-4 < re Initial program 10.5%
Taylor expanded in re around inf
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sqrt.f64N/A
lower-sqrt.f6484.8
Applied rewrites84.8%
Applied rewrites85.4%
Final simplification80.6%
(FPCore (re im) :precision binary64 (if (<= re -4.8e-98) (* 0.5 (sqrt (* -4.0 re))) (if (<= re 1.65e+171) (* 0.5 (sqrt (+ im im))) 0.0)))
double code(double re, double im) {
double tmp;
if (re <= -4.8e-98) {
tmp = 0.5 * sqrt((-4.0 * re));
} else if (re <= 1.65e+171) {
tmp = 0.5 * sqrt((im + im));
} else {
tmp = 0.0;
}
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 <= (-4.8d-98)) then
tmp = 0.5d0 * sqrt(((-4.0d0) * re))
else if (re <= 1.65d+171) then
tmp = 0.5d0 * sqrt((im + im))
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -4.8e-98) {
tmp = 0.5 * Math.sqrt((-4.0 * re));
} else if (re <= 1.65e+171) {
tmp = 0.5 * Math.sqrt((im + im));
} else {
tmp = 0.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -4.8e-98: tmp = 0.5 * math.sqrt((-4.0 * re)) elif re <= 1.65e+171: tmp = 0.5 * math.sqrt((im + im)) else: tmp = 0.0 return tmp
function code(re, im) tmp = 0.0 if (re <= -4.8e-98) tmp = Float64(0.5 * sqrt(Float64(-4.0 * re))); elseif (re <= 1.65e+171) tmp = Float64(0.5 * sqrt(Float64(im + im))); else tmp = 0.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -4.8e-98) tmp = 0.5 * sqrt((-4.0 * re)); elseif (re <= 1.65e+171) tmp = 0.5 * sqrt((im + im)); else tmp = 0.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -4.8e-98], N[(0.5 * N[Sqrt[N[(-4.0 * re), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.65e+171], N[(0.5 * N[Sqrt[N[(im + im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -4.8 \cdot 10^{-98}:\\
\;\;\;\;0.5 \cdot \sqrt{-4 \cdot re}\\
\mathbf{elif}\;re \leq 1.65 \cdot 10^{+171}:\\
\;\;\;\;0.5 \cdot \sqrt{im + im}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if re < -4.8000000000000001e-98Initial program 49.3%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites100.0%
Taylor expanded in re around -inf
lower-*.f6476.8
Applied rewrites76.8%
if -4.8000000000000001e-98 < re < 1.64999999999999996e171Initial program 53.3%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites79.8%
Taylor expanded in re around 0
lower-*.f6470.1
Applied rewrites70.1%
Applied rewrites70.1%
if 1.64999999999999996e171 < re Initial program 2.5%
Applied rewrites22.5%
(FPCore (re im) :precision binary64 (if (<= im 2e-216) 0.0 (* 0.5 (sqrt (+ im im)))))
double code(double re, double im) {
double tmp;
if (im <= 2e-216) {
tmp = 0.0;
} else {
tmp = 0.5 * sqrt((im + 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 (im <= 2d-216) then
tmp = 0.0d0
else
tmp = 0.5d0 * sqrt((im + im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2e-216) {
tmp = 0.0;
} else {
tmp = 0.5 * Math.sqrt((im + im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2e-216: tmp = 0.0 else: tmp = 0.5 * math.sqrt((im + im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 2e-216) tmp = 0.0; else tmp = Float64(0.5 * sqrt(Float64(im + im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2e-216) tmp = 0.0; else tmp = 0.5 * sqrt((im + im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2e-216], 0.0, N[(0.5 * N[Sqrt[N[(im + im), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2 \cdot 10^{-216}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{im + im}\\
\end{array}
\end{array}
if im < 2.0000000000000001e-216Initial program 35.2%
Applied rewrites21.8%
if 2.0000000000000001e-216 < im Initial program 47.8%
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
sqr-abs-revN/A
fp-cancel-sign-sub-invN/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
rem-sqrt-square-revN/A
pow2N/A
sqrt-pow1N/A
metadata-evalN/A
unpow1N/A
remove-double-negN/A
remove-double-negN/A
remove-double-negN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
Applied rewrites82.9%
Taylor expanded in re around 0
lower-*.f6457.4
Applied rewrites57.4%
Applied rewrites57.4%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
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.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 45.6%
Applied rewrites6.3%
herbie shell --seed 2024347
(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)))))