
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) - exp(im));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) - exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) - exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* (sin re) 0.5) (* -2.0 (sinh im))))
double code(double re, double im) {
return (sin(re) * 0.5) * (-2.0 * sinh(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) * 0.5d0) * ((-2.0d0) * sinh(im))
end function
public static double code(double re, double im) {
return (Math.sin(re) * 0.5) * (-2.0 * Math.sinh(im));
}
def code(re, im): return (math.sin(re) * 0.5) * (-2.0 * math.sinh(im))
function code(re, im) return Float64(Float64(sin(re) * 0.5) * Float64(-2.0 * sinh(im))) end
function tmp = code(re, im) tmp = (sin(re) * 0.5) * (-2.0 * sinh(im)); end
code[re_, im_] := N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sin re \cdot 0.5\right) \cdot \left(-2 \cdot \sinh im\right)
\end{array}
Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(* (* (sinh im) (+ re re)) -0.5)
(if (<= t_0 5e+25)
(* (* (sin re) 0.5) (* (fma (* im im) -0.3333333333333333 -2.0) im))
(* (* (* (* re re) -0.08333333333333333) re) (* -2.0 (sinh im)))))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * (exp(-im) - exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (sinh(im) * (re + re)) * -0.5;
} else if (t_0 <= 5e+25) {
tmp = (sin(re) * 0.5) * (fma((im * im), -0.3333333333333333, -2.0) * im);
} else {
tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * sinh(im));
}
return tmp;
}
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(sinh(im) * Float64(re + re)) * -0.5); elseif (t_0 <= 5e+25) tmp = Float64(Float64(sin(re) * 0.5) * Float64(fma(Float64(im * im), -0.3333333333333333, -2.0) * im)); else tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * Float64(-2.0 * sinh(im))); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[Sinh[im], $MachinePrecision] * N[(re + re), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$0, 5e+25], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(N[(im * im), $MachinePrecision] * -0.3333333333333333 + -2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\sinh im \cdot \left(re + re\right)\right) \cdot -0.5\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+25}:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(\mathsf{fma}\left(im \cdot im, -0.3333333333333333, -2\right) \cdot im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(-2 \cdot \sinh im\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -inf.0Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lower-*.f64N/A
lift-sinh.f6462.9
Applied rewrites62.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sinh.f64N/A
count-2-revN/A
lower-+.f6462.9
Applied rewrites62.9%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 5.00000000000000024e25Initial program 65.5%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.8
Applied rewrites83.8%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-*.f6483.8
lift-*.f64N/A
lift-fma.f64N/A
pow2N/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6483.8
Applied rewrites83.8%
if 5.00000000000000024e25 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6425.3
Applied rewrites25.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 0.5 (sin re)) (- (exp (- im)) (exp im)))))
(if (<= t_0 (- INFINITY))
(* (* (sinh im) (+ re re)) -0.5)
(if (<= t_0 5e+25)
(* (- (sin re)) im)
(* (* (* (* re re) -0.08333333333333333) re) (* -2.0 (sinh im)))))))
double code(double re, double im) {
double t_0 = (0.5 * sin(re)) * (exp(-im) - exp(im));
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = (sinh(im) * (re + re)) * -0.5;
} else if (t_0 <= 5e+25) {
tmp = -sin(re) * im;
} else {
tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * sinh(im));
}
return tmp;
}
public static double code(double re, double im) {
double t_0 = (0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im));
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (Math.sinh(im) * (re + re)) * -0.5;
} else if (t_0 <= 5e+25) {
tmp = -Math.sin(re) * im;
} else {
tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * Math.sinh(im));
}
return tmp;
}
def code(re, im): t_0 = (0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im)) tmp = 0 if t_0 <= -math.inf: tmp = (math.sinh(im) * (re + re)) * -0.5 elif t_0 <= 5e+25: tmp = -math.sin(re) * im else: tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * math.sinh(im)) return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(sinh(im) * Float64(re + re)) * -0.5); elseif (t_0 <= 5e+25) tmp = Float64(Float64(-sin(re)) * im); else tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * Float64(-2.0 * sinh(im))); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * sin(re)) * (exp(-im) - exp(im)); tmp = 0.0; if (t_0 <= -Inf) tmp = (sinh(im) * (re + re)) * -0.5; elseif (t_0 <= 5e+25) tmp = -sin(re) * im; else tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * sinh(im)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[Sinh[im], $MachinePrecision] * N[(re + re), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[t$95$0, 5e+25], N[((-N[Sin[re], $MachinePrecision]) * im), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\sinh im \cdot \left(re + re\right)\right) \cdot -0.5\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+25}:\\
\;\;\;\;\left(-\sin re\right) \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(-2 \cdot \sinh im\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -inf.0Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lower-*.f64N/A
lift-sinh.f6462.9
Applied rewrites62.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sinh.f64N/A
count-2-revN/A
lower-+.f6462.9
Applied rewrites62.9%
if -inf.0 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 5.00000000000000024e25Initial program 65.5%
Taylor expanded in im around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
if 5.00000000000000024e25 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6425.3
Applied rewrites25.3%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) 0.0004) (* (* (fma -0.08333333333333333 (* re re) 0.5) re) (* -2.0 (sinh im))) (* (* (- (exp (- im)) (exp im)) re) 0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= 0.0004) {
tmp = (fma(-0.08333333333333333, (re * re), 0.5) * re) * (-2.0 * sinh(im));
} else {
tmp = ((exp(-im) - exp(im)) * re) * 0.5;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 0.0004) tmp = Float64(Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re) * Float64(-2.0 * sinh(im))); else tmp = Float64(Float64(Float64(exp(Float64(-im)) - exp(im)) * re) * 0.5); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 0.0004], N[(N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision] * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq 0.0004:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(-2 \cdot \sinh im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(e^{-im} - e^{im}\right) \cdot re\right) \cdot 0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 4.00000000000000019e-4Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
if 4.00000000000000019e-4 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6462.9
Applied rewrites62.9%
lift-neg.f64N/A
lift-sinh.f64N/A
lower-*.f64N/A
sinh-undef-revN/A
rec-expN/A
sub-negate-revN/A
lower--.f64N/A
rec-expN/A
mul-1-negN/A
lower-exp.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-exp.f6452.0
Applied rewrites52.0%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) 0.0004) (* (* (fma -0.08333333333333333 (* re re) 0.5) re) (* -2.0 (sinh im))) (* (* (sinh im) (+ re re)) -0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= 0.0004) {
tmp = (fma(-0.08333333333333333, (re * re), 0.5) * re) * (-2.0 * sinh(im));
} else {
tmp = (sinh(im) * (re + re)) * -0.5;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= 0.0004) tmp = Float64(Float64(fma(-0.08333333333333333, Float64(re * re), 0.5) * re) * Float64(-2.0 * sinh(im))); else tmp = Float64(Float64(sinh(im) * Float64(re + re)) * -0.5); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], 0.0004], N[(N[(N[(-0.08333333333333333 * N[(re * re), $MachinePrecision] + 0.5), $MachinePrecision] * re), $MachinePrecision] * N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sinh[im], $MachinePrecision] * N[(re + re), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq 0.0004:\\
\;\;\;\;\left(\mathsf{fma}\left(-0.08333333333333333, re \cdot re, 0.5\right) \cdot re\right) \cdot \left(-2 \cdot \sinh im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh im \cdot \left(re + re\right)\right) \cdot -0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < 4.00000000000000019e-4Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
if 4.00000000000000019e-4 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lower-*.f64N/A
lift-sinh.f6462.9
Applied rewrites62.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sinh.f64N/A
count-2-revN/A
lower-+.f6462.9
Applied rewrites62.9%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) -0.02) (* (* (* (* re re) -0.08333333333333333) re) (* -2.0 (sinh im))) (* (* (sinh im) (+ re re)) -0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.02) {
tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * sinh(im));
} else {
tmp = (sinh(im) * (re + re)) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((0.5d0 * sin(re)) <= (-0.02d0)) then
tmp = (((re * re) * (-0.08333333333333333d0)) * re) * ((-2.0d0) * sinh(im))
else
tmp = (sinh(im) * (re + re)) * (-0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.sin(re)) <= -0.02) {
tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * Math.sinh(im));
} else {
tmp = (Math.sinh(im) * (re + re)) * -0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.sin(re)) <= -0.02: tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * math.sinh(im)) else: tmp = (math.sinh(im) * (re + re)) * -0.5 return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.02) tmp = Float64(Float64(Float64(Float64(re * re) * -0.08333333333333333) * re) * Float64(-2.0 * sinh(im))); else tmp = Float64(Float64(sinh(im) * Float64(re + re)) * -0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * sin(re)) <= -0.02) tmp = (((re * re) * -0.08333333333333333) * re) * (-2.0 * sinh(im)); else tmp = (sinh(im) * (re + re)) * -0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.02], N[(N[(N[(N[(re * re), $MachinePrecision] * -0.08333333333333333), $MachinePrecision] * re), $MachinePrecision] * N[(-2.0 * N[Sinh[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sinh[im], $MachinePrecision] * N[(re + re), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.02:\\
\;\;\;\;\left(\left(\left(re \cdot re\right) \cdot -0.08333333333333333\right) \cdot re\right) \cdot \left(-2 \cdot \sinh im\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh im \cdot \left(re + re\right)\right) \cdot -0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0200000000000000004Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6425.3
Applied rewrites25.3%
if -0.0200000000000000004 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lower-*.f64N/A
lift-sinh.f6462.9
Applied rewrites62.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sinh.f64N/A
count-2-revN/A
lower-+.f6462.9
Applied rewrites62.9%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) -0.02) (* (* (pow re 7.0) 0.0001984126984126984) im) (* (* (sinh im) (+ re re)) -0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.02) {
tmp = (pow(re, 7.0) * 0.0001984126984126984) * im;
} else {
tmp = (sinh(im) * (re + re)) * -0.5;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((0.5d0 * sin(re)) <= (-0.02d0)) then
tmp = ((re ** 7.0d0) * 0.0001984126984126984d0) * im
else
tmp = (sinh(im) * (re + re)) * (-0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((0.5 * Math.sin(re)) <= -0.02) {
tmp = (Math.pow(re, 7.0) * 0.0001984126984126984) * im;
} else {
tmp = (Math.sinh(im) * (re + re)) * -0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if (0.5 * math.sin(re)) <= -0.02: tmp = (math.pow(re, 7.0) * 0.0001984126984126984) * im else: tmp = (math.sinh(im) * (re + re)) * -0.5 return tmp
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.02) tmp = Float64(Float64((re ^ 7.0) * 0.0001984126984126984) * im); else tmp = Float64(Float64(sinh(im) * Float64(re + re)) * -0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((0.5 * sin(re)) <= -0.02) tmp = ((re ^ 7.0) * 0.0001984126984126984) * im; else tmp = (sinh(im) * (re + re)) * -0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.02], N[(N[(N[Power[re, 7.0], $MachinePrecision] * 0.0001984126984126984), $MachinePrecision] * im), $MachinePrecision], N[(N[(N[Sinh[im], $MachinePrecision] * N[(re + re), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.02:\\
\;\;\;\;\left({re}^{7} \cdot 0.0001984126984126984\right) \cdot im\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh im \cdot \left(re + re\right)\right) \cdot -0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0200000000000000004Initial program 65.5%
Taylor expanded in im around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites37.1%
Taylor expanded in re around inf
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6424.6
Applied rewrites24.6%
if -0.0200000000000000004 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lower-*.f64N/A
lift-sinh.f6462.9
Applied rewrites62.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sinh.f64N/A
count-2-revN/A
lower-+.f6462.9
Applied rewrites62.9%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) -0.02) (* (fma (* (* re re) im) 0.16666666666666666 (- im)) re) (* (* (sinh im) (+ re re)) -0.5)))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.02) {
tmp = fma(((re * re) * im), 0.16666666666666666, -im) * re;
} else {
tmp = (sinh(im) * (re + re)) * -0.5;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.02) tmp = Float64(fma(Float64(Float64(re * re) * im), 0.16666666666666666, Float64(-im)) * re); else tmp = Float64(Float64(sinh(im) * Float64(re + re)) * -0.5); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.02], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.16666666666666666 + (-im)), $MachinePrecision] * re), $MachinePrecision], N[(N[(N[Sinh[im], $MachinePrecision] * N[(re + re), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, 0.16666666666666666, -im\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(\sinh im \cdot \left(re + re\right)\right) \cdot -0.5\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0200000000000000004Initial program 65.5%
Taylor expanded in im around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -0.0200000000000000004 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.5%
lift-*.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f6465.5
lift--.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
lift-exp.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6499.9
Applied rewrites99.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-sinh.f6499.9
Applied rewrites99.9%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
rec-expN/A
sinh-undef-revN/A
*-commutativeN/A
lower-*.f64N/A
lift-sinh.f6462.9
Applied rewrites62.9%
lift-*.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
associate-*l*N/A
lower-*.f64N/A
lift-sinh.f64N/A
count-2-revN/A
lower-+.f6462.9
Applied rewrites62.9%
(FPCore (re im) :precision binary64 (if (<= (* 0.5 (sin re)) -0.02) (* (fma (* (* re re) im) 0.16666666666666666 (- im)) re) (* (* 0.5 re) (* (fma -0.3333333333333333 (* im im) -2.0) im))))
double code(double re, double im) {
double tmp;
if ((0.5 * sin(re)) <= -0.02) {
tmp = fma(((re * re) * im), 0.16666666666666666, -im) * re;
} else {
tmp = (0.5 * re) * (fma(-0.3333333333333333, (im * im), -2.0) * im);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(0.5 * sin(re)) <= -0.02) tmp = Float64(fma(Float64(Float64(re * re) * im), 0.16666666666666666, Float64(-im)) * re); else tmp = Float64(Float64(0.5 * re) * Float64(fma(-0.3333333333333333, Float64(im * im), -2.0) * im)); end return tmp end
code[re_, im_] := If[LessEqual[N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision], -0.02], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.16666666666666666 + (-im)), $MachinePrecision] * re), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(N[(-0.3333333333333333 * N[(im * im), $MachinePrecision] + -2.0), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0.5 \cdot \sin re \leq -0.02:\\
\;\;\;\;\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, 0.16666666666666666, -im\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(\mathsf{fma}\left(-0.3333333333333333, im \cdot im, -2\right) \cdot im\right)\\
\end{array}
\end{array}
if (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) < -0.0200000000000000004Initial program 65.5%
Taylor expanded in im around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
if -0.0200000000000000004 < (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) Initial program 65.5%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.8
Applied rewrites83.8%
Taylor expanded in re around 0
Applied rewrites52.9%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))) -4e-10) (* (* -0.16666666666666666 (* (* im im) im)) re) (* (fma (* (* re re) im) 0.16666666666666666 (- im)) re)))
double code(double re, double im) {
double tmp;
if (((0.5 * sin(re)) * (exp(-im) - exp(im))) <= -4e-10) {
tmp = (-0.16666666666666666 * ((im * im) * im)) * re;
} else {
tmp = fma(((re * re) * im), 0.16666666666666666, -im) * re;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) <= -4e-10) tmp = Float64(Float64(-0.16666666666666666 * Float64(Float64(im * im) * im)) * re); else tmp = Float64(fma(Float64(Float64(re * re) * im), 0.16666666666666666, Float64(-im)) * re); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e-10], N[(N[(-0.16666666666666666 * N[(N[(im * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision], N[(N[(N[(N[(re * re), $MachinePrecision] * im), $MachinePrecision] * 0.16666666666666666 + (-im)), $MachinePrecision] * re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq -4 \cdot 10^{-10}:\\
\;\;\;\;\left(-0.16666666666666666 \cdot \left(\left(im \cdot im\right) \cdot im\right)\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(re \cdot re\right) \cdot im, 0.16666666666666666, -im\right) \cdot re\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -4.00000000000000015e-10Initial program 65.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6462.9
Applied rewrites62.9%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6450.1
Applied rewrites50.1%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6441.5
Applied rewrites41.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f6441.5
Applied rewrites41.5%
if -4.00000000000000015e-10 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.5%
Taylor expanded in im around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6436.0
Applied rewrites36.0%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))) -4e-10) (* (* -0.16666666666666666 (* (* im im) im)) re) (* (* (fma 0.16666666666666666 (* re re) -1.0) re) im)))
double code(double re, double im) {
double tmp;
if (((0.5 * sin(re)) * (exp(-im) - exp(im))) <= -4e-10) {
tmp = (-0.16666666666666666 * ((im * im) * im)) * re;
} else {
tmp = (fma(0.16666666666666666, (re * re), -1.0) * re) * im;
}
return tmp;
}
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) <= -4e-10) tmp = Float64(Float64(-0.16666666666666666 * Float64(Float64(im * im) * im)) * re); else tmp = Float64(Float64(fma(0.16666666666666666, Float64(re * re), -1.0) * re) * im); end return tmp end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e-10], N[(N[(-0.16666666666666666 * N[(N[(im * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision], N[(N[(N[(0.16666666666666666 * N[(re * re), $MachinePrecision] + -1.0), $MachinePrecision] * re), $MachinePrecision] * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq -4 \cdot 10^{-10}:\\
\;\;\;\;\left(-0.16666666666666666 \cdot \left(\left(im \cdot im\right) \cdot im\right)\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(0.16666666666666666, re \cdot re, -1\right) \cdot re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -4.00000000000000015e-10Initial program 65.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6462.9
Applied rewrites62.9%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6450.1
Applied rewrites50.1%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6441.5
Applied rewrites41.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f6441.5
Applied rewrites41.5%
if -4.00000000000000015e-10 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.5%
Taylor expanded in im around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
sub-flipN/A
metadata-evalN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6436.0
Applied rewrites36.0%
(FPCore (re im) :precision binary64 (if (<= (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))) -4e-10) (* (* -0.16666666666666666 (* (* im im) im)) re) (* (- re) im)))
double code(double re, double im) {
double tmp;
if (((0.5 * sin(re)) * (exp(-im) - exp(im))) <= -4e-10) {
tmp = (-0.16666666666666666 * ((im * im) * im)) * re;
} else {
tmp = -re * im;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (((0.5d0 * sin(re)) * (exp(-im) - exp(im))) <= (-4d-10)) then
tmp = ((-0.16666666666666666d0) * ((im * im) * im)) * re
else
tmp = -re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.sin(re)) * (Math.exp(-im) - Math.exp(im))) <= -4e-10) {
tmp = (-0.16666666666666666 * ((im * im) * im)) * re;
} else {
tmp = -re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.sin(re)) * (math.exp(-im) - math.exp(im))) <= -4e-10: tmp = (-0.16666666666666666 * ((im * im) * im)) * re else: tmp = -re * im return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) - exp(im))) <= -4e-10) tmp = Float64(Float64(-0.16666666666666666 * Float64(Float64(im * im) * im)) * re); else tmp = Float64(Float64(-re) * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * sin(re)) * (exp(-im) - exp(im))) <= -4e-10) tmp = (-0.16666666666666666 * ((im * im) * im)) * re; else tmp = -re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] - N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -4e-10], N[(N[(-0.16666666666666666 * N[(N[(im * im), $MachinePrecision] * im), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision], N[((-re) * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right) \leq -4 \cdot 10^{-10}:\\
\;\;\;\;\left(-0.16666666666666666 \cdot \left(\left(im \cdot im\right) \cdot im\right)\right) \cdot re\\
\mathbf{else}:\\
\;\;\;\;\left(-re\right) \cdot im\\
\end{array}
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -4.00000000000000015e-10Initial program 65.5%
Taylor expanded in re around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
sub-negate-revN/A
lower-neg.f64N/A
sinh-undefN/A
lower-*.f64N/A
lower-sinh.f6462.9
Applied rewrites62.9%
Taylor expanded in im around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6450.1
Applied rewrites50.1%
Taylor expanded in im around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lift-*.f6441.5
Applied rewrites41.5%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow3N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
pow3N/A
lift-*.f64N/A
lift-*.f6441.5
Applied rewrites41.5%
if -4.00000000000000015e-10 < (*.f64 (*.f64 #s(literal 1/2 binary64) (sin.f64 re)) (-.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 65.5%
Taylor expanded in im around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
Taylor expanded in re around 0
Applied rewrites33.0%
(FPCore (re im) :precision binary64 (* (- re) im))
double code(double re, double im) {
return -re * im;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -re * im
end function
public static double code(double re, double im) {
return -re * im;
}
def code(re, im): return -re * im
function code(re, im) return Float64(Float64(-re) * im) end
function tmp = code(re, im) tmp = -re * im; end
code[re_, im_] := N[((-re) * im), $MachinePrecision]
\begin{array}{l}
\\
\left(-re\right) \cdot im
\end{array}
Initial program 65.5%
Taylor expanded in im around 0
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-outN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f6451.4
Applied rewrites51.4%
Taylor expanded in re around 0
Applied rewrites33.0%
herbie shell --seed 2025136
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:precision binary64
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))