
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-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 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\end{array}
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-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 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* (* 2.0 (sinh (- im))) (sin re)) 0.5))
double code(double re, double im) {
return ((2.0 * sinh(-im)) * sin(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)) * sin(re)) * 0.5d0
end function
public static double code(double re, double im) {
return ((2.0 * Math.sinh(-im)) * Math.sin(re)) * 0.5;
}
def code(re, im): return ((2.0 * math.sinh(-im)) * math.sin(re)) * 0.5
function code(re, im) return Float64(Float64(Float64(2.0 * sinh(Float64(-im))) * sin(re)) * 0.5) end
function tmp = code(re, im) tmp = ((2.0 * sinh(-im)) * sin(re)) * 0.5; end
code[re_, im_] := N[(N[(N[(2.0 * N[Sinh[(-im)], $MachinePrecision]), $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(2 \cdot \sinh \left(-im\right)\right) \cdot \sin re\right) \cdot 0.5
\end{array}
Initial program 66.3%
Applied rewrites99.9%
(FPCore (re im)
:precision binary64
(if (<= im -0.0215)
(*
(* re (+ 0.5 (* -0.08333333333333333 (pow re 2.0))))
(- (exp (- im)) (exp im)))
(if (<= im 1.25)
(* -1.0 (* im (sin re)))
(* (* 0.5 (sin re)) (- 1.0 (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= -0.0215) {
tmp = (re * (0.5 + (-0.08333333333333333 * pow(re, 2.0)))) * (exp(-im) - exp(im));
} else if (im <= 1.25) {
tmp = -1.0 * (im * sin(re));
} else {
tmp = (0.5 * sin(re)) * (1.0 - exp(im));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-0.0215d0)) then
tmp = (re * (0.5d0 + ((-0.08333333333333333d0) * (re ** 2.0d0)))) * (exp(-im) - exp(im))
else if (im <= 1.25d0) then
tmp = (-1.0d0) * (im * sin(re))
else
tmp = (0.5d0 * sin(re)) * (1.0d0 - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -0.0215) {
tmp = (re * (0.5 + (-0.08333333333333333 * Math.pow(re, 2.0)))) * (Math.exp(-im) - Math.exp(im));
} else if (im <= 1.25) {
tmp = -1.0 * (im * Math.sin(re));
} else {
tmp = (0.5 * Math.sin(re)) * (1.0 - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -0.0215: tmp = (re * (0.5 + (-0.08333333333333333 * math.pow(re, 2.0)))) * (math.exp(-im) - math.exp(im)) elif im <= 1.25: tmp = -1.0 * (im * math.sin(re)) else: tmp = (0.5 * math.sin(re)) * (1.0 - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (im <= -0.0215) tmp = Float64(Float64(re * Float64(0.5 + Float64(-0.08333333333333333 * (re ^ 2.0)))) * Float64(exp(Float64(-im)) - exp(im))); elseif (im <= 1.25) tmp = Float64(-1.0 * Float64(im * sin(re))); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(1.0 - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -0.0215) tmp = (re * (0.5 + (-0.08333333333333333 * (re ^ 2.0)))) * (exp(-im) - exp(im)); elseif (im <= 1.25) tmp = -1.0 * (im * sin(re)); else tmp = (0.5 * sin(re)) * (1.0 - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -0.0215], N[(N[(re * N[(0.5 + N[(-0.08333333333333333 * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.25], N[(-1.0 * N[(im * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.0215:\\
\;\;\;\;\left(re \cdot \left(0.5 + -0.08333333333333333 \cdot {re}^{2}\right)\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{elif}\;im \leq 1.25:\\
\;\;\;\;-1 \cdot \left(im \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(1 - e^{im}\right)\\
\end{array}
\end{array}
if im < -0.021499999999999998Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
if -0.021499999999999998 < im < 1.25Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
if 1.25 < im Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites40.4%
(FPCore (re im)
:precision binary64
(if (<= im -6.3)
(* (* 0.5 re) (- (exp (- im)) 2.0))
(if (<= im 1.25)
(* -1.0 (* im (sin re)))
(* (* 0.5 (sin re)) (- 1.0 (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= -6.3) {
tmp = (0.5 * re) * (exp(-im) - 2.0);
} else if (im <= 1.25) {
tmp = -1.0 * (im * sin(re));
} else {
tmp = (0.5 * sin(re)) * (1.0 - exp(im));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-6.3d0)) then
tmp = (0.5d0 * re) * (exp(-im) - 2.0d0)
else if (im <= 1.25d0) then
tmp = (-1.0d0) * (im * sin(re))
else
tmp = (0.5d0 * sin(re)) * (1.0d0 - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -6.3) {
tmp = (0.5 * re) * (Math.exp(-im) - 2.0);
} else if (im <= 1.25) {
tmp = -1.0 * (im * Math.sin(re));
} else {
tmp = (0.5 * Math.sin(re)) * (1.0 - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -6.3: tmp = (0.5 * re) * (math.exp(-im) - 2.0) elif im <= 1.25: tmp = -1.0 * (im * math.sin(re)) else: tmp = (0.5 * math.sin(re)) * (1.0 - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (im <= -6.3) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) - 2.0)); elseif (im <= 1.25) tmp = Float64(-1.0 * Float64(im * sin(re))); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(1.0 - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -6.3) tmp = (0.5 * re) * (exp(-im) - 2.0); elseif (im <= 1.25) tmp = -1.0 * (im * sin(re)); else tmp = (0.5 * sin(re)) * (1.0 - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -6.3], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.25], N[(-1.0 * N[(im * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.3:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} - 2\right)\\
\mathbf{elif}\;im \leq 1.25:\\
\;\;\;\;-1 \cdot \left(im \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(1 - e^{im}\right)\\
\end{array}
\end{array}
if im < -6.29999999999999982Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.7%
Taylor expanded in im around 0
Applied rewrites37.3%
Applied rewrites21.8%
if -6.29999999999999982 < im < 1.25Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
if 1.25 < im Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites40.4%
(FPCore (re im)
:precision binary64
(if (<= im -6.3)
(* (* 0.5 re) (- (exp (- im)) 2.0))
(if (<= im 8.5)
(* -1.0 (* im (sin re)))
(*
(* (fma re -0.08333333333333333 0.5) re)
(- (+ 1.0 (* -1.0 im)) (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= -6.3) {
tmp = (0.5 * re) * (exp(-im) - 2.0);
} else if (im <= 8.5) {
tmp = -1.0 * (im * sin(re));
} else {
tmp = (fma(re, -0.08333333333333333, 0.5) * re) * ((1.0 + (-1.0 * im)) - exp(im));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= -6.3) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) - 2.0)); elseif (im <= 8.5) tmp = Float64(-1.0 * Float64(im * sin(re))); else tmp = Float64(Float64(fma(re, -0.08333333333333333, 0.5) * re) * Float64(Float64(1.0 + Float64(-1.0 * im)) - exp(im))); end return tmp end
code[re_, im_] := If[LessEqual[im, -6.3], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 8.5], N[(-1.0 * N[(im * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(1.0 + N[(-1.0 * im), $MachinePrecision]), $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -6.3:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} - 2\right)\\
\mathbf{elif}\;im \leq 8.5:\\
\;\;\;\;-1 \cdot \left(im \cdot \sin re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(1 + -1 \cdot im\right) - e^{im}\right)\\
\end{array}
\end{array}
if im < -6.29999999999999982Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.7%
Taylor expanded in im around 0
Applied rewrites37.3%
Applied rewrites21.8%
if -6.29999999999999982 < im < 8.5Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
if 8.5 < im Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
Taylor expanded in im around 0
Applied rewrites38.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (fma re -0.08333333333333333 0.5) re)))
(if (<= (* 0.5 (sin re)) 5e-5)
(* t_0 (- (exp (- im)) (exp im)))
(* t_0 im))))
double code(double re, double im) {
double t_0 = fma(re, -0.08333333333333333, 0.5) * re;
double tmp;
if ((0.5 * sin(re)) <= 5e-5) {
tmp = t_0 * (exp(-im) - exp(im));
} else {
tmp = t_0 * im;
}
return tmp;
}
function code(re, im) t_0 = Float64(fma(re, -0.08333333333333333, 0.5) * re) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 5e-5) tmp = Float64(t_0 * Float64(exp(Float64(-im)) - exp(im))); else tmp = Float64(t_0 * im); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(re * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 5e-5], N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * im), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(re, -0.08333333333333333, 0.5\right) \cdot re\\
\mathbf{if}\;0.5 \cdot \sin re \leq 5 \cdot 10^{-5}:\\
\;\;\;\;t\_0 \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 5.00000000000000024e-5Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
if 5.00000000000000024e-5 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
Applied rewrites23.0%
(FPCore (re im)
:precision binary64
(if (<= im -1.66)
(* (* 0.5 re) (- (exp (- im)) 2.0))
(if (<= im 0.96)
(* -1.0 (* im re))
(*
(* (fma re -0.08333333333333333 0.5) re)
(- (+ 1.0 (* -1.0 im)) (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= -1.66) {
tmp = (0.5 * re) * (exp(-im) - 2.0);
} else if (im <= 0.96) {
tmp = -1.0 * (im * re);
} else {
tmp = (fma(re, -0.08333333333333333, 0.5) * re) * ((1.0 + (-1.0 * im)) - exp(im));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= -1.66) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) - 2.0)); elseif (im <= 0.96) tmp = Float64(-1.0 * Float64(im * re)); else tmp = Float64(Float64(fma(re, -0.08333333333333333, 0.5) * re) * Float64(Float64(1.0 + Float64(-1.0 * im)) - exp(im))); end return tmp end
code[re_, im_] := If[LessEqual[im, -1.66], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 0.96], N[(-1.0 * N[(im * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(1.0 + N[(-1.0 * im), $MachinePrecision]), $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.66:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} - 2\right)\\
\mathbf{elif}\;im \leq 0.96:\\
\;\;\;\;-1 \cdot \left(im \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(1 + -1 \cdot im\right) - e^{im}\right)\\
\end{array}
\end{array}
if im < -1.65999999999999992Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.7%
Taylor expanded in im around 0
Applied rewrites37.3%
Applied rewrites21.8%
if -1.65999999999999992 < im < 0.95999999999999996Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
if 0.95999999999999996 < im Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
Taylor expanded in im around 0
Applied rewrites38.3%
(FPCore (re im) :precision binary64 (if (<= im -1.66) (* (* 0.5 re) (- (exp (- im)) 2.0)) (if (<= im 1.25) (* -1.0 (* im re)) (* (* 0.5 re) (- 1.0 (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= -1.66) {
tmp = (0.5 * re) * (exp(-im) - 2.0);
} else if (im <= 1.25) {
tmp = -1.0 * (im * re);
} else {
tmp = (0.5 * re) * (1.0 - exp(im));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= (-1.66d0)) then
tmp = (0.5d0 * re) * (exp(-im) - 2.0d0)
else if (im <= 1.25d0) then
tmp = (-1.0d0) * (im * re)
else
tmp = (0.5d0 * re) * (1.0d0 - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= -1.66) {
tmp = (0.5 * re) * (Math.exp(-im) - 2.0);
} else if (im <= 1.25) {
tmp = -1.0 * (im * re);
} else {
tmp = (0.5 * re) * (1.0 - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= -1.66: tmp = (0.5 * re) * (math.exp(-im) - 2.0) elif im <= 1.25: tmp = -1.0 * (im * re) else: tmp = (0.5 * re) * (1.0 - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (im <= -1.66) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) - 2.0)); elseif (im <= 1.25) tmp = Float64(-1.0 * Float64(im * re)); else tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= -1.66) tmp = (0.5 * re) * (exp(-im) - 2.0); elseif (im <= 1.25) tmp = -1.0 * (im * re); else tmp = (0.5 * re) * (1.0 - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, -1.66], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.25], N[(-1.0 * N[(im * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -1.66:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} - 2\right)\\
\mathbf{elif}\;im \leq 1.25:\\
\;\;\;\;-1 \cdot \left(im \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
\end{array}
\end{array}
if im < -1.65999999999999992Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.7%
Taylor expanded in im around 0
Applied rewrites37.3%
Applied rewrites21.8%
if -1.65999999999999992 < im < 1.25Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
if 1.25 < im Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.7%
Taylor expanded in im around 0
Applied rewrites33.6%
(FPCore (re im) :precision binary64 (if (<= im 31000000000000.0) (* -1.0 (* im (* re (+ 1.0 (* (* -0.16666666666666666 re) re))))) (* (* 0.5 re) (- 1.0 (exp im)))))
double code(double re, double im) {
double tmp;
if (im <= 31000000000000.0) {
tmp = -1.0 * (im * (re * (1.0 + ((-0.16666666666666666 * re) * re))));
} else {
tmp = (0.5 * re) * (1.0 - exp(im));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 31000000000000.0d0) then
tmp = (-1.0d0) * (im * (re * (1.0d0 + (((-0.16666666666666666d0) * re) * re))))
else
tmp = (0.5d0 * re) * (1.0d0 - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 31000000000000.0) {
tmp = -1.0 * (im * (re * (1.0 + ((-0.16666666666666666 * re) * re))));
} else {
tmp = (0.5 * re) * (1.0 - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 31000000000000.0: tmp = -1.0 * (im * (re * (1.0 + ((-0.16666666666666666 * re) * re)))) else: tmp = (0.5 * re) * (1.0 - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 31000000000000.0) tmp = Float64(-1.0 * Float64(im * Float64(re * Float64(1.0 + Float64(Float64(-0.16666666666666666 * re) * re))))); else tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 31000000000000.0) tmp = -1.0 * (im * (re * (1.0 + ((-0.16666666666666666 * re) * re)))); else tmp = (0.5 * re) * (1.0 - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 31000000000000.0], N[(-1.0 * N[(im * N[(re * N[(1.0 + N[(N[(-0.16666666666666666 * re), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 31000000000000:\\
\;\;\;\;-1 \cdot \left(im \cdot \left(re \cdot \left(1 + \left(-0.16666666666666666 \cdot re\right) \cdot re\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
\end{array}
\end{array}
if im < 3.1e13Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites36.8%
Applied rewrites36.8%
if 3.1e13 < im Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.7%
Taylor expanded in im around 0
Applied rewrites33.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= t_0 -0.03)
(* -1.0 (* im (* re (* (fma re -0.16666666666666666 2.0) 2.0))))
(if (<= t_0 5e-5)
(* -1.0 (* im (* re (+ 1.0 (* (* -0.16666666666666666 re) re)))))
(* (* (fma re -0.08333333333333333 0.5) re) im)))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (t_0 <= -0.03) {
tmp = -1.0 * (im * (re * (fma(re, -0.16666666666666666, 2.0) * 2.0)));
} else if (t_0 <= 5e-5) {
tmp = -1.0 * (im * (re * (1.0 + ((-0.16666666666666666 * re) * re))));
} else {
tmp = (fma(re, -0.08333333333333333, 0.5) * re) * im;
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (t_0 <= -0.03) tmp = Float64(-1.0 * Float64(im * Float64(re * Float64(fma(re, -0.16666666666666666, 2.0) * 2.0)))); elseif (t_0 <= 5e-5) tmp = Float64(-1.0 * Float64(im * Float64(re * Float64(1.0 + Float64(Float64(-0.16666666666666666 * re) * re))))); else tmp = Float64(Float64(fma(re, -0.08333333333333333, 0.5) * re) * im); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.03], N[(-1.0 * N[(im * N[(re * N[(N[(re * -0.16666666666666666 + 2.0), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-5], N[(-1.0 * N[(im * N[(re * N[(1.0 + N[(N[(-0.16666666666666666 * re), $MachinePrecision] * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;t\_0 \leq -0.03:\\
\;\;\;\;-1 \cdot \left(im \cdot \left(re \cdot \left(\mathsf{fma}\left(re, -0.16666666666666666, 2\right) \cdot 2\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-5}:\\
\;\;\;\;-1 \cdot \left(im \cdot \left(re \cdot \left(1 + \left(-0.16666666666666666 \cdot re\right) \cdot re\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.029999999999999999Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites36.8%
Applied rewrites25.4%
if -0.029999999999999999 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 5.00000000000000024e-5Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites36.8%
Applied rewrites36.8%
if 5.00000000000000024e-5 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
Applied rewrites23.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= t_0 -5e-26)
(* -1.0 (* im (* re (* (fma re -0.16666666666666666 2.0) 2.0))))
(if (<= t_0 0.054)
(* -1.0 (* im re))
(* (* (fma re -0.08333333333333333 0.5) re) im)))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (t_0 <= -5e-26) {
tmp = -1.0 * (im * (re * (fma(re, -0.16666666666666666, 2.0) * 2.0)));
} else if (t_0 <= 0.054) {
tmp = -1.0 * (im * re);
} else {
tmp = (fma(re, -0.08333333333333333, 0.5) * re) * im;
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (t_0 <= -5e-26) tmp = Float64(-1.0 * Float64(im * Float64(re * Float64(fma(re, -0.16666666666666666, 2.0) * 2.0)))); elseif (t_0 <= 0.054) tmp = Float64(-1.0 * Float64(im * re)); else tmp = Float64(Float64(fma(re, -0.08333333333333333, 0.5) * re) * im); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-26], N[(-1.0 * N[(im * N[(re * N[(N[(re * -0.16666666666666666 + 2.0), $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.054], N[(-1.0 * N[(im * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-26}:\\
\;\;\;\;-1 \cdot \left(im \cdot \left(re \cdot \left(\mathsf{fma}\left(re, -0.16666666666666666, 2\right) \cdot 2\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0.054:\\
\;\;\;\;-1 \cdot \left(im \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -5.00000000000000019e-26Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites36.8%
Applied rewrites25.4%
if -5.00000000000000019e-26 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 0.0539999999999999994Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
if 0.0539999999999999994 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
Applied rewrites23.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= t_0 -5e-26)
(* -1.0 (* im (* re (fma re -0.16666666666666666 2.0))))
(if (<= t_0 0.054)
(* -1.0 (* im re))
(* (* (fma re -0.08333333333333333 0.5) re) im)))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (t_0 <= -5e-26) {
tmp = -1.0 * (im * (re * fma(re, -0.16666666666666666, 2.0)));
} else if (t_0 <= 0.054) {
tmp = -1.0 * (im * re);
} else {
tmp = (fma(re, -0.08333333333333333, 0.5) * re) * im;
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (t_0 <= -5e-26) tmp = Float64(-1.0 * Float64(im * Float64(re * fma(re, -0.16666666666666666, 2.0)))); elseif (t_0 <= 0.054) tmp = Float64(-1.0 * Float64(im * re)); else tmp = Float64(Float64(fma(re, -0.08333333333333333, 0.5) * re) * im); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e-26], N[(-1.0 * N[(im * N[(re * N[(re * -0.16666666666666666 + 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.054], N[(-1.0 * N[(im * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;t\_0 \leq -5 \cdot 10^{-26}:\\
\;\;\;\;-1 \cdot \left(im \cdot \left(re \cdot \mathsf{fma}\left(re, -0.16666666666666666, 2\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0.054:\\
\;\;\;\;-1 \cdot \left(im \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -5.00000000000000019e-26Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites36.8%
Applied rewrites25.6%
if -5.00000000000000019e-26 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 0.0539999999999999994Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
if 0.0539999999999999994 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
Applied rewrites23.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= t_0 -0.02)
(* -1.0 (* im (* re (* -0.16666666666666666 re))))
(if (<= t_0 0.054)
(* -1.0 (* im re))
(* (* (fma re -0.08333333333333333 0.5) re) im)))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (t_0 <= -0.02) {
tmp = -1.0 * (im * (re * (-0.16666666666666666 * re)));
} else if (t_0 <= 0.054) {
tmp = -1.0 * (im * re);
} else {
tmp = (fma(re, -0.08333333333333333, 0.5) * re) * im;
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (t_0 <= -0.02) tmp = Float64(-1.0 * Float64(im * Float64(re * Float64(-0.16666666666666666 * re)))); elseif (t_0 <= 0.054) tmp = Float64(-1.0 * Float64(im * re)); else tmp = Float64(Float64(fma(re, -0.08333333333333333, 0.5) * re) * im); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.02], N[(-1.0 * N[(im * N[(re * N[(-0.16666666666666666 * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.054], N[(-1.0 * N[(im * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;t\_0 \leq -0.02:\\
\;\;\;\;-1 \cdot \left(im \cdot \left(re \cdot \left(-0.16666666666666666 \cdot re\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq 0.054:\\
\;\;\;\;-1 \cdot \left(im \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0200000000000000004Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites36.8%
Applied rewrites25.6%
Taylor expanded in re around inf
Applied rewrites23.7%
if -0.0200000000000000004 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 0.0539999999999999994Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
if 0.0539999999999999994 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
Applied rewrites23.0%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) 0.054) (* -1.0 (* im re)) (* (* (fma re -0.08333333333333333 0.5) re) im)))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= 0.054) {
tmp = -1.0 * (im * re);
} else {
tmp = (fma(re, -0.08333333333333333, 0.5) * re) * im;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 0.054) tmp = Float64(-1.0 * Float64(im * re)); else tmp = Float64(Float64(fma(re, -0.08333333333333333, 0.5) * re) * im); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 0.054], N[(-1.0 * N[(im * re), $MachinePrecision]), $MachinePrecision], N[(N[(N[(re * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq 0.054:\\
\;\;\;\;-1 \cdot \left(im \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 0.0539999999999999994Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
if 0.0539999999999999994 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 66.3%
Taylor expanded in re around 0
Applied rewrites52.2%
Applied rewrites52.5%
Applied rewrites23.0%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) 0.054) (* -1.0 (* im re)) (* -1.0 (* im (* re re)))))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= 0.054) {
tmp = -1.0 * (im * re);
} else {
tmp = -1.0 * (im * (re * re));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((0.5d0 * sin(re)) <= 0.054d0) then
tmp = (-1.0d0) * (im * re)
else
tmp = (-1.0d0) * (im * (re * re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.sin(re)) <= 0.054) {
tmp = -1.0 * (im * re);
} else {
tmp = -1.0 * (im * (re * re));
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.sin(re)) <= 0.054: tmp = -1.0 * (im * re) else: tmp = -1.0 * (im * (re * re)) return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 0.054) tmp = Float64(-1.0 * Float64(im * re)); else tmp = Float64(-1.0 * Float64(im * Float64(re * re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * sin(re)) <= 0.054) tmp = -1.0 * (im * re); else tmp = -1.0 * (im * (re * re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 0.054], N[(-1.0 * N[(im * re), $MachinePrecision]), $MachinePrecision], N[(-1.0 * N[(im * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq 0.054:\\
\;\;\;\;-1 \cdot \left(im \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(im \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 0.0539999999999999994Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
if 0.0539999999999999994 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
Applied rewrites23.6%
(FPCore (re im) :precision binary64 (* -1.0 (* im re)))
double code(double re, double im) {
return -1.0 * (im * re);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (-1.0d0) * (im * re)
end function
public static double code(double re, double im) {
return -1.0 * (im * re);
}
def code(re, im): return -1.0 * (im * re)
function code(re, im) return Float64(-1.0 * Float64(im * re)) end
function tmp = code(re, im) tmp = -1.0 * (im * re); end
code[re_, im_] := N[(-1.0 * N[(im * re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 \cdot \left(im \cdot re\right)
\end{array}
Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
(FPCore (re im) :precision binary64 (* -1.0 (- re re)))
double code(double re, double im) {
return -1.0 * (re - re);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (-1.0d0) * (re - re)
end function
public static double code(double re, double im) {
return -1.0 * (re - re);
}
def code(re, im): return -1.0 * (re - re)
function code(re, im) return Float64(-1.0 * Float64(re - re)) end
function tmp = code(re, im) tmp = -1.0 * (re - re); end
code[re_, im_] := N[(-1.0 * N[(re - re), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-1 \cdot \left(re - re\right)
\end{array}
Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
Applied rewrites3.2%
Applied rewrites14.9%
(FPCore (re im) :precision binary64 (* -1.0 re))
double code(double re, double im) {
return -1.0 * re;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (-1.0d0) * re
end function
public static double code(double re, double im) {
return -1.0 * re;
}
def code(re, im): return -1.0 * re
function code(re, im) return Float64(-1.0 * re) end
function tmp = code(re, im) tmp = -1.0 * re; end
code[re_, im_] := N[(-1.0 * re), $MachinePrecision]
\begin{array}{l}
\\
-1 \cdot re
\end{array}
Initial program 66.3%
Taylor expanded in im around 0
Applied rewrites51.0%
Taylor expanded in re around 0
Applied rewrites33.2%
Applied rewrites3.2%
herbie shell --seed 2025159
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:precision binary64
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))