
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 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(j, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}
\end{array}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 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(j, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
t_0 = cos((k / 2.0d0))
code = (((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) return ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) end
function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}
\end{array}
\end{array}
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (* K 0.5)))
(t_1 (cos (/ K 2.0)))
(t_2
(*
(* (* -2.0 J) t_1)
(sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_1)) 2.0)))))
(t_3 (cos (* 0.5 K))))
(if (<= t_2 (- INFINITY))
(* -2.0 (* t_3 (* -1.0 (* U (sqrt (/ 0.25 (pow t_3 2.0)))))))
(if (<= t_2 5e+302)
(* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (+ J J) t_0)) 2.0))))
(* -2.0 (* -0.5 U))))))
double code(double J, double K, double U) {
double t_0 = cos((K * 0.5));
double t_1 = cos((K / 2.0));
double t_2 = ((-2.0 * J) * t_1) * sqrt((1.0 + pow((U / ((2.0 * J) * t_1)), 2.0)));
double t_3 = cos((0.5 * K));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = -2.0 * (t_3 * (-1.0 * (U * sqrt((0.25 / pow(t_3, 2.0))))));
} else if (t_2 <= 5e+302) {
tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((J + J) * t_0)), 2.0)));
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K * 0.5));
double t_1 = Math.cos((K / 2.0));
double t_2 = ((-2.0 * J) * t_1) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_1)), 2.0)));
double t_3 = Math.cos((0.5 * K));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = -2.0 * (t_3 * (-1.0 * (U * Math.sqrt((0.25 / Math.pow(t_3, 2.0))))));
} else if (t_2 <= 5e+302) {
tmp = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((J + J) * t_0)), 2.0)));
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
def code(J, K, U): t_0 = math.cos((K * 0.5)) t_1 = math.cos((K / 2.0)) t_2 = ((-2.0 * J) * t_1) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_1)), 2.0))) t_3 = math.cos((0.5 * K)) tmp = 0 if t_2 <= -math.inf: tmp = -2.0 * (t_3 * (-1.0 * (U * math.sqrt((0.25 / math.pow(t_3, 2.0)))))) elif t_2 <= 5e+302: tmp = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((J + J) * t_0)), 2.0))) else: tmp = -2.0 * (-0.5 * U) return tmp
function code(J, K, U) t_0 = cos(Float64(K * 0.5)) t_1 = cos(Float64(K / 2.0)) t_2 = Float64(Float64(Float64(-2.0 * J) * t_1) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_1)) ^ 2.0)))) t_3 = cos(Float64(0.5 * K)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(-2.0 * Float64(t_3 * Float64(-1.0 * Float64(U * sqrt(Float64(0.25 / (t_3 ^ 2.0))))))); elseif (t_2 <= 5e+302) tmp = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(J + J) * t_0)) ^ 2.0)))); else tmp = Float64(-2.0 * Float64(-0.5 * U)); end return tmp end
function tmp_2 = code(J, K, U) t_0 = cos((K * 0.5)); t_1 = cos((K / 2.0)); t_2 = ((-2.0 * J) * t_1) * sqrt((1.0 + ((U / ((2.0 * J) * t_1)) ^ 2.0))); t_3 = cos((0.5 * K)); tmp = 0.0; if (t_2 <= -Inf) tmp = -2.0 * (t_3 * (-1.0 * (U * sqrt((0.25 / (t_3 ^ 2.0)))))); elseif (t_2 <= 5e+302) tmp = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((J + J) * t_0)) ^ 2.0))); else tmp = -2.0 * (-0.5 * U); end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$1), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(-2.0 * N[(t$95$3 * N[(-1.0 * N[(U * N[Sqrt[N[(0.25 / N[Power[t$95$3, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+302], N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(J + J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(K \cdot 0.5\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := \left(\left(-2 \cdot J\right) \cdot t\_1\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_1}\right)}^{2}}\\
t_3 := \cos \left(0.5 \cdot K\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;-2 \cdot \left(t\_3 \cdot \left(-1 \cdot \left(U \cdot \sqrt{\frac{0.25}{{t\_3}^{2}}}\right)\right)\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(J + J\right) \cdot t\_0}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(-0.5 \cdot U\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -inf.0Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in U around -inf
Applied rewrites26.4%
if -inf.0 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < 5e302Initial program 72.8%
Applied rewrites72.8%
if 5e302 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0)))))
(t_2 (cos (* 0.5 K))))
(if (<= t_1 (- INFINITY))
(* -2.0 (* t_2 (* -1.0 (* U (sqrt (/ 0.25 (pow t_2 2.0)))))))
(if (<= t_1 5e+302)
(*
(* (* -2.0 J) (cos (* K 0.5)))
(sqrt (+ 1.0 (pow (* 0.5 (/ U J)) 2.0))))
(* -2.0 (* -0.5 U))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
double t_2 = cos((0.5 * K));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -2.0 * (t_2 * (-1.0 * (U * sqrt((0.25 / pow(t_2, 2.0))))));
} else if (t_1 <= 5e+302) {
tmp = ((-2.0 * J) * cos((K * 0.5))) * sqrt((1.0 + pow((0.5 * (U / J)), 2.0)));
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
double t_2 = Math.cos((0.5 * K));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -2.0 * (t_2 * (-1.0 * (U * Math.sqrt((0.25 / Math.pow(t_2, 2.0))))));
} else if (t_1 <= 5e+302) {
tmp = ((-2.0 * J) * Math.cos((K * 0.5))) * Math.sqrt((1.0 + Math.pow((0.5 * (U / J)), 2.0)));
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0))) t_2 = math.cos((0.5 * K)) tmp = 0 if t_1 <= -math.inf: tmp = -2.0 * (t_2 * (-1.0 * (U * math.sqrt((0.25 / math.pow(t_2, 2.0)))))) elif t_1 <= 5e+302: tmp = ((-2.0 * J) * math.cos((K * 0.5))) * math.sqrt((1.0 + math.pow((0.5 * (U / J)), 2.0))) else: tmp = -2.0 * (-0.5 * U) return tmp
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) t_2 = cos(Float64(0.5 * K)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-2.0 * Float64(t_2 * Float64(-1.0 * Float64(U * sqrt(Float64(0.25 / (t_2 ^ 2.0))))))); elseif (t_1 <= 5e+302) tmp = Float64(Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) * sqrt(Float64(1.0 + (Float64(0.5 * Float64(U / J)) ^ 2.0)))); else tmp = Float64(-2.0 * Float64(-0.5 * U)); end return tmp end
function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); t_2 = cos((0.5 * K)); tmp = 0.0; if (t_1 <= -Inf) tmp = -2.0 * (t_2 * (-1.0 * (U * sqrt((0.25 / (t_2 ^ 2.0)))))); elseif (t_1 <= 5e+302) tmp = ((-2.0 * J) * cos((K * 0.5))) * sqrt((1.0 + ((0.5 * (U / J)) ^ 2.0))); else tmp = -2.0 * (-0.5 * U); end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(-2.0 * N[(t$95$2 * N[(-1.0 * N[(U * N[Sqrt[N[(0.25 / N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+302], N[(N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}\\
t_2 := \cos \left(0.5 \cdot K\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;-2 \cdot \left(t\_2 \cdot \left(-1 \cdot \left(U \cdot \sqrt{\frac{0.25}{{t\_2}^{2}}}\right)\right)\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \sqrt{1 + {\left(0.5 \cdot \frac{U}{J}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(-0.5 \cdot U\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -inf.0Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in U around -inf
Applied rewrites26.4%
if -inf.0 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < 5e302Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in K around 0
Applied rewrites64.3%
if 5e302 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* (* -2.0 J) t_0)
(sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0)))))
(t_2 (cos (* 0.5 K))))
(if (<= t_1 (- INFINITY))
(* 2.0 (* U (* t_2 (sqrt (/ 0.25 (pow t_2 2.0))))))
(if (<= t_1 5e+302)
(*
(* (* -2.0 J) (cos (* K 0.5)))
(sqrt (+ 1.0 (pow (* 0.5 (/ U J)) 2.0))))
(* -2.0 (* -0.5 U))))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)));
double t_2 = cos((0.5 * K));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = 2.0 * (U * (t_2 * sqrt((0.25 / pow(t_2, 2.0)))));
} else if (t_1 <= 5e+302) {
tmp = ((-2.0 * J) * cos((K * 0.5))) * sqrt((1.0 + pow((0.5 * (U / J)), 2.0)));
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = ((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)));
double t_2 = Math.cos((0.5 * K));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = 2.0 * (U * (t_2 * Math.sqrt((0.25 / Math.pow(t_2, 2.0)))));
} else if (t_1 <= 5e+302) {
tmp = ((-2.0 * J) * Math.cos((K * 0.5))) * Math.sqrt((1.0 + Math.pow((0.5 * (U / J)), 2.0)));
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = ((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0))) t_2 = math.cos((0.5 * K)) tmp = 0 if t_1 <= -math.inf: tmp = 2.0 * (U * (t_2 * math.sqrt((0.25 / math.pow(t_2, 2.0))))) elif t_1 <= 5e+302: tmp = ((-2.0 * J) * math.cos((K * 0.5))) * math.sqrt((1.0 + math.pow((0.5 * (U / J)), 2.0))) else: tmp = -2.0 * (-0.5 * U) return tmp
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) t_2 = cos(Float64(0.5 * K)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(2.0 * Float64(U * Float64(t_2 * sqrt(Float64(0.25 / (t_2 ^ 2.0)))))); elseif (t_1 <= 5e+302) tmp = Float64(Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) * sqrt(Float64(1.0 + (Float64(0.5 * Float64(U / J)) ^ 2.0)))); else tmp = Float64(-2.0 * Float64(-0.5 * U)); end return tmp end
function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = ((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0))); t_2 = cos((0.5 * K)); tmp = 0.0; if (t_1 <= -Inf) tmp = 2.0 * (U * (t_2 * sqrt((0.25 / (t_2 ^ 2.0))))); elseif (t_1 <= 5e+302) tmp = ((-2.0 * J) * cos((K * 0.5))) * sqrt((1.0 + ((0.5 * (U / J)) ^ 2.0))); else tmp = -2.0 * (-0.5 * U); end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(2.0 * N[(U * N[(t$95$2 * N[Sqrt[N[(0.25 / N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+302], N[(N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}}\\
t_2 := \cos \left(0.5 \cdot K\right)\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;2 \cdot \left(U \cdot \left(t\_2 \cdot \sqrt{\frac{0.25}{{t\_2}^{2}}}\right)\right)\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \sqrt{1 + {\left(0.5 \cdot \frac{U}{J}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(-0.5 \cdot U\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -inf.0Initial program 72.8%
Taylor expanded in U around -inf
Applied rewrites13.2%
Taylor expanded in J around 0
Applied rewrites26.4%
if -inf.0 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < 5e302Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in K around 0
Applied rewrites64.3%
if 5e302 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* -0.5 U)))
(t_1 (cos (/ K 2.0)))
(t_2
(*
(* (* -2.0 J) t_1)
(sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_1)) 2.0))))))
(if (<= t_2 (- INFINITY))
t_0
(if (<= t_2 5e+302)
(*
(* (* -2.0 J) (cos (* K 0.5)))
(sqrt (+ 1.0 (pow (* 0.5 (/ U J)) 2.0))))
t_0))))
double code(double J, double K, double U) {
double t_0 = -2.0 * (-0.5 * U);
double t_1 = cos((K / 2.0));
double t_2 = ((-2.0 * J) * t_1) * sqrt((1.0 + pow((U / ((2.0 * J) * t_1)), 2.0)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_0;
} else if (t_2 <= 5e+302) {
tmp = ((-2.0 * J) * cos((K * 0.5))) * sqrt((1.0 + pow((0.5 * (U / J)), 2.0)));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double J, double K, double U) {
double t_0 = -2.0 * (-0.5 * U);
double t_1 = Math.cos((K / 2.0));
double t_2 = ((-2.0 * J) * t_1) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_1)), 2.0)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_0;
} else if (t_2 <= 5e+302) {
tmp = ((-2.0 * J) * Math.cos((K * 0.5))) * Math.sqrt((1.0 + Math.pow((0.5 * (U / J)), 2.0)));
} else {
tmp = t_0;
}
return tmp;
}
def code(J, K, U): t_0 = -2.0 * (-0.5 * U) t_1 = math.cos((K / 2.0)) t_2 = ((-2.0 * J) * t_1) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_1)), 2.0))) tmp = 0 if t_2 <= -math.inf: tmp = t_0 elif t_2 <= 5e+302: tmp = ((-2.0 * J) * math.cos((K * 0.5))) * math.sqrt((1.0 + math.pow((0.5 * (U / J)), 2.0))) else: tmp = t_0 return tmp
function code(J, K, U) t_0 = Float64(-2.0 * Float64(-0.5 * U)) t_1 = cos(Float64(K / 2.0)) t_2 = Float64(Float64(Float64(-2.0 * J) * t_1) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_1)) ^ 2.0)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_0; elseif (t_2 <= 5e+302) tmp = Float64(Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) * sqrt(Float64(1.0 + (Float64(0.5 * Float64(U / J)) ^ 2.0)))); else tmp = t_0; end return tmp end
function tmp_2 = code(J, K, U) t_0 = -2.0 * (-0.5 * U); t_1 = cos((K / 2.0)); t_2 = ((-2.0 * J) * t_1) * sqrt((1.0 + ((U / ((2.0 * J) * t_1)) ^ 2.0))); tmp = 0.0; if (t_2 <= -Inf) tmp = t_0; elseif (t_2 <= 5e+302) tmp = ((-2.0 * J) * cos((K * 0.5))) * sqrt((1.0 + ((0.5 * (U / J)) ^ 2.0))); else tmp = t_0; end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$1), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$0, If[LessEqual[t$95$2, 5e+302], N[(N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \left(-0.5 \cdot U\right)\\
t_1 := \cos \left(\frac{K}{2}\right)\\
t_2 := \left(\left(-2 \cdot J\right) \cdot t\_1\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_1}\right)}^{2}}\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+302}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot \sqrt{1 + {\left(0.5 \cdot \frac{U}{J}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -inf.0 or 5e302 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
if -inf.0 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < 5e302Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in K around 0
Applied rewrites64.3%
(FPCore (J K U)
:precision binary64
(if (<= K 8e-6)
(*
(fma -2.0 J (* 0.25 (* J (pow K 2.0))))
(sqrt (+ 1.0 (pow (* 0.5 (/ U J)) 2.0))))
(* (* (* -2.0 J) (cos (* K 0.5))) 1.0)))
double code(double J, double K, double U) {
double tmp;
if (K <= 8e-6) {
tmp = fma(-2.0, J, (0.25 * (J * pow(K, 2.0)))) * sqrt((1.0 + pow((0.5 * (U / J)), 2.0)));
} else {
tmp = ((-2.0 * J) * cos((K * 0.5))) * 1.0;
}
return tmp;
}
function code(J, K, U) tmp = 0.0 if (K <= 8e-6) tmp = Float64(fma(-2.0, J, Float64(0.25 * Float64(J * (K ^ 2.0)))) * sqrt(Float64(1.0 + (Float64(0.5 * Float64(U / J)) ^ 2.0)))); else tmp = Float64(Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) * 1.0); end return tmp end
code[J_, K_, U_] := If[LessEqual[K, 8e-6], N[(N[(-2.0 * J + N[(0.25 * N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;K \leq 8 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(-2, J, 0.25 \cdot \left(J \cdot {K}^{2}\right)\right) \cdot \sqrt{1 + {\left(0.5 \cdot \frac{U}{J}\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot 1\\
\end{array}
\end{array}
if K < 7.99999999999999964e-6Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in K around 0
Applied rewrites64.3%
Taylor expanded in K around 0
Applied rewrites38.2%
if 7.99999999999999964e-6 < K Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in J around inf
Applied rewrites51.6%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* -0.5 U))))
(if (<= U -3.3e+147)
t_0
(if (<= U -4.3e-98)
(* -2.0 (* J (sqrt (+ 1.0 (* 0.25 (/ (pow U 2.0) (pow J 2.0)))))))
(if (<= U 3.6e+139) (* (* (* -2.0 J) (cos (* K 0.5))) 1.0) t_0)))))
double code(double J, double K, double U) {
double t_0 = -2.0 * (-0.5 * U);
double tmp;
if (U <= -3.3e+147) {
tmp = t_0;
} else if (U <= -4.3e-98) {
tmp = -2.0 * (J * sqrt((1.0 + (0.25 * (pow(U, 2.0) / pow(J, 2.0))))));
} else if (U <= 3.6e+139) {
tmp = ((-2.0 * J) * cos((K * 0.5))) * 1.0;
} else {
tmp = t_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(j, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = (-2.0d0) * ((-0.5d0) * u)
if (u <= (-3.3d+147)) then
tmp = t_0
else if (u <= (-4.3d-98)) then
tmp = (-2.0d0) * (j * sqrt((1.0d0 + (0.25d0 * ((u ** 2.0d0) / (j ** 2.0d0))))))
else if (u <= 3.6d+139) then
tmp = (((-2.0d0) * j) * cos((k * 0.5d0))) * 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double t_0 = -2.0 * (-0.5 * U);
double tmp;
if (U <= -3.3e+147) {
tmp = t_0;
} else if (U <= -4.3e-98) {
tmp = -2.0 * (J * Math.sqrt((1.0 + (0.25 * (Math.pow(U, 2.0) / Math.pow(J, 2.0))))));
} else if (U <= 3.6e+139) {
tmp = ((-2.0 * J) * Math.cos((K * 0.5))) * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(J, K, U): t_0 = -2.0 * (-0.5 * U) tmp = 0 if U <= -3.3e+147: tmp = t_0 elif U <= -4.3e-98: tmp = -2.0 * (J * math.sqrt((1.0 + (0.25 * (math.pow(U, 2.0) / math.pow(J, 2.0)))))) elif U <= 3.6e+139: tmp = ((-2.0 * J) * math.cos((K * 0.5))) * 1.0 else: tmp = t_0 return tmp
function code(J, K, U) t_0 = Float64(-2.0 * Float64(-0.5 * U)) tmp = 0.0 if (U <= -3.3e+147) tmp = t_0; elseif (U <= -4.3e-98) tmp = Float64(-2.0 * Float64(J * sqrt(Float64(1.0 + Float64(0.25 * Float64((U ^ 2.0) / (J ^ 2.0))))))); elseif (U <= 3.6e+139) tmp = Float64(Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) * 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(J, K, U) t_0 = -2.0 * (-0.5 * U); tmp = 0.0; if (U <= -3.3e+147) tmp = t_0; elseif (U <= -4.3e-98) tmp = -2.0 * (J * sqrt((1.0 + (0.25 * ((U ^ 2.0) / (J ^ 2.0)))))); elseif (U <= 3.6e+139) tmp = ((-2.0 * J) * cos((K * 0.5))) * 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U, -3.3e+147], t$95$0, If[LessEqual[U, -4.3e-98], N[(-2.0 * N[(J * N[Sqrt[N[(1.0 + N[(0.25 * N[(N[Power[U, 2.0], $MachinePrecision] / N[Power[J, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 3.6e+139], N[(N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \left(-0.5 \cdot U\right)\\
\mathbf{if}\;U \leq -3.3 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U \leq -4.3 \cdot 10^{-98}:\\
\;\;\;\;-2 \cdot \left(J \cdot \sqrt{1 + 0.25 \cdot \frac{{U}^{2}}{{J}^{2}}}\right)\\
\mathbf{elif}\;U \leq 3.6 \cdot 10^{+139}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if U < -3.30000000000000025e147 or 3.59999999999999985e139 < U Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
if -3.30000000000000025e147 < U < -4.29999999999999988e-98Initial program 72.8%
Taylor expanded in K around 0
Applied rewrites33.2%
if -4.29999999999999988e-98 < U < 3.59999999999999985e139Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in J around inf
Applied rewrites51.6%
(FPCore (J K U)
:precision binary64
(if (<= U -8.8e+33)
(* 2.0 (* J (* U (sqrt (/ 0.25 (pow J 2.0))))))
(if (<= U 3.6e+139)
(* (* (* -2.0 J) (cos (* K 0.5))) 1.0)
(* -2.0 (* -0.5 U)))))
double code(double J, double K, double U) {
double tmp;
if (U <= -8.8e+33) {
tmp = 2.0 * (J * (U * sqrt((0.25 / pow(J, 2.0)))));
} else if (U <= 3.6e+139) {
tmp = ((-2.0 * J) * cos((K * 0.5))) * 1.0;
} else {
tmp = -2.0 * (-0.5 * U);
}
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(j, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (u <= (-8.8d+33)) then
tmp = 2.0d0 * (j * (u * sqrt((0.25d0 / (j ** 2.0d0)))))
else if (u <= 3.6d+139) then
tmp = (((-2.0d0) * j) * cos((k * 0.5d0))) * 1.0d0
else
tmp = (-2.0d0) * ((-0.5d0) * u)
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double tmp;
if (U <= -8.8e+33) {
tmp = 2.0 * (J * (U * Math.sqrt((0.25 / Math.pow(J, 2.0)))));
} else if (U <= 3.6e+139) {
tmp = ((-2.0 * J) * Math.cos((K * 0.5))) * 1.0;
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
def code(J, K, U): tmp = 0 if U <= -8.8e+33: tmp = 2.0 * (J * (U * math.sqrt((0.25 / math.pow(J, 2.0))))) elif U <= 3.6e+139: tmp = ((-2.0 * J) * math.cos((K * 0.5))) * 1.0 else: tmp = -2.0 * (-0.5 * U) return tmp
function code(J, K, U) tmp = 0.0 if (U <= -8.8e+33) tmp = Float64(2.0 * Float64(J * Float64(U * sqrt(Float64(0.25 / (J ^ 2.0)))))); elseif (U <= 3.6e+139) tmp = Float64(Float64(Float64(-2.0 * J) * cos(Float64(K * 0.5))) * 1.0); else tmp = Float64(-2.0 * Float64(-0.5 * U)); end return tmp end
function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= -8.8e+33) tmp = 2.0 * (J * (U * sqrt((0.25 / (J ^ 2.0))))); elseif (U <= 3.6e+139) tmp = ((-2.0 * J) * cos((K * 0.5))) * 1.0; else tmp = -2.0 * (-0.5 * U); end tmp_2 = tmp; end
code[J_, K_, U_] := If[LessEqual[U, -8.8e+33], N[(2.0 * N[(J * N[(U * N[Sqrt[N[(0.25 / N[Power[J, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 3.6e+139], N[(N[(N[(-2.0 * J), $MachinePrecision] * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -8.8 \cdot 10^{+33}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(U \cdot \sqrt{\frac{0.25}{{J}^{2}}}\right)\right)\\
\mathbf{elif}\;U \leq 3.6 \cdot 10^{+139}:\\
\;\;\;\;\left(\left(-2 \cdot J\right) \cdot \cos \left(K \cdot 0.5\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(-0.5 \cdot U\right)\\
\end{array}
\end{array}
if U < -8.79999999999999975e33Initial program 72.8%
Taylor expanded in U around -inf
Applied rewrites13.2%
Taylor expanded in K around 0
Applied rewrites13.1%
if -8.79999999999999975e33 < U < 3.59999999999999985e139Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in J around inf
Applied rewrites51.6%
if 3.59999999999999985e139 < U Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
(FPCore (J K U)
:precision binary64
(if (<= U -1.06e+30)
(* 2.0 (* J (* U (sqrt (/ 0.25 (pow J 2.0))))))
(if (<= U 2.4e+75)
(* (fma -2.0 J (* 0.25 (* J (pow K 2.0)))) 1.0)
(* -2.0 (* -0.5 U)))))
double code(double J, double K, double U) {
double tmp;
if (U <= -1.06e+30) {
tmp = 2.0 * (J * (U * sqrt((0.25 / pow(J, 2.0)))));
} else if (U <= 2.4e+75) {
tmp = fma(-2.0, J, (0.25 * (J * pow(K, 2.0)))) * 1.0;
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
function code(J, K, U) tmp = 0.0 if (U <= -1.06e+30) tmp = Float64(2.0 * Float64(J * Float64(U * sqrt(Float64(0.25 / (J ^ 2.0)))))); elseif (U <= 2.4e+75) tmp = Float64(fma(-2.0, J, Float64(0.25 * Float64(J * (K ^ 2.0)))) * 1.0); else tmp = Float64(-2.0 * Float64(-0.5 * U)); end return tmp end
code[J_, K_, U_] := If[LessEqual[U, -1.06e+30], N[(2.0 * N[(J * N[(U * N[Sqrt[N[(0.25 / N[Power[J, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 2.4e+75], N[(N[(-2.0 * J + N[(0.25 * N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;U \leq -1.06 \cdot 10^{+30}:\\
\;\;\;\;2 \cdot \left(J \cdot \left(U \cdot \sqrt{\frac{0.25}{{J}^{2}}}\right)\right)\\
\mathbf{elif}\;U \leq 2.4 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(-2, J, 0.25 \cdot \left(J \cdot {K}^{2}\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(-0.5 \cdot U\right)\\
\end{array}
\end{array}
if U < -1.06e30Initial program 72.8%
Taylor expanded in U around -inf
Applied rewrites13.2%
Taylor expanded in K around 0
Applied rewrites13.1%
if -1.06e30 < U < 2.4e75Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in J around inf
Applied rewrites51.6%
Taylor expanded in K around 0
Applied rewrites27.3%
if 2.4e75 < U Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* -2.0 (* -0.5 U))))
(if (<= U -3.8e-26)
t_0
(if (<= U 2.4e+75) (* (fma -2.0 J (* 0.25 (* J (pow K 2.0)))) 1.0) t_0))))
double code(double J, double K, double U) {
double t_0 = -2.0 * (-0.5 * U);
double tmp;
if (U <= -3.8e-26) {
tmp = t_0;
} else if (U <= 2.4e+75) {
tmp = fma(-2.0, J, (0.25 * (J * pow(K, 2.0)))) * 1.0;
} else {
tmp = t_0;
}
return tmp;
}
function code(J, K, U) t_0 = Float64(-2.0 * Float64(-0.5 * U)) tmp = 0.0 if (U <= -3.8e-26) tmp = t_0; elseif (U <= 2.4e+75) tmp = Float64(fma(-2.0, J, Float64(0.25 * Float64(J * (K ^ 2.0)))) * 1.0); else tmp = t_0; end return tmp end
code[J_, K_, U_] := Block[{t$95$0 = N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[U, -3.8e-26], t$95$0, If[LessEqual[U, 2.4e+75], N[(N[(-2.0 * J + N[(0.25 * N[(J * N[Power[K, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -2 \cdot \left(-0.5 \cdot U\right)\\
\mathbf{if}\;U \leq -3.8 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;U \leq 2.4 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{fma}\left(-2, J, 0.25 \cdot \left(J \cdot {K}^{2}\right)\right) \cdot 1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if U < -3.80000000000000015e-26 or 2.4e75 < U Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
if -3.80000000000000015e-26 < U < 2.4e75Initial program 72.8%
Applied rewrites72.8%
Taylor expanded in J around inf
Applied rewrites51.6%
Taylor expanded in K around 0
Applied rewrites27.3%
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0))))
(if (<=
(* (* (* -2.0 J) t_0) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) t_0)) 2.0))))
-1e-138)
(* -2.0 (sqrt (* 0.25 (pow U 2.0))))
(* -2.0 (* -0.5 U)))))
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double tmp;
if ((((-2.0 * J) * t_0) * sqrt((1.0 + pow((U / ((2.0 * J) * t_0)), 2.0)))) <= -1e-138) {
tmp = -2.0 * sqrt((0.25 * pow(U, 2.0)));
} else {
tmp = -2.0 * (-0.5 * U);
}
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(j, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = cos((k / 2.0d0))
if (((((-2.0d0) * j) * t_0) * sqrt((1.0d0 + ((u / ((2.0d0 * j) * t_0)) ** 2.0d0)))) <= (-1d-138)) then
tmp = (-2.0d0) * sqrt((0.25d0 * (u ** 2.0d0)))
else
tmp = (-2.0d0) * ((-0.5d0) * u)
end if
code = tmp
end function
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double tmp;
if ((((-2.0 * J) * t_0) * Math.sqrt((1.0 + Math.pow((U / ((2.0 * J) * t_0)), 2.0)))) <= -1e-138) {
tmp = -2.0 * Math.sqrt((0.25 * Math.pow(U, 2.0)));
} else {
tmp = -2.0 * (-0.5 * U);
}
return tmp;
}
def code(J, K, U): t_0 = math.cos((K / 2.0)) tmp = 0 if (((-2.0 * J) * t_0) * math.sqrt((1.0 + math.pow((U / ((2.0 * J) * t_0)), 2.0)))) <= -1e-138: tmp = -2.0 * math.sqrt((0.25 * math.pow(U, 2.0))) else: tmp = -2.0 * (-0.5 * U) return tmp
function code(J, K, U) t_0 = cos(Float64(K / 2.0)) tmp = 0.0 if (Float64(Float64(Float64(-2.0 * J) * t_0) * sqrt(Float64(1.0 + (Float64(U / Float64(Float64(2.0 * J) * t_0)) ^ 2.0)))) <= -1e-138) tmp = Float64(-2.0 * sqrt(Float64(0.25 * (U ^ 2.0)))); else tmp = Float64(-2.0 * Float64(-0.5 * U)); end return tmp end
function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); tmp = 0.0; if ((((-2.0 * J) * t_0) * sqrt((1.0 + ((U / ((2.0 * J) * t_0)) ^ 2.0)))) <= -1e-138) tmp = -2.0 * sqrt((0.25 * (U ^ 2.0))); else tmp = -2.0 * (-0.5 * U); end tmp_2 = tmp; end
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(-2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(N[(2.0 * J), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -1e-138], N[(-2.0 * N[Sqrt[N[(0.25 * N[Power[U, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
\mathbf{if}\;\left(\left(-2 \cdot J\right) \cdot t\_0\right) \cdot \sqrt{1 + {\left(\frac{U}{\left(2 \cdot J\right) \cdot t\_0}\right)}^{2}} \leq -1 \cdot 10^{-138}:\\
\;\;\;\;-2 \cdot \sqrt{0.25 \cdot {U}^{2}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \left(-0.5 \cdot U\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) < -1.00000000000000007e-138Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
if -1.00000000000000007e-138 < (*.f64 (*.f64 (*.f64 #s(literal -2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64)))) (sqrt.f64 (+.f64 #s(literal 1 binary64) (pow.f64 (/.f64 U (*.f64 (*.f64 #s(literal 2 binary64) J) (cos.f64 (/.f64 K #s(literal 2 binary64))))) #s(literal 2 binary64))))) Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
(FPCore (J K U) :precision binary64 (* -2.0 (* -0.5 U)))
double code(double J, double K, double U) {
return -2.0 * (-0.5 * U);
}
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(j, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = (-2.0d0) * ((-0.5d0) * u)
end function
public static double code(double J, double K, double U) {
return -2.0 * (-0.5 * U);
}
def code(J, K, U): return -2.0 * (-0.5 * U)
function code(J, K, U) return Float64(-2.0 * Float64(-0.5 * U)) end
function tmp = code(J, K, U) tmp = -2.0 * (-0.5 * U); end
code[J_, K_, U_] := N[(-2.0 * N[(-0.5 * U), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \left(-0.5 \cdot U\right)
\end{array}
Initial program 72.8%
Taylor expanded in J around 0
Applied rewrites15.5%
Taylor expanded in K around 0
Applied rewrites16.1%
Taylor expanded in U around -inf
Applied rewrites27.0%
herbie shell --seed 2025160
(FPCore (J K U)
:name "Maksimov and Kolovsky, Equation (3)"
:precision binary64
(* (* (* -2.0 J) (cos (/ K 2.0))) (sqrt (+ 1.0 (pow (/ U (* (* 2.0 J) (cos (/ K 2.0)))) 2.0)))))