
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * cos(re)) * (exp((0.0d0 - im)) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp((0.0 - im)) - Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp((0.0 - im)) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp((0.0 - im)) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
(FPCore (re im) :precision binary64 (* (sinh (- im)) (cos re)))
double code(double re, double im) {
return sinh(-im) * cos(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) * cos(re)
end function
public static double code(double re, double im) {
return Math.sinh(-im) * Math.cos(re);
}
def code(re, im): return math.sinh(-im) * math.cos(re)
function code(re, im) return Float64(sinh(Float64(-im)) * cos(re)) end
function tmp = code(re, im) tmp = sinh(-im) * cos(re); end
code[re_, im_] := N[(N[Sinh[(-im)], $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision]
\sinh \left(-im\right) \cdot \cos re
Initial program 54.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
--rgt-identityN/A
sub-negate-revN/A
lift--.f64N/A
sinh-defN/A
lower-*.f64N/A
lower-sinh.f6499.9%
lift--.f64N/A
sub0-negN/A
lower-neg.f6499.9%
Applied rewrites99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0
(*
(* 0.5 (cos re))
(- (exp (- 0.0 (fabs im))) (exp (fabs im))))))
(*
(copysign 1.0 im)
(if (<= t_0 -0.005)
(* (sinh (- (fabs im))) 1.0)
(if (<= t_0 1.0)
(* (- (cos re)) (fabs im))
(- (* 0.5 (* (fabs im) (pow re 2.0))) (fabs im)))))))double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)));
double tmp;
if (t_0 <= -0.005) {
tmp = sinh(-fabs(im)) * 1.0;
} else if (t_0 <= 1.0) {
tmp = -cos(re) * fabs(im);
} else {
tmp = (0.5 * (fabs(im) * pow(re, 2.0))) - fabs(im);
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = (0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)));
double tmp;
if (t_0 <= -0.005) {
tmp = Math.sinh(-Math.abs(im)) * 1.0;
} else if (t_0 <= 1.0) {
tmp = -Math.cos(re) * Math.abs(im);
} else {
tmp = (0.5 * (Math.abs(im) * Math.pow(re, 2.0))) - Math.abs(im);
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = (0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im))) tmp = 0 if t_0 <= -0.005: tmp = math.sinh(-math.fabs(im)) * 1.0 elif t_0 <= 1.0: tmp = -math.cos(re) * math.fabs(im) else: tmp = (0.5 * (math.fabs(im) * math.pow(re, 2.0))) - math.fabs(im) return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im)))) tmp = 0.0 if (t_0 <= -0.005) tmp = Float64(sinh(Float64(-abs(im))) * 1.0); elseif (t_0 <= 1.0) tmp = Float64(Float64(-cos(re)) * abs(im)); else tmp = Float64(Float64(0.5 * Float64(abs(im) * (re ^ 2.0))) - abs(im)); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = (0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im))); tmp = 0.0; if (t_0 <= -0.005) tmp = sinh(-abs(im)) * 1.0; elseif (t_0 <= 1.0) tmp = -cos(re) * abs(im); else tmp = (0.5 * (abs(im) * (re ^ 2.0))) - abs(im); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$0, -0.005], N[(N[Sinh[(-N[Abs[im], $MachinePrecision])], $MachinePrecision] * 1.0), $MachinePrecision], If[LessEqual[t$95$0, 1.0], N[((-N[Cos[re], $MachinePrecision]) * N[Abs[im], $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[(N[Abs[im], $MachinePrecision] * N[Power[re, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Abs[im], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right)\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -0.005:\\
\;\;\;\;\sinh \left(-\left|im\right|\right) \cdot 1\\
\mathbf{elif}\;t\_0 \leq 1:\\
\;\;\;\;\left(-\cos re\right) \cdot \left|im\right|\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left|im\right| \cdot {re}^{2}\right) - \left|im\right|\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0050000000000000001Initial program 54.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
--rgt-identityN/A
sub-negate-revN/A
lift--.f64N/A
sinh-defN/A
lower-*.f64N/A
lower-sinh.f6499.9%
lift--.f64N/A
sub0-negN/A
lower-neg.f6499.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.1%
if -0.0050000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6452.5%
Applied rewrites52.5%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6452.5%
Applied rewrites52.5%
if 1 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6452.5%
Applied rewrites52.5%
Taylor expanded in re around 0
Applied rewrites29.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6429.5%
Applied rewrites29.5%
Taylor expanded in re around 0
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6435.7%
Applied rewrites35.7%
(FPCore (re im)
:precision binary64
(*
(copysign 1.0 im)
(if (<=
(* (* 0.5 (cos re)) (- (exp (- 0.0 (fabs im))) (exp (fabs im))))
-0.005)
(* (sinh (- (fabs im))) 1.0)
(*
(* (cos re) 0.5)
(*
(- (* (* (fabs im) (fabs im)) -0.3333333333333333) 2.0)
(fabs im))))))double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)))) <= -0.005) {
tmp = sinh(-fabs(im)) * 1.0;
} else {
tmp = (cos(re) * 0.5) * ((((fabs(im) * fabs(im)) * -0.3333333333333333) - 2.0) * fabs(im));
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)))) <= -0.005) {
tmp = Math.sinh(-Math.abs(im)) * 1.0;
} else {
tmp = (Math.cos(re) * 0.5) * ((((Math.abs(im) * Math.abs(im)) * -0.3333333333333333) - 2.0) * Math.abs(im));
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im)))) <= -0.005: tmp = math.sinh(-math.fabs(im)) * 1.0 else: tmp = (math.cos(re) * 0.5) * ((((math.fabs(im) * math.fabs(im)) * -0.3333333333333333) - 2.0) * math.fabs(im)) return math.copysign(1.0, im) * tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im)))) <= -0.005) tmp = Float64(sinh(Float64(-abs(im))) * 1.0); else tmp = Float64(Float64(cos(re) * 0.5) * Float64(Float64(Float64(Float64(abs(im) * abs(im)) * -0.3333333333333333) - 2.0) * abs(im))); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im)))) <= -0.005) tmp = sinh(-abs(im)) * 1.0; else tmp = (cos(re) * 0.5) * ((((abs(im) * abs(im)) * -0.3333333333333333) - 2.0) * abs(im)); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.005], N[(N[Sinh[(-N[Abs[im], $MachinePrecision])], $MachinePrecision] * 1.0), $MachinePrecision], N[(N[(N[Cos[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 2.0), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right) \leq -0.005:\\
\;\;\;\;\sinh \left(-\left|im\right|\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\left(\cos re \cdot 0.5\right) \cdot \left(\left(\left(\left|im\right| \cdot \left|im\right|\right) \cdot -0.3333333333333333 - 2\right) \cdot \left|im\right|\right)\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0050000000000000001Initial program 54.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
--rgt-identityN/A
sub-negate-revN/A
lift--.f64N/A
sinh-defN/A
lower-*.f64N/A
lower-sinh.f6499.9%
lift--.f64N/A
sub0-negN/A
lower-neg.f6499.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.1%
if -0.0050000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6484.5%
Applied rewrites84.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6484.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6484.5%
Applied rewrites84.5%
(FPCore (re im)
:precision binary64
(*
(copysign 1.0 im)
(if (<=
(* (* 0.5 (cos re)) (- (exp (- 0.0 (fabs im))) (exp (fabs im))))
-0.005)
(* (sinh (- (fabs im))) 1.0)
(* (- (cos re)) (fabs im)))))double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)))) <= -0.005) {
tmp = sinh(-fabs(im)) * 1.0;
} else {
tmp = -cos(re) * fabs(im);
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)))) <= -0.005) {
tmp = Math.sinh(-Math.abs(im)) * 1.0;
} else {
tmp = -Math.cos(re) * Math.abs(im);
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im)))) <= -0.005: tmp = math.sinh(-math.fabs(im)) * 1.0 else: tmp = -math.cos(re) * math.fabs(im) return math.copysign(1.0, im) * tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im)))) <= -0.005) tmp = Float64(sinh(Float64(-abs(im))) * 1.0); else tmp = Float64(Float64(-cos(re)) * abs(im)); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im)))) <= -0.005) tmp = sinh(-abs(im)) * 1.0; else tmp = -cos(re) * abs(im); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[(N[(0.5 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.005], N[(N[Sinh[(-N[Abs[im], $MachinePrecision])], $MachinePrecision] * 1.0), $MachinePrecision], N[((-N[Cos[re], $MachinePrecision]) * N[Abs[im], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right) \leq -0.005:\\
\;\;\;\;\sinh \left(-\left|im\right|\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\left(-\cos re\right) \cdot \left|im\right|\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0050000000000000001Initial program 54.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
--rgt-identityN/A
sub-negate-revN/A
lift--.f64N/A
sinh-defN/A
lower-*.f64N/A
lower-sinh.f6499.9%
lift--.f64N/A
sub0-negN/A
lower-neg.f6499.9%
Applied rewrites99.9%
Taylor expanded in re around 0
Applied rewrites65.1%
if -0.0050000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6452.5%
Applied rewrites52.5%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6452.5%
Applied rewrites52.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.3333333333333333 (* (fabs im) (fabs im))))
(t_1 (- 1.0 t_0)))
(*
(copysign 1.0 im)
(if (<=
(*
(* 0.5 (cos re))
(- (exp (- 0.0 (fabs im))) (exp (fabs im))))
-0.005)
(* 0.5 (* (fabs im) (- (/ (* t_1 t_1) t_0) (/ 1.0 t_0))))
(* (- (cos re)) (fabs im))))))double code(double re, double im) {
double t_0 = -0.3333333333333333 * (fabs(im) * fabs(im));
double t_1 = 1.0 - t_0;
double tmp;
if (((0.5 * cos(re)) * (exp((0.0 - fabs(im))) - exp(fabs(im)))) <= -0.005) {
tmp = 0.5 * (fabs(im) * (((t_1 * t_1) / t_0) - (1.0 / t_0)));
} else {
tmp = -cos(re) * fabs(im);
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = -0.3333333333333333 * (Math.abs(im) * Math.abs(im));
double t_1 = 1.0 - t_0;
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp((0.0 - Math.abs(im))) - Math.exp(Math.abs(im)))) <= -0.005) {
tmp = 0.5 * (Math.abs(im) * (((t_1 * t_1) / t_0) - (1.0 / t_0)));
} else {
tmp = -Math.cos(re) * Math.abs(im);
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = -0.3333333333333333 * (math.fabs(im) * math.fabs(im)) t_1 = 1.0 - t_0 tmp = 0 if ((0.5 * math.cos(re)) * (math.exp((0.0 - math.fabs(im))) - math.exp(math.fabs(im)))) <= -0.005: tmp = 0.5 * (math.fabs(im) * (((t_1 * t_1) / t_0) - (1.0 / t_0))) else: tmp = -math.cos(re) * math.fabs(im) return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(-0.3333333333333333 * Float64(abs(im) * abs(im))) t_1 = Float64(1.0 - t_0) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(0.0 - abs(im))) - exp(abs(im)))) <= -0.005) tmp = Float64(0.5 * Float64(abs(im) * Float64(Float64(Float64(t_1 * t_1) / t_0) - Float64(1.0 / t_0)))); else tmp = Float64(Float64(-cos(re)) * abs(im)); end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = -0.3333333333333333 * (abs(im) * abs(im)); t_1 = 1.0 - t_0; tmp = 0.0; if (((0.5 * cos(re)) * (exp((0.0 - abs(im))) - exp(abs(im)))) <= -0.005) tmp = 0.5 * (abs(im) * (((t_1 * t_1) / t_0) - (1.0 / t_0))); else tmp = -cos(re) * abs(im); end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.3333333333333333 * N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $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[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - N[Abs[im], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.005], N[(0.5 * N[(N[Abs[im], $MachinePrecision] * N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision] - N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[Cos[re], $MachinePrecision]) * N[Abs[im], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := -0.3333333333333333 \cdot \left(\left|im\right| \cdot \left|im\right|\right)\\
t_1 := 1 - t\_0\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - \left|im\right|} - e^{\left|im\right|}\right) \leq -0.005:\\
\;\;\;\;0.5 \cdot \left(\left|im\right| \cdot \left(\frac{t\_1 \cdot t\_1}{t\_0} - \frac{1}{t\_0}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-\cos re\right) \cdot \left|im\right|\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0050000000000000001Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6484.5%
Applied rewrites84.5%
lift--.f64N/A
metadata-evalN/A
associate--r+N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites13.8%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
metadata-evalN/A
div-subN/A
lower--.f64N/A
Applied rewrites14.5%
Taylor expanded in re around 0
Applied rewrites11.0%
if -0.0050000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (-.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6452.5%
Applied rewrites52.5%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f6452.5%
Applied rewrites52.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.3333333333333333 (* (fabs im) (fabs im))))
(t_1 (- 1.0 t_0))
(t_2 (- (fabs im))))
(*
(copysign 1.0 im)
(if (<= (fabs im) 8.2e-10)
t_2
(if (<= (fabs im) 1.35e+154)
(* 0.5 (* (fabs im) (- (/ (* t_1 t_1) t_0) (/ 1.0 t_0))))
t_2)))))double code(double re, double im) {
double t_0 = -0.3333333333333333 * (fabs(im) * fabs(im));
double t_1 = 1.0 - t_0;
double t_2 = -fabs(im);
double tmp;
if (fabs(im) <= 8.2e-10) {
tmp = t_2;
} else if (fabs(im) <= 1.35e+154) {
tmp = 0.5 * (fabs(im) * (((t_1 * t_1) / t_0) - (1.0 / t_0)));
} else {
tmp = t_2;
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = -0.3333333333333333 * (Math.abs(im) * Math.abs(im));
double t_1 = 1.0 - t_0;
double t_2 = -Math.abs(im);
double tmp;
if (Math.abs(im) <= 8.2e-10) {
tmp = t_2;
} else if (Math.abs(im) <= 1.35e+154) {
tmp = 0.5 * (Math.abs(im) * (((t_1 * t_1) / t_0) - (1.0 / t_0)));
} else {
tmp = t_2;
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = -0.3333333333333333 * (math.fabs(im) * math.fabs(im)) t_1 = 1.0 - t_0 t_2 = -math.fabs(im) tmp = 0 if math.fabs(im) <= 8.2e-10: tmp = t_2 elif math.fabs(im) <= 1.35e+154: tmp = 0.5 * (math.fabs(im) * (((t_1 * t_1) / t_0) - (1.0 / t_0))) else: tmp = t_2 return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(-0.3333333333333333 * Float64(abs(im) * abs(im))) t_1 = Float64(1.0 - t_0) t_2 = Float64(-abs(im)) tmp = 0.0 if (abs(im) <= 8.2e-10) tmp = t_2; elseif (abs(im) <= 1.35e+154) tmp = Float64(0.5 * Float64(abs(im) * Float64(Float64(Float64(t_1 * t_1) / t_0) - Float64(1.0 / t_0)))); else tmp = t_2; end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = -0.3333333333333333 * (abs(im) * abs(im)); t_1 = 1.0 - t_0; t_2 = -abs(im); tmp = 0.0; if (abs(im) <= 8.2e-10) tmp = t_2; elseif (abs(im) <= 1.35e+154) tmp = 0.5 * (abs(im) * (((t_1 * t_1) / t_0) - (1.0 / t_0))); else tmp = t_2; end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.3333333333333333 * N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = (-N[Abs[im], $MachinePrecision])}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[im], $MachinePrecision], 8.2e-10], t$95$2, If[LessEqual[N[Abs[im], $MachinePrecision], 1.35e+154], N[(0.5 * N[(N[Abs[im], $MachinePrecision] * N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] / t$95$0), $MachinePrecision] - N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := -0.3333333333333333 \cdot \left(\left|im\right| \cdot \left|im\right|\right)\\
t_1 := 1 - t\_0\\
t_2 := -\left|im\right|\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|im\right| \leq 8.2 \cdot 10^{-10}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\left|im\right| \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(\left|im\right| \cdot \left(\frac{t\_1 \cdot t\_1}{t\_0} - \frac{1}{t\_0}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if im < 8.1999999999999996e-10 or 1.35e154 < im Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6452.5%
Applied rewrites52.5%
Taylor expanded in re around 0
Applied rewrites29.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6429.5%
Applied rewrites29.5%
if 8.1999999999999996e-10 < im < 1.35e154Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6484.5%
Applied rewrites84.5%
lift--.f64N/A
metadata-evalN/A
associate--r+N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites13.8%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
metadata-evalN/A
div-subN/A
lower--.f64N/A
Applied rewrites14.5%
Taylor expanded in re around 0
Applied rewrites11.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (* (* (fabs im) (fabs im)) -0.3333333333333333) 1.0))
(t_1 (- (fabs im))))
(*
(copysign 1.0 im)
(if (<= (fabs im) 4e-7)
t_1
(if (<= (fabs im) 1.35e+154)
(*
0.5
(* (fabs im) (/ (- (* t_0 t_0) (* 1.0 1.0)) (+ t_0 1.0))))
t_1)))))double code(double re, double im) {
double t_0 = ((fabs(im) * fabs(im)) * -0.3333333333333333) - 1.0;
double t_1 = -fabs(im);
double tmp;
if (fabs(im) <= 4e-7) {
tmp = t_1;
} else if (fabs(im) <= 1.35e+154) {
tmp = 0.5 * (fabs(im) * (((t_0 * t_0) - (1.0 * 1.0)) / (t_0 + 1.0)));
} else {
tmp = t_1;
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = ((Math.abs(im) * Math.abs(im)) * -0.3333333333333333) - 1.0;
double t_1 = -Math.abs(im);
double tmp;
if (Math.abs(im) <= 4e-7) {
tmp = t_1;
} else if (Math.abs(im) <= 1.35e+154) {
tmp = 0.5 * (Math.abs(im) * (((t_0 * t_0) - (1.0 * 1.0)) / (t_0 + 1.0)));
} else {
tmp = t_1;
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = ((math.fabs(im) * math.fabs(im)) * -0.3333333333333333) - 1.0 t_1 = -math.fabs(im) tmp = 0 if math.fabs(im) <= 4e-7: tmp = t_1 elif math.fabs(im) <= 1.35e+154: tmp = 0.5 * (math.fabs(im) * (((t_0 * t_0) - (1.0 * 1.0)) / (t_0 + 1.0))) else: tmp = t_1 return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(Float64(Float64(abs(im) * abs(im)) * -0.3333333333333333) - 1.0) t_1 = Float64(-abs(im)) tmp = 0.0 if (abs(im) <= 4e-7) tmp = t_1; elseif (abs(im) <= 1.35e+154) tmp = Float64(0.5 * Float64(abs(im) * Float64(Float64(Float64(t_0 * t_0) - Float64(1.0 * 1.0)) / Float64(t_0 + 1.0)))); else tmp = t_1; end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = ((abs(im) * abs(im)) * -0.3333333333333333) - 1.0; t_1 = -abs(im); tmp = 0.0; if (abs(im) <= 4e-7) tmp = t_1; elseif (abs(im) <= 1.35e+154) tmp = 0.5 * (abs(im) * (((t_0 * t_0) - (1.0 * 1.0)) / (t_0 + 1.0))); else tmp = t_1; end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] - 1.0), $MachinePrecision]}, Block[{t$95$1 = (-N[Abs[im], $MachinePrecision])}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[im], $MachinePrecision], 4e-7], t$95$1, If[LessEqual[N[Abs[im], $MachinePrecision], 1.35e+154], N[(0.5 * N[(N[Abs[im], $MachinePrecision] * N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(1.0 * 1.0), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left|im\right| \cdot \left|im\right|\right) \cdot -0.3333333333333333 - 1\\
t_1 := -\left|im\right|\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|im\right| \leq 4 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\left|im\right| \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(\left|im\right| \cdot \frac{t\_0 \cdot t\_0 - 1 \cdot 1}{t\_0 + 1}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if im < 3.9999999999999998e-7 or 1.35e154 < im Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6452.5%
Applied rewrites52.5%
Taylor expanded in re around 0
Applied rewrites29.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6429.5%
Applied rewrites29.5%
if 3.9999999999999998e-7 < im < 1.35e154Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6484.5%
Applied rewrites84.5%
lift--.f64N/A
metadata-evalN/A
associate--r+N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites13.8%
Taylor expanded in re around 0
Applied rewrites10.2%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.3333333333333333 (* (fabs im) (fabs im))))
(t_1 (- (fabs im))))
(*
(copysign 1.0 im)
(if (<= (fabs im) 5e-12)
t_1
(if (<= (fabs im) 1.35e+154)
(* 0.5 (* (* (- t_0 2.0) t_0) (* (/ 1.0 t_0) (fabs im))))
t_1)))))double code(double re, double im) {
double t_0 = -0.3333333333333333 * (fabs(im) * fabs(im));
double t_1 = -fabs(im);
double tmp;
if (fabs(im) <= 5e-12) {
tmp = t_1;
} else if (fabs(im) <= 1.35e+154) {
tmp = 0.5 * (((t_0 - 2.0) * t_0) * ((1.0 / t_0) * fabs(im)));
} else {
tmp = t_1;
}
return copysign(1.0, im) * tmp;
}
public static double code(double re, double im) {
double t_0 = -0.3333333333333333 * (Math.abs(im) * Math.abs(im));
double t_1 = -Math.abs(im);
double tmp;
if (Math.abs(im) <= 5e-12) {
tmp = t_1;
} else if (Math.abs(im) <= 1.35e+154) {
tmp = 0.5 * (((t_0 - 2.0) * t_0) * ((1.0 / t_0) * Math.abs(im)));
} else {
tmp = t_1;
}
return Math.copySign(1.0, im) * tmp;
}
def code(re, im): t_0 = -0.3333333333333333 * (math.fabs(im) * math.fabs(im)) t_1 = -math.fabs(im) tmp = 0 if math.fabs(im) <= 5e-12: tmp = t_1 elif math.fabs(im) <= 1.35e+154: tmp = 0.5 * (((t_0 - 2.0) * t_0) * ((1.0 / t_0) * math.fabs(im))) else: tmp = t_1 return math.copysign(1.0, im) * tmp
function code(re, im) t_0 = Float64(-0.3333333333333333 * Float64(abs(im) * abs(im))) t_1 = Float64(-abs(im)) tmp = 0.0 if (abs(im) <= 5e-12) tmp = t_1; elseif (abs(im) <= 1.35e+154) tmp = Float64(0.5 * Float64(Float64(Float64(t_0 - 2.0) * t_0) * Float64(Float64(1.0 / t_0) * abs(im)))); else tmp = t_1; end return Float64(copysign(1.0, im) * tmp) end
function tmp_2 = code(re, im) t_0 = -0.3333333333333333 * (abs(im) * abs(im)); t_1 = -abs(im); tmp = 0.0; if (abs(im) <= 5e-12) tmp = t_1; elseif (abs(im) <= 1.35e+154) tmp = 0.5 * (((t_0 - 2.0) * t_0) * ((1.0 / t_0) * abs(im))); else tmp = t_1; end tmp_2 = (sign(im) * abs(1.0)) * tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.3333333333333333 * N[(N[Abs[im], $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = (-N[Abs[im], $MachinePrecision])}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[im]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[im], $MachinePrecision], 5e-12], t$95$1, If[LessEqual[N[Abs[im], $MachinePrecision], 1.35e+154], N[(0.5 * N[(N[(N[(t$95$0 - 2.0), $MachinePrecision] * t$95$0), $MachinePrecision] * N[(N[(1.0 / t$95$0), $MachinePrecision] * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := -0.3333333333333333 \cdot \left(\left|im\right| \cdot \left|im\right|\right)\\
t_1 := -\left|im\right|\\
\mathsf{copysign}\left(1, im\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|im\right| \leq 5 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\left|im\right| \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;0.5 \cdot \left(\left(\left(t\_0 - 2\right) \cdot t\_0\right) \cdot \left(\frac{1}{t\_0} \cdot \left|im\right|\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if im < 4.9999999999999997e-12 or 1.35e154 < im Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6452.5%
Applied rewrites52.5%
Taylor expanded in re around 0
Applied rewrites29.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6429.5%
Applied rewrites29.5%
if 4.9999999999999997e-12 < im < 1.35e154Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6484.5%
Applied rewrites84.5%
lift--.f64N/A
metadata-evalN/A
associate--r+N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites13.8%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
associate-*l*N/A
lower-*.f64N/A
Applied rewrites37.8%
Taylor expanded in re around 0
Applied rewrites23.3%
(FPCore (re im) :precision binary64 (- im))
double code(double re, double im) {
return -im;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -im
end function
public static double code(double re, double im) {
return -im;
}
def code(re, im): return -im
function code(re, im) return Float64(-im) end
function tmp = code(re, im) tmp = -im; end
code[re_, im_] := (-im)
-im
Initial program 54.0%
Taylor expanded in im around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f6452.5%
Applied rewrites52.5%
Taylor expanded in re around 0
Applied rewrites29.5%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6429.5%
Applied rewrites29.5%
herbie shell --seed 2025258
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))