
(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)));
}
real(8) function code(j, k, u)
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}
Sampling outcomes in binary64 precision:
Herbie found 8 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)));
}
real(8) function code(j, k, u)
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}
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (cos (/ K 2.0)))
(t_1
(*
(* t_0 (* -2.0 J))
(sqrt (+ 1.0 (pow (/ U (* t_0 (* J 2.0))) 2.0))))))
(if (<= t_1 (- INFINITY))
(- U)
(if (<= t_1 1e+297)
(* (* J (* -2.0 t_0)) (hypot 1.0 (/ U (* J (* 2.0 t_0)))))
U))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J)) * sqrt((1.0 + pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = -U;
} else if (t_1 <= 1e+297) {
tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
double t_1 = (t_0 * (-2.0 * J)) * Math.sqrt((1.0 + Math.pow((U / (t_0 * (J * 2.0))), 2.0)));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = -U;
} else if (t_1 <= 1e+297) {
tmp = (J * (-2.0 * t_0)) * Math.hypot(1.0, (U / (J * (2.0 * t_0))));
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) t_1 = (t_0 * (-2.0 * J)) * math.sqrt((1.0 + math.pow((U / (t_0 * (J * 2.0))), 2.0))) tmp = 0 if t_1 <= -math.inf: tmp = -U elif t_1 <= 1e+297: tmp = (J * (-2.0 * t_0)) * math.hypot(1.0, (U / (J * (2.0 * t_0)))) else: tmp = U return tmp
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) t_1 = Float64(Float64(t_0 * Float64(-2.0 * J)) * sqrt(Float64(1.0 + (Float64(U / Float64(t_0 * Float64(J * 2.0))) ^ 2.0)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(-U); elseif (t_1 <= 1e+297) tmp = Float64(Float64(J * Float64(-2.0 * t_0)) * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = cos((K / 2.0)); t_1 = (t_0 * (-2.0 * J)) * sqrt((1.0 + ((U / (t_0 * (J * 2.0))) ^ 2.0))); tmp = 0.0; if (t_1 <= -Inf) tmp = -U; elseif (t_1 <= 1e+297) tmp = (J * (-2.0 * t_0)) * hypot(1.0, (U / (J * (2.0 * t_0)))); else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[(-2.0 * J), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(1.0 + N[Power[N[(U / N[(t$95$0 * N[(J * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], (-U), If[LessEqual[t$95$1, 1e+297], N[(N[(J * N[(-2.0 * t$95$0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], U]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
t_1 := \left(t_0 \cdot \left(-2 \cdot J\right)\right) \cdot \sqrt{1 + {\left(\frac{U}{t_0 \cdot \left(J \cdot 2\right)}\right)}^{2}}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;-U\\
\mathbf{elif}\;t_1 \leq 10^{+297}:\\
\;\;\;\;\left(J \cdot \left(-2 \cdot t_0\right)\right) \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < -inf.0Initial program 5.4%
*-commutative5.4%
associate-*l*5.4%
associate-*r*5.4%
*-commutative5.4%
associate-*l*5.4%
*-commutative5.4%
unpow25.4%
hypot-1-def62.2%
*-commutative62.2%
associate-*l*62.2%
Simplified62.2%
Taylor expanded in J around 0 55.0%
neg-mul-155.0%
Simplified55.0%
if -inf.0 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) < 1e297Initial program 99.8%
*-commutative99.8%
associate-*l*99.8%
unpow299.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
if 1e297 < (*.f64 (*.f64 (*.f64 -2 J) (cos.f64 (/.f64 K 2))) (sqrt.f64 (+.f64 1 (pow.f64 (/.f64 U (*.f64 (*.f64 2 J) (cos.f64 (/.f64 K 2)))) 2)))) Initial program 10.6%
*-commutative10.6%
associate-*l*10.6%
associate-*r*10.6%
*-commutative10.6%
associate-*l*10.5%
*-commutative10.5%
unpow210.5%
hypot-1-def70.8%
*-commutative70.8%
associate-*l*70.8%
Simplified70.8%
Taylor expanded in U around -inf 58.2%
Final simplification86.3%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (let* ((t_0 (cos (/ K 2.0)))) (* J (* t_0 (* -2.0 (hypot 1.0 (/ U (* J (* 2.0 t_0)))))))))
U = abs(U);
double code(double J, double K, double U) {
double t_0 = cos((K / 2.0));
return J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = Math.cos((K / 2.0));
return J * (t_0 * (-2.0 * Math.hypot(1.0, (U / (J * (2.0 * t_0))))));
}
U = abs(U) def code(J, K, U): t_0 = math.cos((K / 2.0)) return J * (t_0 * (-2.0 * math.hypot(1.0, (U / (J * (2.0 * t_0))))))
U = abs(U) function code(J, K, U) t_0 = cos(Float64(K / 2.0)) return Float64(J * Float64(t_0 * Float64(-2.0 * hypot(1.0, Float64(U / Float64(J * Float64(2.0 * t_0))))))) end
U = abs(U) function tmp = code(J, K, U) t_0 = cos((K / 2.0)); tmp = J * (t_0 * (-2.0 * hypot(1.0, (U / (J * (2.0 * t_0)))))); end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[Cos[N[(K / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(J * N[(t$95$0 * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(U / N[(J * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K}{2}\right)\\
J \cdot \left(t_0 \cdot \left(-2 \cdot \mathsf{hypot}\left(1, \frac{U}{J \cdot \left(2 \cdot t_0\right)}\right)\right)\right)
\end{array}
\end{array}
Initial program 71.1%
*-commutative71.1%
associate-*l*71.1%
associate-*r*71.1%
*-commutative71.1%
associate-*l*71.1%
*-commutative71.1%
unpow271.1%
hypot-1-def89.3%
*-commutative89.3%
associate-*l*89.3%
Simplified89.3%
Final simplification89.3%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(let* ((t_0 (* J (* -2.0 (cos (* K 0.5))))))
(if (<= J -0.27)
t_0
(if (<= J -4e-310)
U
(if (or (<= J 2.6e-51) (and (not (<= J 2.2e+41)) (<= J 6.5e+100)))
(- U)
t_0)))))U = abs(U);
double code(double J, double K, double U) {
double t_0 = J * (-2.0 * cos((K * 0.5)));
double tmp;
if (J <= -0.27) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if ((J <= 2.6e-51) || (!(J <= 2.2e+41) && (J <= 6.5e+100))) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: t_0
real(8) :: tmp
t_0 = j * ((-2.0d0) * cos((k * 0.5d0)))
if (j <= (-0.27d0)) then
tmp = t_0
else if (j <= (-4d-310)) then
tmp = u
else if ((j <= 2.6d-51) .or. (.not. (j <= 2.2d+41)) .and. (j <= 6.5d+100)) then
tmp = -u
else
tmp = t_0
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double t_0 = J * (-2.0 * Math.cos((K * 0.5)));
double tmp;
if (J <= -0.27) {
tmp = t_0;
} else if (J <= -4e-310) {
tmp = U;
} else if ((J <= 2.6e-51) || (!(J <= 2.2e+41) && (J <= 6.5e+100))) {
tmp = -U;
} else {
tmp = t_0;
}
return tmp;
}
U = abs(U) def code(J, K, U): t_0 = J * (-2.0 * math.cos((K * 0.5))) tmp = 0 if J <= -0.27: tmp = t_0 elif J <= -4e-310: tmp = U elif (J <= 2.6e-51) or (not (J <= 2.2e+41) and (J <= 6.5e+100)): tmp = -U else: tmp = t_0 return tmp
U = abs(U) function code(J, K, U) t_0 = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))) tmp = 0.0 if (J <= -0.27) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif ((J <= 2.6e-51) || (!(J <= 2.2e+41) && (J <= 6.5e+100))) tmp = Float64(-U); else tmp = t_0; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) t_0 = J * (-2.0 * cos((K * 0.5))); tmp = 0.0; if (J <= -0.27) tmp = t_0; elseif (J <= -4e-310) tmp = U; elseif ((J <= 2.6e-51) || (~((J <= 2.2e+41)) && (J <= 6.5e+100))) tmp = -U; else tmp = t_0; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function
code[J_, K_, U_] := Block[{t$95$0 = N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[J, -0.27], t$95$0, If[LessEqual[J, -4e-310], U, If[Or[LessEqual[J, 2.6e-51], And[N[Not[LessEqual[J, 2.2e+41]], $MachinePrecision], LessEqual[J, 6.5e+100]]], (-U), t$95$0]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
t_0 := J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{if}\;J \leq -0.27:\\
\;\;\;\;t_0\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.6 \cdot 10^{-51} \lor \neg \left(J \leq 2.2 \cdot 10^{+41}\right) \land J \leq 6.5 \cdot 10^{+100}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if J < -0.27000000000000002 or 2.6e-51 < J < 2.1999999999999999e41 or 6.50000000000000001e100 < J Initial program 96.1%
*-commutative96.1%
associate-*l*96.1%
associate-*r*96.1%
*-commutative96.1%
associate-*l*96.0%
*-commutative96.0%
unpow296.0%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 77.2%
if -0.27000000000000002 < J < -3.999999999999988e-310Initial program 42.5%
*-commutative42.5%
associate-*l*42.5%
associate-*r*42.5%
*-commutative42.5%
associate-*l*42.5%
*-commutative42.5%
unpow242.5%
hypot-1-def78.5%
*-commutative78.5%
associate-*l*78.5%
Simplified78.5%
Taylor expanded in U around -inf 44.9%
if -3.999999999999988e-310 < J < 2.6e-51 or 2.1999999999999999e41 < J < 6.50000000000000001e100Initial program 53.3%
*-commutative53.3%
associate-*l*53.3%
associate-*r*53.3%
*-commutative53.3%
associate-*l*53.2%
*-commutative53.2%
unpow253.2%
hypot-1-def80.6%
*-commutative80.6%
associate-*l*80.6%
Simplified80.6%
Taylor expanded in J around 0 48.8%
neg-mul-148.8%
Simplified48.8%
Final simplification61.5%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= U 1.05e-130)
(* J (* -2.0 (cos (* K 0.5))))
(if (<= U 5e+230)
(* J (* -2.0 (hypot 1.0 (* 0.5 (/ U J)))))
(if (<= U 1.95e+297) (- U) U))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (U <= 1.05e-130) {
tmp = J * (-2.0 * cos((K * 0.5)));
} else if (U <= 5e+230) {
tmp = J * (-2.0 * hypot(1.0, (0.5 * (U / J))));
} else if (U <= 1.95e+297) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (U <= 1.05e-130) {
tmp = J * (-2.0 * Math.cos((K * 0.5)));
} else if (U <= 5e+230) {
tmp = J * (-2.0 * Math.hypot(1.0, (0.5 * (U / J))));
} else if (U <= 1.95e+297) {
tmp = -U;
} else {
tmp = U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if U <= 1.05e-130: tmp = J * (-2.0 * math.cos((K * 0.5))) elif U <= 5e+230: tmp = J * (-2.0 * math.hypot(1.0, (0.5 * (U / J)))) elif U <= 1.95e+297: tmp = -U else: tmp = U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (U <= 1.05e-130) tmp = Float64(J * Float64(-2.0 * cos(Float64(K * 0.5)))); elseif (U <= 5e+230) tmp = Float64(J * Float64(-2.0 * hypot(1.0, Float64(0.5 * Float64(U / J))))); elseif (U <= 1.95e+297) tmp = Float64(-U); else tmp = U; end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (U <= 1.05e-130) tmp = J * (-2.0 * cos((K * 0.5))); elseif (U <= 5e+230) tmp = J * (-2.0 * hypot(1.0, (0.5 * (U / J)))); elseif (U <= 1.95e+297) tmp = -U; else tmp = U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[U, 1.05e-130], N[(J * N[(-2.0 * N[Cos[N[(K * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 5e+230], N[(J * N[(-2.0 * N[Sqrt[1.0 ^ 2 + N[(0.5 * N[(U / J), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[U, 1.95e+297], (-U), U]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;U \leq 1.05 \cdot 10^{-130}:\\
\;\;\;\;J \cdot \left(-2 \cdot \cos \left(K \cdot 0.5\right)\right)\\
\mathbf{elif}\;U \leq 5 \cdot 10^{+230}:\\
\;\;\;\;J \cdot \left(-2 \cdot \mathsf{hypot}\left(1, 0.5 \cdot \frac{U}{J}\right)\right)\\
\mathbf{elif}\;U \leq 1.95 \cdot 10^{+297}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;U\\
\end{array}
\end{array}
if U < 1.05000000000000001e-130Initial program 80.2%
*-commutative80.2%
associate-*l*80.2%
associate-*r*80.2%
*-commutative80.2%
associate-*l*80.2%
*-commutative80.2%
unpow280.2%
hypot-1-def90.7%
*-commutative90.7%
associate-*l*90.7%
Simplified90.7%
Taylor expanded in U around 0 57.8%
if 1.05000000000000001e-130 < U < 5.0000000000000003e230Initial program 60.8%
*-commutative60.8%
associate-*l*60.8%
associate-*r*60.8%
*-commutative60.8%
associate-*l*60.7%
*-commutative60.7%
unpow260.7%
hypot-1-def93.6%
*-commutative93.6%
associate-*l*93.6%
Simplified93.6%
add-cube-cbrt91.5%
pow391.5%
Applied egg-rr91.5%
Taylor expanded in K around 0 34.9%
unpow234.9%
unpow234.9%
times-frac48.0%
Simplified48.0%
add-sqr-sqrt48.0%
hypot-1-def48.0%
sqrt-prod48.0%
metadata-eval48.0%
sqrt-prod42.1%
add-sqr-sqrt75.9%
Applied egg-rr75.9%
if 5.0000000000000003e230 < U < 1.95e297Initial program 28.9%
*-commutative28.9%
associate-*l*28.9%
associate-*r*28.9%
*-commutative28.9%
associate-*l*28.8%
*-commutative28.8%
unpow228.8%
hypot-1-def64.0%
*-commutative64.0%
associate-*l*64.0%
Simplified64.0%
Taylor expanded in J around 0 53.9%
neg-mul-153.9%
Simplified53.9%
if 1.95e297 < U Initial program 33.7%
*-commutative33.7%
associate-*l*33.7%
associate-*r*33.7%
*-commutative33.7%
associate-*l*33.7%
*-commutative33.7%
unpow233.7%
hypot-1-def33.7%
*-commutative33.7%
associate-*l*33.7%
Simplified33.7%
Taylor expanded in U around -inf 75.0%
Final simplification63.3%
NOTE: U should be positive before calling this function
(FPCore (J K U)
:precision binary64
(if (<= J -4.8e+61)
(* -2.0 J)
(if (<= J -4e-310)
U
(if (<= J 2.3e+103) (- U) (* J (+ -2.0 (* 0.25 (* K K))))))))U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -4.8e+61) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 2.3e+103) {
tmp = -U;
} else {
tmp = J * (-2.0 + (0.25 * (K * K)));
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-4.8d+61)) then
tmp = (-2.0d0) * j
else if (j <= (-4d-310)) then
tmp = u
else if (j <= 2.3d+103) then
tmp = -u
else
tmp = j * ((-2.0d0) + (0.25d0 * (k * k)))
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -4.8e+61) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 2.3e+103) {
tmp = -U;
} else {
tmp = J * (-2.0 + (0.25 * (K * K)));
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -4.8e+61: tmp = -2.0 * J elif J <= -4e-310: tmp = U elif J <= 2.3e+103: tmp = -U else: tmp = J * (-2.0 + (0.25 * (K * K))) return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -4.8e+61) tmp = Float64(-2.0 * J); elseif (J <= -4e-310) tmp = U; elseif (J <= 2.3e+103) tmp = Float64(-U); else tmp = Float64(J * Float64(-2.0 + Float64(0.25 * Float64(K * K)))); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -4.8e+61) tmp = -2.0 * J; elseif (J <= -4e-310) tmp = U; elseif (J <= 2.3e+103) tmp = -U; else tmp = J * (-2.0 + (0.25 * (K * K))); end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -4.8e+61], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -4e-310], U, If[LessEqual[J, 2.3e+103], (-U), N[(J * N[(-2.0 + N[(0.25 * N[(K * K), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -4.8 \cdot 10^{+61}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 2.3 \cdot 10^{+103}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;J \cdot \left(-2 + 0.25 \cdot \left(K \cdot K\right)\right)\\
\end{array}
\end{array}
if J < -4.7999999999999998e61Initial program 98.0%
*-commutative98.0%
associate-*l*98.0%
associate-*r*98.0%
*-commutative98.0%
associate-*l*97.9%
*-commutative97.9%
unpow297.9%
hypot-1-def99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in U around 0 79.9%
Taylor expanded in K around 0 41.4%
*-commutative41.4%
Simplified41.4%
if -4.7999999999999998e61 < J < -3.999999999999988e-310Initial program 47.9%
*-commutative47.9%
associate-*l*47.9%
associate-*r*47.9%
*-commutative47.9%
associate-*l*47.9%
*-commutative47.9%
unpow247.9%
hypot-1-def80.9%
*-commutative80.9%
associate-*l*80.9%
Simplified80.9%
Taylor expanded in U around -inf 42.6%
if -3.999999999999988e-310 < J < 2.30000000000000008e103Initial program 61.1%
*-commutative61.1%
associate-*l*61.1%
associate-*r*61.1%
*-commutative61.1%
associate-*l*61.1%
*-commutative61.1%
unpow261.1%
hypot-1-def85.2%
*-commutative85.2%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in J around 0 41.1%
neg-mul-141.1%
Simplified41.1%
if 2.30000000000000008e103 < J Initial program 99.9%
*-commutative99.9%
associate-*l*99.9%
associate-*r*99.9%
*-commutative99.9%
associate-*l*99.9%
*-commutative99.9%
unpow299.9%
hypot-1-def99.9%
*-commutative99.9%
associate-*l*99.9%
Simplified99.9%
Taylor expanded in U around 0 80.8%
Taylor expanded in K around 0 50.9%
+-commutative50.9%
associate-*r*50.9%
distribute-rgt-out50.9%
unpow250.9%
Simplified50.9%
Final simplification43.3%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -2.5e+61) (* -2.0 J) (if (<= J -4e-310) U (if (<= J 1.3e+106) (- U) (* -2.0 J)))))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -2.5e+61) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 1.3e+106) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-2.5d+61)) then
tmp = (-2.0d0) * j
else if (j <= (-4d-310)) then
tmp = u
else if (j <= 1.3d+106) then
tmp = -u
else
tmp = (-2.0d0) * j
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -2.5e+61) {
tmp = -2.0 * J;
} else if (J <= -4e-310) {
tmp = U;
} else if (J <= 1.3e+106) {
tmp = -U;
} else {
tmp = -2.0 * J;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -2.5e+61: tmp = -2.0 * J elif J <= -4e-310: tmp = U elif J <= 1.3e+106: tmp = -U else: tmp = -2.0 * J return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -2.5e+61) tmp = Float64(-2.0 * J); elseif (J <= -4e-310) tmp = U; elseif (J <= 1.3e+106) tmp = Float64(-U); else tmp = Float64(-2.0 * J); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -2.5e+61) tmp = -2.0 * J; elseif (J <= -4e-310) tmp = U; elseif (J <= 1.3e+106) tmp = -U; else tmp = -2.0 * J; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -2.5e+61], N[(-2.0 * J), $MachinePrecision], If[LessEqual[J, -4e-310], U, If[LessEqual[J, 1.3e+106], (-U), N[(-2.0 * J), $MachinePrecision]]]]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -2.5 \cdot 10^{+61}:\\
\;\;\;\;-2 \cdot J\\
\mathbf{elif}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{elif}\;J \leq 1.3 \cdot 10^{+106}:\\
\;\;\;\;-U\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot J\\
\end{array}
\end{array}
if J < -2.50000000000000009e61 or 1.3000000000000001e106 < J Initial program 98.9%
*-commutative98.9%
associate-*l*98.9%
associate-*r*98.9%
*-commutative98.9%
associate-*l*98.8%
*-commutative98.8%
unpow298.8%
hypot-1-def99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in U around 0 80.3%
Taylor expanded in K around 0 45.2%
*-commutative45.2%
Simplified45.2%
if -2.50000000000000009e61 < J < -3.999999999999988e-310Initial program 47.9%
*-commutative47.9%
associate-*l*47.9%
associate-*r*47.9%
*-commutative47.9%
associate-*l*47.9%
*-commutative47.9%
unpow247.9%
hypot-1-def80.9%
*-commutative80.9%
associate-*l*80.9%
Simplified80.9%
Taylor expanded in U around -inf 42.6%
if -3.999999999999988e-310 < J < 1.3000000000000001e106Initial program 61.1%
*-commutative61.1%
associate-*l*61.1%
associate-*r*61.1%
*-commutative61.1%
associate-*l*61.1%
*-commutative61.1%
unpow261.1%
hypot-1-def85.2%
*-commutative85.2%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in J around 0 41.1%
neg-mul-141.1%
Simplified41.1%
Final simplification43.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 (if (<= J -4e-310) U (- U)))
U = abs(U);
double code(double J, double K, double U) {
double tmp;
if (J <= -4e-310) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
real(8) :: tmp
if (j <= (-4d-310)) then
tmp = u
else
tmp = -u
end if
code = tmp
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
double tmp;
if (J <= -4e-310) {
tmp = U;
} else {
tmp = -U;
}
return tmp;
}
U = abs(U) def code(J, K, U): tmp = 0 if J <= -4e-310: tmp = U else: tmp = -U return tmp
U = abs(U) function code(J, K, U) tmp = 0.0 if (J <= -4e-310) tmp = U; else tmp = Float64(-U); end return tmp end
U = abs(U) function tmp_2 = code(J, K, U) tmp = 0.0; if (J <= -4e-310) tmp = U; else tmp = -U; end tmp_2 = tmp; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := If[LessEqual[J, -4e-310], U, (-U)]
\begin{array}{l}
U = |U|\\
\\
\begin{array}{l}
\mathbf{if}\;J \leq -4 \cdot 10^{-310}:\\
\;\;\;\;U\\
\mathbf{else}:\\
\;\;\;\;-U\\
\end{array}
\end{array}
if J < -3.999999999999988e-310Initial program 67.7%
*-commutative67.7%
associate-*l*67.7%
associate-*r*67.7%
*-commutative67.7%
associate-*l*67.7%
*-commutative67.7%
unpow267.7%
hypot-1-def88.4%
*-commutative88.4%
associate-*l*88.4%
Simplified88.4%
Taylor expanded in U around -inf 31.3%
if -3.999999999999988e-310 < J Initial program 74.6%
*-commutative74.6%
associate-*l*74.6%
associate-*r*74.6%
*-commutative74.6%
associate-*l*74.5%
*-commutative74.5%
unpow274.5%
hypot-1-def90.3%
*-commutative90.3%
associate-*l*90.3%
Simplified90.3%
Taylor expanded in J around 0 30.8%
neg-mul-130.8%
Simplified30.8%
Final simplification31.1%
NOTE: U should be positive before calling this function (FPCore (J K U) :precision binary64 U)
U = abs(U);
double code(double J, double K, double U) {
return U;
}
NOTE: U should be positive before calling this function
real(8) function code(j, k, u)
real(8), intent (in) :: j
real(8), intent (in) :: k
real(8), intent (in) :: u
code = u
end function
U = Math.abs(U);
public static double code(double J, double K, double U) {
return U;
}
U = abs(U) def code(J, K, U): return U
U = abs(U) function code(J, K, U) return U end
U = abs(U) function tmp = code(J, K, U) tmp = U; end
NOTE: U should be positive before calling this function code[J_, K_, U_] := U
\begin{array}{l}
U = |U|\\
\\
U
\end{array}
Initial program 71.1%
*-commutative71.1%
associate-*l*71.1%
associate-*r*71.1%
*-commutative71.1%
associate-*l*71.1%
*-commutative71.1%
unpow271.1%
hypot-1-def89.3%
*-commutative89.3%
associate-*l*89.3%
Simplified89.3%
Taylor expanded in U around -inf 29.1%
Final simplification29.1%
herbie shell --seed 2023257
(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)))))