
(FPCore (re im) :precision binary64 (* (* 1/2 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(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 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 1/2 (cos re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * cos(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 * cos(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * cos(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
(FPCore (re im) :precision binary64 (* (cosh im) (cos re)))
double code(double re, double im) {
return cosh(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 = cosh(im) * cos(re)
end function
public static double code(double re, double im) {
return Math.cosh(im) * Math.cos(re);
}
def code(re, im): return math.cosh(im) * math.cos(re)
function code(re, im) return Float64(cosh(im) * cos(re)) end
function tmp = code(re, im) tmp = cosh(im) * cos(re); end
code[re_, im_] := N[(N[Cosh[im], $MachinePrecision] * N[Cos[re], $MachinePrecision]), $MachinePrecision]
\cosh im \cdot \cos re
Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lower-*.f64N/A
lower-cosh.f64100.0%
Applied rewrites100.0%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 1/2 (cos re)))
(t_1 (* t_0 (+ (exp (- im)) (exp im))))
(t_2 (+ 1 (* im (+ 1 (* 1/2 im))))))
(if (<=
t_1
-50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704)
(*
(+ 1/2 (* -1/4 (pow re 2)))
(* (+ 2 (* im (- (* 2 im) 2))) t_2))
(if (<= t_1 9007199254737117/9007199254740992)
(* t_0 (* (+ 2 (* im (- (* im (+ 2 (* -4/3 im))) 2))) t_2))
(* (cosh im) 1)))))double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = t_0 * (exp(-im) + exp(im));
double t_2 = 1.0 + (im * (1.0 + (0.5 * im)));
double tmp;
if (t_1 <= -5e+172) {
tmp = (0.5 + (-0.25 * pow(re, 2.0))) * ((2.0 + (im * ((2.0 * im) - 2.0))) * t_2);
} else if (t_1 <= 0.9999999999995698) {
tmp = t_0 * ((2.0 + (im * ((im * (2.0 + (-1.3333333333333333 * im))) - 2.0))) * t_2);
} else {
tmp = cosh(im) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 * cos(re)
t_1 = t_0 * (exp(-im) + exp(im))
t_2 = 1.0d0 + (im * (1.0d0 + (0.5d0 * im)))
if (t_1 <= (-5d+172)) then
tmp = (0.5d0 + ((-0.25d0) * (re ** 2.0d0))) * ((2.0d0 + (im * ((2.0d0 * im) - 2.0d0))) * t_2)
else if (t_1 <= 0.9999999999995698d0) then
tmp = t_0 * ((2.0d0 + (im * ((im * (2.0d0 + ((-1.3333333333333333d0) * im))) - 2.0d0))) * t_2)
else
tmp = cosh(im) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double t_1 = t_0 * (Math.exp(-im) + Math.exp(im));
double t_2 = 1.0 + (im * (1.0 + (0.5 * im)));
double tmp;
if (t_1 <= -5e+172) {
tmp = (0.5 + (-0.25 * Math.pow(re, 2.0))) * ((2.0 + (im * ((2.0 * im) - 2.0))) * t_2);
} else if (t_1 <= 0.9999999999995698) {
tmp = t_0 * ((2.0 + (im * ((im * (2.0 + (-1.3333333333333333 * im))) - 2.0))) * t_2);
} else {
tmp = Math.cosh(im) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = t_0 * (math.exp(-im) + math.exp(im)) t_2 = 1.0 + (im * (1.0 + (0.5 * im))) tmp = 0 if t_1 <= -5e+172: tmp = (0.5 + (-0.25 * math.pow(re, 2.0))) * ((2.0 + (im * ((2.0 * im) - 2.0))) * t_2) elif t_1 <= 0.9999999999995698: tmp = t_0 * ((2.0 + (im * ((im * (2.0 + (-1.3333333333333333 * im))) - 2.0))) * t_2) else: tmp = math.cosh(im) * 1.0 return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(t_0 * Float64(exp(Float64(-im)) + exp(im))) t_2 = Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))) tmp = 0.0 if (t_1 <= -5e+172) tmp = Float64(Float64(0.5 + Float64(-0.25 * (re ^ 2.0))) * Float64(Float64(2.0 + Float64(im * Float64(Float64(2.0 * im) - 2.0))) * t_2)); elseif (t_1 <= 0.9999999999995698) tmp = Float64(t_0 * Float64(Float64(2.0 + Float64(im * Float64(Float64(im * Float64(2.0 + Float64(-1.3333333333333333 * im))) - 2.0))) * t_2)); else tmp = Float64(cosh(im) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = t_0 * (exp(-im) + exp(im)); t_2 = 1.0 + (im * (1.0 + (0.5 * im))); tmp = 0.0; if (t_1 <= -5e+172) tmp = (0.5 + (-0.25 * (re ^ 2.0))) * ((2.0 + (im * ((2.0 * im) - 2.0))) * t_2); elseif (t_1 <= 0.9999999999995698) tmp = t_0 * ((2.0 + (im * ((im * (2.0 + (-1.3333333333333333 * im))) - 2.0))) * t_2); else tmp = cosh(im) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1 + N[(im * N[(1 + N[(1/2 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704], N[(N[(1/2 + N[(-1/4 * N[Power[re, 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(2 + N[(im * N[(N[(2 * im), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 9007199254737117/9007199254740992], N[(t$95$0 * N[(N[(2 + N[(im * N[(N[(im * N[(2 + N[(-4/3 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[Cosh[im], $MachinePrecision] * 1), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{1}{2} \cdot \cos re\\
t_1 := t\_0 \cdot \left(e^{-im} + e^{im}\right)\\
t_2 := 1 + im \cdot \left(1 + \frac{1}{2} \cdot im\right)\\
\mathbf{if}\;t\_1 \leq -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right) \cdot \left(\left(2 + im \cdot \left(2 \cdot im - 2\right)\right) \cdot t\_2\right)\\
\mathbf{elif}\;t\_1 \leq \frac{9007199254737117}{9007199254740992}:\\
\;\;\;\;t\_0 \cdot \left(\left(2 + im \cdot \left(im \cdot \left(2 + \frac{-4}{3} \cdot im\right) - 2\right)\right) \cdot t\_2\right)\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot 1\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -5.0000000000000001e172Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites75.4%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6474.9%
Applied rewrites74.9%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6487.6%
Applied rewrites87.6%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6455.9%
Applied rewrites55.9%
if -5.0000000000000001e172 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999956979Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites75.4%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6474.9%
Applied rewrites74.9%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6487.6%
Applied rewrites87.6%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6469.7%
Applied rewrites69.7%
if 0.99999999999956979 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lower-*.f64N/A
lower-cosh.f64100.0%
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites64.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 1/2 (cos re)) (+ (exp (- im)) (exp im)))))
(if (<=
t_0
-50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704)
(*
(+ 1/2 (* -1/4 (pow re 2)))
(* (+ 2 (* im (- (* 2 im) 2))) (+ 1 (* im (+ 1 (* 1/2 im))))))
(if (<= t_0 9007199254737117/9007199254740992)
(*
(*
(* (cos re) (- (* (- (* im 1/2) -1) im) -1))
(- (* (- (+ im im) 2) im) -2))
1/2)
(* (cosh im) 1)))))double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp(-im) + exp(im));
double tmp;
if (t_0 <= -5e+172) {
tmp = (0.5 + (-0.25 * pow(re, 2.0))) * ((2.0 + (im * ((2.0 * im) - 2.0))) * (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (t_0 <= 0.9999999999995698) {
tmp = ((cos(re) * ((((im * 0.5) - -1.0) * im) - -1.0)) * ((((im + im) - 2.0) * im) - -2.0)) * 0.5;
} else {
tmp = cosh(im) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
if (t_0 <= (-5d+172)) then
tmp = (0.5d0 + ((-0.25d0) * (re ** 2.0d0))) * ((2.0d0 + (im * ((2.0d0 * im) - 2.0d0))) * (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (t_0 <= 0.9999999999995698d0) then
tmp = ((cos(re) * ((((im * 0.5d0) - (-1.0d0)) * im) - (-1.0d0))) * ((((im + im) - 2.0d0) * im) - (-2.0d0))) * 0.5d0
else
tmp = cosh(im) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
double tmp;
if (t_0 <= -5e+172) {
tmp = (0.5 + (-0.25 * Math.pow(re, 2.0))) * ((2.0 + (im * ((2.0 * im) - 2.0))) * (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (t_0 <= 0.9999999999995698) {
tmp = ((Math.cos(re) * ((((im * 0.5) - -1.0) * im) - -1.0)) * ((((im + im) - 2.0) * im) - -2.0)) * 0.5;
} else {
tmp = Math.cosh(im) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im)) tmp = 0 if t_0 <= -5e+172: tmp = (0.5 + (-0.25 * math.pow(re, 2.0))) * ((2.0 + (im * ((2.0 * im) - 2.0))) * (1.0 + (im * (1.0 + (0.5 * im))))) elif t_0 <= 0.9999999999995698: tmp = ((math.cos(re) * ((((im * 0.5) - -1.0) * im) - -1.0)) * ((((im + im) - 2.0) * im) - -2.0)) * 0.5 else: tmp = math.cosh(im) * 1.0 return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (t_0 <= -5e+172) tmp = Float64(Float64(0.5 + Float64(-0.25 * (re ^ 2.0))) * Float64(Float64(2.0 + Float64(im * Float64(Float64(2.0 * im) - 2.0))) * Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (t_0 <= 0.9999999999995698) tmp = Float64(Float64(Float64(cos(re) * Float64(Float64(Float64(Float64(im * 0.5) - -1.0) * im) - -1.0)) * Float64(Float64(Float64(Float64(im + im) - 2.0) * im) - -2.0)) * 0.5); else tmp = Float64(cosh(im) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * cos(re)) * (exp(-im) + exp(im)); tmp = 0.0; if (t_0 <= -5e+172) tmp = (0.5 + (-0.25 * (re ^ 2.0))) * ((2.0 + (im * ((2.0 * im) - 2.0))) * (1.0 + (im * (1.0 + (0.5 * im))))); elseif (t_0 <= 0.9999999999995698) tmp = ((cos(re) * ((((im * 0.5) - -1.0) * im) - -1.0)) * ((((im + im) - 2.0) * im) - -2.0)) * 0.5; else tmp = cosh(im) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704], N[(N[(1/2 + N[(-1/4 * N[Power[re, 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(2 + N[(im * N[(N[(2 * im), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1 + N[(im * N[(1 + N[(1/2 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 9007199254737117/9007199254740992], N[(N[(N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[(im * 1/2), $MachinePrecision] - -1), $MachinePrecision] * im), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(im + im), $MachinePrecision] - 2), $MachinePrecision] * im), $MachinePrecision] - -2), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[Cosh[im], $MachinePrecision] * 1), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_0 \leq -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot {re}^{2}\right) \cdot \left(\left(2 + im \cdot \left(2 \cdot im - 2\right)\right) \cdot \left(1 + im \cdot \left(1 + \frac{1}{2} \cdot im\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq \frac{9007199254737117}{9007199254740992}:\\
\;\;\;\;\left(\left(\cos re \cdot \left(\left(im \cdot \frac{1}{2} - -1\right) \cdot im - -1\right)\right) \cdot \left(\left(\left(im + im\right) - 2\right) \cdot im - -2\right)\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot 1\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -5.0000000000000001e172Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites75.4%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6474.9%
Applied rewrites74.9%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6487.6%
Applied rewrites87.6%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6455.9%
Applied rewrites55.9%
if -5.0000000000000001e172 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999956979Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites75.4%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6474.9%
Applied rewrites74.9%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6487.6%
Applied rewrites87.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.6%
if 0.99999999999956979 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lower-*.f64N/A
lower-cosh.f64100.0%
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites64.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 1/2 (cos re)) (+ (exp (- im)) (exp im))))
(t_1 (* (* (* re re) re) re)))
(if (<=
t_0
-50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704)
(* (+ 1/2 (* -1/4 (sqrt (sqrt (* t_1 t_1))))) 2)
(if (<= t_0 9007199254737117/9007199254740992)
(*
(*
(* (cos re) (- (* (- (* im 1/2) -1) im) -1))
(- (* (- (+ im im) 2) im) -2))
1/2)
(* (cosh im) 1)))))double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp(-im) + exp(im));
double t_1 = ((re * re) * re) * re;
double tmp;
if (t_0 <= -5e+172) {
tmp = (0.5 + (-0.25 * sqrt(sqrt((t_1 * t_1))))) * 2.0;
} else if (t_0 <= 0.9999999999995698) {
tmp = ((cos(re) * ((((im * 0.5) - -1.0) * im) - -1.0)) * ((((im + im) - 2.0) * im) - -2.0)) * 0.5;
} else {
tmp = cosh(im) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
t_1 = ((re * re) * re) * re
if (t_0 <= (-5d+172)) then
tmp = (0.5d0 + ((-0.25d0) * sqrt(sqrt((t_1 * t_1))))) * 2.0d0
else if (t_0 <= 0.9999999999995698d0) then
tmp = ((cos(re) * ((((im * 0.5d0) - (-1.0d0)) * im) - (-1.0d0))) * ((((im + im) - 2.0d0) * im) - (-2.0d0))) * 0.5d0
else
tmp = cosh(im) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
double t_1 = ((re * re) * re) * re;
double tmp;
if (t_0 <= -5e+172) {
tmp = (0.5 + (-0.25 * Math.sqrt(Math.sqrt((t_1 * t_1))))) * 2.0;
} else if (t_0 <= 0.9999999999995698) {
tmp = ((Math.cos(re) * ((((im * 0.5) - -1.0) * im) - -1.0)) * ((((im + im) - 2.0) * im) - -2.0)) * 0.5;
} else {
tmp = Math.cosh(im) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im)) t_1 = ((re * re) * re) * re tmp = 0 if t_0 <= -5e+172: tmp = (0.5 + (-0.25 * math.sqrt(math.sqrt((t_1 * t_1))))) * 2.0 elif t_0 <= 0.9999999999995698: tmp = ((math.cos(re) * ((((im * 0.5) - -1.0) * im) - -1.0)) * ((((im + im) - 2.0) * im) - -2.0)) * 0.5 else: tmp = math.cosh(im) * 1.0 return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) t_1 = Float64(Float64(Float64(re * re) * re) * re) tmp = 0.0 if (t_0 <= -5e+172) tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(sqrt(Float64(t_1 * t_1))))) * 2.0); elseif (t_0 <= 0.9999999999995698) tmp = Float64(Float64(Float64(cos(re) * Float64(Float64(Float64(Float64(im * 0.5) - -1.0) * im) - -1.0)) * Float64(Float64(Float64(Float64(im + im) - 2.0) * im) - -2.0)) * 0.5); else tmp = Float64(cosh(im) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * cos(re)) * (exp(-im) + exp(im)); t_1 = ((re * re) * re) * re; tmp = 0.0; if (t_0 <= -5e+172) tmp = (0.5 + (-0.25 * sqrt(sqrt((t_1 * t_1))))) * 2.0; elseif (t_0 <= 0.9999999999995698) tmp = ((cos(re) * ((((im * 0.5) - -1.0) * im) - -1.0)) * ((((im + im) - 2.0) * im) - -2.0)) * 0.5; else tmp = cosh(im) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(re * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[t$95$0, -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704], N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[Sqrt[N[(t$95$1 * t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], If[LessEqual[t$95$0, 9007199254737117/9007199254740992], N[(N[(N[(N[Cos[re], $MachinePrecision] * N[(N[(N[(N[(im * 1/2), $MachinePrecision] - -1), $MachinePrecision] * im), $MachinePrecision] - -1), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(im + im), $MachinePrecision] - 2), $MachinePrecision] * im), $MachinePrecision] - -2), $MachinePrecision]), $MachinePrecision] * 1/2), $MachinePrecision], N[(N[Cosh[im], $MachinePrecision] * 1), $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)\\
t_1 := \left(\left(re \cdot re\right) \cdot re\right) \cdot re\\
\mathbf{if}\;t\_0 \leq -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\sqrt{t\_1 \cdot t\_1}}\right) \cdot 2\\
\mathbf{elif}\;t\_0 \leq \frac{9007199254737117}{9007199254740992}:\\
\;\;\;\;\left(\left(\cos re \cdot \left(\left(im \cdot \frac{1}{2} - -1\right) \cdot im - -1\right)\right) \cdot \left(\left(\left(im + im\right) - 2\right) \cdot im - -2\right)\right) \cdot \frac{1}{2}\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot 1\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -5.0000000000000001e172Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
Applied rewrites35.5%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
Applied rewrites37.0%
if -5.0000000000000001e172 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999956979Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites75.4%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6474.9%
Applied rewrites74.9%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6487.6%
Applied rewrites87.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.6%
if 0.99999999999956979 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lower-*.f64N/A
lower-cosh.f64100.0%
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites64.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 1/2 (cos re)))
(t_1 (* t_0 (+ (exp (- (fabs im))) (exp (fabs im)))))
(t_2 (* (* (* re re) re) re)))
(if (<=
t_1
-50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704)
(* (+ 1/2 (* -1/4 (sqrt (sqrt (* t_2 t_2))))) 2)
(if (<= t_1 9007199254737117/9007199254740992)
(*
t_0
(* (+ 2 (* (fabs im) (- (* 2 (fabs im)) 2))) (+ 1 (fabs im))))
(* (cosh (fabs im)) 1)))))double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = t_0 * (exp(-fabs(im)) + exp(fabs(im)));
double t_2 = ((re * re) * re) * re;
double tmp;
if (t_1 <= -5e+172) {
tmp = (0.5 + (-0.25 * sqrt(sqrt((t_2 * t_2))))) * 2.0;
} else if (t_1 <= 0.9999999999995698) {
tmp = t_0 * ((2.0 + (fabs(im) * ((2.0 * fabs(im)) - 2.0))) * (1.0 + fabs(im)));
} else {
tmp = cosh(fabs(im)) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 * cos(re)
t_1 = t_0 * (exp(-abs(im)) + exp(abs(im)))
t_2 = ((re * re) * re) * re
if (t_1 <= (-5d+172)) then
tmp = (0.5d0 + ((-0.25d0) * sqrt(sqrt((t_2 * t_2))))) * 2.0d0
else if (t_1 <= 0.9999999999995698d0) then
tmp = t_0 * ((2.0d0 + (abs(im) * ((2.0d0 * abs(im)) - 2.0d0))) * (1.0d0 + abs(im)))
else
tmp = cosh(abs(im)) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double t_1 = t_0 * (Math.exp(-Math.abs(im)) + Math.exp(Math.abs(im)));
double t_2 = ((re * re) * re) * re;
double tmp;
if (t_1 <= -5e+172) {
tmp = (0.5 + (-0.25 * Math.sqrt(Math.sqrt((t_2 * t_2))))) * 2.0;
} else if (t_1 <= 0.9999999999995698) {
tmp = t_0 * ((2.0 + (Math.abs(im) * ((2.0 * Math.abs(im)) - 2.0))) * (1.0 + Math.abs(im)));
} else {
tmp = Math.cosh(Math.abs(im)) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = t_0 * (math.exp(-math.fabs(im)) + math.exp(math.fabs(im))) t_2 = ((re * re) * re) * re tmp = 0 if t_1 <= -5e+172: tmp = (0.5 + (-0.25 * math.sqrt(math.sqrt((t_2 * t_2))))) * 2.0 elif t_1 <= 0.9999999999995698: tmp = t_0 * ((2.0 + (math.fabs(im) * ((2.0 * math.fabs(im)) - 2.0))) * (1.0 + math.fabs(im))) else: tmp = math.cosh(math.fabs(im)) * 1.0 return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(t_0 * Float64(exp(Float64(-abs(im))) + exp(abs(im)))) t_2 = Float64(Float64(Float64(re * re) * re) * re) tmp = 0.0 if (t_1 <= -5e+172) tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(sqrt(Float64(t_2 * t_2))))) * 2.0); elseif (t_1 <= 0.9999999999995698) tmp = Float64(t_0 * Float64(Float64(2.0 + Float64(abs(im) * Float64(Float64(2.0 * abs(im)) - 2.0))) * Float64(1.0 + abs(im)))); else tmp = Float64(cosh(abs(im)) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = t_0 * (exp(-abs(im)) + exp(abs(im))); t_2 = ((re * re) * re) * re; tmp = 0.0; if (t_1 <= -5e+172) tmp = (0.5 + (-0.25 * sqrt(sqrt((t_2 * t_2))))) * 2.0; elseif (t_1 <= 0.9999999999995698) tmp = t_0 * ((2.0 + (abs(im) * ((2.0 * abs(im)) - 2.0))) * (1.0 + abs(im))); else tmp = cosh(abs(im)) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Exp[(-N[Abs[im], $MachinePrecision])], $MachinePrecision] + N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(re * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[t$95$1, -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704], N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[Sqrt[N[(t$95$2 * t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], If[LessEqual[t$95$1, 9007199254737117/9007199254740992], N[(t$95$0 * N[(N[(2 + N[(N[Abs[im], $MachinePrecision] * N[(N[(2 * N[Abs[im], $MachinePrecision]), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1 + N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cosh[N[Abs[im], $MachinePrecision]], $MachinePrecision] * 1), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{1}{2} \cdot \cos re\\
t_1 := t\_0 \cdot \left(e^{-\left|im\right|} + e^{\left|im\right|}\right)\\
t_2 := \left(\left(re \cdot re\right) \cdot re\right) \cdot re\\
\mathbf{if}\;t\_1 \leq -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\sqrt{t\_2 \cdot t\_2}}\right) \cdot 2\\
\mathbf{elif}\;t\_1 \leq \frac{9007199254737117}{9007199254740992}:\\
\;\;\;\;t\_0 \cdot \left(\left(2 + \left|im\right| \cdot \left(2 \cdot \left|im\right| - 2\right)\right) \cdot \left(1 + \left|im\right|\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cosh \left(\left|im\right|\right) \cdot 1\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -5.0000000000000001e172Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
Applied rewrites35.5%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
Applied rewrites37.0%
if -5.0000000000000001e172 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999956979Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites75.4%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6474.9%
Applied rewrites74.9%
Taylor expanded in im around 0
lower-+.f6466.7%
Applied rewrites66.7%
if 0.99999999999956979 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lower-*.f64N/A
lower-cosh.f64100.0%
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites64.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 1/2 (cos re)))
(t_1 (* t_0 (+ (exp (- im)) (exp im))))
(t_2 (* (* (* re re) re) re)))
(if (<=
t_1
-50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704)
(* (+ 1/2 (* -1/4 (sqrt (sqrt (* t_2 t_2))))) 2)
(if (<= t_1 9007199254737117/9007199254740992)
(* t_0 2)
(* (cosh im) 1)))))double code(double re, double im) {
double t_0 = 0.5 * cos(re);
double t_1 = t_0 * (exp(-im) + exp(im));
double t_2 = ((re * re) * re) * re;
double tmp;
if (t_1 <= -5e+172) {
tmp = (0.5 + (-0.25 * sqrt(sqrt((t_2 * t_2))))) * 2.0;
} else if (t_1 <= 0.9999999999995698) {
tmp = t_0 * 2.0;
} else {
tmp = cosh(im) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 * cos(re)
t_1 = t_0 * (exp(-im) + exp(im))
t_2 = ((re * re) * re) * re
if (t_1 <= (-5d+172)) then
tmp = (0.5d0 + ((-0.25d0) * sqrt(sqrt((t_2 * t_2))))) * 2.0d0
else if (t_1 <= 0.9999999999995698d0) then
tmp = t_0 * 2.0d0
else
tmp = cosh(im) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * Math.cos(re);
double t_1 = t_0 * (Math.exp(-im) + Math.exp(im));
double t_2 = ((re * re) * re) * re;
double tmp;
if (t_1 <= -5e+172) {
tmp = (0.5 + (-0.25 * Math.sqrt(Math.sqrt((t_2 * t_2))))) * 2.0;
} else if (t_1 <= 0.9999999999995698) {
tmp = t_0 * 2.0;
} else {
tmp = Math.cosh(im) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = 0.5 * math.cos(re) t_1 = t_0 * (math.exp(-im) + math.exp(im)) t_2 = ((re * re) * re) * re tmp = 0 if t_1 <= -5e+172: tmp = (0.5 + (-0.25 * math.sqrt(math.sqrt((t_2 * t_2))))) * 2.0 elif t_1 <= 0.9999999999995698: tmp = t_0 * 2.0 else: tmp = math.cosh(im) * 1.0 return tmp
function code(re, im) t_0 = Float64(0.5 * cos(re)) t_1 = Float64(t_0 * Float64(exp(Float64(-im)) + exp(im))) t_2 = Float64(Float64(Float64(re * re) * re) * re) tmp = 0.0 if (t_1 <= -5e+172) tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(sqrt(Float64(t_2 * t_2))))) * 2.0); elseif (t_1 <= 0.9999999999995698) tmp = Float64(t_0 * 2.0); else tmp = Float64(cosh(im) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * cos(re); t_1 = t_0 * (exp(-im) + exp(im)); t_2 = ((re * re) * re) * re; tmp = 0.0; if (t_1 <= -5e+172) tmp = (0.5 + (-0.25 * sqrt(sqrt((t_2 * t_2))))) * 2.0; elseif (t_1 <= 0.9999999999995698) tmp = t_0 * 2.0; else tmp = cosh(im) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(re * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[t$95$1, -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704], N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[Sqrt[N[(t$95$2 * t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], If[LessEqual[t$95$1, 9007199254737117/9007199254740992], N[(t$95$0 * 2), $MachinePrecision], N[(N[Cosh[im], $MachinePrecision] * 1), $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \frac{1}{2} \cdot \cos re\\
t_1 := t\_0 \cdot \left(e^{-im} + e^{im}\right)\\
t_2 := \left(\left(re \cdot re\right) \cdot re\right) \cdot re\\
\mathbf{if}\;t\_1 \leq -50000000000000000701959312789985260891230985285064568046915021472510652274325054054092066621782843422306142881889050953096494638431569844936383886042210844858380302841544704:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\sqrt{t\_2 \cdot t\_2}}\right) \cdot 2\\
\mathbf{elif}\;t\_1 \leq \frac{9007199254737117}{9007199254740992}:\\
\;\;\;\;t\_0 \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot 1\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -5.0000000000000001e172Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
Applied rewrites35.5%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
Applied rewrites37.0%
if -5.0000000000000001e172 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 0.99999999999956979Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
if 0.99999999999956979 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lower-*.f64N/A
lower-cosh.f64100.0%
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites64.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* (* re re) re) re)))
(if (<=
(* (* 1/2 (cos re)) (+ (exp (- im)) (exp im)))
-3602879701896397/72057594037927936)
(* (+ 1/2 (* -1/4 (sqrt (sqrt (* t_0 t_0))))) 2)
(* (cosh im) 1))))double code(double re, double im) {
double t_0 = ((re * re) * re) * re;
double tmp;
if (((0.5 * cos(re)) * (exp(-im) + exp(im))) <= -0.05) {
tmp = (0.5 + (-0.25 * sqrt(sqrt((t_0 * t_0))))) * 2.0;
} else {
tmp = cosh(im) * 1.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = ((re * re) * re) * re
if (((0.5d0 * cos(re)) * (exp(-im) + exp(im))) <= (-0.05d0)) then
tmp = (0.5d0 + ((-0.25d0) * sqrt(sqrt((t_0 * t_0))))) * 2.0d0
else
tmp = cosh(im) * 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = ((re * re) * re) * re;
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im))) <= -0.05) {
tmp = (0.5 + (-0.25 * Math.sqrt(Math.sqrt((t_0 * t_0))))) * 2.0;
} else {
tmp = Math.cosh(im) * 1.0;
}
return tmp;
}
def code(re, im): t_0 = ((re * re) * re) * re tmp = 0 if ((0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))) <= -0.05: tmp = (0.5 + (-0.25 * math.sqrt(math.sqrt((t_0 * t_0))))) * 2.0 else: tmp = math.cosh(im) * 1.0 return tmp
function code(re, im) t_0 = Float64(Float64(Float64(re * re) * re) * re) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) <= -0.05) tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(sqrt(Float64(t_0 * t_0))))) * 2.0); else tmp = Float64(cosh(im) * 1.0); end return tmp end
function tmp_2 = code(re, im) t_0 = ((re * re) * re) * re; tmp = 0.0; if (((0.5 * cos(re)) * (exp(-im) + exp(im))) <= -0.05) tmp = (0.5 + (-0.25 * sqrt(sqrt((t_0 * t_0))))) * 2.0; else tmp = cosh(im) * 1.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(re * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -3602879701896397/72057594037927936], N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[Sqrt[N[(t$95$0 * t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], N[(N[Cosh[im], $MachinePrecision] * 1), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left(re \cdot re\right) \cdot re\right) \cdot re\\
\mathbf{if}\;\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \leq \frac{-3602879701896397}{72057594037927936}:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\sqrt{t\_0 \cdot t\_0}}\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\cosh im \cdot 1\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
Applied rewrites35.5%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
Applied rewrites37.0%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
metadata-evalN/A
mult-flip-revN/A
lift-+.f64N/A
+-commutativeN/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-defN/A
lower-*.f64N/A
lower-cosh.f64100.0%
Applied rewrites100.0%
Taylor expanded in re around 0
Applied rewrites64.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* (* re re) re) re)))
(if (<=
(* (* 1/2 (cos re)) (+ (exp (- (fabs im))) (exp (fabs im))))
-3602879701896397/72057594037927936)
(* (+ 1/2 (* -1/4 (sqrt (sqrt (* t_0 t_0))))) 2)
(*
1/2
(*
(+ 2 (* (fabs im) (- (* 2 (fabs im)) 2)))
(+ 1 (* (fabs im) (+ 1 (* 1/2 (fabs im))))))))))double code(double re, double im) {
double t_0 = ((re * re) * re) * re;
double tmp;
if (((0.5 * cos(re)) * (exp(-fabs(im)) + exp(fabs(im)))) <= -0.05) {
tmp = (0.5 + (-0.25 * sqrt(sqrt((t_0 * t_0))))) * 2.0;
} else {
tmp = 0.5 * ((2.0 + (fabs(im) * ((2.0 * fabs(im)) - 2.0))) * (1.0 + (fabs(im) * (1.0 + (0.5 * fabs(im))))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = ((re * re) * re) * re
if (((0.5d0 * cos(re)) * (exp(-abs(im)) + exp(abs(im)))) <= (-0.05d0)) then
tmp = (0.5d0 + ((-0.25d0) * sqrt(sqrt((t_0 * t_0))))) * 2.0d0
else
tmp = 0.5d0 * ((2.0d0 + (abs(im) * ((2.0d0 * abs(im)) - 2.0d0))) * (1.0d0 + (abs(im) * (1.0d0 + (0.5d0 * abs(im))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = ((re * re) * re) * re;
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp(-Math.abs(im)) + Math.exp(Math.abs(im)))) <= -0.05) {
tmp = (0.5 + (-0.25 * Math.sqrt(Math.sqrt((t_0 * t_0))))) * 2.0;
} else {
tmp = 0.5 * ((2.0 + (Math.abs(im) * ((2.0 * Math.abs(im)) - 2.0))) * (1.0 + (Math.abs(im) * (1.0 + (0.5 * Math.abs(im))))));
}
return tmp;
}
def code(re, im): t_0 = ((re * re) * re) * re tmp = 0 if ((0.5 * math.cos(re)) * (math.exp(-math.fabs(im)) + math.exp(math.fabs(im)))) <= -0.05: tmp = (0.5 + (-0.25 * math.sqrt(math.sqrt((t_0 * t_0))))) * 2.0 else: tmp = 0.5 * ((2.0 + (math.fabs(im) * ((2.0 * math.fabs(im)) - 2.0))) * (1.0 + (math.fabs(im) * (1.0 + (0.5 * math.fabs(im)))))) return tmp
function code(re, im) t_0 = Float64(Float64(Float64(re * re) * re) * re) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-abs(im))) + exp(abs(im)))) <= -0.05) tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(sqrt(Float64(t_0 * t_0))))) * 2.0); else tmp = Float64(0.5 * Float64(Float64(2.0 + Float64(abs(im) * Float64(Float64(2.0 * abs(im)) - 2.0))) * Float64(1.0 + Float64(abs(im) * Float64(1.0 + Float64(0.5 * abs(im))))))); end return tmp end
function tmp_2 = code(re, im) t_0 = ((re * re) * re) * re; tmp = 0.0; if (((0.5 * cos(re)) * (exp(-abs(im)) + exp(abs(im)))) <= -0.05) tmp = (0.5 + (-0.25 * sqrt(sqrt((t_0 * t_0))))) * 2.0; else tmp = 0.5 * ((2.0 + (abs(im) * ((2.0 * abs(im)) - 2.0))) * (1.0 + (abs(im) * (1.0 + (0.5 * abs(im)))))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(N[(re * re), $MachinePrecision] * re), $MachinePrecision] * re), $MachinePrecision]}, If[LessEqual[N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-N[Abs[im], $MachinePrecision])], $MachinePrecision] + N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -3602879701896397/72057594037927936], N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[Sqrt[N[(t$95$0 * t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], N[(1/2 * N[(N[(2 + N[(N[Abs[im], $MachinePrecision] * N[(N[(2 * N[Abs[im], $MachinePrecision]), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1 + N[(N[Abs[im], $MachinePrecision] * N[(1 + N[(1/2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := \left(\left(re \cdot re\right) \cdot re\right) \cdot re\\
\mathbf{if}\;\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-\left|im\right|} + e^{\left|im\right|}\right) \leq \frac{-3602879701896397}{72057594037927936}:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\sqrt{t\_0 \cdot t\_0}}\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \left(\left(2 + \left|im\right| \cdot \left(2 \cdot \left|im\right| - 2\right)\right) \cdot \left(1 + \left|im\right| \cdot \left(1 + \frac{1}{2} \cdot \left|im\right|\right)\right)\right)\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
Applied rewrites35.5%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6437.0%
Applied rewrites37.0%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites75.4%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6474.9%
Applied rewrites74.9%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6487.6%
Applied rewrites87.6%
Taylor expanded in re around 0
Applied rewrites55.8%
(FPCore (re im)
:precision binary64
(if (<=
(* (* 1/2 (cos re)) (+ (exp (- (fabs im))) (exp (fabs im))))
-3602879701896397/72057594037927936)
(* (+ 1/2 (* -1/4 (sqrt (* (* re re) (* re re))))) 2)
(*
1/2
(*
(+ 2 (* (fabs im) (- (* 2 (fabs im)) 2)))
(+ 1 (* (fabs im) (+ 1 (* 1/2 (fabs im)))))))))double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp(-fabs(im)) + exp(fabs(im)))) <= -0.05) {
tmp = (0.5 + (-0.25 * sqrt(((re * re) * (re * re))))) * 2.0;
} else {
tmp = 0.5 * ((2.0 + (fabs(im) * ((2.0 * fabs(im)) - 2.0))) * (1.0 + (fabs(im) * (1.0 + (0.5 * fabs(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 * cos(re)) * (exp(-abs(im)) + exp(abs(im)))) <= (-0.05d0)) then
tmp = (0.5d0 + ((-0.25d0) * sqrt(((re * re) * (re * re))))) * 2.0d0
else
tmp = 0.5d0 * ((2.0d0 + (abs(im) * ((2.0d0 * abs(im)) - 2.0d0))) * (1.0d0 + (abs(im) * (1.0d0 + (0.5d0 * abs(im))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp(-Math.abs(im)) + Math.exp(Math.abs(im)))) <= -0.05) {
tmp = (0.5 + (-0.25 * Math.sqrt(((re * re) * (re * re))))) * 2.0;
} else {
tmp = 0.5 * ((2.0 + (Math.abs(im) * ((2.0 * Math.abs(im)) - 2.0))) * (1.0 + (Math.abs(im) * (1.0 + (0.5 * Math.abs(im))))));
}
return tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp(-math.fabs(im)) + math.exp(math.fabs(im)))) <= -0.05: tmp = (0.5 + (-0.25 * math.sqrt(((re * re) * (re * re))))) * 2.0 else: tmp = 0.5 * ((2.0 + (math.fabs(im) * ((2.0 * math.fabs(im)) - 2.0))) * (1.0 + (math.fabs(im) * (1.0 + (0.5 * math.fabs(im)))))) return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-abs(im))) + exp(abs(im)))) <= -0.05) tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(Float64(Float64(re * re) * Float64(re * re))))) * 2.0); else tmp = Float64(0.5 * Float64(Float64(2.0 + Float64(abs(im) * Float64(Float64(2.0 * abs(im)) - 2.0))) * Float64(1.0 + Float64(abs(im) * Float64(1.0 + Float64(0.5 * abs(im))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp(-abs(im)) + exp(abs(im)))) <= -0.05) tmp = (0.5 + (-0.25 * sqrt(((re * re) * (re * re))))) * 2.0; else tmp = 0.5 * ((2.0 + (abs(im) * ((2.0 * abs(im)) - 2.0))) * (1.0 + (abs(im) * (1.0 + (0.5 * abs(im)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-N[Abs[im], $MachinePrecision])], $MachinePrecision] + N[Exp[N[Abs[im], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -3602879701896397/72057594037927936], N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], N[(1/2 * N[(N[(2 + N[(N[Abs[im], $MachinePrecision] * N[(N[(2 * N[Abs[im], $MachinePrecision]), $MachinePrecision] - 2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1 + N[(N[Abs[im], $MachinePrecision] * N[(1 + N[(1/2 * N[Abs[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-\left|im\right|} + e^{\left|im\right|}\right) \leq \frac{-3602879701896397}{72057594037927936}:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \left(\left(2 + \left|im\right| \cdot \left(2 \cdot \left|im\right| - 2\right)\right) \cdot \left(1 + \left|im\right| \cdot \left(1 + \frac{1}{2} \cdot \left|im\right|\right)\right)\right)\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
Applied rewrites35.5%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
lift-+.f64N/A
+-commutativeN/A
sum-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites75.4%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6474.9%
Applied rewrites74.9%
Taylor expanded in im around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6487.6%
Applied rewrites87.6%
Taylor expanded in re around 0
Applied rewrites55.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (* 1/2 (cos re)) (+ (exp (- im)) (exp im)))))
(if (<= t_0 -3602879701896397/72057594037927936)
(* (+ 1/2 (* -1/4 (sqrt (* (* re re) (* re re))))) 2)
(if (<=
t_0
10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216)
(* 1/2 2)
(* (* (* (- 1 (/ 2 (* re re))) (* -1/4 re)) re) 2)))))double code(double re, double im) {
double t_0 = (0.5 * cos(re)) * (exp(-im) + exp(im));
double tmp;
if (t_0 <= -0.05) {
tmp = (0.5 + (-0.25 * sqrt(((re * re) * (re * re))))) * 2.0;
} else if (t_0 <= 1e+121) {
tmp = 0.5 * 2.0;
} else {
tmp = (((1.0 - (2.0 / (re * re))) * (-0.25 * re)) * re) * 2.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = (0.5d0 * cos(re)) * (exp(-im) + exp(im))
if (t_0 <= (-0.05d0)) then
tmp = (0.5d0 + ((-0.25d0) * sqrt(((re * re) * (re * re))))) * 2.0d0
else if (t_0 <= 1d+121) then
tmp = 0.5d0 * 2.0d0
else
tmp = (((1.0d0 - (2.0d0 / (re * re))) * ((-0.25d0) * re)) * re) * 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = (0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im));
double tmp;
if (t_0 <= -0.05) {
tmp = (0.5 + (-0.25 * Math.sqrt(((re * re) * (re * re))))) * 2.0;
} else if (t_0 <= 1e+121) {
tmp = 0.5 * 2.0;
} else {
tmp = (((1.0 - (2.0 / (re * re))) * (-0.25 * re)) * re) * 2.0;
}
return tmp;
}
def code(re, im): t_0 = (0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im)) tmp = 0 if t_0 <= -0.05: tmp = (0.5 + (-0.25 * math.sqrt(((re * re) * (re * re))))) * 2.0 elif t_0 <= 1e+121: tmp = 0.5 * 2.0 else: tmp = (((1.0 - (2.0 / (re * re))) * (-0.25 * re)) * re) * 2.0 return tmp
function code(re, im) t_0 = Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) tmp = 0.0 if (t_0 <= -0.05) tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(Float64(Float64(re * re) * Float64(re * re))))) * 2.0); elseif (t_0 <= 1e+121) tmp = Float64(0.5 * 2.0); else tmp = Float64(Float64(Float64(Float64(1.0 - Float64(2.0 / Float64(re * re))) * Float64(-0.25 * re)) * re) * 2.0); end return tmp end
function tmp_2 = code(re, im) t_0 = (0.5 * cos(re)) * (exp(-im) + exp(im)); tmp = 0.0; if (t_0 <= -0.05) tmp = (0.5 + (-0.25 * sqrt(((re * re) * (re * re))))) * 2.0; elseif (t_0 <= 1e+121) tmp = 0.5 * 2.0; else tmp = (((1.0 - (2.0 / (re * re))) * (-0.25 * re)) * re) * 2.0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -3602879701896397/72057594037927936], N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], If[LessEqual[t$95$0, 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216], N[(1/2 * 2), $MachinePrecision], N[(N[(N[(N[(1 - N[(2 / N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1/4 * re), $MachinePrecision]), $MachinePrecision] * re), $MachinePrecision] * 2), $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{if}\;t\_0 \leq \frac{-3602879701896397}{72057594037927936}:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}\right) \cdot 2\\
\mathbf{elif}\;t\_0 \leq 10000000000000000373409337471459889719393275754491820381027730410378005080671497101378613371421126415052399029342192009216:\\
\;\;\;\;\frac{1}{2} \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(1 - \frac{2}{re \cdot re}\right) \cdot \left(\frac{-1}{4} \cdot re\right)\right) \cdot re\right) \cdot 2\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
Applied rewrites35.5%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < 1e121Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
Applied rewrites28.6%
if 1e121 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
metadata-eval21.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6421.1%
lift-pow.f64N/A
unpow2N/A
lower-*.f6421.1%
Applied rewrites21.1%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f6432.9%
Applied rewrites32.9%
(FPCore (re im)
:precision binary64
(if (<=
(* (* 1/2 (cos re)) (+ (exp (- im)) (exp im)))
-3602879701896397/72057594037927936)
(* (+ 1/2 (* -1/4 (sqrt (* (* re re) (* re re))))) 2)
(* 1/2 2)))double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp(-im) + exp(im))) <= -0.05) {
tmp = (0.5 + (-0.25 * sqrt(((re * re) * (re * re))))) * 2.0;
} else {
tmp = 0.5 * 2.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (((0.5d0 * cos(re)) * (exp(-im) + exp(im))) <= (-0.05d0)) then
tmp = (0.5d0 + ((-0.25d0) * sqrt(((re * re) * (re * re))))) * 2.0d0
else
tmp = 0.5d0 * 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im))) <= -0.05) {
tmp = (0.5 + (-0.25 * Math.sqrt(((re * re) * (re * re))))) * 2.0;
} else {
tmp = 0.5 * 2.0;
}
return tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))) <= -0.05: tmp = (0.5 + (-0.25 * math.sqrt(((re * re) * (re * re))))) * 2.0 else: tmp = 0.5 * 2.0 return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) <= -0.05) tmp = Float64(Float64(0.5 + Float64(-0.25 * sqrt(Float64(Float64(re * re) * Float64(re * re))))) * 2.0); else tmp = Float64(0.5 * 2.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp(-im) + exp(im))) <= -0.05) tmp = (0.5 + (-0.25 * sqrt(((re * re) * (re * re))))) * 2.0; else tmp = 0.5 * 2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -3602879701896397/72057594037927936], N[(N[(1/2 + N[(-1/4 * N[Sqrt[N[(N[(re * re), $MachinePrecision] * N[(re * re), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 2), $MachinePrecision], N[(1/2 * 2), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \leq \frac{-3602879701896397}{72057594037927936}:\\
\;\;\;\;\left(\frac{1}{2} + \frac{-1}{4} \cdot \sqrt{\left(re \cdot re\right) \cdot \left(re \cdot re\right)}\right) \cdot 2\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot 2\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
rem-square-sqrtN/A
sqrt-unprodN/A
lower-sqrt.f64N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
lift-pow.f64N/A
unpow2N/A
lower-*.f6435.5%
Applied rewrites35.5%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
Applied rewrites28.6%
(FPCore (re im)
:precision binary64
(if (<=
(* (* 1/2 (cos re)) (+ (exp (- im)) (exp im)))
-3602879701896397/72057594037927936)
(* 2 (- (* -1/4 (* re re)) -1/2))
(* 1/2 2)))double code(double re, double im) {
double tmp;
if (((0.5 * cos(re)) * (exp(-im) + exp(im))) <= -0.05) {
tmp = 2.0 * ((-0.25 * (re * re)) - -0.5);
} else {
tmp = 0.5 * 2.0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(re, im)
use fmin_fmax_functions
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (((0.5d0 * cos(re)) * (exp(-im) + exp(im))) <= (-0.05d0)) then
tmp = 2.0d0 * (((-0.25d0) * (re * re)) - (-0.5d0))
else
tmp = 0.5d0 * 2.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (((0.5 * Math.cos(re)) * (Math.exp(-im) + Math.exp(im))) <= -0.05) {
tmp = 2.0 * ((-0.25 * (re * re)) - -0.5);
} else {
tmp = 0.5 * 2.0;
}
return tmp;
}
def code(re, im): tmp = 0 if ((0.5 * math.cos(re)) * (math.exp(-im) + math.exp(im))) <= -0.05: tmp = 2.0 * ((-0.25 * (re * re)) - -0.5) else: tmp = 0.5 * 2.0 return tmp
function code(re, im) tmp = 0.0 if (Float64(Float64(0.5 * cos(re)) * Float64(exp(Float64(-im)) + exp(im))) <= -0.05) tmp = Float64(2.0 * Float64(Float64(-0.25 * Float64(re * re)) - -0.5)); else tmp = Float64(0.5 * 2.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (((0.5 * cos(re)) * (exp(-im) + exp(im))) <= -0.05) tmp = 2.0 * ((-0.25 * (re * re)) - -0.5); else tmp = 0.5 * 2.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[(N[(1/2 * N[Cos[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -3602879701896397/72057594037927936], N[(2 * N[(N[(-1/4 * N[(re * re), $MachinePrecision]), $MachinePrecision] - -1/2), $MachinePrecision]), $MachinePrecision], N[(1/2 * 2), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right) \leq \frac{-3602879701896397}{72057594037927936}:\\
\;\;\;\;2 \cdot \left(\frac{-1}{4} \cdot \left(re \cdot re\right) - \frac{-1}{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot 2\\
\end{array}
if (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) < -0.050000000000000003Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6433.0%
Applied rewrites33.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6433.0%
lift-+.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
lift-pow.f64N/A
unpow2N/A
lower-*.f64N/A
metadata-eval33.0%
Applied rewrites33.0%
if -0.050000000000000003 < (*.f64 (*.f64 #s(literal 1/2 binary64) (cos.f64 re)) (+.f64 (exp.f64 (neg.f64 im)) (exp.f64 im))) Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
Applied rewrites28.6%
(FPCore (re im) :precision binary64 (* 1/2 2))
double code(double re, double im) {
return 0.5 * 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 * 2.0d0
end function
public static double code(double re, double im) {
return 0.5 * 2.0;
}
def code(re, im): return 0.5 * 2.0
function code(re, im) return Float64(0.5 * 2.0) end
function tmp = code(re, im) tmp = 0.5 * 2.0; end
code[re_, im_] := N[(1/2 * 2), $MachinePrecision]
\frac{1}{2} \cdot 2
Initial program 100.0%
Taylor expanded in im around 0
Applied rewrites51.2%
Taylor expanded in re around 0
Applied rewrites28.6%
herbie shell --seed 2025285 -o generate:evaluate
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 1/2 (cos re)) (+ (exp (- im)) (exp im))))