
(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 16 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 (* (* (* 2.0 (sinh (- im))) (cos re)) 0.5))
double code(double re, double im) {
return ((2.0 * sinh(-im)) * cos(re)) * 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 = ((2.0d0 * sinh(-im)) * cos(re)) * 0.5d0
end function
public static double code(double re, double im) {
return ((2.0 * Math.sinh(-im)) * Math.cos(re)) * 0.5;
}
def code(re, im): return ((2.0 * math.sinh(-im)) * math.cos(re)) * 0.5
function code(re, im) return Float64(Float64(Float64(2.0 * sinh(Float64(-im))) * cos(re)) * 0.5) end
function tmp = code(re, im) tmp = ((2.0 * sinh(-im)) * cos(re)) * 0.5; end
code[re_, im_] := N[(N[(N[(2.0 * N[Sinh[(-im)], $MachinePrecision]), $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(2 \cdot \sinh \left(-im\right)\right) \cdot \cos re\right) \cdot 0.5
\end{array}
Initial program 54.9%
Applied rewrites99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (exp (- 0.0 im))))
(if (<= im -5.5)
(* (fma re -0.25 0.5) (- t_0 (+ 1.0 im)))
(if (<= im 0.0102)
(* -1.0 (* im (cos re)))
(* (fma re -0.25 0.5) (- t_0 (exp im)))))))
double code(double re, double im) {
double t_0 = exp((0.0 - im));
double tmp;
if (im <= -5.5) {
tmp = fma(re, -0.25, 0.5) * (t_0 - (1.0 + im));
} else if (im <= 0.0102) {
tmp = -1.0 * (im * cos(re));
} else {
tmp = fma(re, -0.25, 0.5) * (t_0 - exp(im));
}
return tmp;
}
function code(re, im) t_0 = exp(Float64(0.0 - im)) tmp = 0.0 if (im <= -5.5) tmp = Float64(fma(re, -0.25, 0.5) * Float64(t_0 - Float64(1.0 + im))); elseif (im <= 0.0102) tmp = Float64(-1.0 * Float64(im * cos(re))); else tmp = Float64(fma(re, -0.25, 0.5) * Float64(t_0 - exp(im))); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[im, -5.5], N[(N[(re * -0.25 + 0.5), $MachinePrecision] * N[(t$95$0 - N[(1.0 + im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 0.0102], N[(-1.0 * N[(im * N[Cos[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(re * -0.25 + 0.5), $MachinePrecision] * N[(t$95$0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{0 - im}\\
\mathbf{if}\;im \leq -5.5:\\
\;\;\;\;\mathsf{fma}\left(re, -0.25, 0.5\right) \cdot \left(t\_0 - \left(1 + im\right)\right)\\
\mathbf{elif}\;im \leq 0.0102:\\
\;\;\;\;-1 \cdot \left(im \cdot \cos re\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(re, -0.25, 0.5\right) \cdot \left(t\_0 - e^{im}\right)\\
\end{array}
\end{array}
if im < -5.5Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites40.8%
Applied rewrites41.7%
Taylor expanded in im around 0
Applied rewrites26.1%
if -5.5 < im < 0.010200000000000001Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
if 0.010200000000000001 < im Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites40.8%
Applied rewrites41.7%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.01) (* (* -0.25 re) (- (exp (- 0.0 im)) (exp im))) (* (* (* 2.0 (sinh (- im))) 1.0) 0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.01) {
tmp = (-0.25 * re) * (exp((0.0 - im)) - exp(im));
} else {
tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((0.5d0 * cos(re)) <= (-0.01d0)) then
tmp = ((-0.25d0) * re) * (exp((0.0d0 - im)) - exp(im))
else
tmp = ((2.0d0 * sinh(-im)) * 1.0d0) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.cos(re)) <= -0.01) {
tmp = (-0.25 * re) * (Math.exp((0.0 - im)) - Math.exp(im));
} else {
tmp = ((2.0 * Math.sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.cos(re)) <= -0.01: tmp = (-0.25 * re) * (math.exp((0.0 - im)) - math.exp(im)) else: tmp = ((2.0 * math.sinh(-im)) * 1.0) * 0.5 return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.01) tmp = Float64(Float64(-0.25 * re) * Float64(exp(Float64(0.0 - im)) - exp(im))); else tmp = Float64(Float64(Float64(2.0 * sinh(Float64(-im))) * 1.0) * 0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * cos(re)) <= -0.01) tmp = (-0.25 * re) * (exp((0.0 - im)) - exp(im)); else tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.01], N[(N[(-0.25 * re), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 * N[Sinh[(-im)], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.01:\\
\;\;\;\;\left(-0.25 \cdot re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(2 \cdot \sinh \left(-im\right)\right) \cdot 1\right) \cdot 0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.0100000000000000002Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites40.8%
Applied rewrites41.7%
Taylor expanded in re around inf
Applied rewrites28.1%
if -0.0100000000000000002 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.8%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.02) (fma -1.0 im (* 0.5 (* im (pow (* re re) 2.0)))) (* (* (* 2.0 (sinh (- im))) 1.0) 0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.02) {
tmp = fma(-1.0, im, (0.5 * (im * pow((re * re), 2.0))));
} else {
tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.02) tmp = fma(-1.0, im, Float64(0.5 * Float64(im * (Float64(re * re) ^ 2.0)))); else tmp = Float64(Float64(Float64(2.0 * sinh(Float64(-im))) * 1.0) * 0.5); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.02], N[(-1.0 * im + N[(0.5 * N[(im * N[Power[N[(re * re), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 * N[Sinh[(-im)], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(-1, im, 0.5 \cdot \left(im \cdot {\left(re \cdot re\right)}^{2}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(2 \cdot \sinh \left(-im\right)\right) \cdot 1\right) \cdot 0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.0200000000000000004Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Applied rewrites37.6%
if -0.0200000000000000004 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.8%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.02) (* im (- (* 0.5 (pow re 2.0)) 1.0)) (* (* (* 2.0 (sinh (- im))) 1.0) 0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.02) {
tmp = im * ((0.5 * pow(re, 2.0)) - 1.0);
} else {
tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((0.5d0 * cos(re)) <= (-0.02d0)) then
tmp = im * ((0.5d0 * (re ** 2.0d0)) - 1.0d0)
else
tmp = ((2.0d0 * sinh(-im)) * 1.0d0) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.cos(re)) <= -0.02) {
tmp = im * ((0.5 * Math.pow(re, 2.0)) - 1.0);
} else {
tmp = ((2.0 * Math.sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.cos(re)) <= -0.02: tmp = im * ((0.5 * math.pow(re, 2.0)) - 1.0) else: tmp = ((2.0 * math.sinh(-im)) * 1.0) * 0.5 return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.02) tmp = Float64(im * Float64(Float64(0.5 * (re ^ 2.0)) - 1.0)); else tmp = Float64(Float64(Float64(2.0 * sinh(Float64(-im))) * 1.0) * 0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * cos(re)) <= -0.02) tmp = im * ((0.5 * (re ^ 2.0)) - 1.0); else tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.02], N[(im * N[(N[(0.5 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 * N[Sinh[(-im)], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.02:\\
\;\;\;\;im \cdot \left(0.5 \cdot {re}^{2} - 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(2 \cdot \sinh \left(-im\right)\right) \cdot 1\right) \cdot 0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.0200000000000000004Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Taylor expanded in im around 0
Applied rewrites36.4%
if -0.0200000000000000004 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.8%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.01) (* 0.5 (- (+ 1.0 (* -1.0 im)) (+ 1.0 (* im (+ 1.0 (* 0.5 im)))))) (* (* (* 2.0 (sinh (- im))) 1.0) 0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.01) {
tmp = 0.5 * ((1.0 + (-1.0 * im)) - (1.0 + (im * (1.0 + (0.5 * im)))));
} else {
tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((0.5d0 * cos(re)) <= (-0.01d0)) then
tmp = 0.5d0 * ((1.0d0 + ((-1.0d0) * im)) - (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else
tmp = ((2.0d0 * sinh(-im)) * 1.0d0) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.cos(re)) <= -0.01) {
tmp = 0.5 * ((1.0 + (-1.0 * im)) - (1.0 + (im * (1.0 + (0.5 * im)))));
} else {
tmp = ((2.0 * Math.sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.cos(re)) <= -0.01: tmp = 0.5 * ((1.0 + (-1.0 * im)) - (1.0 + (im * (1.0 + (0.5 * im))))) else: tmp = ((2.0 * math.sinh(-im)) * 1.0) * 0.5 return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.01) tmp = Float64(0.5 * Float64(Float64(1.0 + Float64(-1.0 * im)) - Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); else tmp = Float64(Float64(Float64(2.0 * sinh(Float64(-im))) * 1.0) * 0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * cos(re)) <= -0.01) tmp = 0.5 * ((1.0 + (-1.0 * im)) - (1.0 + (im * (1.0 + (0.5 * im))))); else tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.01], N[(0.5 * N[(N[(1.0 + N[(-1.0 * im), $MachinePrecision]), $MachinePrecision] - N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 * N[Sinh[(-im)], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.01:\\
\;\;\;\;0.5 \cdot \left(\left(1 + -1 \cdot im\right) - \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(2 \cdot \sinh \left(-im\right)\right) \cdot 1\right) \cdot 0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.0100000000000000002Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites41.5%
Taylor expanded in im around 0
Applied rewrites23.2%
Taylor expanded in im around 0
Applied rewrites16.4%
if -0.0100000000000000002 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.8%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.09) (* 0.5 (- 2.0 (+ 1.0 (* im (+ 1.0 (* 0.5 im)))))) (* (* (* 2.0 (sinh (- im))) 1.0) 0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.09) {
tmp = 0.5 * (2.0 - (1.0 + (im * (1.0 + (0.5 * im)))));
} else {
tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((0.5d0 * cos(re)) <= (-0.09d0)) then
tmp = 0.5d0 * (2.0d0 - (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else
tmp = ((2.0d0 * sinh(-im)) * 1.0d0) * 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.cos(re)) <= -0.09) {
tmp = 0.5 * (2.0 - (1.0 + (im * (1.0 + (0.5 * im)))));
} else {
tmp = ((2.0 * Math.sinh(-im)) * 1.0) * 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.cos(re)) <= -0.09: tmp = 0.5 * (2.0 - (1.0 + (im * (1.0 + (0.5 * im))))) else: tmp = ((2.0 * math.sinh(-im)) * 1.0) * 0.5 return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.09) tmp = Float64(0.5 * Float64(2.0 - Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); else tmp = Float64(Float64(Float64(2.0 * sinh(Float64(-im))) * 1.0) * 0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * cos(re)) <= -0.09) tmp = 0.5 * (2.0 - (1.0 + (im * (1.0 + (0.5 * im))))); else tmp = ((2.0 * sinh(-im)) * 1.0) * 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.09], N[(0.5 * N[(2.0 - N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 * N[Sinh[(-im)], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.09:\\
\;\;\;\;0.5 \cdot \left(2 - \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(2 \cdot \sinh \left(-im\right)\right) \cdot 1\right) \cdot 0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.089999999999999997Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites41.5%
Taylor expanded in im around 0
Applied rewrites23.2%
Taylor expanded in im around 0
Applied rewrites16.4%
Applied rewrites15.0%
if -0.089999999999999997 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(* 0.5 (- 2.0 (exp im)))
(if (<= t_0 2e-5) (* -1.0 im) (* 0.5 (- (exp (- im)) (+ 1.0 im)))))))
double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 0.5 * (2.0 - exp(im));
} else if (t_0 <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = 0.5 * (exp(-im) - (1.0 + im));
}
return tmp;
}
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 <= -Double.POSITIVE_INFINITY) {
tmp = 0.5 * (2.0 - Math.exp(im));
} else if (t_0 <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = 0.5 * (Math.exp(-im) - (1.0 + im));
}
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 <= -math.inf: tmp = 0.5 * (2.0 - math.exp(im)) elif t_0 <= 2e-5: tmp = -1.0 * im else: tmp = 0.5 * (math.exp(-im) - (1.0 + im)) 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 <= Float64(-Inf)) tmp = Float64(0.5 * Float64(2.0 - exp(im))); elseif (t_0 <= 2e-5) tmp = Float64(-1.0 * im); else tmp = Float64(0.5 * Float64(exp(Float64(-im)) - Float64(1.0 + im))); 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 <= -Inf) tmp = 0.5 * (2.0 - exp(im)); elseif (t_0 <= 2e-5) tmp = -1.0 * im; else tmp = 0.5 * (exp(-im) - (1.0 + im)); 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, (-Infinity)], N[(0.5 * N[(2.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-5], N[(-1.0 * im), $MachinePrecision], N[(0.5 * N[(N[Exp[(-im)], $MachinePrecision] - N[(1.0 + im), $MachinePrecision]), $MachinePrecision]), $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 -\infty:\\
\;\;\;\;0.5 \cdot \left(2 - e^{im}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;-1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(e^{-im} - \left(1 + 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))) < -inf.0Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites41.5%
Taylor expanded in im around 0
Applied rewrites23.2%
Applied rewrites21.4%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 2.00000000000000016e-5Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.7%
if 2.00000000000000016e-5 < (*.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.9%
Taylor expanded in re around 0
Applied rewrites41.5%
Taylor expanded in im around 0
Applied rewrites23.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(* 0.5 (- 2.0 (exp im)))
(if (<= t_0 2e-5)
(* -1.0 im)
(fma -1.0 im (* 0.5 (* (* 2.0 re) (* 2.0 re))))))))
double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 0.5 * (2.0 - exp(im));
} else if (t_0 <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = fma(-1.0, im, (0.5 * ((2.0 * re) * (2.0 * re))));
}
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 <= Float64(-Inf)) tmp = Float64(0.5 * Float64(2.0 - exp(im))); elseif (t_0 <= 2e-5) tmp = Float64(-1.0 * im); else tmp = fma(-1.0, im, Float64(0.5 * Float64(Float64(2.0 * re) * Float64(2.0 * re)))); 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, (-Infinity)], N[(0.5 * N[(2.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-5], N[(-1.0 * im), $MachinePrecision], N[(-1.0 * im + N[(0.5 * N[(N[(2.0 * re), $MachinePrecision] * N[(2.0 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 -\infty:\\
\;\;\;\;0.5 \cdot \left(2 - e^{im}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;-1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-1, im, 0.5 \cdot \left(\left(2 \cdot re\right) \cdot \left(2 \cdot re\right)\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))) < -inf.0Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites41.5%
Taylor expanded in im around 0
Applied rewrites23.2%
Applied rewrites21.4%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 2.00000000000000016e-5Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.7%
if 2.00000000000000016e-5 < (*.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.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Applied rewrites27.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(* 0.5 (- 2.0 (exp im)))
(if (<= t_0 2e-5) (* -1.0 im) (* (* 2.0 re) (* re 0.5))))))
double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = 0.5 * (2.0 - exp(im));
} else if (t_0 <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = (2.0 * re) * (re * 0.5);
}
return tmp;
}
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 <= -Double.POSITIVE_INFINITY) {
tmp = 0.5 * (2.0 - Math.exp(im));
} else if (t_0 <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = (2.0 * re) * (re * 0.5);
}
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 <= -math.inf: tmp = 0.5 * (2.0 - math.exp(im)) elif t_0 <= 2e-5: tmp = -1.0 * im else: tmp = (2.0 * re) * (re * 0.5) 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 <= Float64(-Inf)) tmp = Float64(0.5 * Float64(2.0 - exp(im))); elseif (t_0 <= 2e-5) tmp = Float64(-1.0 * im); else tmp = Float64(Float64(2.0 * re) * Float64(re * 0.5)); 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 <= -Inf) tmp = 0.5 * (2.0 - exp(im)); elseif (t_0 <= 2e-5) tmp = -1.0 * im; else tmp = (2.0 * re) * (re * 0.5); 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, (-Infinity)], N[(0.5 * N[(2.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-5], N[(-1.0 * im), $MachinePrecision], N[(N[(2.0 * re), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $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 -\infty:\\
\;\;\;\;0.5 \cdot \left(2 - e^{im}\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;-1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot re\right) \cdot \left(re \cdot 0.5\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))) < -inf.0Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites41.5%
Taylor expanded in im around 0
Applied rewrites23.2%
Applied rewrites21.4%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 2.00000000000000016e-5Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.7%
if 2.00000000000000016e-5 < (*.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.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Applied rewrites8.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(fma -1.0 im (* 0.5 (* (* 2.0 re) (- re))))
(if (<= t_0 2e-5) (* -1.0 im) (* (* 2.0 re) (* re 0.5))))))
double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma(-1.0, im, (0.5 * ((2.0 * re) * -re)));
} else if (t_0 <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = (2.0 * re) * (re * 0.5);
}
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 <= Float64(-Inf)) tmp = fma(-1.0, im, Float64(0.5 * Float64(Float64(2.0 * re) * Float64(-re)))); elseif (t_0 <= 2e-5) tmp = Float64(-1.0 * im); else tmp = Float64(Float64(2.0 * re) * Float64(re * 0.5)); 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, (-Infinity)], N[(-1.0 * im + N[(0.5 * N[(N[(2.0 * re), $MachinePrecision] * (-re)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-5], N[(-1.0 * im), $MachinePrecision], N[(N[(2.0 * re), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $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 -\infty:\\
\;\;\;\;\mathsf{fma}\left(-1, im, 0.5 \cdot \left(\left(2 \cdot re\right) \cdot \left(-re\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;-1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot re\right) \cdot \left(re \cdot 0.5\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))) < -inf.0Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Applied rewrites27.1%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 2.00000000000000016e-5Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.7%
if 2.00000000000000016e-5 < (*.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.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Applied rewrites8.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(* (fma (* re re) -0.25 0.5) 2.0)
(if (<= t_0 2e-5) (* -1.0 im) (* (* 2.0 re) (* re 0.5))))))
double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = fma((re * re), -0.25, 0.5) * 2.0;
} else if (t_0 <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = (2.0 * re) * (re * 0.5);
}
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 <= Float64(-Inf)) tmp = Float64(fma(Float64(re * re), -0.25, 0.5) * 2.0); elseif (t_0 <= 2e-5) tmp = Float64(-1.0 * im); else tmp = Float64(Float64(2.0 * re) * Float64(re * 0.5)); 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, (-Infinity)], N[(N[(N[(re * re), $MachinePrecision] * -0.25 + 0.5), $MachinePrecision] * 2.0), $MachinePrecision], If[LessEqual[t$95$0, 2e-5], N[(-1.0 * im), $MachinePrecision], N[(N[(2.0 * re), $MachinePrecision] * N[(re * 0.5), $MachinePrecision]), $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 -\infty:\\
\;\;\;\;\mathsf{fma}\left(re \cdot re, -0.25, 0.5\right) \cdot 2\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;-1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot re\right) \cdot \left(re \cdot 0.5\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))) < -inf.0Initial program 54.9%
Taylor expanded in re around 0
Applied rewrites40.8%
Applied rewrites2.8%
Applied rewrites8.4%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 2.00000000000000016e-5Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.7%
if 2.00000000000000016e-5 < (*.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.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Applied rewrites8.8%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))) 2e-5) (* -1.0 im) (* (* 2.0 re) (* re 0.5))))
double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = (2.0 * re) * (re * 0.5);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (((0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))) <= 2d-5) then
tmp = (-1.0d0) * im
else
tmp = (2.0d0 * re) * (re * 0.5d0)
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))) <= 2e-5) {
tmp = -1.0 * im;
} else {
tmp = (2.0 * re) * (re * 0.5);
}
return tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))) <= 2e-5: tmp = -1.0 * im else: tmp = (2.0 * re) * (re * 0.5) return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) <= 2e-5) tmp = Float64(-1.0 * im); else tmp = Float64(Float64(2.0 * re) * Float64(re * 0.5)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp((0.0 - im)) - exp(im))) <= 2e-5) tmp = -1.0 * im; else tmp = (2.0 * re) * (re * 0.5); 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], 2e-5], N[(-1.0 * im), $MachinePrecision], N[(N[(2.0 * re), $MachinePrecision] * N[(re * 0.5), $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 2 \cdot 10^{-5}:\\
\;\;\;\;-1 \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(2 \cdot re\right) \cdot \left(re \cdot 0.5\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))) < 2.00000000000000016e-5Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.7%
if 2.00000000000000016e-5 < (*.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.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Applied rewrites8.8%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (cos re)) -0.01) (* (* im 1.0) 0.5) (* -1.0 im)))
double code(double re, double im) {
double tmp;
if ((0.5 * cos(re)) <= -0.01) {
tmp = (im * 1.0) * 0.5;
} else {
tmp = -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 ((0.5d0 * cos(re)) <= (-0.01d0)) then
tmp = (im * 1.0d0) * 0.5d0
else
tmp = (-1.0d0) * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.cos(re)) <= -0.01) {
tmp = (im * 1.0) * 0.5;
} else {
tmp = -1.0 * im;
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.cos(re)) <= -0.01: tmp = (im * 1.0) * 0.5 else: tmp = -1.0 * im return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * cos(re)) <= -0.01) tmp = Float64(Float64(im * 1.0) * 0.5); else tmp = Float64(-1.0 * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * cos(re)) <= -0.01) tmp = (im * 1.0) * 0.5; else tmp = -1.0 * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision], -0.01], N[(N[(im * 1.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(-1.0 * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \cos re \leq -0.01:\\
\;\;\;\;\left(im \cdot 1\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) < -0.0100000000000000002Initial program 54.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.8%
Applied rewrites4.6%
if -0.0100000000000000002 < (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.7%
(FPCore (re im) :precision binary64 (* -1.0 im))
double code(double re, double im) {
return -1.0 * 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 = (-1.0d0) * im
end function
public static double code(double re, double im) {
return -1.0 * im;
}
def code(re, im): return -1.0 * im
function code(re, im) return Float64(-1.0 * im) end
function tmp = code(re, im) tmp = -1.0 * im; end
code[re_, im_] := N[(-1.0 * im), $MachinePrecision]
\begin{array}{l}
\\
-1 \cdot im
\end{array}
Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites29.7%
(FPCore (re im) :precision binary64 (* re 0.5))
double code(double re, double im) {
return re * 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 = re * 0.5d0
end function
public static double code(double re, double im) {
return re * 0.5;
}
def code(re, im): return re * 0.5
function code(re, im) return Float64(re * 0.5) end
function tmp = code(re, im) tmp = re * 0.5; end
code[re_, im_] := N[(re * 0.5), $MachinePrecision]
\begin{array}{l}
\\
re \cdot 0.5
\end{array}
Initial program 54.9%
Taylor expanded in im around 0
Applied rewrites51.5%
Taylor expanded in re around 0
Applied rewrites36.5%
Applied rewrites3.0%
herbie shell --seed 2025159
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))