
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + 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, l, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (J l K U) :precision binary64 (+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + 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, l, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * (exp(l) - exp(-l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * (Math.exp(l) - Math.exp(-l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * (math.exp(l) - math.exp(-l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(exp(l) - exp(Float64(-l)))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * (exp(l) - exp(-l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[Exp[l], $MachinePrecision] - N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(e^{\ell} - e^{-\ell}\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
(FPCore (J l K U) :precision binary64 (+ (* (* J (* (* (cosh l) 2.0) (tanh l))) (cos (/ K 2.0))) U))
double code(double J, double l, double K, double U) {
return ((J * ((cosh(l) * 2.0) * tanh(l))) * cos((K / 2.0))) + 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, l, k, u)
use fmin_fmax_functions
real(8), intent (in) :: j
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8), intent (in) :: u
code = ((j * ((cosh(l) * 2.0d0) * tanh(l))) * cos((k / 2.0d0))) + u
end function
public static double code(double J, double l, double K, double U) {
return ((J * ((Math.cosh(l) * 2.0) * Math.tanh(l))) * Math.cos((K / 2.0))) + U;
}
def code(J, l, K, U): return ((J * ((math.cosh(l) * 2.0) * math.tanh(l))) * math.cos((K / 2.0))) + U
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(Float64(cosh(l) * 2.0) * tanh(l))) * cos(Float64(K / 2.0))) + U) end
function tmp = code(J, l, K, U) tmp = ((J * ((cosh(l) * 2.0) * tanh(l))) * cos((K / 2.0))) + U; end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[(N[Cosh[l], $MachinePrecision] * 2.0), $MachinePrecision] * N[Tanh[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(\left(\cosh \ell \cdot 2\right) \cdot \tanh \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Initial program 85.1%
lift--.f64N/A
flip--N/A
difference-of-squaresN/A
lift--.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
cosh-undefN/A
*-commutativeN/A
lower-*.f64N/A
lower-cosh.f64N/A
lift--.f64N/A
lift-exp.f64N/A
lift-exp.f64N/A
lift-neg.f64N/A
Applied rewrites100.0%
(FPCore (J l K U) :precision binary64 (fma (* (* (sinh l) (cos (/ K -2.0))) 2.0) J U))
double code(double J, double l, double K, double U) {
return fma(((sinh(l) * cos((K / -2.0))) * 2.0), J, U);
}
function code(J, l, K, U) return fma(Float64(Float64(sinh(l) * cos(Float64(K / -2.0))) * 2.0), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[(N[Sinh[l], $MachinePrecision] * N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\sinh \ell \cdot \cos \left(\frac{K}{-2}\right)\right) \cdot 2, J, U\right)
\end{array}
Initial program 85.1%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.9%
(FPCore (J l K U)
:precision binary64
(+
(*
(*
J
(*
(fma
(fma
(fma 0.0003968253968253968 (* l l) 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
(cos (/ K 2.0)))
U))
double code(double J, double l, double K, double U) {
return ((J * (fma(fma(fma(0.0003968253968253968, (l * l), 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * cos((K / 2.0))) + U;
}
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(fma(fma(fma(0.0003968253968253968, Float64(l * l), 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) * cos(Float64(K / 2.0))) + U) end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[(N[(N[(0.0003968253968253968 * N[(l * l), $MachinePrecision] + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.0003968253968253968, \ell \cdot \ell, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.6
Applied rewrites96.6%
(FPCore (J l K U)
:precision binary64
(fma
(*
(cos (/ K -2.0))
(*
(fma
(fma
(fma (* l l) 0.0003968253968253968 0.016666666666666666)
(* l l)
0.3333333333333333)
(* l l)
2.0)
l))
J
U))
double code(double J, double l, double K, double U) {
return fma((cos((K / -2.0)) * (fma(fma(fma((l * l), 0.0003968253968253968, 0.016666666666666666), (l * l), 0.3333333333333333), (l * l), 2.0) * l)), J, U);
}
function code(J, l, K, U) return fma(Float64(cos(Float64(K / -2.0)) * Float64(fma(fma(fma(Float64(l * l), 0.0003968253968253968, 0.016666666666666666), Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.0003968253968253968 + 0.016666666666666666), $MachinePrecision] * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.0003968253968253968, 0.016666666666666666\right), \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right), J, U\right)
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6496.6
Applied rewrites96.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites96.6%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U))
(t_1 (fma (* l l) 0.3333333333333333 2.0))
(t_2 (* (* (* t_1 l) J) (cos (* -0.5 K)))))
(if (<= l -9.8e+101)
t_2
(if (<= l -7.8e+25)
t_0
(if (<= l 400.0)
(+ (* (* (* J t_1) l) (cos (/ K 2.0))) U)
(if (<= l 1.1e+100) t_0 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
double t_1 = fma((l * l), 0.3333333333333333, 2.0);
double t_2 = ((t_1 * l) * J) * cos((-0.5 * K));
double tmp;
if (l <= -9.8e+101) {
tmp = t_2;
} else if (l <= -7.8e+25) {
tmp = t_0;
} else if (l <= 400.0) {
tmp = (((J * t_1) * l) * cos((K / 2.0))) + U;
} else if (l <= 1.1e+100) {
tmp = t_0;
} else {
tmp = t_2;
}
return tmp;
}
function code(J, l, K, U) t_0 = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U) t_1 = fma(Float64(l * l), 0.3333333333333333, 2.0) t_2 = Float64(Float64(Float64(t_1 * l) * J) * cos(Float64(-0.5 * K))) tmp = 0.0 if (l <= -9.8e+101) tmp = t_2; elseif (l <= -7.8e+25) tmp = t_0; elseif (l <= 400.0) tmp = Float64(Float64(Float64(Float64(J * t_1) * l) * cos(Float64(K / 2.0))) + U); elseif (l <= 1.1e+100) tmp = t_0; else tmp = t_2; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(t$95$1 * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -9.8e+101], t$95$2, If[LessEqual[l, -7.8e+25], t$95$0, If[LessEqual[l, 400.0], N[(N[(N[(N[(J * t$95$1), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], t$95$0, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
t_1 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\
t_2 := \left(\left(t\_1 \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\
\mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 400:\\
\;\;\;\;\left(\left(J \cdot t\_1\right) \cdot \ell\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if l < -9.79999999999999965e101 or 1.1e100 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites86.1%
Taylor expanded in J around inf
Applied rewrites100.0%
if -9.79999999999999965e101 < l < -7.8000000000000004e25 or 400 < l < 1.1e100Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval19.0
Applied rewrites19.0%
Applied rewrites19.0%
Taylor expanded in K around 0
Applied rewrites38.0%
Taylor expanded in K around inf
Applied rewrites77.5%
if -7.8000000000000004e25 < l < 400Initial program 72.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.5
Applied rewrites97.5%
Final simplification95.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* -0.5 K)))
(t_1 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U))
(t_2 (fma (* l l) 0.3333333333333333 2.0))
(t_3 (* (* (* t_2 l) J) t_0)))
(if (<= l -9.8e+101)
t_3
(if (<= l -7.8e+25)
t_1
(if (<= l 400.0)
(+ (* (* t_0 (* J t_2)) l) U)
(if (<= l 1.1e+100) t_1 t_3))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((-0.5 * K));
double t_1 = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
double t_2 = fma((l * l), 0.3333333333333333, 2.0);
double t_3 = ((t_2 * l) * J) * t_0;
double tmp;
if (l <= -9.8e+101) {
tmp = t_3;
} else if (l <= -7.8e+25) {
tmp = t_1;
} else if (l <= 400.0) {
tmp = ((t_0 * (J * t_2)) * l) + U;
} else if (l <= 1.1e+100) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(-0.5 * K)) t_1 = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U) t_2 = fma(Float64(l * l), 0.3333333333333333, 2.0) t_3 = Float64(Float64(Float64(t_2 * l) * J) * t_0) tmp = 0.0 if (l <= -9.8e+101) tmp = t_3; elseif (l <= -7.8e+25) tmp = t_1; elseif (l <= 400.0) tmp = Float64(Float64(Float64(t_0 * Float64(J * t_2)) * l) + U); elseif (l <= 1.1e+100) tmp = t_1; else tmp = t_3; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$2 = N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(t$95$2 * l), $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[l, -9.8e+101], t$95$3, If[LessEqual[l, -7.8e+25], t$95$1, If[LessEqual[l, 400.0], N[(N[(N[(t$95$0 * N[(J * t$95$2), $MachinePrecision]), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], t$95$1, t$95$3]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(-0.5 \cdot K\right)\\
t_1 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
t_2 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\
t_3 := \left(\left(t\_2 \cdot \ell\right) \cdot J\right) \cdot t\_0\\
\mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq 400:\\
\;\;\;\;\left(t\_0 \cdot \left(J \cdot t\_2\right)\right) \cdot \ell + U\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if l < -9.79999999999999965e101 or 1.1e100 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites86.1%
Taylor expanded in J around inf
Applied rewrites100.0%
if -9.79999999999999965e101 < l < -7.8000000000000004e25 or 400 < l < 1.1e100Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval19.0
Applied rewrites19.0%
Applied rewrites19.0%
Taylor expanded in K around 0
Applied rewrites38.0%
Taylor expanded in K around inf
Applied rewrites77.5%
if -7.8000000000000004e25 < l < 400Initial program 72.0%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.5%
Final simplification95.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U))
(t_1
(*
(* (* (fma (* l l) 0.3333333333333333 2.0) l) J)
(cos (* -0.5 K)))))
(if (<= l -9.8e+101)
t_1
(if (<= l -7.8e+25)
t_0
(if (<= l 400.0)
(fma
(* l (* (cos (* 0.5 K)) J))
(fma 0.3333333333333333 (* l l) 2.0)
U)
(if (<= l 1.1e+100) t_0 t_1))))))
double code(double J, double l, double K, double U) {
double t_0 = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
double t_1 = ((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * cos((-0.5 * K));
double tmp;
if (l <= -9.8e+101) {
tmp = t_1;
} else if (l <= -7.8e+25) {
tmp = t_0;
} else if (l <= 400.0) {
tmp = fma((l * (cos((0.5 * K)) * J)), fma(0.3333333333333333, (l * l), 2.0), U);
} else if (l <= 1.1e+100) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(J, l, K, U) t_0 = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U) t_1 = Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * cos(Float64(-0.5 * K))) tmp = 0.0 if (l <= -9.8e+101) tmp = t_1; elseif (l <= -7.8e+25) tmp = t_0; elseif (l <= 400.0) tmp = fma(Float64(l * Float64(cos(Float64(0.5 * K)) * J)), fma(0.3333333333333333, Float64(l * l), 2.0), U); elseif (l <= 1.1e+100) tmp = t_0; else tmp = t_1; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -9.8e+101], t$95$1, If[LessEqual[l, -7.8e+25], t$95$0, If[LessEqual[l, 400.0], N[(N[(l * N[(N[Cos[N[(0.5 * K), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision]), $MachinePrecision] * N[(0.3333333333333333 * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
t_1 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\
\mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 400:\\
\;\;\;\;\mathsf{fma}\left(\ell \cdot \left(\cos \left(0.5 \cdot K\right) \cdot J\right), \mathsf{fma}\left(0.3333333333333333, \ell \cdot \ell, 2\right), U\right)\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if l < -9.79999999999999965e101 or 1.1e100 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites86.1%
Taylor expanded in J around inf
Applied rewrites100.0%
if -9.79999999999999965e101 < l < -7.8000000000000004e25 or 400 < l < 1.1e100Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval19.0
Applied rewrites19.0%
Applied rewrites19.0%
Taylor expanded in K around 0
Applied rewrites38.0%
Taylor expanded in K around inf
Applied rewrites77.5%
if -7.8000000000000004e25 < l < 400Initial program 72.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites97.5%
Applied rewrites97.5%
Final simplification95.2%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (cos (* -0.5 K)))
(t_1 (fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U))
(t_2 (* (* (* (fma (* l l) 0.3333333333333333 2.0) l) J) t_0)))
(if (<= l -9.8e+101)
t_2
(if (<= l -7.8e+25)
t_1
(if (<= l 400.0)
(fma (* (+ J J) l) t_0 U)
(if (<= l 1.1e+100) t_1 t_2))))))
double code(double J, double l, double K, double U) {
double t_0 = cos((-0.5 * K));
double t_1 = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
double t_2 = ((fma((l * l), 0.3333333333333333, 2.0) * l) * J) * t_0;
double tmp;
if (l <= -9.8e+101) {
tmp = t_2;
} else if (l <= -7.8e+25) {
tmp = t_1;
} else if (l <= 400.0) {
tmp = fma(((J + J) * l), t_0, U);
} else if (l <= 1.1e+100) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
function code(J, l, K, U) t_0 = cos(Float64(-0.5 * K)) t_1 = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U) t_2 = Float64(Float64(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) * J) * t_0) tmp = 0.0 if (l <= -9.8e+101) tmp = t_2; elseif (l <= -7.8e+25) tmp = t_1; elseif (l <= 400.0) tmp = fma(Float64(Float64(J + J) * l), t_0, U); elseif (l <= 1.1e+100) tmp = t_1; else tmp = t_2; end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[l, -9.8e+101], t$95$2, If[LessEqual[l, -7.8e+25], t$95$1, If[LessEqual[l, 400.0], N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * t$95$0 + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(-0.5 \cdot K\right)\\
t_1 := \mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
t_2 := \left(\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\right) \cdot J\right) \cdot t\_0\\
\mathbf{if}\;\ell \leq -9.8 \cdot 10^{+101}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\ell \leq 400:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, t\_0, U\right)\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if l < -9.79999999999999965e101 or 1.1e100 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites86.1%
Taylor expanded in J around inf
Applied rewrites100.0%
if -9.79999999999999965e101 < l < -7.8000000000000004e25 or 400 < l < 1.1e100Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval19.0
Applied rewrites19.0%
Applied rewrites19.0%
Taylor expanded in K around 0
Applied rewrites38.0%
Taylor expanded in K around inf
Applied rewrites77.5%
if -7.8000000000000004e25 < l < 400Initial program 72.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval97.0
Applied rewrites97.0%
Applied rewrites97.0%
Final simplification94.9%
(FPCore (J l K U)
:precision binary64
(+
(*
(*
J
(*
(fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0)
l))
(cos (/ K 2.0)))
U))
double code(double J, double l, double K, double U) {
return ((J * (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l)) * cos((K / 2.0))) + U;
}
function code(J, l, K, U) return Float64(Float64(Float64(J * Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l)) * cos(Float64(K / 2.0))) + U) end
code[J_, l_, K_, U_] := N[(N[(N[(J * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision]), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\left(J \cdot \left(\mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell\right)\right) \cdot \cos \left(\frac{K}{2}\right) + U
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.1
Applied rewrites95.1%
(FPCore (J l K U) :precision binary64 (fma (* (cos (/ K -2.0)) J) (* (fma (fma 0.016666666666666666 (* l l) 0.3333333333333333) (* l l) 2.0) l) U))
double code(double J, double l, double K, double U) {
return fma((cos((K / -2.0)) * J), (fma(fma(0.016666666666666666, (l * l), 0.3333333333333333), (l * l), 2.0) * l), U);
}
function code(J, l, K, U) return fma(Float64(cos(Float64(K / -2.0)) * J), Float64(fma(fma(0.016666666666666666, Float64(l * l), 0.3333333333333333), Float64(l * l), 2.0) * l), U) end
code[J_, l_, K_, U_] := N[(N[(N[Cos[N[(K / -2.0), $MachinePrecision]], $MachinePrecision] * J), $MachinePrecision] * N[(N[(N[(0.016666666666666666 * N[(l * l), $MachinePrecision] + 0.3333333333333333), $MachinePrecision] * N[(l * l), $MachinePrecision] + 2.0), $MachinePrecision] * l), $MachinePrecision] + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\cos \left(\frac{K}{-2}\right) \cdot J, \mathsf{fma}\left(\mathsf{fma}\left(0.016666666666666666, \ell \cdot \ell, 0.3333333333333333\right), \ell \cdot \ell, 2\right) \cdot \ell, U\right)
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6495.1
Applied rewrites95.1%
lift-+.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites95.0%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (* (fma (* l l) 0.3333333333333333 2.0) l)))
(if (<= l 400.0)
(+ (* (* J t_0) (cos (/ K 2.0))) U)
(if (<= l 1.1e+100)
(fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U)
(* (* t_0 J) (cos (* -0.5 K)))))))
double code(double J, double l, double K, double U) {
double t_0 = fma((l * l), 0.3333333333333333, 2.0) * l;
double tmp;
if (l <= 400.0) {
tmp = ((J * t_0) * cos((K / 2.0))) + U;
} else if (l <= 1.1e+100) {
tmp = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
} else {
tmp = (t_0 * J) * cos((-0.5 * K));
}
return tmp;
}
function code(J, l, K, U) t_0 = Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l) tmp = 0.0 if (l <= 400.0) tmp = Float64(Float64(Float64(J * t_0) * cos(Float64(K / 2.0))) + U); elseif (l <= 1.1e+100) tmp = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U); else tmp = Float64(Float64(t_0 * J) * cos(Float64(-0.5 * K))); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision]}, If[LessEqual[l, 400.0], N[(N[(N[(J * t$95$0), $MachinePrecision] * N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + U), $MachinePrecision], If[LessEqual[l, 1.1e+100], N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(t$95$0 * J), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell\\
\mathbf{if}\;\ell \leq 400:\\
\;\;\;\;\left(J \cdot t\_0\right) \cdot \cos \left(\frac{K}{2}\right) + U\\
\mathbf{elif}\;\ell \leq 1.1 \cdot 10^{+100}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot J\right) \cdot \cos \left(-0.5 \cdot K\right)\\
\end{array}
\end{array}
if l < 400Initial program 80.5%
Taylor expanded in l around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6493.4
Applied rewrites93.4%
if 400 < l < 1.1e100Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval17.9
Applied rewrites17.9%
Applied rewrites17.9%
Taylor expanded in K around 0
Applied rewrites36.4%
Taylor expanded in K around inf
Applied rewrites81.9%
if 1.1e100 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites81.1%
Taylor expanded in J around inf
Applied rewrites100.0%
Final simplification93.5%
(FPCore (J l K U)
:precision binary64
(if (<= l -5e+104)
(fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U)
(if (or (<= l -7.8e+25) (not (<= l 400.0)))
(fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U)
(fma (* (+ J J) l) (cos (* -0.5 K)) U))))
double code(double J, double l, double K, double U) {
double tmp;
if (l <= -5e+104) {
tmp = fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
} else if ((l <= -7.8e+25) || !(l <= 400.0)) {
tmp = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
} else {
tmp = fma(((J + J) * l), cos((-0.5 * K)), U);
}
return tmp;
}
function code(J, l, K, U) tmp = 0.0 if (l <= -5e+104) tmp = fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U); elseif ((l <= -7.8e+25) || !(l <= 400.0)) tmp = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U); else tmp = fma(Float64(Float64(J + J) * l), cos(Float64(-0.5 * K)), U); end return tmp end
code[J_, l_, K_, U_] := If[LessEqual[l, -5e+104], N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision], If[Or[LessEqual[l, -7.8e+25], N[Not[LessEqual[l, 400.0]], $MachinePrecision]], N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(N[(J + J), $MachinePrecision] * l), $MachinePrecision] * N[Cos[N[(-0.5 * K), $MachinePrecision]], $MachinePrecision] + U), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{+104}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)\\
\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 400\right):\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(J + J\right) \cdot \ell, \cos \left(-0.5 \cdot K\right), U\right)\\
\end{array}
\end{array}
if l < -4.9999999999999997e104Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.9%
Applied rewrites90.9%
Taylor expanded in K around 0
Applied rewrites87.8%
if -4.9999999999999997e104 < l < -7.8000000000000004e25 or 400 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval22.5
Applied rewrites22.5%
Applied rewrites22.5%
Taylor expanded in K around 0
Applied rewrites35.1%
Taylor expanded in K around inf
Applied rewrites76.3%
if -7.8000000000000004e25 < l < 400Initial program 72.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval97.0
Applied rewrites97.0%
Applied rewrites97.0%
Final simplification89.1%
(FPCore (J l K U)
:precision binary64
(let* ((t_0 (fma (* l l) 0.3333333333333333 2.0)))
(if (<= l -5e+104)
(fma (* t_0 l) J U)
(if (or (<= l -7.8e+25) (not (<= l 400.0)))
(fma (* (* (fma -0.125 l (/ l (* K K))) K) K) (* 2.0 J) U)
(fma (* t_0 J) l U)))))
double code(double J, double l, double K, double U) {
double t_0 = fma((l * l), 0.3333333333333333, 2.0);
double tmp;
if (l <= -5e+104) {
tmp = fma((t_0 * l), J, U);
} else if ((l <= -7.8e+25) || !(l <= 400.0)) {
tmp = fma(((fma(-0.125, l, (l / (K * K))) * K) * K), (2.0 * J), U);
} else {
tmp = fma((t_0 * J), l, U);
}
return tmp;
}
function code(J, l, K, U) t_0 = fma(Float64(l * l), 0.3333333333333333, 2.0) tmp = 0.0 if (l <= -5e+104) tmp = fma(Float64(t_0 * l), J, U); elseif ((l <= -7.8e+25) || !(l <= 400.0)) tmp = fma(Float64(Float64(fma(-0.125, l, Float64(l / Float64(K * K))) * K) * K), Float64(2.0 * J), U); else tmp = fma(Float64(t_0 * J), l, U); end return tmp end
code[J_, l_, K_, U_] := Block[{t$95$0 = N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision]}, If[LessEqual[l, -5e+104], N[(N[(t$95$0 * l), $MachinePrecision] * J + U), $MachinePrecision], If[Or[LessEqual[l, -7.8e+25], N[Not[LessEqual[l, 400.0]], $MachinePrecision]], N[(N[(N[(N[(-0.125 * l + N[(l / N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * K), $MachinePrecision] * K), $MachinePrecision] * N[(2.0 * J), $MachinePrecision] + U), $MachinePrecision], N[(N[(t$95$0 * J), $MachinePrecision] * l + U), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right)\\
\mathbf{if}\;\ell \leq -5 \cdot 10^{+104}:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot \ell, J, U\right)\\
\mathbf{elif}\;\ell \leq -7.8 \cdot 10^{+25} \lor \neg \left(\ell \leq 400\right):\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{fma}\left(-0.125, \ell, \frac{\ell}{K \cdot K}\right) \cdot K\right) \cdot K, 2 \cdot J, U\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot J, \ell, U\right)\\
\end{array}
\end{array}
if l < -4.9999999999999997e104Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites90.9%
Applied rewrites90.9%
Taylor expanded in K around 0
Applied rewrites87.8%
if -4.9999999999999997e104 < l < -7.8000000000000004e25 or 400 < l Initial program 100.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval22.5
Applied rewrites22.5%
Applied rewrites22.5%
Taylor expanded in K around 0
Applied rewrites35.1%
Taylor expanded in K around inf
Applied rewrites76.3%
if -7.8000000000000004e25 < l < 400Initial program 72.0%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites97.5%
Taylor expanded in K around 0
Applied rewrites81.9%
Final simplification81.1%
(FPCore (J l K U) :precision binary64 (fma (* (fma (* l l) 0.3333333333333333 2.0) l) J U))
double code(double J, double l, double K, double U) {
return fma((fma((l * l), 0.3333333333333333, 2.0) * l), J, U);
}
function code(J, l, K, U) return fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * l), J, U) end
code[J_, l_, K_, U_] := N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * l), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot \ell, J, U\right)
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites85.7%
Applied rewrites85.7%
Taylor expanded in K around 0
Applied rewrites74.4%
(FPCore (J l K U) :precision binary64 (fma (* (fma (* l l) 0.3333333333333333 2.0) J) l U))
double code(double J, double l, double K, double U) {
return fma((fma((l * l), 0.3333333333333333, 2.0) * J), l, U);
}
function code(J, l, K, U) return fma(Float64(fma(Float64(l * l), 0.3333333333333333, 2.0) * J), l, U) end
code[J_, l_, K_, U_] := N[(N[(N[(N[(l * l), $MachinePrecision] * 0.3333333333333333 + 2.0), $MachinePrecision] * J), $MachinePrecision] * l + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\ell \cdot \ell, 0.3333333333333333, 2\right) \cdot J, \ell, U\right)
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites85.7%
Taylor expanded in K around 0
Applied rewrites71.1%
Final simplification71.1%
(FPCore (J l K U) :precision binary64 (fma (+ l l) J U))
double code(double J, double l, double K, double U) {
return fma((l + l), J, U);
}
function code(J, l, K, U) return fma(Float64(l + l), J, U) end
code[J_, l_, K_, U_] := N[(N[(l + l), $MachinePrecision] * J + U), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\ell + \ell, J, U\right)
\end{array}
Initial program 85.1%
Taylor expanded in l around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
associate-*r*N/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval63.1
Applied rewrites63.1%
Taylor expanded in K around 0
Applied rewrites53.6%
Applied rewrites53.6%
herbie shell --seed 2024366
(FPCore (J l K U)
:name "Maksimov and Kolovsky, Equation (4)"
:precision binary64
(+ (* (* J (- (exp l) (exp (- l)))) (cos (/ K 2.0))) U))