
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(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 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(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 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
(FPCore (re im) :precision binary64 (* (sin re) (cosh im)))
double code(double re, double im) {
return sin(re) * cosh(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 = sin(re) * cosh(im)
end function
public static double code(double re, double im) {
return Math.sin(re) * Math.cosh(im);
}
def code(re, im): return math.sin(re) * math.cosh(im)
function code(re, im) return Float64(sin(re) * cosh(im)) end
function tmp = code(re, im) tmp = sin(re) * cosh(im); end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[Cosh[im], $MachinePrecision]), $MachinePrecision]
\sin re \cdot \cosh im
Initial program 100.0%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift--.f64N/A
sub0-negN/A
cosh-defN/A
lower-*.f64N/A
lower-cosh.f64100.0%
Applied rewrites100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (sin (fabs re)))
(t_1 (* (* 0.5 t_0) (+ (exp (- 0.0 im)) (exp im)))))
(*
(copysign 1.0 re)
(if (<= t_1 (- INFINITY))
(*
(+ (exp im) (exp (- im)))
(*
(fma (* (fabs re) (fabs re)) -0.08333333333333333 0.5)
(fabs re)))
(if (<= t_1 1.0) t_0 (* (cosh im) (fabs re)))))))double code(double re, double im) {
double t_0 = sin(fabs(re));
double t_1 = (0.5 * t_0) * (exp((0.0 - im)) + exp(im));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (exp(im) + exp(-im)) * (fma((fabs(re) * fabs(re)), -0.08333333333333333, 0.5) * fabs(re));
} else if (t_1 <= 1.0) {
tmp = t_0;
} else {
tmp = cosh(im) * fabs(re);
}
return copysign(1.0, re) * tmp;
}
function code(re, im) t_0 = sin(abs(re)) t_1 = Float64(Float64(0.5 * t_0) * Float64(exp(Float64(0.0 - im)) + exp(im))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(fma(Float64(abs(re) * abs(re)), -0.08333333333333333, 0.5) * abs(re))); elseif (t_1 <= 1.0) tmp = t_0; else tmp = Float64(cosh(im) * abs(re)); end return Float64(copysign(1.0, re) * tmp) end
code[re_, im_] := Block[{t$95$0 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 * t$95$0), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.0], t$95$0, N[(N[Cosh[im], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\left|re\right|\right)\\
t_1 := \left(0.5 \cdot t\_0\right) \cdot \left(e^{0 - im} + e^{im}\right)\\
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(\mathsf{fma}\left(\left|re\right| \cdot \left|re\right|, -0.08333333333333333, 0.5\right) \cdot \left|re\right|\right)\\
\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot \left|re\right|\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites50.5%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.3%
Applied rewrites34.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6434.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6434.3%
Applied rewrites34.3%
Taylor expanded in im around inf
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6462.7%
Applied rewrites62.7%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6463.2%
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-exp.f64N/A
exp-negN/A
distribute-lft-inN/A
lift-exp.f64N/A
cosh-undefN/A
lift-cosh.f64N/A
associate-*r*N/A
lower-*.f64N/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
*-lft-identityN/A
lower-+.f6463.2%
Applied rewrites63.2%
Taylor expanded in im around 0
lower-sin.f6450.5%
Applied rewrites50.5%
if 1 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-+.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
mult-flip-revN/A
metadata-evalN/A
mult-flip-revN/A
div-addN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lift-cosh.f64N/A
lower-*.f6463.3%
Applied rewrites63.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (sin (fabs re)))
(t_1 (* (* 0.5 t_0) (+ (exp (- 0.0 im)) (exp im)))))
(*
(copysign 1.0 re)
(if (<= t_1 (- INFINITY))
(*
(+ 2.0 (pow im 2.0))
(*
(fma (* (fabs re) (fabs re)) -0.08333333333333333 0.5)
(fabs re)))
(if (<= t_1 1.0) t_0 (* (cosh im) (fabs re)))))))double code(double re, double im) {
double t_0 = sin(fabs(re));
double t_1 = (0.5 * t_0) * (exp((0.0 - im)) + exp(im));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = (2.0 + pow(im, 2.0)) * (fma((fabs(re) * fabs(re)), -0.08333333333333333, 0.5) * fabs(re));
} else if (t_1 <= 1.0) {
tmp = t_0;
} else {
tmp = cosh(im) * fabs(re);
}
return copysign(1.0, re) * tmp;
}
function code(re, im) t_0 = sin(abs(re)) t_1 = Float64(Float64(0.5 * t_0) * Float64(exp(Float64(0.0 - im)) + exp(im))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(2.0 + (im ^ 2.0)) * Float64(fma(Float64(abs(re) * abs(re)), -0.08333333333333333, 0.5) * abs(re))); elseif (t_1 <= 1.0) tmp = t_0; else tmp = Float64(cosh(im) * abs(re)); end return Float64(copysign(1.0, re) * tmp) end
code[re_, im_] := Block[{t$95$0 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 * t$95$0), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, (-Infinity)], N[(N[(2.0 + N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.0], t$95$0, N[(N[Cosh[im], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\left|re\right|\right)\\
t_1 := \left(0.5 \cdot t\_0\right) \cdot \left(e^{0 - im} + e^{im}\right)\\
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(2 + {im}^{2}\right) \cdot \left(\mathsf{fma}\left(\left|re\right| \cdot \left|re\right|, -0.08333333333333333, 0.5\right) \cdot \left|re\right|\right)\\
\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot \left|re\right|\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites50.5%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.3%
Applied rewrites34.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6434.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6434.3%
Applied rewrites34.3%
Taylor expanded in im around 0
lower-+.f64N/A
lower-pow.f6449.7%
Applied rewrites49.7%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6463.2%
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-exp.f64N/A
exp-negN/A
distribute-lft-inN/A
lift-exp.f64N/A
cosh-undefN/A
lift-cosh.f64N/A
associate-*r*N/A
lower-*.f64N/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
*-lft-identityN/A
lower-+.f6463.2%
Applied rewrites63.2%
Taylor expanded in im around 0
lower-sin.f6450.5%
Applied rewrites50.5%
if 1 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-+.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
mult-flip-revN/A
metadata-evalN/A
mult-flip-revN/A
div-addN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lift-cosh.f64N/A
lower-*.f6463.3%
Applied rewrites63.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (sin (fabs re)))
(t_1 (* (* 0.5 t_0) (+ (exp (- 0.0 im)) (exp im))))
(t_2 (* (fabs re) (fabs re))))
(*
(copysign 1.0 re)
(if (<= t_1 (- INFINITY))
(*
2.0
(* (fma (sqrt (* t_2 t_2)) -0.08333333333333333 0.5) (fabs re)))
(if (<= t_1 1.0) t_0 (* (cosh im) (fabs re)))))))double code(double re, double im) {
double t_0 = sin(fabs(re));
double t_1 = (0.5 * t_0) * (exp((0.0 - im)) + exp(im));
double t_2 = fabs(re) * fabs(re);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = 2.0 * (fma(sqrt((t_2 * t_2)), -0.08333333333333333, 0.5) * fabs(re));
} else if (t_1 <= 1.0) {
tmp = t_0;
} else {
tmp = cosh(im) * fabs(re);
}
return copysign(1.0, re) * tmp;
}
function code(re, im) t_0 = sin(abs(re)) t_1 = Float64(Float64(0.5 * t_0) * Float64(exp(Float64(0.0 - im)) + exp(im))) t_2 = Float64(abs(re) * abs(re)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(2.0 * Float64(fma(sqrt(Float64(t_2 * t_2)), -0.08333333333333333, 0.5) * abs(re))); elseif (t_1 <= 1.0) tmp = t_0; else tmp = Float64(cosh(im) * abs(re)); end return Float64(copysign(1.0, re) * tmp) end
code[re_, im_] := Block[{t$95$0 = N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(0.5 * t$95$0), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Abs[re], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[re]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$1, (-Infinity)], N[(2.0 * N[(N[(N[Sqrt[N[(t$95$2 * t$95$2), $MachinePrecision]], $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1.0], t$95$0, N[(N[Cosh[im], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \sin \left(\left|re\right|\right)\\
t_1 := \left(0.5 \cdot t\_0\right) \cdot \left(e^{0 - im} + e^{im}\right)\\
t_2 := \left|re\right| \cdot \left|re\right|\\
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(\sqrt{t\_2 \cdot t\_2}, -0.08333333333333333, 0.5\right) \cdot \left|re\right|\right)\\
\mathbf{elif}\;t\_1 \leq 1:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot \left|re\right|\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -inf.0Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites50.5%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.3%
Applied rewrites34.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6434.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6434.3%
Applied rewrites34.3%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.1%
Applied rewrites35.1%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 1Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
lift-+.f64N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
exp-negN/A
lift-exp.f64N/A
mult-flip-revN/A
lower-/.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
mult-flip-revN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6463.2%
lift-fma.f64N/A
*-commutativeN/A
lift-/.f64N/A
mult-flipN/A
lift-exp.f64N/A
exp-negN/A
distribute-lft-inN/A
lift-exp.f64N/A
cosh-undefN/A
lift-cosh.f64N/A
associate-*r*N/A
lower-*.f64N/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
*-lft-identityN/A
lower-+.f6463.2%
Applied rewrites63.2%
Taylor expanded in im around 0
lower-sin.f6450.5%
Applied rewrites50.5%
if 1 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-+.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
mult-flip-revN/A
metadata-evalN/A
mult-flip-revN/A
div-addN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lift-cosh.f64N/A
lower-*.f6463.3%
Applied rewrites63.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (fabs re) (fabs re))))
(*
(copysign 1.0 re)
(if (<=
(* (* 0.5 (sin (fabs re))) (+ (exp (- 0.0 im)) (exp im)))
-0.005)
(*
2.0
(* (fma (sqrt (* t_0 t_0)) -0.08333333333333333 0.5) (fabs re)))
(* (cosh im) (fabs re))))))double code(double re, double im) {
double t_0 = fabs(re) * fabs(re);
double tmp;
if (((0.5 * sin(fabs(re))) * (exp((0.0 - im)) + exp(im))) <= -0.005) {
tmp = 2.0 * (fma(sqrt((t_0 * t_0)), -0.08333333333333333, 0.5) * fabs(re));
} else {
tmp = cosh(im) * fabs(re);
}
return copysign(1.0, re) * tmp;
}
function code(re, im) t_0 = Float64(abs(re) * abs(re)) tmp = 0.0 if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(Float64(0.0 - im)) + exp(im))) <= -0.005) tmp = Float64(2.0 * Float64(fma(sqrt(Float64(t_0 * t_0)), -0.08333333333333333, 0.5) * abs(re))); else tmp = Float64(cosh(im) * abs(re)); end return Float64(copysign(1.0, re) * tmp) end
code[re_, im_] := Block[{t$95$0 = N[(N[Abs[re], $MachinePrecision] * 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[(N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.005], N[(2.0 * N[(N[(N[Sqrt[N[(t$95$0 * t$95$0), $MachinePrecision]], $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cosh[im], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|re\right| \cdot \left|re\right|\\
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{0 - im} + e^{im}\right) \leq -0.005:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(\sqrt{t\_0 \cdot t\_0}, -0.08333333333333333, 0.5\right) \cdot \left|re\right|\right)\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot \left|re\right|\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0050000000000000001Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites50.5%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.3%
Applied rewrites34.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6434.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6434.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6434.3%
Applied rewrites34.3%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.1%
Applied rewrites35.1%
if -0.0050000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-+.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
mult-flip-revN/A
metadata-evalN/A
mult-flip-revN/A
div-addN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lift-cosh.f64N/A
lower-*.f6463.3%
Applied rewrites63.3%
(FPCore (re im)
:precision binary64
(*
(copysign 1.0 re)
(if (<=
(* (* 0.5 (sin (fabs re))) (+ (exp (- 0.0 im)) (exp im)))
-0.005)
(*
(*
(fabs re)
(fma (* -0.08333333333333333 (fabs re)) (fabs re) 0.5))
2.0)
(* (cosh im) (fabs re)))))double code(double re, double im) {
double tmp;
if (((0.5 * sin(fabs(re))) * (exp((0.0 - im)) + exp(im))) <= -0.005) {
tmp = (fabs(re) * fma((-0.08333333333333333 * fabs(re)), fabs(re), 0.5)) * 2.0;
} else {
tmp = cosh(im) * fabs(re);
}
return copysign(1.0, re) * tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(Float64(0.0 - im)) + exp(im))) <= -0.005) tmp = Float64(Float64(abs(re) * fma(Float64(-0.08333333333333333 * abs(re)), abs(re), 0.5)) * 2.0); else tmp = Float64(cosh(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[(N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -0.005], N[(N[(N[Abs[re], $MachinePrecision] * N[(N[(-0.08333333333333333 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], N[(N[Cosh[im], $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{0 - im} + e^{im}\right) \leq -0.005:\\
\;\;\;\;\left(\left|re\right| \cdot \mathsf{fma}\left(-0.08333333333333333 \cdot \left|re\right|, \left|re\right|, 0.5\right)\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot \left|re\right|\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < -0.0050000000000000001Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites50.5%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.3%
Applied rewrites34.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6434.3%
Applied rewrites34.3%
if -0.0050000000000000001 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lift-+.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
mult-flip-revN/A
metadata-evalN/A
mult-flip-revN/A
div-addN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lift-cosh.f64N/A
lower-*.f6463.3%
Applied rewrites63.3%
(FPCore (re im)
:precision binary64
(*
(copysign 1.0 re)
(if (<=
(* (* 0.5 (sin (fabs re))) (+ (exp (- 0.0 im)) (exp im)))
0.0004)
(*
(*
(fabs re)
(fma (* -0.08333333333333333 (fabs re)) (fabs re) 0.5))
2.0)
(* (fma (* im im) 0.5 1.0) (fabs re)))))double code(double re, double im) {
double tmp;
if (((0.5 * sin(fabs(re))) * (exp((0.0 - im)) + exp(im))) <= 0.0004) {
tmp = (fabs(re) * fma((-0.08333333333333333 * fabs(re)), fabs(re), 0.5)) * 2.0;
} else {
tmp = fma((im * im), 0.5, 1.0) * fabs(re);
}
return copysign(1.0, re) * tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * sin(abs(re))) * Float64(exp(Float64(0.0 - im)) + exp(im))) <= 0.0004) tmp = Float64(Float64(abs(re) * fma(Float64(-0.08333333333333333 * abs(re)), abs(re), 0.5)) * 2.0); else tmp = Float64(fma(Float64(im * im), 0.5, 1.0) * 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[(N[(0.5 * N[Sin[N[Abs[re], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0004], N[(N[(N[Abs[re], $MachinePrecision] * N[(N[(-0.08333333333333333 * N[Abs[re], $MachinePrecision]), $MachinePrecision] * N[Abs[re], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision], N[(N[(N[(im * im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * N[Abs[re], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, re\right) \cdot \begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin \left(\left|re\right|\right)\right) \cdot \left(e^{0 - im} + e^{im}\right) \leq 0.0004:\\
\;\;\;\;\left(\left|re\right| \cdot \mathsf{fma}\left(-0.08333333333333333 \cdot \left|re\right|, \left|re\right|, 0.5\right)\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot \left|re\right|\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) < 4.0000000000000002e-4Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites50.5%
Taylor expanded in re around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6434.3%
Applied rewrites34.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6434.3%
Applied rewrites34.3%
if 4.0000000000000002e-4 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (+.f64 (exp.f64 (-.f64 #s(literal 0 binary64) im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6448.3%
Applied rewrites48.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6448.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6448.3%
Applied rewrites48.3%
(FPCore (re im) :precision binary64 (fma (* (* im im) re) 0.5 re))
double code(double re, double im) {
return fma(((im * im) * re), 0.5, re);
}
function code(re, im) return fma(Float64(Float64(im * im) * re), 0.5, re) end
code[re_, im_] := N[(N[(N[(im * im), $MachinePrecision] * re), $MachinePrecision] * 0.5 + re), $MachinePrecision]
\mathsf{fma}\left(\left(im \cdot im\right) \cdot re, 0.5, re\right)
Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6448.3%
Applied rewrites48.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6448.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6448.3%
Applied rewrites48.3%
(FPCore (re im) :precision binary64 (* (fma (* im im) 0.5 1.0) re))
double code(double re, double im) {
return fma((im * im), 0.5, 1.0) * re;
}
function code(re, im) return Float64(fma(Float64(im * im), 0.5, 1.0) * re) end
code[re_, im_] := N[(N[(N[(im * im), $MachinePrecision] * 0.5 + 1.0), $MachinePrecision] * re), $MachinePrecision]
\mathsf{fma}\left(im \cdot im, 0.5, 1\right) \cdot re
Initial program 100.0%
Taylor expanded in re around 0
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-exp.f64N/A
lower-exp.f64N/A
lower-neg.f6463.3%
Applied rewrites63.3%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6448.3%
Applied rewrites48.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f6448.3%
lift-pow.f64N/A
unpow2N/A
lower-*.f6448.3%
Applied rewrites48.3%
(FPCore (re im) :precision binary64 (* (* 0.5 re) 2.0))
double code(double re, double im) {
return (0.5 * re) * 2.0;
}
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 * re) * 2.0d0
end function
public static double code(double re, double im) {
return (0.5 * re) * 2.0;
}
def code(re, im): return (0.5 * re) * 2.0
function code(re, im) return Float64(Float64(0.5 * re) * 2.0) end
function tmp = code(re, im) tmp = (0.5 * re) * 2.0; end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * 2.0), $MachinePrecision]
\left(0.5 \cdot re\right) \cdot 2
Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites50.5%
Taylor expanded in re around 0
lower-*.f6426.6%
Applied rewrites26.6%
herbie shell --seed 2025212
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))