
(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 26 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
(let* ((t_0 (* 0.5 (sin re))) (t_1 (exp (- im))))
(if (<= im -3.7)
(* t_0 (- t_1 1.0))
(if (<= im 0.052)
(*
(fma
(fma
(*
(sin re)
(fma -0.0001984126984126984 (* im im) -0.008333333333333333))
(* im im)
(* -0.16666666666666666 (sin re)))
(* im im)
(- (sin re)))
im)
(* t_0 (- (- t_1 (cosh im)) (sinh im)))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double t_1 = exp(-im);
double tmp;
if (im <= -3.7) {
tmp = t_0 * (t_1 - 1.0);
} else if (im <= 0.052) {
tmp = fma(fma((sin(re) * fma(-0.0001984126984126984, (im * im), -0.008333333333333333)), (im * im), (-0.16666666666666666 * sin(re))), (im * im), -sin(re)) * im;
} else {
tmp = t_0 * ((t_1 - cosh(im)) - sinh(im));
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) t_1 = exp(Float64(-im)) tmp = 0.0 if (im <= -3.7) tmp = Float64(t_0 * Float64(t_1 - 1.0)); elseif (im <= 0.052) tmp = Float64(fma(fma(Float64(sin(re) * fma(-0.0001984126984126984, Float64(im * im), -0.008333333333333333)), Float64(im * im), Float64(-0.16666666666666666 * sin(re))), Float64(im * im), Float64(-sin(re))) * im); else tmp = Float64(t_0 * Float64(Float64(t_1 - cosh(im)) - sinh(im))); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-im)], $MachinePrecision]}, If[LessEqual[im, -3.7], N[(t$95$0 * N[(t$95$1 - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 0.052], N[(N[(N[(N[(N[Sin[re], $MachinePrecision] * N[(-0.0001984126984126984 * N[(im * im), $MachinePrecision] + -0.008333333333333333), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision] + N[(-0.16666666666666666 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision] + (-N[Sin[re], $MachinePrecision])), $MachinePrecision] * im), $MachinePrecision], N[(t$95$0 * N[(N[(t$95$1 - N[Cosh[im], $MachinePrecision]), $MachinePrecision] - N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
t_1 := e^{-im}\\
\mathbf{if}\;im \leq -3.7:\\
\;\;\;\;t\_0 \cdot \left(t\_1 - 1\right)\\
\mathbf{elif}\;im \leq 0.052:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\sin re \cdot \mathsf{fma}\left(-0.0001984126984126984, im \cdot im, -0.008333333333333333\right), im \cdot im, -0.16666666666666666 \cdot \sin re\right), im \cdot im, -\sin re\right) \cdot im\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(t\_1 - \cosh im\right) - \sinh im\right)\\
\end{array}
\end{array}
if im < -3.7000000000000002Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
if -3.7000000000000002 < im < 0.0519999999999999976Initial program 31.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
if 0.0519999999999999976 < im Initial program 100.0%
lift--.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
sinh-+-cosh-revN/A
associate--r+N/A
lower--.f64N/A
lower--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lower-cosh.f64N/A
lower-sinh.f64100.0
Applied rewrites100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
(if (<= t_0 -0.0001)
(* (* 0.5 re) (- 1.0 (fma (fma im 0.5 1.0) im 1.0)))
(if (<= t_0 2e-16)
(* (- re) im)
(* (* 0.5 re) (- (fma (- (* im 0.5) 1.0) im 1.0) 1.0))))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * (exp(-im) - exp(im));
double tmp;
if (t_0 <= -0.0001) {
tmp = (0.5 * re) * (1.0 - fma(fma(im, 0.5, 1.0), im, 1.0));
} else if (t_0 <= 2e-16) {
tmp = -re * im;
} else {
tmp = (0.5 * re) * (fma(((im * 0.5) - 1.0), im, 1.0) - 1.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) tmp = 0.0 if (t_0 <= -0.0001) tmp = Float64(Float64(0.5 * re) * Float64(1.0 - fma(fma(im, 0.5, 1.0), im, 1.0))); elseif (t_0 <= 2e-16) tmp = Float64(Float64(-re) * im); else tmp = Float64(Float64(0.5 * re) * Float64(fma(Float64(Float64(im * 0.5) - 1.0), im, 1.0) - 1.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -0.0001], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[(N[(im * 0.5 + 1.0), $MachinePrecision] * im + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e-16], N[((-re) * im), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(N[(N[(im * 0.5), $MachinePrecision] - 1.0), $MachinePrecision] * im + 1.0), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -0.0001:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - \mathsf{fma}\left(\mathsf{fma}\left(im, 0.5, 1\right), im, 1\right)\right)\\
\mathbf{elif}\;t\_0 \leq 2 \cdot 10^{-16}:\\
\;\;\;\;\left(-re\right) \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{fma}\left(im \cdot 0.5 - 1, im, 1\right) - 1\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -1.00000000000000005e-4Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites47.2%
Taylor expanded in re around 0
Applied rewrites38.2%
Taylor expanded in im around 0
Applied rewrites1.6%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6434.8
Applied rewrites34.8%
if -1.00000000000000005e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 2e-16Initial program 30.9%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6498.3
Applied rewrites98.3%
Taylor expanded in re around 0
Applied rewrites51.8%
if 2e-16 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 99.7%
Taylor expanded in im around 0
Applied rewrites46.0%
Taylor expanded in re around 0
Applied rewrites35.2%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f6428.7
Applied rewrites28.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))) (t_1 (exp (- im))))
(if (<= im -3.7)
(* t_0 (- t_1 1.0))
(if (<= im 0.06)
(*
(fma
(fma
(*
(sin re)
(fma -0.0001984126984126984 (* im im) -0.008333333333333333))
(* im im)
(* -0.16666666666666666 (sin re)))
(* im im)
(- (sin re)))
im)
(* t_0 (- t_1 (exp im)))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double t_1 = exp(-im);
double tmp;
if (im <= -3.7) {
tmp = t_0 * (t_1 - 1.0);
} else if (im <= 0.06) {
tmp = fma(fma((sin(re) * fma(-0.0001984126984126984, (im * im), -0.008333333333333333)), (im * im), (-0.16666666666666666 * sin(re))), (im * im), -sin(re)) * im;
} else {
tmp = t_0 * (t_1 - exp(im));
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) t_1 = exp(Float64(-im)) tmp = 0.0 if (im <= -3.7) tmp = Float64(t_0 * Float64(t_1 - 1.0)); elseif (im <= 0.06) tmp = Float64(fma(fma(Float64(sin(re) * fma(-0.0001984126984126984, Float64(im * im), -0.008333333333333333)), Float64(im * im), Float64(-0.16666666666666666 * sin(re))), Float64(im * im), Float64(-sin(re))) * im); else tmp = Float64(t_0 * Float64(t_1 - exp(im))); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-im)], $MachinePrecision]}, If[LessEqual[im, -3.7], N[(t$95$0 * N[(t$95$1 - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 0.06], N[(N[(N[(N[(N[Sin[re], $MachinePrecision] * N[(-0.0001984126984126984 * N[(im * im), $MachinePrecision] + -0.008333333333333333), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision] + N[(-0.16666666666666666 * N[Sin[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * im), $MachinePrecision] + (-N[Sin[re], $MachinePrecision])), $MachinePrecision] * im), $MachinePrecision], N[(t$95$0 * N[(t$95$1 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
t_1 := e^{-im}\\
\mathbf{if}\;im \leq -3.7:\\
\;\;\;\;t\_0 \cdot \left(t\_1 - 1\right)\\
\mathbf{elif}\;im \leq 0.06:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\sin re \cdot \mathsf{fma}\left(-0.0001984126984126984, im \cdot im, -0.008333333333333333\right), im \cdot im, -0.16666666666666666 \cdot \sin re\right), im \cdot im, -\sin re\right) \cdot im\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 - e^{im}\right)\\
\end{array}
\end{array}
if im < -3.7000000000000002Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
if -3.7000000000000002 < im < 0.059999999999999998Initial program 31.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
if 0.059999999999999998 < im Initial program 100.0%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))) (- INFINITY)) (* (* 0.5 re) (- 1.0 (fma (fma im 0.5 1.0) im 1.0))) (* (fma (* (* re re) im) 0.16666666666666666 (- im)) re)))
double code(double re, double im) {
double tmp;
if (((0.5 * sin(re)) * (exp(-im) - exp(im))) <= -((double) INFINITY)) {
tmp = (0.5 * re) * (1.0 - fma(fma(im, 0.5, 1.0), im, 1.0));
} else {
tmp = fma(((re * re) * im), 0.16666666666666666, -im) * re;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) <= Float64(-Inf)) tmp = Float64(Float64(0.5 * re) * Float64(1.0 - fma(fma(im, 0.5, 1.0), im, 1.0))); else tmp = Float64(fma(Float64(Float64(re * re) * im), 0.16666666666666666, Float64(-im)) * re); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[(N[(im * 0.5 + 1.0), $MachinePrecision] * im + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.16666666666666666 + (-im)), $MachinePrecision] * re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq -\infty:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - \mathsf{fma}\left(\mathsf{fma}\left(im, 0.5, 1\right), im, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, 0.16666666666666666, -im\right) \cdot re\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -inf.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites46.9%
Taylor expanded in re around 0
Applied rewrites37.6%
Taylor expanded in im around 0
Applied rewrites1.6%
Taylor expanded in im around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6435.6
Applied rewrites35.6%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 56.2%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6464.2
Applied rewrites64.2%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lift-neg.f6438.6
Applied rewrites38.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))) (t_1 (exp (- im))))
(if (<= im -3.7)
(* t_0 (- t_1 1.0))
(if (<= im 0.06)
(*
t_0
(*
(-
(*
(-
(*
(*
(- (* -0.0003968253968253968 (* im im)) 0.016666666666666666)
im)
im)
0.3333333333333333)
(* im im))
2.0)
im))
(* t_0 (- t_1 (exp im)))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double t_1 = exp(-im);
double tmp;
if (im <= -3.7) {
tmp = t_0 * (t_1 - 1.0);
} else if (im <= 0.06) {
tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = t_0 * (t_1 - 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 0.5d0 * sin(re)
t_1 = exp(-im)
if (im <= (-3.7d0)) then
tmp = t_0 * (t_1 - 1.0d0)
else if (im <= 0.06d0) then
tmp = t_0 * (((((((((-0.0003968253968253968d0) * (im * im)) - 0.016666666666666666d0) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
else
tmp = t_0 * (t_1 - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sin(re);
double t_1 = Math.exp(-im);
double tmp;
if (im <= -3.7) {
tmp = t_0 * (t_1 - 1.0);
} else if (im <= 0.06) {
tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = t_0 * (t_1 - Math.exp(im));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.sin(re) t_1 = math.exp(-im) tmp = 0 if im <= -3.7: tmp = t_0 * (t_1 - 1.0) elif im <= 0.06: tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im) else: tmp = t_0 * (t_1 - math.exp(im)) return tmp
function code(re, im) t_0 = Float64(0.5 * sin(re)) t_1 = exp(Float64(-im)) tmp = 0.0 if (im <= -3.7) tmp = Float64(t_0 * Float64(t_1 - 1.0)); elseif (im <= 0.06) tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)); else tmp = Float64(t_0 * Float64(t_1 - exp(im))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * sin(re); t_1 = exp(-im); tmp = 0.0; if (im <= -3.7) tmp = t_0 * (t_1 - 1.0); elseif (im <= 0.06) tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im); else tmp = t_0 * (t_1 - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[(-im)], $MachinePrecision]}, If[LessEqual[im, -3.7], N[(t$95$0 * N[(t$95$1 - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 0.06], N[(t$95$0 * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(t$95$1 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
t_1 := e^{-im}\\
\mathbf{if}\;im \leq -3.7:\\
\;\;\;\;t\_0 \cdot \left(t\_1 - 1\right)\\
\mathbf{elif}\;im \leq 0.06:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(t\_1 - e^{im}\right)\\
\end{array}
\end{array}
if im < -3.7000000000000002Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
if -3.7000000000000002 < im < 0.059999999999999998Initial program 31.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
if 0.059999999999999998 < im Initial program 100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= im -3.7)
(* t_0 (- (exp (- im)) 1.0))
(if (<= im 3.8)
(*
t_0
(*
(-
(*
(-
(*
(*
(- (* -0.0003968253968253968 (* im im)) 0.016666666666666666)
im)
im)
0.3333333333333333)
(* im im))
2.0)
im))
(* t_0 (- 1.0 (exp im)))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (im <= -3.7) {
tmp = t_0 * (exp(-im) - 1.0);
} else if (im <= 3.8) {
tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = t_0 * (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) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * sin(re)
if (im <= (-3.7d0)) then
tmp = t_0 * (exp(-im) - 1.0d0)
else if (im <= 3.8d0) then
tmp = t_0 * (((((((((-0.0003968253968253968d0) * (im * im)) - 0.016666666666666666d0) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
else
tmp = t_0 * (1.0d0 - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sin(re);
double tmp;
if (im <= -3.7) {
tmp = t_0 * (Math.exp(-im) - 1.0);
} else if (im <= 3.8) {
tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = t_0 * (1.0 - Math.exp(im));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.sin(re) tmp = 0 if im <= -3.7: tmp = t_0 * (math.exp(-im) - 1.0) elif im <= 3.8: tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im) else: tmp = t_0 * (1.0 - math.exp(im)) return tmp
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (im <= -3.7) tmp = Float64(t_0 * Float64(exp(Float64(-im)) - 1.0)); elseif (im <= 3.8) tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)); else tmp = Float64(t_0 * Float64(1.0 - exp(im))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * sin(re); tmp = 0.0; if (im <= -3.7) tmp = t_0 * (exp(-im) - 1.0); elseif (im <= 3.8) tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im); else tmp = t_0 * (1.0 - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -3.7], N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 3.8], N[(t$95$0 * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq -3.7:\\
\;\;\;\;t\_0 \cdot \left(e^{-im} - 1\right)\\
\mathbf{elif}\;im \leq 3.8:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 - e^{im}\right)\\
\end{array}
\end{array}
if im < -3.7000000000000002Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
if -3.7000000000000002 < im < 3.7999999999999998Initial program 31.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites99.8%
if 3.7999999999999998 < im Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites98.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (sin re))))
(if (<= im 3.8)
(*
t_0
(*
(-
(*
(-
(*
(* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
im)
0.3333333333333333)
(* im im))
2.0)
im))
(* t_0 (- 1.0 (exp im))))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (im <= 3.8) {
tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = t_0 * (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) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * sin(re)
if (im <= 3.8d0) then
tmp = t_0 * (((((((((-0.0003968253968253968d0) * (im * im)) - 0.016666666666666666d0) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
else
tmp = t_0 * (1.0d0 - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.sin(re);
double tmp;
if (im <= 3.8) {
tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = t_0 * (1.0 - Math.exp(im));
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.sin(re) tmp = 0 if im <= 3.8: tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im) else: tmp = t_0 * (1.0 - math.exp(im)) return tmp
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (im <= 3.8) tmp = Float64(t_0 * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)); else tmp = Float64(t_0 * Float64(1.0 - exp(im))); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * sin(re); tmp = 0.0; if (im <= 3.8) tmp = t_0 * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im); else tmp = t_0 * (1.0 - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 3.8], N[(t$95$0 * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 3.8:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(1 - e^{im}\right)\\
\end{array}
\end{array}
if im < 3.7999999999999998Initial program 54.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.7%
if 3.7999999999999998 < im Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites98.2%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(-
(*
(-
(*
(*
(- (* -0.0003968253968253968 (* im im)) 0.016666666666666666)
im)
im)
0.3333333333333333)
(* im im))
2.0)
im)))
(if (<= (* 0.5 (sin re)) 0.002)
(* (* (fma (* re re) -0.08333333333333333 0.5) re) t_0)
(*
(*
(fma
(- (* 0.004166666666666667 (* re re)) 0.08333333333333333)
(* re re)
0.5)
re)
t_0))))
double code(double re, double im) {
double t_0 = (((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im;
double tmp;
if ((0.5 * sin(re)) <= 0.002) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * t_0;
} else {
tmp = (fma(((0.004166666666666667 * (re * re)) - 0.08333333333333333), (re * re), 0.5) * re) * t_0;
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 0.002) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * t_0); else tmp = Float64(Float64(fma(Float64(Float64(0.004166666666666667 * Float64(re * re)) - 0.08333333333333333), Float64(re * re), 0.5) * re) * t_0); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 0.002], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\\
\mathbf{if}\;0.5 \cdot \sin re \leq 0.002:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 2e-3Initial program 72.0%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6474.9
Applied rewrites74.9%
if 2e-3 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 55.1%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.1%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6426.1
Applied rewrites26.1%
(FPCore (re im)
:precision binary64
(if (<= (* 0.5 (sin re)) 1e-6)
(*
(* (fma (* re re) -0.08333333333333333 0.5) re)
(*
(-
(*
(-
(*
(* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
im)
0.3333333333333333)
(* im im))
2.0)
im))
(*
(* im re)
(-
(*
(-
(*
(- (* (* im im) -0.0001984126984126984) 0.008333333333333333)
(* im im))
0.16666666666666666)
(* im im))
1.0))))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= 1e-6) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = (im * re) * (((((((im * im) * -0.0001984126984126984) - 0.008333333333333333) * (im * im)) - 0.16666666666666666) * (im * im)) - 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 1e-6) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)); else tmp = Float64(Float64(im * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(im * im) * -0.0001984126984126984) - 0.008333333333333333) * Float64(im * im)) - 0.16666666666666666) * Float64(im * im)) - 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 1e-6], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(im * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(im * im), $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] - 0.008333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq 10^{-6}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(im \cdot re\right) \cdot \left(\left(\left(\left(im \cdot im\right) \cdot -0.0001984126984126984 - 0.008333333333333333\right) \cdot \left(im \cdot im\right) - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 9.99999999999999955e-7Initial program 71.9%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.8%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6475.2
Applied rewrites75.2%
if 9.99999999999999955e-7 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 55.8%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.0%
Taylor expanded in re around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites25.5%
(FPCore (re im)
:precision binary64
(if (<= (* 0.5 (sin re)) -0.005)
(*
(* (fma (* re re) -0.08333333333333333 0.5) re)
(*
(-
(* (- (* (* -0.016666666666666666 im) im) 0.3333333333333333) (* im im))
2.0)
im))
(*
(* im re)
(-
(*
(-
(*
(- (* (* im im) -0.0001984126984126984) 0.008333333333333333)
(* im im))
0.16666666666666666)
(* im im))
1.0))))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.005) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((-0.016666666666666666 * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = (im * re) * (((((((im * im) * -0.0001984126984126984) - 0.008333333333333333) * (im * im)) - 0.16666666666666666) * (im * im)) - 1.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.005) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(-0.016666666666666666 * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)); else tmp = Float64(Float64(im * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(im * im) * -0.0001984126984126984) - 0.008333333333333333) * Float64(im * im)) - 0.16666666666666666) * Float64(im * im)) - 1.0)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(-0.016666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(im * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(im * im), $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] - 0.008333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(im \cdot re\right) \cdot \left(\left(\left(\left(im \cdot im\right) \cdot -0.0001984126984126984 - 0.008333333333333333\right) \cdot \left(im \cdot im\right) - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001Initial program 55.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.9%
Taylor expanded in im around inf
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6492.9
Applied rewrites92.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6425.5
Applied rewrites25.5%
Taylor expanded in im around 0
Applied rewrites25.5%
if -0.0050000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 70.7%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.5%
Taylor expanded in re around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites71.2%
(FPCore (re im)
:precision binary64
(if (<= (* 0.5 (sin re)) -0.005)
(*
(* (* (* re re) -0.08333333333333333) re)
(* (- (* -0.3333333333333333 (* im im)) 2.0) im))
(*
(* im re)
(-
(*
(-
(*
(- (* (* im im) -0.0001984126984126984) 0.008333333333333333)
(* im im))
0.16666666666666666)
(* im im))
1.0))))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.005) {
tmp = (((re * re) * -0.08333333333333333) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
} else {
tmp = (im * re) * (((((((im * im) * -0.0001984126984126984) - 0.008333333333333333) * (im * im)) - 0.16666666666666666) * (im * im)) - 1.0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((0.5d0 * sin(re)) <= (-0.005d0)) then
tmp = (((re * re) * (-0.08333333333333333d0)) * re) * ((((-0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
else
tmp = (im * re) * (((((((im * im) * (-0.0001984126984126984d0)) - 0.008333333333333333d0) * (im * im)) - 0.16666666666666666d0) * (im * im)) - 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.sin(re)) <= -0.005) {
tmp = (((re * re) * -0.08333333333333333) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
} else {
tmp = (im * re) * (((((((im * im) * -0.0001984126984126984) - 0.008333333333333333) * (im * im)) - 0.16666666666666666) * (im * im)) - 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.sin(re)) <= -0.005: tmp = (((re * re) * -0.08333333333333333) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im) else: tmp = (im * re) * (((((((im * im) * -0.0001984126984126984) - 0.008333333333333333) * (im * im)) - 0.16666666666666666) * (im * im)) - 1.0) return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.005) tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * Float64(Float64(Float64(-0.3333333333333333 * Float64(im * im)) - 2.0) * im)); else tmp = Float64(Float64(im * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(im * im) * -0.0001984126984126984) - 0.008333333333333333) * Float64(im * im)) - 0.16666666666666666) * Float64(im * im)) - 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * sin(re)) <= -0.005) tmp = (((re * re) * -0.08333333333333333) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im); else tmp = (im * re) * (((((((im * im) * -0.0001984126984126984) - 0.008333333333333333) * (im * im)) - 0.16666666666666666) * (im * im)) - 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(im * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(im * im), $MachinePrecision] * -0.0001984126984126984), $MachinePrecision] - 0.008333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(im \cdot re\right) \cdot \left(\left(\left(\left(im \cdot im\right) \cdot -0.0001984126984126984 - 0.008333333333333333\right) \cdot \left(im \cdot im\right) - 0.16666666666666666\right) \cdot \left(im \cdot im\right) - 1\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001Initial program 55.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.5
Applied rewrites87.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6425.5
Applied rewrites25.5%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6425.5
Applied rewrites25.5%
if -0.0050000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 70.7%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.5%
Taylor expanded in re around 0
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
Applied rewrites71.2%
(FPCore (re im)
:precision binary64
(*
(* 0.5 (sin re))
(*
(-
(*
(-
(*
(* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
im)
0.3333333333333333)
(* im im))
2.0)
im)))
double code(double re, double im) {
return (0.5 * sin(re)) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.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 = (0.5d0 * sin(re)) * (((((((((-0.0003968253968253968d0) * (im * im)) - 0.016666666666666666d0) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
}
def code(re, im): return (0.5 * math.sin(re)) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im)
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)
\end{array}
Initial program 67.5%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites95.2%
(FPCore (re im)
:precision binary64
(if (or (<= im -3.8e+87) (not (<= im -6.0)))
(*
(* 0.5 (sin re))
(*
(-
(* (* (- (* -0.016666666666666666 (* im im)) 0.3333333333333333) im) im)
2.0)
im))
(* (* 0.5 re) (- (exp (- im)) 1.0))))
double code(double re, double im) {
double tmp;
if ((im <= -3.8e+87) || !(im <= -6.0)) {
tmp = (0.5 * sin(re)) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
} else {
tmp = (0.5 * re) * (exp(-im) - 1.0);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= (-3.8d+87)) .or. (.not. (im <= (-6.0d0)))) then
tmp = (0.5d0 * sin(re)) * (((((((-0.016666666666666666d0) * (im * im)) - 0.3333333333333333d0) * im) * im) - 2.0d0) * im)
else
tmp = (0.5d0 * re) * (exp(-im) - 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= -3.8e+87) || !(im <= -6.0)) {
tmp = (0.5 * Math.sin(re)) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im);
} else {
tmp = (0.5 * re) * (Math.exp(-im) - 1.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= -3.8e+87) or not (im <= -6.0): tmp = (0.5 * math.sin(re)) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im) else: tmp = (0.5 * re) * (math.exp(-im) - 1.0) return tmp
function code(re, im) tmp = 0.0 if ((im <= -3.8e+87) || !(im <= -6.0)) tmp = Float64(Float64(0.5 * sin(re)) * Float64(Float64(Float64(Float64(Float64(Float64(-0.016666666666666666 * Float64(im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im)); else tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) - 1.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= -3.8e+87) || ~((im <= -6.0))) tmp = (0.5 * sin(re)) * ((((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * im) * im) - 2.0) * im); else tmp = (0.5 * re) * (exp(-im) - 1.0); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, -3.8e+87], N[Not[LessEqual[im, -6.0]], $MachinePrecision]], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(N[(-0.016666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -3.8 \cdot 10^{+87} \lor \neg \left(im \leq -6\right):\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot im\right) \cdot im - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} - 1\right)\\
\end{array}
\end{array}
if im < -3.80000000000000011e87 or -6 < im Initial program 65.2%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.9
Applied rewrites95.9%
if -3.80000000000000011e87 < im < -6Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites94.1%
Final simplification95.8%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(* 0.5 (sin re))
(* (- (* -0.3333333333333333 (* im im)) 2.0) im))))
(if (<= im -2.15e+101)
t_0
(if (<= im -5.2)
(* (* 0.5 re) (- (exp (- im)) 1.0))
(if (or (<= im 11.0) (not (<= im 8e+102)))
t_0
(* (* 0.5 re) (- 1.0 (exp im))))))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
double tmp;
if (im <= -2.15e+101) {
tmp = t_0;
} else if (im <= -5.2) {
tmp = (0.5 * re) * (exp(-im) - 1.0);
} else if ((im <= 11.0) || !(im <= 8e+102)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (0.5d0 * sin(re)) * ((((-0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
if (im <= (-2.15d+101)) then
tmp = t_0
else if (im <= (-5.2d0)) then
tmp = (0.5d0 * re) * (exp(-im) - 1.0d0)
else if ((im <= 11.0d0) .or. (.not. (im <= 8d+102))) then
tmp = t_0
else
tmp = (0.5d0 * re) * (1.0d0 - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 * Math.sin(re)) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
double tmp;
if (im <= -2.15e+101) {
tmp = t_0;
} else if (im <= -5.2) {
tmp = (0.5 * re) * (Math.exp(-im) - 1.0);
} else if ((im <= 11.0) || !(im <= 8e+102)) {
tmp = t_0;
} else {
tmp = (0.5 * re) * (1.0 - Math.exp(im));
}
return tmp;
}
def code(re, im): t_0 = (0.5 * math.sin(re)) * (((-0.3333333333333333 * (im * im)) - 2.0) * im) tmp = 0 if im <= -2.15e+101: tmp = t_0 elif im <= -5.2: tmp = (0.5 * re) * (math.exp(-im) - 1.0) elif (im <= 11.0) or not (im <= 8e+102): tmp = t_0 else: tmp = (0.5 * re) * (1.0 - math.exp(im)) return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * Float64(Float64(Float64(-0.3333333333333333 * Float64(im * im)) - 2.0) * im)) tmp = 0.0 if (im <= -2.15e+101) tmp = t_0; elseif (im <= -5.2) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) - 1.0)); elseif ((im <= 11.0) || !(im <= 8e+102)) tmp = t_0; else tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im))); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * sin(re)) * (((-0.3333333333333333 * (im * im)) - 2.0) * im); tmp = 0.0; if (im <= -2.15e+101) tmp = t_0; elseif (im <= -5.2) tmp = (0.5 * re) * (exp(-im) - 1.0); elseif ((im <= 11.0) || ~((im <= 8e+102))) tmp = t_0; else tmp = (0.5 * re) * (1.0 - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -2.15e+101], t$95$0, If[LessEqual[im, -5.2], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[im, 11.0], N[Not[LessEqual[im, 8e+102]], $MachinePrecision]], t$95$0, N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{if}\;im \leq -2.15 \cdot 10^{+101}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq -5.2:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} - 1\right)\\
\mathbf{elif}\;im \leq 11 \lor \neg \left(im \leq 8 \cdot 10^{+102}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
\end{array}
\end{array}
if im < -2.15e101 or -5.20000000000000018 < im < 11 or 7.99999999999999982e102 < im Initial program 61.9%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6498.3
Applied rewrites98.3%
if -2.15e101 < im < -5.20000000000000018Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites89.5%
if 11 < im < 7.99999999999999982e102Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites89.5%
Final simplification97.0%
(FPCore (re im)
:precision binary64
(if (<= (* 0.5 (sin re)) -0.005)
(*
(* (* (* re re) -0.08333333333333333) re)
(* (- (* -0.3333333333333333 (* im im)) 2.0) im))
(*
(* 0.5 re)
(*
(-
(* (- (* -0.016666666666666666 (* im im)) 0.3333333333333333) (* im im))
2.0)
im))))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.005) {
tmp = (((re * re) * -0.08333333333333333) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
} else {
tmp = (0.5 * re) * (((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * (im * im)) - 2.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 * sin(re)) <= (-0.005d0)) then
tmp = (((re * re) * (-0.08333333333333333d0)) * re) * ((((-0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
else
tmp = (0.5d0 * re) * ((((((-0.016666666666666666d0) * (im * im)) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.sin(re)) <= -0.005) {
tmp = (((re * re) * -0.08333333333333333) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
} else {
tmp = (0.5 * re) * (((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * (im * im)) - 2.0) * im);
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.sin(re)) <= -0.005: tmp = (((re * re) * -0.08333333333333333) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im) else: tmp = (0.5 * re) * (((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * (im * im)) - 2.0) * im) return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.005) tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * Float64(Float64(Float64(-0.3333333333333333 * Float64(im * im)) - 2.0) * im)); else tmp = Float64(Float64(0.5 * re) * Float64(Float64(Float64(Float64(Float64(-0.016666666666666666 * Float64(im * im)) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * sin(re)) <= -0.005) tmp = (((re * re) * -0.08333333333333333) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im); else tmp = (0.5 * re) * (((((-0.016666666666666666 * (im * im)) - 0.3333333333333333) * (im * im)) - 2.0) * im); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(N[(N[(N[(-0.016666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\left(\left(-0.016666666666666666 \cdot \left(im \cdot im\right) - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001Initial program 55.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.5
Applied rewrites87.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6425.5
Applied rewrites25.5%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6425.5
Applied rewrites25.5%
if -0.0050000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 70.7%
Taylor expanded in im around 0
Applied rewrites39.9%
Taylor expanded in re around 0
Applied rewrites36.3%
Taylor expanded in im around 0
Applied rewrites16.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6469.1
Applied rewrites69.1%
(FPCore (re im)
:precision binary64
(*
(* 0.5 (sin re))
(*
(-
(*
(- (* (* (* (* -0.0003968253968253968 im) im) im) im) 0.3333333333333333)
(* im im))
2.0)
im)))
double code(double re, double im) {
return (0.5 * sin(re)) * ((((((((-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * (im * im)) - 2.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 = (0.5d0 * sin(re)) * (((((((((-0.0003968253968253968d0) * im) * im) * im) * im) - 0.3333333333333333d0) * (im * im)) - 2.0d0) * im)
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * ((((((((-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
}
def code(re, im): return (0.5 * math.sin(re)) * ((((((((-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im)
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * ((((((((-0.0003968253968253968 * im) * im) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(\left(\left(\left(-0.0003968253968253968 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)
\end{array}
Initial program 67.5%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites95.2%
Taylor expanded in im around inf
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6494.8
Applied rewrites94.8%
(FPCore (re im)
:precision binary64
(if (<= (* 0.5 (sin re)) 0.006)
(*
(* (fma (* re re) -0.08333333333333333 0.5) re)
(* (- (* -0.3333333333333333 (* im im)) 2.0) im))
(*
(*
(-
(* (fma -0.008333333333333333 (* re re) 0.16666666666666666) (* re re))
1.0)
re)
im)))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= 0.006) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
} else {
tmp = (((fma(-0.008333333333333333, (re * re), 0.16666666666666666) * (re * re)) - 1.0) * re) * im;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 0.006) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(-0.3333333333333333 * Float64(im * im)) - 2.0) * im)); else tmp = Float64(Float64(Float64(Float64(fma(-0.008333333333333333, Float64(re * re), 0.16666666666666666) * Float64(re * re)) - 1.0) * re) * im); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 0.006], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(-0.008333333333333333 * N[(re * re), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq 0.006:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-0.008333333333333333, re \cdot re, 0.16666666666666666\right) \cdot \left(re \cdot re\right) - 1\right) \cdot re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 0.0060000000000000001Initial program 72.2%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.8
Applied rewrites83.8%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6465.9
Applied rewrites65.9%
if 0.0060000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 54.5%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6422.1
Applied rewrites22.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (- (* -0.3333333333333333 (* im im)) 2.0) im)))
(if (<= (* 0.5 (sin re)) -0.005)
(* (* (* (* re re) -0.08333333333333333) re) t_0)
(* (* 0.5 re) t_0))))
double code(double re, double im) {
double t_0 = ((-0.3333333333333333 * (im * im)) - 2.0) * im;
double tmp;
if ((0.5 * sin(re)) <= -0.005) {
tmp = (((re * re) * -0.08333333333333333) * re) * t_0;
} else {
tmp = (0.5 * re) * t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (((-0.3333333333333333d0) * (im * im)) - 2.0d0) * im
if ((0.5d0 * sin(re)) <= (-0.005d0)) then
tmp = (((re * re) * (-0.08333333333333333d0)) * re) * t_0
else
tmp = (0.5d0 * re) * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = ((-0.3333333333333333 * (im * im)) - 2.0) * im;
double tmp;
if ((0.5 * Math.sin(re)) <= -0.005) {
tmp = (((re * re) * -0.08333333333333333) * re) * t_0;
} else {
tmp = (0.5 * re) * t_0;
}
return tmp;
}
def code(re, im): t_0 = ((-0.3333333333333333 * (im * im)) - 2.0) * im tmp = 0 if (0.5 * math.sin(re)) <= -0.005: tmp = (((re * re) * -0.08333333333333333) * re) * t_0 else: tmp = (0.5 * re) * t_0 return tmp
function code(re, im) t_0 = Float64(Float64(Float64(-0.3333333333333333 * Float64(im * im)) - 2.0) * im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.005) tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * t_0); else tmp = Float64(Float64(0.5 * re) * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = ((-0.3333333333333333 * (im * im)) - 2.0) * im; tmp = 0.0; if ((0.5 * sin(re)) <= -0.005) tmp = (((re * re) * -0.08333333333333333) * re) * t_0; else tmp = (0.5 * re) * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * t$95$0), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\\
\mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot t\_0\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001Initial program 55.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.5
Applied rewrites87.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6425.5
Applied rewrites25.5%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6425.5
Applied rewrites25.5%
if -0.0050000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 70.7%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.5
Applied rewrites83.5%
Taylor expanded in re around 0
Applied rewrites61.6%
(FPCore (re im)
:precision binary64
(if (<= (* 0.5 (sin re)) -0.005)
(*
(* (fma (* re re) -0.08333333333333333 0.5) re)
(* (* (* im im) -0.3333333333333333) im))
(* (* 0.5 re) (* (- (* -0.3333333333333333 (* im im)) 2.0) im))))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.005) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * (((im * im) * -0.3333333333333333) * im);
} else {
tmp = (0.5 * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.005) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(im * im) * -0.3333333333333333) * im)); else tmp = Float64(Float64(0.5 * re) * Float64(Float64(Float64(-0.3333333333333333 * Float64(im * im)) - 2.0) * im)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001Initial program 55.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.5
Applied rewrites87.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6425.5
Applied rewrites25.5%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6425.2
Applied rewrites25.2%
if -0.0050000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 70.7%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.5
Applied rewrites83.5%
Taylor expanded in re around 0
Applied rewrites61.6%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) -0.005) (* (fma (* (* re re) im) 0.16666666666666666 (- im)) re) (* (* 0.5 re) (* (- (* -0.3333333333333333 (* im im)) 2.0) im))))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.005) {
tmp = fma(((re * re) * im), 0.16666666666666666, -im) * re;
} else {
tmp = (0.5 * re) * (((-0.3333333333333333 * (im * im)) - 2.0) * im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.005) tmp = Float64(fma(Float64(Float64(re * re) * im), 0.16666666666666666, Float64(-im)) * re); else tmp = Float64(Float64(0.5 * re) * Float64(Float64(Float64(-0.3333333333333333 * Float64(im * im)) - 2.0) * im)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.16666666666666666 + (-im)), $MachinePrecision] * re), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(N[(-0.3333333333333333 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.005:\\
\;\;\;\;\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, 0.16666666666666666, -im\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\left(-0.3333333333333333 \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0050000000000000001Initial program 55.3%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6450.2
Applied rewrites50.2%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lift-neg.f6421.9
Applied rewrites21.9%
if -0.0050000000000000001 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 70.7%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.5
Applied rewrites83.5%
Taylor expanded in re around 0
Applied rewrites61.6%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) 1e-6) (* (fma (* (* re re) im) 0.16666666666666666 (- im)) re) (* (- re) im)))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= 1e-6) {
tmp = fma(((re * re) * im), 0.16666666666666666, -im) * re;
} else {
tmp = -re * im;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 1e-6) tmp = Float64(fma(Float64(Float64(re * re) * im), 0.16666666666666666, Float64(-im)) * re); else tmp = Float64(Float64(-re) * im); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 1e-6], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.16666666666666666 + (-im)), $MachinePrecision] * re), $MachinePrecision], N[((-re) * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, 0.16666666666666666, -im\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(-re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 9.99999999999999955e-7Initial program 71.9%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6448.2
Applied rewrites48.2%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lift-neg.f6439.7
Applied rewrites39.7%
if 9.99999999999999955e-7 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 55.8%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6450.2
Applied rewrites50.2%
Taylor expanded in re around 0
Applied rewrites14.5%
(FPCore (re im)
:precision binary64
(if (<= im -4.8)
(* (* 0.5 re) (- (exp (- im)) 1.0))
(if (<= im 11.0)
(* (- (sin re)) im)
(if (<= im 1e+106)
(* (* 0.5 re) (- 1.0 (exp im)))
(*
(* (fma (* re re) -0.08333333333333333 0.5) re)
(* (* (* im im) -0.3333333333333333) im))))))
double code(double re, double im) {
double tmp;
if (im <= -4.8) {
tmp = (0.5 * re) * (exp(-im) - 1.0);
} else if (im <= 11.0) {
tmp = -sin(re) * im;
} else if (im <= 1e+106) {
tmp = (0.5 * re) * (1.0 - exp(im));
} else {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * (((im * im) * -0.3333333333333333) * im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= -4.8) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) - 1.0)); elseif (im <= 11.0) tmp = Float64(Float64(-sin(re)) * im); elseif (im <= 1e+106) tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im))); else tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(im * im) * -0.3333333333333333) * im)); end return tmp end
code[re_, im_] := If[LessEqual[im, -4.8], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 11.0], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], If[LessEqual[im, 1e+106], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -4.8:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} - 1\right)\\
\mathbf{elif}\;im \leq 11:\\
\;\;\;\;\left(-\sin re\right) \cdot im\\
\mathbf{elif}\;im \leq 10^{+106}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333\right) \cdot im\right)\\
\end{array}
\end{array}
if im < -4.79999999999999982Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites78.7%
if -4.79999999999999982 < im < 11Initial program 32.4%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6496.7
Applied rewrites96.7%
if 11 < im < 1.00000000000000009e106Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites89.5%
if 1.00000000000000009e106 < im Initial program 100.0%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6484.9
Applied rewrites84.9%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6484.9
Applied rewrites84.9%
(FPCore (re im)
:precision binary64
(if (<= im -0.00088)
(*
(*
(fma
(- (* 0.004166666666666667 (* re re)) 0.08333333333333333)
(* re re)
0.5)
re)
(*
(-
(*
(-
(*
(* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
im)
0.3333333333333333)
(* im im))
2.0)
im))
(if (<= im 11.0)
(* (- (sin re)) im)
(if (<= im 1e+106)
(* (* 0.5 re) (- 1.0 (exp im)))
(*
(* (fma (* re re) -0.08333333333333333 0.5) re)
(* (* (* im im) -0.3333333333333333) im))))))
double code(double re, double im) {
double tmp;
if (im <= -0.00088) {
tmp = (fma(((0.004166666666666667 * (re * re)) - 0.08333333333333333), (re * re), 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else if (im <= 11.0) {
tmp = -sin(re) * im;
} else if (im <= 1e+106) {
tmp = (0.5 * re) * (1.0 - exp(im));
} else {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * (((im * im) * -0.3333333333333333) * im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= -0.00088) tmp = Float64(Float64(fma(Float64(Float64(0.004166666666666667 * Float64(re * re)) - 0.08333333333333333), Float64(re * re), 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)); elseif (im <= 11.0) tmp = Float64(Float64(-sin(re)) * im); elseif (im <= 1e+106) tmp = Float64(Float64(0.5 * re) * Float64(1.0 - exp(im))); else tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(im * im) * -0.3333333333333333) * im)); end return tmp end
code[re_, im_] := If[LessEqual[im, -0.00088], N[(N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 11.0], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], If[LessEqual[im, 1e+106], N[(N[(0.5 * re), $MachinePrecision] * N[(1.0 - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq -0.00088:\\
\;\;\;\;\left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{elif}\;im \leq 11:\\
\;\;\;\;\left(-\sin re\right) \cdot im\\
\mathbf{elif}\;im \leq 10^{+106}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(1 - e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333\right) \cdot im\right)\\
\end{array}
\end{array}
if im < -8.80000000000000031e-4Initial program 99.9%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6474.7
Applied rewrites74.7%
if -8.80000000000000031e-4 < im < 11Initial program 31.4%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6497.6
Applied rewrites97.6%
if 11 < im < 1.00000000000000009e106Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites89.5%
if 1.00000000000000009e106 < im Initial program 100.0%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6484.9
Applied rewrites84.9%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6484.9
Applied rewrites84.9%
(FPCore (re im)
:precision binary64
(if (<= re 650.0)
(*
(* (fma (* re re) -0.08333333333333333 0.5) re)
(*
(-
(*
(-
(*
(* (- (* -0.0003968253968253968 (* im im)) 0.016666666666666666) im)
im)
0.3333333333333333)
(* im im))
2.0)
im))
(* (* (sin re) (fma (* -0.16666666666666666 im) im -1.0)) im)))
double code(double re, double im) {
double tmp;
if (re <= 650.0) {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
} else {
tmp = (sin(re) * fma((-0.16666666666666666 * im), im, -1.0)) * im;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (re <= 650.0) tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)); else tmp = Float64(Float64(sin(re) * fma(Float64(-0.16666666666666666 * im), im, -1.0)) * im); end return tmp end
code[re_, im_] := If[LessEqual[re, 650.0], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[re], $MachinePrecision] * N[(N[(-0.16666666666666666 * im), $MachinePrecision] * im + -1.0), $MachinePrecision]), $MachinePrecision] * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 650:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sin re \cdot \mathsf{fma}\left(-0.16666666666666666 \cdot im, im, -1\right)\right) \cdot im\\
\end{array}
\end{array}
if re < 650Initial program 70.3%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites95.7%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6473.1
Applied rewrites73.1%
if 650 < re Initial program 57.5%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-sin.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6479.7
Applied rewrites79.7%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(*
(fma
(- (* 0.004166666666666667 (* re re)) 0.08333333333333333)
(* re re)
0.5)
re)
(*
(-
(*
(-
(*
(*
(- (* -0.0003968253968253968 (* im im)) 0.016666666666666666)
im)
im)
0.3333333333333333)
(* im im))
2.0)
im))))
(if (<= im -0.00088)
t_0
(if (<= im 2.4e-19)
(* (- (sin re)) im)
(if (<= im 1e+106)
t_0
(*
(* (fma (* re re) -0.08333333333333333 0.5) re)
(* (* (* im im) -0.3333333333333333) im)))))))
double code(double re, double im) {
double t_0 = (fma(((0.004166666666666667 * (re * re)) - 0.08333333333333333), (re * re), 0.5) * re) * ((((((((-0.0003968253968253968 * (im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * (im * im)) - 2.0) * im);
double tmp;
if (im <= -0.00088) {
tmp = t_0;
} else if (im <= 2.4e-19) {
tmp = -sin(re) * im;
} else if (im <= 1e+106) {
tmp = t_0;
} else {
tmp = (fma((re * re), -0.08333333333333333, 0.5) * re) * (((im * im) * -0.3333333333333333) * im);
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(fma(Float64(Float64(0.004166666666666667 * Float64(re * re)) - 0.08333333333333333), Float64(re * re), 0.5) * re) * Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(-0.0003968253968253968 * Float64(im * im)) - 0.016666666666666666) * im) * im) - 0.3333333333333333) * Float64(im * im)) - 2.0) * im)) tmp = 0.0 if (im <= -0.00088) tmp = t_0; elseif (im <= 2.4e-19) tmp = Float64(Float64(-sin(re)) * im); elseif (im <= 1e+106) tmp = t_0; else tmp = Float64(Float64(fma(Float64(re * re), -0.08333333333333333, 0.5) * re) * Float64(Float64(Float64(im * im) * -0.3333333333333333) * im)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(N[(N[(0.004166666666666667 * N[(re * re), $MachinePrecision]), $MachinePrecision] - 0.08333333333333333), $MachinePrecision] * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(N[(N[(N[(N[(N[(-0.0003968253968253968 * N[(im * im), $MachinePrecision]), $MachinePrecision] - 0.016666666666666666), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] - 0.3333333333333333), $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, -0.00088], t$95$0, If[LessEqual[im, 2.4e-19], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], If[LessEqual[im, 1e+106], t$95$0, N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{fma}\left(0.004166666666666667 \cdot \left(re \cdot re\right) - 0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(\left(\left(\left(\left(-0.0003968253968253968 \cdot \left(im \cdot im\right) - 0.016666666666666666\right) \cdot im\right) \cdot im - 0.3333333333333333\right) \cdot \left(im \cdot im\right) - 2\right) \cdot im\right)\\
\mathbf{if}\;im \leq -0.00088:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;im \leq 2.4 \cdot 10^{-19}:\\
\;\;\;\;\left(-\sin re\right) \cdot im\\
\mathbf{elif}\;im \leq 10^{+106}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(re \cdot re, -0.08333333333333333, 0.5\right) \cdot re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot -0.3333333333333333\right) \cdot im\right)\\
\end{array}
\end{array}
if im < -8.80000000000000031e-4 or 2.40000000000000023e-19 < im < 1.00000000000000009e106Initial program 97.6%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites86.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6472.9
Applied rewrites72.9%
if -8.80000000000000031e-4 < im < 2.40000000000000023e-19Initial program 30.2%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
if 1.00000000000000009e106 < im Initial program 100.0%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6484.9
Applied rewrites84.9%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6484.9
Applied rewrites84.9%
(FPCore (re im) :precision binary64 (* (- re) im))
double code(double re, double im) {
return -re * 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 = -re * im
end function
public static double code(double re, double im) {
return -re * im;
}
def code(re, im): return -re * im
function code(re, im) return Float64(Float64(-re) * im) end
function tmp = code(re, im) tmp = -re * im; end
code[re_, im_] := N[((-re) * im), $MachinePrecision]
\begin{array}{l}
\\
\left(-re\right) \cdot im
\end{array}
Initial program 67.5%
Taylor expanded in im around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6448.8
Applied rewrites48.8%
Taylor expanded in re around 0
Applied rewrites32.7%
(FPCore (re im)
:precision binary64
(if (< (fabs im) 1.0)
(-
(*
(sin re)
(+
(+ im (* (* (* 0.16666666666666666 im) im) im))
(* (* (* (* (* 0.008333333333333333 im) im) im) im) im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
double code(double re, double im) {
double tmp;
if (fabs(im) < 1.0) {
tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * sin(re)) * (exp(-im) - 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 (abs(im) < 1.0d0) then
tmp = -(sin(re) * ((im + (((0.16666666666666666d0 * im) * im) * im)) + (((((0.008333333333333333d0 * im) * im) * im) * im) * im)))
else
tmp = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.abs(im) < 1.0) {
tmp = -(Math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im)));
} else {
tmp = (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
return tmp;
}
def code(re, im): tmp = 0 if math.fabs(im) < 1.0: tmp = -(math.sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))) else: tmp = (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im)) return tmp
function code(re, im) tmp = 0.0 if (abs(im) < 1.0) tmp = Float64(-Float64(sin(re) * Float64(Float64(im + Float64(Float64(Float64(0.16666666666666666 * im) * im) * im)) + Float64(Float64(Float64(Float64(Float64(0.008333333333333333 * im) * im) * im) * im) * im)))); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (abs(im) < 1.0) tmp = -(sin(re) * ((im + (((0.16666666666666666 * im) * im) * im)) + (((((0.008333333333333333 * im) * im) * im) * im) * im))); else tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end tmp_2 = tmp; end
code[re_, im_] := If[Less[N[Abs[im], $MachinePrecision], 1.0], (-N[(N[Sin[re], $MachinePrecision] * N[(N[(im + N[(N[(N[(0.16666666666666666 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(N[(0.008333333333333333 * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|im\right| < 1:\\
\;\;\;\;-\sin re \cdot \left(\left(im + \left(\left(0.16666666666666666 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333 \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\end{array}
\end{array}
herbie shell --seed 2025082
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:precision binary64
:alt
(! :herbie-platform default (if (< (fabs im) 1) (- (* (sin re) (+ im (* 1/6 im im im) (* 1/120 im im im im im)))) (* (* 1/2 (sin re)) (- (exp (- im)) (exp im)))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))