
(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]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
Herbie found 10 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]
\begin{array}{l}
\\
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* (cos re) (* -2.0 (sinh im))) 0.5))
double code(double re, double im) {
return (cos(re) * (-2.0 * sinh(im))) * 0.5;
}
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 = (cos(re) * ((-2.0d0) * sinh(im))) * 0.5d0
end function
public static double code(double re, double im) {
return (Math.cos(re) * (-2.0 * Math.sinh(im))) * 0.5;
}
def code(re, im): return (math.cos(re) * (-2.0 * math.sinh(im))) * 0.5
function code(re, im) return Float64(Float64(cos(re) * Float64(-2.0 * sinh(im))) * 0.5) end
function tmp = code(re, im) tmp = (cos(re) * (-2.0 * sinh(im))) * 0.5; end
code[re_, im_] := N[(N[(N[Cos[re], $MachinePrecision] * N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\cos re \cdot \left(-2 \cdot \sinh im\right)\right) \cdot 0.5
\end{array}
Initial program 54.3%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift--.f64N/A
sub0-negN/A
mul-1-negN/A
lower-exp.f64N/A
lift-exp.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.9%
lift-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
(if (<= t_0 -5e+107)
(* (* -2.0 (sinh im)) 0.5)
(if (<= t_0 5e+39)
(* (* im (cos re)) (fma (* im im) -0.16666666666666666 -1.0))
(* (* (pow re 6.0) im) 0.001388888888888889)))))
double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
double tmp;
if (t_0 <= -5e+107) {
tmp = (-2.0 * sinh(im)) * 0.5;
} else if (t_0 <= 5e+39) {
tmp = (im * cos(re)) * fma((im * im), -0.16666666666666666, -1.0);
} else {
tmp = (pow(re, 6.0) * im) * 0.001388888888888889;
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) tmp = 0.0 if (t_0 <= -5e+107) tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5); elseif (t_0 <= 5e+39) tmp = Float64(Float64(im * cos(re)) * fma(Float64(im * im), -0.16666666666666666, -1.0)); else tmp = Float64(Float64((re ^ 6.0) * im) * 0.001388888888888889); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+107], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 5e+39], N[(N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[re, 6.0], $MachinePrecision] * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+107}:\\
\;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+39}:\\
\;\;\;\;\left(im \cdot \cos re\right) \cdot \mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right)\\
\mathbf{else}:\\
\;\;\;\;\left({re}^{6} \cdot im\right) \cdot 0.001388888888888889\\
\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))) < -5.0000000000000002e107Initial program 54.3%
Taylor expanded in re around 0
Applied rewrites40.9%
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
sub0-negN/A
sub-negate-revN/A
sinh-undef-revN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6465.0
Applied rewrites65.0%
if -5.0000000000000002e107 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 5.00000000000000015e39Initial program 54.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6484.0
Applied rewrites84.0%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-fma.f64N/A
add-flipN/A
pow2N/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
*-commutativeN/A
pow2N/A
metadata-evalN/A
add-flipN/A
lift-fma.f64N/A
lift-*.f6484.0
Applied rewrites84.0%
if 5.00000000000000015e39 < (*.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.3%
Taylor expanded in im around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6452.2
Applied rewrites52.2%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites37.9%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6413.6
Applied rewrites13.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
(if (<= t_0 -5e+107)
(* (* -2.0 (sinh im)) 0.5)
(if (<= t_0 5e+39)
(* (- im) (cos re))
(* (* (pow re 6.0) im) 0.001388888888888889)))))
double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
double tmp;
if (t_0 <= -5e+107) {
tmp = (-2.0 * sinh(im)) * 0.5;
} else if (t_0 <= 5e+39) {
tmp = -im * cos(re);
} else {
tmp = (pow(re, 6.0) * im) * 0.001388888888888889;
}
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) :: t_0
real(8) :: tmp
t_0 = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
if (t_0 <= (-5d+107)) then
tmp = ((-2.0d0) * sinh(im)) * 0.5d0
else if (t_0 <= 5d+39) then
tmp = -im * cos(re)
else
tmp = ((re ** 6.0d0) * im) * 0.001388888888888889d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
double tmp;
if (t_0 <= -5e+107) {
tmp = (-2.0 * Math.sinh(im)) * 0.5;
} else if (t_0 <= 5e+39) {
tmp = -im * Math.cos(re);
} else {
tmp = (Math.pow(re, 6.0) * im) * 0.001388888888888889;
}
return tmp;
}
def code(re, im): t_0 = (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im)) tmp = 0 if t_0 <= -5e+107: tmp = (-2.0 * math.sinh(im)) * 0.5 elif t_0 <= 5e+39: tmp = -im * math.cos(re) else: tmp = (math.pow(re, 6.0) * im) * 0.001388888888888889 return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) tmp = 0.0 if (t_0 <= -5e+107) tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5); elseif (t_0 <= 5e+39) tmp = Float64(Float64(-im) * cos(re)); else tmp = Float64(Float64((re ^ 6.0) * im) * 0.001388888888888889); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); tmp = 0.0; if (t_0 <= -5e+107) tmp = (-2.0 * sinh(im)) * 0.5; elseif (t_0 <= 5e+39) tmp = -im * cos(re); else tmp = ((re ^ 6.0) * im) * 0.001388888888888889; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+107], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], If[LessEqual[t$95$0, 5e+39], N[((-im) * N[Cos[re], $MachinePrecision]), $MachinePrecision], N[(N[(N[Power[re, 6.0], $MachinePrecision] * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{+107}:\\
\;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+39}:\\
\;\;\;\;\left(-im\right) \cdot \cos re\\
\mathbf{else}:\\
\;\;\;\;\left({re}^{6} \cdot im\right) \cdot 0.001388888888888889\\
\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))) < -5.0000000000000002e107Initial program 54.3%
Taylor expanded in re around 0
Applied rewrites40.9%
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
sub0-negN/A
sub-negate-revN/A
sinh-undef-revN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6465.0
Applied rewrites65.0%
if -5.0000000000000002e107 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 5.00000000000000015e39Initial program 54.3%
Taylor expanded in im around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6452.2
Applied rewrites52.2%
if 5.00000000000000015e39 < (*.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.3%
Taylor expanded in im around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6452.2
Applied rewrites52.2%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites37.9%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6413.6
Applied rewrites13.6%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))) 0.0) (* (* -2.0 (sinh im)) 0.5) (* (* (pow re 6.0) im) 0.001388888888888889)))
double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= 0.0) {
tmp = (-2.0 * sinh(im)) * 0.5;
} else {
tmp = (pow(re, 6.0) * im) * 0.001388888888888889;
}
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 (((0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))) <= 0.0d0) then
tmp = ((-2.0d0) * sinh(im)) * 0.5d0
else
tmp = ((re ** 6.0d0) * im) * 0.001388888888888889d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im))) <= 0.0) {
tmp = (-2.0 * Math.sinh(im)) * 0.5;
} else {
tmp = (Math.pow(re, 6.0) * im) * 0.001388888888888889;
}
return tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))) <= 0.0: tmp = (-2.0 * math.sinh(im)) * 0.5 else: tmp = (math.pow(re, 6.0) * im) * 0.001388888888888889 return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) <= 0.0) tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5); else tmp = Float64(Float64((re ^ 6.0) * im) * 0.001388888888888889); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= 0.0) tmp = (-2.0 * sinh(im)) * 0.5; else tmp = ((re ^ 6.0) * im) * 0.001388888888888889; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[Power[re, 6.0], $MachinePrecision] * im), $MachinePrecision] * 0.001388888888888889), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \leq 0:\\
\;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left({re}^{6} \cdot im\right) \cdot 0.001388888888888889\\
\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.3%
Taylor expanded in re around 0
Applied rewrites40.9%
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
sub0-negN/A
sub-negate-revN/A
sinh-undef-revN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6465.0
Applied rewrites65.0%
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.3%
Taylor expanded in im around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6452.2
Applied rewrites52.2%
Taylor expanded in re around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites37.9%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6413.6
Applied rewrites13.6%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))) 0.0) (* (* -2.0 (sinh im)) 0.5) (* (* (* (* im im) im) -0.3333333333333333) (* (* re re) -0.25))))
double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= 0.0) {
tmp = (-2.0 * sinh(im)) * 0.5;
} else {
tmp = (((im * im) * im) * -0.3333333333333333) * ((re * re) * -0.25);
}
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 (((0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))) <= 0.0d0) then
tmp = ((-2.0d0) * sinh(im)) * 0.5d0
else
tmp = (((im * im) * im) * (-0.3333333333333333d0)) * ((re * re) * (-0.25d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im))) <= 0.0) {
tmp = (-2.0 * Math.sinh(im)) * 0.5;
} else {
tmp = (((im * im) * im) * -0.3333333333333333) * ((re * re) * -0.25);
}
return tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))) <= 0.0: tmp = (-2.0 * math.sinh(im)) * 0.5 else: tmp = (((im * im) * im) * -0.3333333333333333) * ((re * re) * -0.25) return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) <= 0.0) tmp = Float64(Float64(-2.0 * sinh(im)) * 0.5); else tmp = Float64(Float64(Float64(Float64(im * im) * im) * -0.3333333333333333) * Float64(Float64(re * re) * -0.25)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= 0.0) tmp = (-2.0 * sinh(im)) * 0.5; else tmp = (((im * im) * im) * -0.3333333333333333) * ((re * re) * -0.25); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(N[(im * im), $MachinePrecision] * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \leq 0:\\
\;\;\;\;\left(-2 \cdot \sinh im\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(im \cdot im\right) \cdot im\right) \cdot -0.3333333333333333\right) \cdot \left(\left(re \cdot re\right) \cdot -0.25\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.3%
Taylor expanded in re around 0
Applied rewrites40.9%
lift-*.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift--.f64N/A
lift-exp.f64N/A
*-commutativeN/A
sub0-negN/A
sub-negate-revN/A
sinh-undef-revN/A
lower-*.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6465.0
Applied rewrites65.0%
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.3%
Taylor expanded in re around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
sub0-negN/A
sub-negate-revN/A
lower-neg.f64N/A
sub0-negN/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites63.4%
Taylor expanded in im around 0
sinh-undef-revN/A
sub-negate-revN/A
sub0-negN/A
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6454.5
Applied rewrites54.5%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6413.5
Applied rewrites13.5%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6413.7
Applied rewrites13.7%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))) 0.0) (* (fma (* im im) -0.16666666666666666 -1.0) im) (* (* (* (* im im) im) -0.3333333333333333) (* (* re re) -0.25))))
double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= 0.0) {
tmp = fma((im * im), -0.16666666666666666, -1.0) * im;
} else {
tmp = (((im * im) * im) * -0.3333333333333333) * ((re * re) * -0.25);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) <= 0.0) tmp = Float64(fma(Float64(im * im), -0.16666666666666666, -1.0) * im); else tmp = Float64(Float64(Float64(Float64(im * im) * im) * -0.3333333333333333) * Float64(Float64(re * re) * -0.25)); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision] * im), $MachinePrecision], N[(N[(N[(N[(im * im), $MachinePrecision] * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * N[(N[(re * re), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \leq 0:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(im \cdot im\right) \cdot im\right) \cdot -0.3333333333333333\right) \cdot \left(\left(re \cdot re\right) \cdot -0.25\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.3%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
sub0-negN/A
sub-negate-revN/A
lower-neg.f64N/A
sub0-negN/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6465.0
Applied rewrites65.0%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6453.3
Applied rewrites53.3%
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.3%
Taylor expanded in re around 0
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
sub0-negN/A
sub-negate-revN/A
lower-neg.f64N/A
sub0-negN/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites63.4%
Taylor expanded in im around 0
sinh-undef-revN/A
sub-negate-revN/A
sub0-negN/A
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6454.5
Applied rewrites54.5%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6413.5
Applied rewrites13.5%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6413.7
Applied rewrites13.7%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))) 0.0) (* (fma (* im im) -0.16666666666666666 -1.0) im) (- (* (* (* re re) im) 0.5) im)))
double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= 0.0) {
tmp = fma((im * im), -0.16666666666666666, -1.0) * im;
} else {
tmp = (((re * re) * im) * 0.5) - im;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) <= 0.0) tmp = Float64(fma(Float64(im * im), -0.16666666666666666, -1.0) * im); else tmp = Float64(Float64(Float64(Float64(re * re) * im) * 0.5) - im); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision] * im), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.5), $MachinePrecision] - im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \leq 0:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(\left(re \cdot re\right) \cdot im\right) \cdot 0.5 - im\\
\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.3%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
sub0-negN/A
sub-negate-revN/A
lower-neg.f64N/A
sub0-negN/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6465.0
Applied rewrites65.0%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6453.3
Applied rewrites53.3%
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.3%
Taylor expanded in im around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6452.2
Applied rewrites52.2%
Taylor expanded in re around 0
mul-1-negN/A
lift-neg.f6429.6
Applied rewrites29.6%
Taylor expanded in re around 0
+-commutativeN/A
mul-1-negN/A
sub-flipN/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
pow2N/A
lift-*.f64N/A
lift-*.f6436.0
Applied rewrites36.0%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))) -5e+107) (* (* (* im im) im) -0.16666666666666666) (- im)))
double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= -5e+107) {
tmp = ((im * im) * im) * -0.16666666666666666;
} else {
tmp = -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 (((0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))) <= (-5d+107)) then
tmp = ((im * im) * im) * (-0.16666666666666666d0)
else
tmp = -im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im))) <= -5e+107) {
tmp = ((im * im) * im) * -0.16666666666666666;
} else {
tmp = -im;
}
return tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))) <= -5e+107: tmp = ((im * im) * im) * -0.16666666666666666 else: tmp = -im return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) <= -5e+107) tmp = Float64(Float64(Float64(im * im) * im) * -0.16666666666666666); else tmp = Float64(-im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= -5e+107) tmp = ((im * im) * im) * -0.16666666666666666; else tmp = -im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e+107], N[(N[(N[(im * im), $MachinePrecision] * im), $MachinePrecision] * -0.16666666666666666), $MachinePrecision], (-im)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right) \leq -5 \cdot 10^{+107}:\\
\;\;\;\;\left(\left(im \cdot im\right) \cdot im\right) \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;-im\\
\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))) < -5.0000000000000002e107Initial program 54.3%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
sub0-negN/A
sub-negate-revN/A
lower-neg.f64N/A
sub0-negN/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6465.0
Applied rewrites65.0%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6453.3
Applied rewrites53.3%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6428.7
Applied rewrites28.7%
if -5.0000000000000002e107 < (*.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.3%
Taylor expanded in im around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6452.2
Applied rewrites52.2%
Taylor expanded in re around 0
mul-1-negN/A
lift-neg.f6429.6
Applied rewrites29.6%
(FPCore (re im) :precision binary64 (* (fma (* im im) -0.16666666666666666 -1.0) im))
double code(double re, double im) {
return fma((im * im), -0.16666666666666666, -1.0) * im;
}
function code(re, im) return Float64(fma(Float64(im * im), -0.16666666666666666, -1.0) * im) end
code[re_, im_] := N[(N[(N[(im * im), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision] * im), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(im \cdot im, -0.16666666666666666, -1\right) \cdot im
\end{array}
Initial program 54.3%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
sub0-negN/A
sub-negate-revN/A
lower-neg.f64N/A
sub0-negN/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6465.0
Applied rewrites65.0%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6453.3
Applied rewrites53.3%
(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)
\begin{array}{l}
\\
-im
\end{array}
Initial program 54.3%
Taylor expanded in im around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f6452.2
Applied rewrites52.2%
Taylor expanded in re around 0
mul-1-negN/A
lift-neg.f6429.6
Applied rewrites29.6%
herbie shell --seed 2025134
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))