
(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]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
Herbie found 10 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]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
(FPCore (re im) :precision binary64 (* (sinh (- im)) (sin re)))
double code(double re, double im) {
return sinh(-im) * sin(re);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sinh(-im) * sin(re)
end function
public static double code(double re, double im) {
return Math.sinh(-im) * Math.sin(re);
}
def code(re, im): return math.sinh(-im) * math.sin(re)
function code(re, im) return Float64(sinh(Float64(-im)) * sin(re)) end
function tmp = code(re, im) tmp = sinh(-im) * sin(re); end
code[re_, im_] := N[(N[Sinh[(-im)], $MachinePrecision] * N[Sin[re], $MachinePrecision]), $MachinePrecision]
\sinh \left(-im\right) \cdot \sin re
Initial program 65.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
metadata-evalN/A
mult-flipN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
sinh-negN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-sinh.f6499.9%
Applied rewrites99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (fabs im)))
(t_1 (exp (fabs im)))
(t_2 (sin (fabs re)))
(t_3 (* (* 0.5 t_2) (- (exp t_0) t_1))))
(*
(copysign 1.0 re)
(*
(copysign 1.0 im)
(if (<= t_3 (- INFINITY))
(* (* 0.5 (fabs re)) (- 1.0 t_1))
(if (<= t_3 0.0002)
(*
(*
(fma (* (fabs im) (fabs im)) -0.16666666666666666 -1.0)
t_2)
(fabs im))
(*
(sinh t_0)
(*
(fabs re)
(+ 1.0 (* -0.16666666666666666 (pow (fabs re) 2.0)))))))))))double code(double re, double im) {
double t_0 = -fabs(im);
double t_1 = exp(fabs(im));
double t_2 = sin(fabs(re));
double t_3 = (0.5 * t_2) * (exp(t_0) - t_1);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (0.5 * fabs(re)) * (1.0 - t_1);
} else if (t_3 <= 0.0002) {
tmp = (fma((fabs(im) * fabs(im)), -0.16666666666666666, -1.0) * t_2) * fabs(im);
} else {
tmp = sinh(t_0) * (fabs(re) * (1.0 + (-0.16666666666666666 * pow(fabs(re), 2.0))));
}
return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
function code(re, im) t_0 = Float64(-abs(im)) t_1 = exp(abs(im)) t_2 = sin(abs(re)) t_3 = Float64(Float64(0.5 * t_2) * Float64(exp(t_0) - t_1)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_1)); elseif (t_3 <= 0.0002) tmp = Float64(Float64(fma(Float64(abs(im) * abs(im)), -0.16666666666666666, -1.0) * t_2) * abs(im)); else tmp = Float64(sinh(t_0) * Float64(abs(re) * Float64(1.0 + Float64(-0.16666666666666666 * (abs(re) ^ 2.0))))); end return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp)) end
code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, Block[{t$95$1 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 * t$95$2), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, (-Infinity)], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0002], N[(N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision] * t$95$2), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision], N[(N[Sinh[t$95$0], $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * N[(1.0 + N[(-0.16666666666666666 * N[Power[N[Abs[re], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := e^{\left|im\right|}\\
t_2 := \sin \left(\left|re\right|\right)\\
t_3 := \left(0.5 \cdot t\_2\right) \cdot \left(e^{t\_0} - t\_1\right)\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\
\mathbf{elif}\;t\_3 \leq 0.0002:\\
\;\;\;\;\left(\mathsf{fma}\left(\left|im\right| \cdot \left|im\right|, -0.16666666666666666, -1\right) \cdot t\_2\right) \cdot \left|im\right|\\
\mathbf{else}:\\
\;\;\;\;\sinh t\_0 \cdot \left(\left|re\right| \cdot \left(1 + -0.16666666666666666 \cdot {\left(\left|re\right|\right)}^{2}\right)\right)\\
\end{array}\right)
\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 65.7%
Taylor expanded in re around 0
lower-*.f6452.6%
Applied rewrites52.6%
Taylor expanded in im around 0
Applied rewrites33.9%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 2.0000000000000001e-4Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6480.3%
Applied rewrites80.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6480.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6480.3%
Applied rewrites80.3%
if 2.0000000000000001e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
metadata-evalN/A
mult-flipN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
sinh-negN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-sinh.f6499.9%
Applied rewrites99.9%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6462.3%
Applied rewrites62.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (fabs im)))
(t_1 (exp (fabs im)))
(t_2 (sin (fabs re)))
(t_3 (* (* 0.5 t_2) (- (exp t_0) t_1))))
(*
(copysign 1.0 re)
(*
(copysign 1.0 im)
(if (<= t_3 (- INFINITY))
(* (* 0.5 (fabs re)) (- 1.0 t_1))
(if (<= t_3 0.0002)
(* t_2 t_0)
(*
(sinh t_0)
(*
(fabs re)
(+ 1.0 (* -0.16666666666666666 (pow (fabs re) 2.0)))))))))))double code(double re, double im) {
double t_0 = -fabs(im);
double t_1 = exp(fabs(im));
double t_2 = sin(fabs(re));
double t_3 = (0.5 * t_2) * (exp(t_0) - t_1);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (0.5 * fabs(re)) * (1.0 - t_1);
} else if (t_3 <= 0.0002) {
tmp = t_2 * t_0;
} else {
tmp = sinh(t_0) * (fabs(re) * (1.0 + (-0.16666666666666666 * pow(fabs(re), 2.0))));
}
return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
public static double code(double re, double im) {
double t_0 = -Math.abs(im);
double t_1 = Math.exp(Math.abs(im));
double t_2 = Math.sin(Math.abs(re));
double t_3 = (0.5 * t_2) * (Math.exp(t_0) - t_1);
double tmp;
if (t_3 <= -Double.POSITIVE_INFINITY) {
tmp = (0.5 * Math.abs(re)) * (1.0 - t_1);
} else if (t_3 <= 0.0002) {
tmp = t_2 * t_0;
} else {
tmp = Math.sinh(t_0) * (Math.abs(re) * (1.0 + (-0.16666666666666666 * Math.pow(Math.abs(re), 2.0))));
}
return Math.copySign(1.0, re) * (Math.copySign(1.0, im) * tmp);
}
def code(re, im): t_0 = -math.fabs(im) t_1 = math.exp(math.fabs(im)) t_2 = math.sin(math.fabs(re)) t_3 = (0.5 * t_2) * (math.exp(t_0) - t_1) tmp = 0 if t_3 <= -math.inf: tmp = (0.5 * math.fabs(re)) * (1.0 - t_1) elif t_3 <= 0.0002: tmp = t_2 * t_0 else: tmp = math.sinh(t_0) * (math.fabs(re) * (1.0 + (-0.16666666666666666 * math.pow(math.fabs(re), 2.0)))) return math.copysign(1.0, re) * (math.copysign(1.0, im) * tmp)
function code(re, im) t_0 = Float64(-abs(im)) t_1 = exp(abs(im)) t_2 = sin(abs(re)) t_3 = Float64(Float64(0.5 * t_2) * Float64(exp(t_0) - t_1)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_1)); elseif (t_3 <= 0.0002) tmp = Float64(t_2 * t_0); else tmp = Float64(sinh(t_0) * Float64(abs(re) * Float64(1.0 + Float64(-0.16666666666666666 * (abs(re) ^ 2.0))))); end return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp)) end
function tmp_2 = code(re, im) t_0 = -abs(im); t_1 = exp(abs(im)); t_2 = sin(abs(re)); t_3 = (0.5 * t_2) * (exp(t_0) - t_1); tmp = 0.0; if (t_3 <= -Inf) tmp = (0.5 * abs(re)) * (1.0 - t_1); elseif (t_3 <= 0.0002) tmp = t_2 * t_0; else tmp = sinh(t_0) * (abs(re) * (1.0 + (-0.16666666666666666 * (abs(re) ^ 2.0)))); end tmp_2 = (sign(re) * abs(1.0)) * ((sign(im) * abs(1.0)) * tmp); end
code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, Block[{t$95$1 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 * t$95$2), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, (-Infinity)], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0002], N[(t$95$2 * t$95$0), $MachinePrecision], N[(N[Sinh[t$95$0], $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * N[(1.0 + N[(-0.16666666666666666 * N[Power[N[Abs[re], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := e^{\left|im\right|}\\
t_2 := \sin \left(\left|re\right|\right)\\
t_3 := \left(0.5 \cdot t\_2\right) \cdot \left(e^{t\_0} - t\_1\right)\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\
\mathbf{elif}\;t\_3 \leq 0.0002:\\
\;\;\;\;t\_2 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sinh t\_0 \cdot \left(\left|re\right| \cdot \left(1 + -0.16666666666666666 \cdot {\left(\left|re\right|\right)}^{2}\right)\right)\\
\end{array}\right)
\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 65.7%
Taylor expanded in re around 0
lower-*.f6452.6%
Applied rewrites52.6%
Taylor expanded in im around 0
Applied rewrites33.9%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 2.0000000000000001e-4Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f6451.4%
Applied rewrites51.4%
if 2.0000000000000001e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.7%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift--.f64N/A
sub-negate-revN/A
distribute-lft-neg-outN/A
metadata-evalN/A
mult-flipN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-defN/A
sinh-negN/A
lift-neg.f64N/A
lower-*.f64N/A
lower-sinh.f6499.9%
Applied rewrites99.9%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6462.3%
Applied rewrites62.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (fabs im)))
(t_1 (exp (fabs im)))
(t_2 (sin (fabs re)))
(t_3 (* (* 0.5 t_2) (- (exp t_0) t_1))))
(*
(copysign 1.0 re)
(*
(copysign 1.0 im)
(if (<= t_3 (- INFINITY))
(* (* 0.5 (fabs re)) (- 1.0 t_1))
(if (<= t_3 0.0002)
(* t_2 t_0)
(*
(*
(fma (* (fabs im) (fabs im)) -0.16666666666666666 -1.0)
(*
(fabs re)
(+ 1.0 (* -0.16666666666666666 (pow (fabs re) 2.0)))))
(fabs im))))))))double code(double re, double im) {
double t_0 = -fabs(im);
double t_1 = exp(fabs(im));
double t_2 = sin(fabs(re));
double t_3 = (0.5 * t_2) * (exp(t_0) - t_1);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (0.5 * fabs(re)) * (1.0 - t_1);
} else if (t_3 <= 0.0002) {
tmp = t_2 * t_0;
} else {
tmp = (fma((fabs(im) * fabs(im)), -0.16666666666666666, -1.0) * (fabs(re) * (1.0 + (-0.16666666666666666 * pow(fabs(re), 2.0))))) * fabs(im);
}
return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
function code(re, im) t_0 = Float64(-abs(im)) t_1 = exp(abs(im)) t_2 = sin(abs(re)) t_3 = Float64(Float64(0.5 * t_2) * Float64(exp(t_0) - t_1)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_1)); elseif (t_3 <= 0.0002) tmp = Float64(t_2 * t_0); else tmp = Float64(Float64(fma(Float64(abs(im) * abs(im)), -0.16666666666666666, -1.0) * Float64(abs(re) * Float64(1.0 + Float64(-0.16666666666666666 * (abs(re) ^ 2.0))))) * abs(im)); end return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp)) end
code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, Block[{t$95$1 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 * t$95$2), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, (-Infinity)], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0002], N[(t$95$2 * t$95$0), $MachinePrecision], N[(N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + -1.0), $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * N[(1.0 + N[(-0.16666666666666666 * N[Power[N[Abs[re], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := e^{\left|im\right|}\\
t_2 := \sin \left(\left|re\right|\right)\\
t_3 := \left(0.5 \cdot t\_2\right) \cdot \left(e^{t\_0} - t\_1\right)\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\
\mathbf{elif}\;t\_3 \leq 0.0002:\\
\;\;\;\;t\_2 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left|im\right| \cdot \left|im\right|, -0.16666666666666666, -1\right) \cdot \left(\left|re\right| \cdot \left(1 + -0.16666666666666666 \cdot {\left(\left|re\right|\right)}^{2}\right)\right)\right) \cdot \left|im\right|\\
\end{array}\right)
\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 65.7%
Taylor expanded in re around 0
lower-*.f6452.6%
Applied rewrites52.6%
Taylor expanded in im around 0
Applied rewrites33.9%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 2.0000000000000001e-4Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f6451.4%
Applied rewrites51.4%
if 2.0000000000000001e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6480.3%
Applied rewrites80.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6480.3%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6480.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6480.3%
Applied rewrites80.3%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6450.1%
Applied rewrites50.1%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (fabs im)))
(t_1 (exp (fabs im)))
(t_2 (sin (fabs re)))
(t_3 (* (* 0.5 t_2) (- (exp t_0) t_1))))
(*
(copysign 1.0 re)
(*
(copysign 1.0 im)
(if (<= t_3 (- INFINITY))
(* (* 0.5 (fabs re)) (- 1.0 t_1))
(if (<= t_3 0.0002)
(* t_2 t_0)
(*
-1.0
(*
(fabs im)
(* -0.16666666666666666 (pow (fabs re) 3.0))))))))))double code(double re, double im) {
double t_0 = -fabs(im);
double t_1 = exp(fabs(im));
double t_2 = sin(fabs(re));
double t_3 = (0.5 * t_2) * (exp(t_0) - t_1);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = (0.5 * fabs(re)) * (1.0 - t_1);
} else if (t_3 <= 0.0002) {
tmp = t_2 * t_0;
} else {
tmp = -1.0 * (fabs(im) * (-0.16666666666666666 * pow(fabs(re), 3.0)));
}
return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
public static double code(double re, double im) {
double t_0 = -Math.abs(im);
double t_1 = Math.exp(Math.abs(im));
double t_2 = Math.sin(Math.abs(re));
double t_3 = (0.5 * t_2) * (Math.exp(t_0) - t_1);
double tmp;
if (t_3 <= -Double.POSITIVE_INFINITY) {
tmp = (0.5 * Math.abs(re)) * (1.0 - t_1);
} else if (t_3 <= 0.0002) {
tmp = t_2 * t_0;
} else {
tmp = -1.0 * (Math.abs(im) * (-0.16666666666666666 * Math.pow(Math.abs(re), 3.0)));
}
return Math.copySign(1.0, re) * (Math.copySign(1.0, im) * tmp);
}
def code(re, im): t_0 = -math.fabs(im) t_1 = math.exp(math.fabs(im)) t_2 = math.sin(math.fabs(re)) t_3 = (0.5 * t_2) * (math.exp(t_0) - t_1) tmp = 0 if t_3 <= -math.inf: tmp = (0.5 * math.fabs(re)) * (1.0 - t_1) elif t_3 <= 0.0002: tmp = t_2 * t_0 else: tmp = -1.0 * (math.fabs(im) * (-0.16666666666666666 * math.pow(math.fabs(re), 3.0))) return math.copysign(1.0, re) * (math.copysign(1.0, im) * tmp)
function code(re, im) t_0 = Float64(-abs(im)) t_1 = exp(abs(im)) t_2 = sin(abs(re)) t_3 = Float64(Float64(0.5 * t_2) * Float64(exp(t_0) - t_1)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_1)); elseif (t_3 <= 0.0002) tmp = Float64(t_2 * t_0); else tmp = Float64(-1.0 * Float64(abs(im) * Float64(-0.16666666666666666 * (abs(re) ^ 3.0)))); end return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp)) end
function tmp_2 = code(re, im) t_0 = -abs(im); t_1 = exp(abs(im)); t_2 = sin(abs(re)); t_3 = (0.5 * t_2) * (exp(t_0) - t_1); tmp = 0.0; if (t_3 <= -Inf) tmp = (0.5 * abs(re)) * (1.0 - t_1); elseif (t_3 <= 0.0002) tmp = t_2 * t_0; else tmp = -1.0 * (abs(im) * (-0.16666666666666666 * (abs(re) ^ 3.0))); end tmp_2 = (sign(re) * abs(1.0)) * ((sign(im) * abs(1.0)) * tmp); end
code[re_, im_] := Block[{t$95$0 = (-N[Abs[im], $MachinePrecision])}, Block[{t$95$1 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(0.5 * t$95$2), $MachinePrecision] * N[(N[Exp[t$95$0], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$3, (-Infinity)], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.0002], N[(t$95$2 * t$95$0), $MachinePrecision], N[(-1.0 * N[(N[Abs[im], $MachinePrecision] * N[(-0.16666666666666666 * N[Power[N[Abs[re], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := -\left|im\right|\\
t_1 := e^{\left|im\right|}\\
t_2 := \sin \left(\left|re\right|\right)\\
t_3 := \left(0.5 \cdot t\_2\right) \cdot \left(e^{t\_0} - t\_1\right)\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_3 \leq -\infty:\\
\;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_1\right)\\
\mathbf{elif}\;t\_3 \leq 0.0002:\\
\;\;\;\;t\_2 \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;-1 \cdot \left(\left|im\right| \cdot \left(-0.16666666666666666 \cdot {\left(\left|re\right|\right)}^{3}\right)\right)\\
\end{array}\right)
\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 65.7%
Taylor expanded in re around 0
lower-*.f6452.6%
Applied rewrites52.6%
Taylor expanded in im around 0
Applied rewrites33.9%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 2.0000000000000001e-4Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lift-neg.f64N/A
lower-*.f6451.4%
Applied rewrites51.4%
if 2.0000000000000001e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
Taylor expanded in re around inf
lower-*.f64N/A
lower-pow.f6423.5%
Applied rewrites23.5%
(FPCore (re im)
:precision binary64
(*
(copysign 1.0 re)
(if (<= (* 0.5 (sin (fabs re))) -0.02)
(*
(fabs re)
(- (* (* (* im (fabs re)) (fabs re)) 0.16666666666666666) im))
(* (* -2.0 (sinh im)) (* (fabs re) 0.5)))))double code(double re, double im) {
double tmp;
if ((0.5 * sin(fabs(re))) <= -0.02) {
tmp = fabs(re) * ((((im * fabs(re)) * fabs(re)) * 0.16666666666666666) - im);
} else {
tmp = (-2.0 * sinh(im)) * (fabs(re) * 0.5);
}
return copysign(1.0, re) * tmp;
}
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.sin(Math.abs(re))) <= -0.02) {
tmp = Math.abs(re) * ((((im * Math.abs(re)) * Math.abs(re)) * 0.16666666666666666) - im);
} else {
tmp = (-2.0 * Math.sinh(im)) * (Math.abs(re) * 0.5);
}
return Math.copySign(1.0, re) * tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.sin(math.fabs(re))) <= -0.02: tmp = math.fabs(re) * ((((im * math.fabs(re)) * math.fabs(re)) * 0.16666666666666666) - im) else: tmp = (-2.0 * math.sinh(im)) * (math.fabs(re) * 0.5) return math.copysign(1.0, re) * tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(abs(re))) <= -0.02) tmp = Float64(abs(re) * Float64(Float64(Float64(Float64(im * abs(re)) * abs(re)) * 0.16666666666666666) - im)); else tmp = Float64(Float64(-2.0 * sinh(im)) * Float64(abs(re) * 0.5)); end return Float64(copysign(1.0, re) * tmp) end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * sin(abs(re))) <= -0.02) tmp = abs(re) * ((((im * abs(re)) * abs(re)) * 0.16666666666666666) - im); else tmp = (-2.0 * sinh(im)) * (abs(re) * 0.5); end tmp_2 = (sign(re) * abs(1.0)) * tmp; end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.02], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(N[(im * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision] * N[(N[Abs[re], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq -0.02:\\
\;\;\;\;\left|re\right| \cdot \left(\left(\left(im \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-2 \cdot \sinh im\right) \cdot \left(\left|re\right| \cdot 0.5\right)\\
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.02Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
Taylor expanded in re around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
lift-fma.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6436.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6436.2%
Applied rewrites36.2%
if -0.02 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.7%
Taylor expanded in re around 0
lower-*.f6452.6%
Applied rewrites52.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6452.6%
lift--.f64N/A
sub-negate-revN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
sinh-undefN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-sinh.f6463.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6463.6%
Applied rewrites63.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (exp (fabs im))))
(*
(copysign 1.0 re)
(*
(copysign 1.0 im)
(if (<=
(* (* 0.5 (sin (fabs re))) (- (exp (- (fabs im))) t_0))
-2e-7)
(* (* 0.5 (fabs re)) (- 1.0 t_0))
(*
(fabs re)
(-
(* (* (* (fabs im) (fabs re)) (fabs re)) 0.16666666666666666)
(fabs im))))))))double code(double re, double im) {
double t_0 = exp(fabs(im));
double tmp;
if (((0.5 * sin(fabs(re))) * (exp(-fabs(im)) - t_0)) <= -2e-7) {
tmp = (0.5 * fabs(re)) * (1.0 - t_0);
} else {
tmp = fabs(re) * ((((fabs(im) * fabs(re)) * fabs(re)) * 0.16666666666666666) - fabs(im));
}
return copysign(1.0, re) * (copysign(1.0, im) * tmp);
}
public static double code(double re, double im) {
double t_0 = Math.exp(Math.abs(im));
double tmp;
if (((0.5 * Math.sin(Math.abs(re))) * (Math.exp(-Math.abs(im)) - t_0)) <= -2e-7) {
tmp = (0.5 * Math.abs(re)) * (1.0 - t_0);
} else {
tmp = Math.abs(re) * ((((Math.abs(im) * Math.abs(re)) * Math.abs(re)) * 0.16666666666666666) - Math.abs(im));
}
return Math.copySign(1.0, re) * (Math.copySign(1.0, im) * tmp);
}
def code(re, im): t_0 = math.exp(math.fabs(im)) tmp = 0 if ((0.5 * math.sin(math.fabs(re))) * (math.exp(-math.fabs(im)) - t_0)) <= -2e-7: tmp = (0.5 * math.fabs(re)) * (1.0 - t_0) else: tmp = math.fabs(re) * ((((math.fabs(im) * math.fabs(re)) * math.fabs(re)) * 0.16666666666666666) - math.fabs(im)) return math.copysign(1.0, re) * (math.copysign(1.0, im) * tmp)
function code(re, im) t_0 = exp(abs(im)) tmp = 0.0 if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(Float64(-abs(im))) - t_0)) <= -2e-7) tmp = Float64(Float64(0.5 * abs(re)) * Float64(1.0 - t_0)); else tmp = Float64(abs(re) * Float64(Float64(Float64(Float64(abs(im) * abs(re)) * abs(re)) * 0.16666666666666666) - abs(im))); end return Float64(copysign(1.0, re) * Float64(copysign(1.0, im) * tmp)) end
function tmp_2 = code(re, im) t_0 = exp(abs(im)); tmp = 0.0; if (((0.5 * sin(abs(re))) * (exp(-abs(im)) - t_0)) <= -2e-7) tmp = (0.5 * abs(re)) * (1.0 - t_0); else tmp = abs(re) * ((((abs(im) * abs(re)) * abs(re)) * 0.16666666666666666) - abs(im)); end tmp_2 = (sign(re) * abs(1.0)) * ((sign(im) * abs(1.0)) * tmp); end
code[re_, im_] := Block[{t$95$0 = N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-N[Abs[im], $MachinePrecision])], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision], -2e-7], N[(N[(0.5 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[(1.0 - t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := e^{\left|im\right|}\\
\mathsf{copysign}\left(1, re\right) \cdot \left(\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{-\left|im\right|} - t\_0\right) \leq -2 \cdot 10^{-7}:\\
\;\;\;\;\left(0.5 \cdot \left|re\right|\right) \cdot \left(1 - t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;\left|re\right| \cdot \left(\left(\left(\left|im\right| \cdot \left|re\right|\right) \cdot \left|re\right|\right) \cdot 0.16666666666666666 - \left|im\right|\right)\\
\end{array}\right)
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -1.9999999999999999e-7Initial program 65.7%
Taylor expanded in re around 0
lower-*.f6452.6%
Applied rewrites52.6%
Taylor expanded in im around 0
Applied rewrites33.9%
if -1.9999999999999999e-7 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
Taylor expanded in re around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
lift-fma.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6436.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6436.2%
Applied rewrites36.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (fabs re))))
(*
(copysign 1.0 re)
(if (<= (* 0.5 (sin (fabs re))) -0.02)
(* (fabs re) (- (* (* t_0 (fabs re)) 0.16666666666666666) im))
(- t_0)))))double code(double re, double im) {
double t_0 = im * fabs(re);
double tmp;
if ((0.5 * sin(fabs(re))) <= -0.02) {
tmp = fabs(re) * (((t_0 * fabs(re)) * 0.16666666666666666) - im);
} else {
tmp = -t_0;
}
return copysign(1.0, re) * tmp;
}
public static double code(double re, double im) {
double t_0 = im * Math.abs(re);
double tmp;
if ((0.5 * Math.sin(Math.abs(re))) <= -0.02) {
tmp = Math.abs(re) * (((t_0 * Math.abs(re)) * 0.16666666666666666) - im);
} else {
tmp = -t_0;
}
return Math.copySign(1.0, re) * tmp;
}
def code(re, im): t_0 = im * math.fabs(re) tmp = 0 if (0.5 * math.sin(math.fabs(re))) <= -0.02: tmp = math.fabs(re) * (((t_0 * math.fabs(re)) * 0.16666666666666666) - im) else: tmp = -t_0 return math.copysign(1.0, re) * tmp
function code(re, im) t_0 = Float64(im * abs(re)) tmp = 0.0 if (Float64(0.5 * sin(abs(re))) <= -0.02) tmp = Float64(abs(re) * Float64(Float64(Float64(t_0 * abs(re)) * 0.16666666666666666) - im)); else tmp = Float64(-t_0); end return Float64(copysign(1.0, re) * tmp) end
function tmp_2 = code(re, im) t_0 = im * abs(re); tmp = 0.0; if ((0.5 * sin(abs(re))) <= -0.02) tmp = abs(re) * (((t_0 * abs(re)) * 0.16666666666666666) - im); else tmp = -t_0; end tmp_2 = (sign(re) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[Abs[re], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.02], N[(N[Abs[re], $MachinePrecision] * N[(N[(N[(t$95$0 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * 0.16666666666666666), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision], (-t$95$0)]), $MachinePrecision]]
\begin{array}{l}
t_0 := im \cdot \left|re\right|\\
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq -0.02:\\
\;\;\;\;\left|re\right| \cdot \left(\left(t\_0 \cdot \left|re\right|\right) \cdot 0.16666666666666666 - im\right)\\
\mathbf{else}:\\
\;\;\;\;-t\_0\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.02Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
Taylor expanded in re around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
lift-fma.f64N/A
+-commutativeN/A
mul-1-negN/A
sub-flip-reverseN/A
lower--.f6436.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.2%
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6436.2%
Applied rewrites36.2%
if -0.02 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
Taylor expanded in re around 0
lower-*.f6433.5%
Applied rewrites33.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6433.5%
Applied rewrites33.5%
(FPCore (re im)
:precision binary64
(*
(copysign 1.0 re)
(if (<= (* 0.5 (sin (fabs re))) -0.02)
(*
(* im (fma (* 0.16666666666666666 (fabs re)) (fabs re) -1.0))
(fabs re))
(- (* im (fabs re))))))double code(double re, double im) {
double tmp;
if ((0.5 * sin(fabs(re))) <= -0.02) {
tmp = (im * fma((0.16666666666666666 * fabs(re)), fabs(re), -1.0)) * fabs(re);
} else {
tmp = -(im * fabs(re));
}
return copysign(1.0, re) * tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(abs(re))) <= -0.02) tmp = Float64(Float64(im * fma(Float64(0.16666666666666666 * abs(re)), abs(re), -1.0)) * abs(re)); else tmp = Float64(-Float64(im * abs(re))); end return Float64(copysign(1.0, re) * tmp) end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -0.02], N[(N[(im * N[(N[(0.16666666666666666 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision], (-N[(im * N[Abs[re], $MachinePrecision]), $MachinePrecision])]), $MachinePrecision]
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin \left(\left|re\right|\right) \leq -0.02:\\
\;\;\;\;\left(im \cdot \mathsf{fma}\left(0.16666666666666666 \cdot \left|re\right|, \left|re\right|, -1\right)\right) \cdot \left|re\right|\\
\mathbf{else}:\\
\;\;\;\;-im \cdot \left|re\right|\\
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.02Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
Taylor expanded in re around 0
lower-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6436.2%
Applied rewrites36.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6436.2%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6436.2%
Applied rewrites36.2%
if -0.02 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
Taylor expanded in re around 0
lower-*.f6433.5%
Applied rewrites33.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6433.5%
Applied rewrites33.5%
(FPCore (re im) :precision binary64 (- (* im re)))
double code(double re, double im) {
return -(im * re);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -(im * re)
end function
public static double code(double re, double im) {
return -(im * re);
}
def code(re, im): return -(im * re)
function code(re, im) return Float64(-Float64(im * re)) end
function tmp = code(re, im) tmp = -(im * re); end
code[re_, im_] := (-N[(im * re), $MachinePrecision])
-im \cdot re
Initial program 65.7%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f6451.4%
Applied rewrites51.4%
Taylor expanded in re around 0
lower-*.f6433.5%
Applied rewrites33.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6433.5%
Applied rewrites33.5%
herbie shell --seed 2025253
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:precision binary64
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))