
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
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 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
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 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
(FPCore (re im) :precision binary64 (* (sinh (- im)) (cos re)))
double code(double re, double im) {
return sinh(-im) * cos(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 = sinh(-im) * cos(re)
end function
public static double code(double re, double im) {
return Math.sinh(-im) * Math.cos(re);
}
def code(re, im): return math.sinh(-im) * math.cos(re)
function code(re, im) return Float64(sinh(Float64(-im)) * cos(re)) end
function tmp = code(re, im) tmp = sinh(-im) * cos(re); end
code[re_, im_] := N[(N[Sinh[(-im)], $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision]
\sinh \left(-im\right) \cdot \cos re
Initial program 54.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
--rgt-identityN/A
sub-negate-revN/A
lift--.f64N/A
sinh-defN/A
lower-*.f64N/A
lower-sinh.f6499.9%
lift--.f64N/A
sub0-negN/A
lower-neg.f6499.9%
Applied rewrites99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (sinh (- (fabs im))))
(t_1
(*
(* 0.5 (cos re))
(- (exp (- 0.0 (fabs im))) (exp (fabs im))))))
(*
(copysign 1.0 im)
(if (<= t_1 -0.0001)
t_0
(if (<= t_1 0.0)
(* (- (cos re)) (fabs im))
(* t_0 (+ 1.0 (* -0.5 (pow re 2.0)))))))))double code(double re, double im) {
double t_0 = sinh(-fabs(im));
double t_1 = (0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)));
double tmp;
if (t_1 <= -0.0001) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = -cos(re) * fabs(im);
} else {
tmp = t_0 * (1.0 + (-0.5 * pow(re, 2.0)));
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = Math.sinh(-Math.abs(im));
double t_1 = (0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)));
double tmp;
if (t_1 <= -0.0001) {
tmp = t_0;
} else if (t_1 <= 0.0) {
tmp = -Math.cos(re) * Math.abs(im);
} else {
tmp = t_0 * (1.0 + (-0.5 * Math.pow(re, 2.0)));
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = math.sinh(-math.fabs(im)) t_1 = (0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im))) tmp = 0 if t_1 <= -0.0001: tmp = t_0 elif t_1 <= 0.0: tmp = -math.cos(re) * math.fabs(im) else: tmp = t_0 * (1.0 + (-0.5 * math.pow(re, 2.0))) return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = sinh(Float64(-abs(im))) t_1 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im)))) tmp = 0.0 if (t_1 <= -0.0001) tmp = t_0; elseif (t_1 <= 0.0) tmp = Float64(Float64(-cos(re)) * abs(im)); else tmp = Float64(t_0 * Float64(1.0 + Float64(-0.5 * (re ^ 2.0)))); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = sinh(-abs(im)); t_1 = (0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im))); tmp = 0.0; if (t_1 <= -0.0001) tmp = t_0; elseif (t_1 <= 0.0) tmp = -cos(re) * abs(im); else tmp = t_0 * (1.0 + (-0.5 * (re ^ 2.0))); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[Sinh[(-N[Abs[im], $MachinePrecision])], $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, -0.0001], t$95$0, If[LessEqual[t$95$1, 0.0], N[((-N[Cos[re], $MachinePrecision]) * N[Abs[im], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 + N[(-0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sinh \left(-\left|im\right|\right)\\
t_1 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -0.0001:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\left(-\cos re\right) \cdot \left|im\right|\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 + -0.5 \cdot {re}^{2}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -1e-4Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
sub-negate-revN/A
distribute-neg-fracN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
sinh-negN/A
lift-neg.f64N/A
lift-sinh.f6464.9%
Applied rewrites64.9%
if -1e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 0.0Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6451.5%
Applied rewrites51.5%
if 0.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 54.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
--rgt-identityN/A
sub-negate-revN/A
lift--.f64N/A
sinh-defN/A
lower-*.f64N/A
lower-sinh.f6499.9%
lift--.f64N/A
sub0-negN/A
lower-neg.f6499.9%
Applied rewrites99.9%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6463.8%
Applied rewrites63.8%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(* 0.5 (cos re))
(- (exp (- 0.0 (fabs im))) (exp (fabs im)))))
(t_1 (/ 1.0 (* re re))))
(*
(copysign 1.0 im)
(if (<= t_0 -0.0001)
(sinh (- (fabs im)))
(if (<= t_0 0.0)
(* (- (cos re)) (fabs im))
(fma
-1.0
(fabs im)
(/
1.0
(/
(fma t_1 (fabs im) (* (fabs im) t_1))
(* (fabs im) (fabs im))))))))))double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)));
double t_1 = 1.0 / (re * re);
double tmp;
if (t_0 <= -0.0001) {
tmp = sinh(-fabs(im));
} else if (t_0 <= 0.0) {
tmp = -cos(re) * fabs(im);
} else {
tmp = fma(-1.0, fabs(im), (1.0 / (fma(t_1, fabs(im), (fabs(im) * t_1)) / (fabs(im) * fabs(im)))));
}
return copysign(1.0, im) * tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im)))) t_1 = Float64(1.0 / Float64(re * re)) tmp = 0.0 if (t_0 <= -0.0001) tmp = sinh(Float64(-abs(im))); elseif (t_0 <= 0.0) tmp = Float64(Float64(-cos(re)) * abs(im)); else tmp = fma(-1.0, abs(im), Float64(1.0 / Float64(fma(t_1, abs(im), Float64(abs(im) * t_1)) / Float64(abs(im) * abs(im))))); end return Float64(copysign(1.0, im) * tmp) end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / N[(re * re), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$0, -0.0001], N[Sinh[(-N[Abs[im], $MachinePrecision])], $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[((-N[Cos[re], $MachinePrecision]) * N[Abs[im], $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[Abs[im], $MachinePrecision] + N[(1.0 / N[(N[(t$95$1 * N[Abs[im], $MachinePrecision] + N[(N[Abs[im], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\
t_1 := \frac{1}{re \cdot re}\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -0.0001:\\
\;\;\;\;\sinh \left(-\left|im\right|\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(-\cos re\right) \cdot \left|im\right|\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \left|im\right|, \frac{1}{\frac{\mathsf{fma}\left(t\_1, \left|im\right|, \left|im\right| \cdot t\_1\right)}{\left|im\right| \cdot \left|im\right|}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -1e-4Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
sub-negate-revN/A
distribute-neg-fracN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
sinh-negN/A
lift-neg.f64N/A
lift-sinh.f6464.9%
Applied rewrites64.9%
if -1e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 0.0Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6451.5%
Applied rewrites51.5%
if 0.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
Taylor expanded in re around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6437.0%
Applied rewrites37.0%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6437.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-pow.f64N/A
unpow2N/A
lower-*.f6437.0%
Applied rewrites37.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
div-addN/A
div-add-revN/A
frac-addN/A
sqr-neg-revN/A
mul-1-negN/A
mul-1-negN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
mul-1-negN/A
mul-1-negN/A
sqr-neg-revN/A
lower-*.f6436.8%
Applied rewrites36.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (/ 1.0 (* re re))))
(*
(copysign 1.0 im)
(if (<=
(*
(* 0.5 (cos re))
(- (exp (- 0.0 (fabs im))) (exp (fabs im))))
0.0)
(sinh (- (fabs im)))
(fma
-1.0
(fabs im)
(/
1.0
(/
(fma t_0 (fabs im) (* (fabs im) t_0))
(* (fabs im) (fabs im)))))))))double code(double re, double im) {
double t_0 = 1.0 / (re * re);
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)))) <= 0.0) {
tmp = sinh(-fabs(im));
} else {
tmp = fma(-1.0, fabs(im), (1.0 / (fma(t_0, fabs(im), (fabs(im) * t_0)) / (fabs(im) * fabs(im)))));
}
return copysign(1.0, im) * tmp;
}
function code(re, im) t_0 = Float64(1.0 / Float64(re * re)) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im)))) <= 0.0) tmp = sinh(Float64(-abs(im))); else tmp = fma(-1.0, abs(im), Float64(1.0 / Float64(fma(t_0, abs(im), Float64(abs(im) * t_0)) / Float64(abs(im) * abs(im))))); end return Float64(copysign(1.0, im) * tmp) end
code[re_, im_] := Block[{t$95$0 = N[(1.0 / N[(re * re), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[Sinh[(-N[Abs[im], $MachinePrecision])], $MachinePrecision], N[(-1.0 * N[Abs[im], $MachinePrecision] + N[(1.0 / N[(N[(t$95$0 * N[Abs[im], $MachinePrecision] + N[(N[Abs[im], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{1}{re \cdot re}\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right) \leq 0:\\
\;\;\;\;\sinh \left(-\left|im\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \left|im\right|, \frac{1}{\frac{\mathsf{fma}\left(t\_0, \left|im\right|, \left|im\right| \cdot t\_0\right)}{\left|im\right| \cdot \left|im\right|}}\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 0.0Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
sub-negate-revN/A
distribute-neg-fracN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
sinh-negN/A
lift-neg.f64N/A
lift-sinh.f6464.9%
Applied rewrites64.9%
if 0.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
Taylor expanded in re around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6437.0%
Applied rewrites37.0%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6437.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-pow.f64N/A
unpow2N/A
lower-*.f6437.0%
Applied rewrites37.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
div-addN/A
div-add-revN/A
frac-addN/A
sqr-neg-revN/A
mul-1-negN/A
mul-1-negN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
lower-/.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
mul-1-negN/A
mul-1-negN/A
sqr-neg-revN/A
lower-*.f6436.8%
Applied rewrites36.8%
(FPCore (re im)
:precision binary64
(*
(copysign 1.0 im)
(if (<=
(* (* 0.5 (cos re)) (- (exp (- 0.0 (fabs im))) (exp (fabs im))))
0.0)
(sinh (- (fabs im)))
(fma
-1.0
(fabs im)
(* 0.5 (* (fabs im) (sqrt (* (* re re) (* re re)))))))))double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)))) <= 0.0) {
tmp = sinh(-fabs(im));
} else {
tmp = fma(-1.0, fabs(im), (0.5 * (fabs(im) * sqrt(((re * re) * (re * re))))));
}
return copysign(1.0, im) * tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im)))) <= 0.0) tmp = sinh(Float64(-abs(im))); else tmp = fma(-1.0, abs(im), Float64(0.5 * Float64(abs(im) * sqrt(Float64(Float64(re * re) * Float64(re * re)))))); end return Float64(copysign(1.0, im) * tmp) end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[Sinh[(-N[Abs[im], $MachinePrecision])], $MachinePrecision], N[(-1.0 * N[Abs[im], $MachinePrecision] + N[(0.5 * N[(N[Abs[im], $MachinePrecision] * N[Sqrt[N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right) \leq 0:\\
\;\;\;\;\sinh \left(-\left|im\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, \left|im\right|, 0.5 \cdot \left(\left|im\right| \cdot \sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}\right)\right)\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 0.0Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
sub-negate-revN/A
distribute-neg-fracN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
sinh-negN/A
lift-neg.f64N/A
lift-sinh.f6464.9%
Applied rewrites64.9%
if 0.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
Taylor expanded in re around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6437.0%
Applied rewrites37.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6437.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6437.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6437.5%
Applied rewrites37.5%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.05) (fma (* (* im 0.5) re) re (- im)) (sinh (- im))))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.05) {
tmp = fma(((im * 0.5) * re), re, -im);
} else {
tmp = sinh(-im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.05) tmp = fma(Float64(Float64(im * 0.5) * re), re, Float64(-im)); else tmp = sinh(Float64(-im)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.05], N[(N[(N[(im * 0.5), $MachinePrecision] * re), $MachinePrecision] * re + (-im)), $MachinePrecision], N[Sinh[(-im)], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\left(im \cdot 0.5\right) \cdot re, re, -im\right)\\
\mathbf{else}:\\
\;\;\;\;\sinh \left(-im\right)\\
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.050000000000000003Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
Taylor expanded in re around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6437.0%
Applied rewrites37.0%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6437.0%
Applied rewrites37.0%
if -0.050000000000000003 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
sub-negate-revN/A
distribute-neg-fracN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
sinh-negN/A
lift-neg.f64N/A
lift-sinh.f6464.9%
Applied rewrites64.9%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.05) (fma (* (* im 0.5) re) re (- im)) (fma (* (* -0.16666666666666666 im) im) im (- im))))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.05) {
tmp = fma(((im * 0.5) * re), re, -im);
} else {
tmp = fma(((-0.16666666666666666 * im) * im), im, -im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.05) tmp = fma(Float64(Float64(im * 0.5) * re), re, Float64(-im)); else tmp = fma(Float64(Float64(-0.16666666666666666 * im) * im), im, Float64(-im)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.05], N[(N[(N[(im * 0.5), $MachinePrecision] * re), $MachinePrecision] * re + (-im)), $MachinePrecision], N[(N[(N[(-0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im + (-im)), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\left(im \cdot 0.5\right) \cdot re, re, -im\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-0.16666666666666666 \cdot im\right) \cdot im, im, -im\right)\\
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.050000000000000003Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
Taylor expanded in re around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6437.0%
Applied rewrites37.0%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6437.0%
Applied rewrites37.0%
if -0.050000000000000003 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-exp.f64N/A
exp-fabsN/A
lift-exp.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
exp-lft-sqr-revN/A
lift-neg.f64N/A
distribute-lft-neg-inN/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-exp.f64N/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval40.7%
Applied rewrites40.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6453.5%
Applied rewrites53.5%
lift-*.f64N/A
lift--.f64N/A
sub-flipN/A
metadata-evalN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6453.5%
Applied rewrites53.5%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.05) (fma (* (* im 0.5) re) re (- im)) (* im (fma (* im im) -0.16666666666666666 -1.0))))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.05) {
tmp = fma(((im * 0.5) * re), re, -im);
} else {
tmp = im * fma((im * im), -0.16666666666666666, -1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.05) tmp = fma(Float64(Float64(im * 0.5) * re), re, Float64(-im)); else tmp = Float64(im * fma(Float64(im * im), -0.16666666666666666, -1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.05], N[(N[(N[(im * 0.5), $MachinePrecision] * re), $MachinePrecision] * re + (-im)), $MachinePrecision], N[(im * N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.05:\\
\;\;\;\;\mathsf{fma}\left(\left(im \cdot 0.5\right) \cdot re, re, -im\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right)\\
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.050000000000000003Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
Taylor expanded in re around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6437.0%
Applied rewrites37.0%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6437.0%
Applied rewrites37.0%
if -0.050000000000000003 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-exp.f64N/A
exp-fabsN/A
lift-exp.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
exp-lft-sqr-revN/A
lift-neg.f64N/A
distribute-lft-neg-inN/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-exp.f64N/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval40.7%
Applied rewrites40.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6453.5%
Applied rewrites53.5%
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
sqr-neg-revN/A
mul-1-negN/A
mul-1-negN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
metadata-evalN/A
lower-fma.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
mul-1-negN/A
mul-1-negN/A
sqr-neg-revN/A
lower-*.f6453.5%
Applied rewrites53.5%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.05) (- (* (* (* re re) im) 0.5) im) (* im (fma (* im im) -0.16666666666666666 -1.0))))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.05) {
tmp = (((re * re) * im) * 0.5) - im;
} else {
tmp = im * fma((im * im), -0.16666666666666666, -1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.05) tmp = Float64(Float64(Float64(Float64(re * re) * im) * 0.5) - im); else tmp = Float64(im * fma(Float64(im * im), -0.16666666666666666, -1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.05], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.5), $MachinePrecision] - im), $MachinePrecision], N[(im * N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.05:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 - im\\
\mathbf{else}:\\
\;\;\;\;im \cdot \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right)\\
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.050000000000000003Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
Taylor expanded in re around 0
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6437.0%
Applied rewrites37.0%
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6437.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-pow.f64N/A
unpow2N/A
lower-*.f6437.0%
Applied rewrites37.0%
if -0.050000000000000003 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-exp.f64N/A
exp-fabsN/A
lift-exp.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
exp-lft-sqr-revN/A
lift-neg.f64N/A
distribute-lft-neg-inN/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-exp.f64N/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval40.7%
Applied rewrites40.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6453.5%
Applied rewrites53.5%
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
sqr-neg-revN/A
mul-1-negN/A
mul-1-negN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
metadata-evalN/A
lower-fma.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
mul-1-negN/A
mul-1-negN/A
sqr-neg-revN/A
lower-*.f6453.5%
Applied rewrites53.5%
(FPCore (re im) :precision binary64 (* im (fma (* im im) -0.16666666666666666 -1.0)))
double code(double re, double im) {
return im * fma((im * im), -0.16666666666666666, -1.0);
}
function code(re, im) return Float64(im * fma(Float64(im * im), -0.16666666666666666, -1.0)) end
code[re_, im_] := N[(im * N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision]
im \cdot \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right)
Initial program 54.8%
Taylor expanded in re around 0
lower-*.f64N/A
lower--.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-exp.f6440.7%
Applied rewrites40.7%
lift-exp.f64N/A
exp-fabsN/A
lift-exp.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
exp-lft-sqr-revN/A
lift-neg.f64N/A
distribute-lft-neg-inN/A
*-commutativeN/A
count-2N/A
lift-+.f64N/A
lower-exp.f64N/A
lift-+.f64N/A
count-2N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval40.7%
Applied rewrites40.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6453.5%
Applied rewrites53.5%
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
unpow2N/A
sqr-neg-revN/A
mul-1-negN/A
mul-1-negN/A
lower-*.f32N/A
lower-unsound-*.f32N/A
metadata-evalN/A
lower-fma.f64N/A
lower-unsound-*.f32N/A
lower-*.f32N/A
mul-1-negN/A
mul-1-negN/A
sqr-neg-revN/A
lower-*.f6453.5%
Applied rewrites53.5%
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
return -im;
}
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 = -im
end function
public static double code(double re, double im) {
return -im;
}
def code(re, im): return -im
function code(re, im) return Float64(-im) end
function tmp = code(re, im) tmp = -im; end
code[re_, im_] := (-im)
-im
Initial program 54.8%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6451.5%
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.6%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6429.6%
Applied rewrites29.6%
herbie shell --seed 2025260
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))