
(FPCore (t l k) :precision binary64 (/ 2.0 (* (* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k)) (- (+ 1.0 (pow (/ k t) 2.0)) 1.0))))
double code(double t, double l, double k) {
return 2.0 / ((((pow(t, 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + pow((k / t), 2.0)) - 1.0));
}
real(8) function code(t, l, k)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: k
code = 2.0d0 / (((((t ** 3.0d0) / (l * l)) * sin(k)) * tan(k)) * ((1.0d0 + ((k / t) ** 2.0d0)) - 1.0d0))
end function
public static double code(double t, double l, double k) {
return 2.0 / ((((Math.pow(t, 3.0) / (l * l)) * Math.sin(k)) * Math.tan(k)) * ((1.0 + Math.pow((k / t), 2.0)) - 1.0));
}
def code(t, l, k): return 2.0 / ((((math.pow(t, 3.0) / (l * l)) * math.sin(k)) * math.tan(k)) * ((1.0 + math.pow((k / t), 2.0)) - 1.0))
function code(t, l, k) return Float64(2.0 / Float64(Float64(Float64(Float64((t ^ 3.0) / Float64(l * l)) * sin(k)) * tan(k)) * Float64(Float64(1.0 + (Float64(k / t) ^ 2.0)) - 1.0))) end
function tmp = code(t, l, k) tmp = 2.0 / (((((t ^ 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + ((k / t) ^ 2.0)) - 1.0)); end
code[t_, l_, k_] := N[(2.0 / N[(N[(N[(N[(N[Power[t, 3.0], $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision] * N[Sin[k], $MachinePrecision]), $MachinePrecision] * N[Tan[k], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[Power[N[(k / t), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 22 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (t l k) :precision binary64 (/ 2.0 (* (* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k)) (- (+ 1.0 (pow (/ k t) 2.0)) 1.0))))
double code(double t, double l, double k) {
return 2.0 / ((((pow(t, 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + pow((k / t), 2.0)) - 1.0));
}
real(8) function code(t, l, k)
real(8), intent (in) :: t
real(8), intent (in) :: l
real(8), intent (in) :: k
code = 2.0d0 / (((((t ** 3.0d0) / (l * l)) * sin(k)) * tan(k)) * ((1.0d0 + ((k / t) ** 2.0d0)) - 1.0d0))
end function
public static double code(double t, double l, double k) {
return 2.0 / ((((Math.pow(t, 3.0) / (l * l)) * Math.sin(k)) * Math.tan(k)) * ((1.0 + Math.pow((k / t), 2.0)) - 1.0));
}
def code(t, l, k): return 2.0 / ((((math.pow(t, 3.0) / (l * l)) * math.sin(k)) * math.tan(k)) * ((1.0 + math.pow((k / t), 2.0)) - 1.0))
function code(t, l, k) return Float64(2.0 / Float64(Float64(Float64(Float64((t ^ 3.0) / Float64(l * l)) * sin(k)) * tan(k)) * Float64(Float64(1.0 + (Float64(k / t) ^ 2.0)) - 1.0))) end
function tmp = code(t, l, k) tmp = 2.0 / (((((t ^ 3.0) / (l * l)) * sin(k)) * tan(k)) * ((1.0 + ((k / t) ^ 2.0)) - 1.0)); end
code[t_, l_, k_] := N[(2.0 / N[(N[(N[(N[(N[Power[t, 3.0], $MachinePrecision] / N[(l * l), $MachinePrecision]), $MachinePrecision] * N[Sin[k], $MachinePrecision]), $MachinePrecision] * N[Tan[k], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[Power[N[(k / t), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{2}{\left(\left(\frac{{t}^{3}}{\ell \cdot \ell} \cdot \sin k\right) \cdot \tan k\right) \cdot \left(\left(1 + {\left(\frac{k}{t}\right)}^{2}\right) - 1\right)}
\end{array}
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k)
:precision binary64
(let* ((t_2 (/ (* 2.0 l) k)))
(*
t_s
(if (<= t_m 1.6e+124)
(/ (/ t_2 (tan k)) (* (sin k) (/ (* t_m k) l)))
(* t_2 (/ (/ (/ (/ l (tan k)) (sin k)) t_m) k))))))t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k) {
double t_2 = (2.0 * l) / k;
double tmp;
if (t_m <= 1.6e+124) {
tmp = (t_2 / tan(k)) / (sin(k) * ((t_m * k) / l));
} else {
tmp = t_2 * ((((l / tan(k)) / sin(k)) / t_m) / k);
}
return t_s * tmp;
}
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k)
real(8), intent (in) :: t_s
real(8), intent (in) :: t_m
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8) :: t_2
real(8) :: tmp
t_2 = (2.0d0 * l) / k
if (t_m <= 1.6d+124) then
tmp = (t_2 / tan(k)) / (sin(k) * ((t_m * k) / l))
else
tmp = t_2 * ((((l / tan(k)) / sin(k)) / t_m) / k)
end if
code = t_s * tmp
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k) {
double t_2 = (2.0 * l) / k;
double tmp;
if (t_m <= 1.6e+124) {
tmp = (t_2 / Math.tan(k)) / (Math.sin(k) * ((t_m * k) / l));
} else {
tmp = t_2 * ((((l / Math.tan(k)) / Math.sin(k)) / t_m) / k);
}
return t_s * tmp;
}
t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) def code(t_s, t_m, l, k): t_2 = (2.0 * l) / k tmp = 0 if t_m <= 1.6e+124: tmp = (t_2 / math.tan(k)) / (math.sin(k) * ((t_m * k) / l)) else: tmp = t_2 * ((((l / math.tan(k)) / math.sin(k)) / t_m) / k) return t_s * tmp
t\_m = abs(t) t\_s = copysign(1.0, t) function code(t_s, t_m, l, k) t_2 = Float64(Float64(2.0 * l) / k) tmp = 0.0 if (t_m <= 1.6e+124) tmp = Float64(Float64(t_2 / tan(k)) / Float64(sin(k) * Float64(Float64(t_m * k) / l))); else tmp = Float64(t_2 * Float64(Float64(Float64(Float64(l / tan(k)) / sin(k)) / t_m) / k)); end return Float64(t_s * tmp) end
t\_m = abs(t); t\_s = sign(t) * abs(1.0); function tmp_2 = code(t_s, t_m, l, k) t_2 = (2.0 * l) / k; tmp = 0.0; if (t_m <= 1.6e+124) tmp = (t_2 / tan(k)) / (sin(k) * ((t_m * k) / l)); else tmp = t_2 * ((((l / tan(k)) / sin(k)) / t_m) / k); end tmp_2 = t_s * tmp; end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k_] := Block[{t$95$2 = N[(N[(2.0 * l), $MachinePrecision] / k), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 1.6e+124], N[(N[(t$95$2 / N[Tan[k], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[k], $MachinePrecision] * N[(N[(t$95$m * k), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[(N[(N[(N[(l / N[Tan[k], $MachinePrecision]), $MachinePrecision] / N[Sin[k], $MachinePrecision]), $MachinePrecision] / t$95$m), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := \frac{2 \cdot \ell}{k}\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 1.6 \cdot 10^{+124}:\\
\;\;\;\;\frac{\frac{t\_2}{\tan k}}{\sin k \cdot \frac{t\_m \cdot k}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t\_2 \cdot \frac{\frac{\frac{\frac{\ell}{\tan k}}{\sin k}}{t\_m}}{k}\\
\end{array}
\end{array}
\end{array}
if t < 1.59999999999999996e124Initial program 44.3%
Taylor expanded in t around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6474.1
Applied rewrites74.1%
Applied rewrites90.3%
Applied rewrites93.3%
Applied rewrites98.6%
if 1.59999999999999996e124 < t Initial program 7.6%
Taylor expanded in t around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6477.4
Applied rewrites77.4%
Applied rewrites67.5%
Applied rewrites93.7%
Applied rewrites99.8%
Final simplification99.0%
t\_m = (fabs.f64 t)
t\_s = (copysign.f64 #s(literal 1 binary64) t)
(FPCore (t_s t_m l k)
:precision binary64
(let* ((t_2 (/ (* 2.0 l) k)))
(*
t_s
(if (<= t_m 3e+162)
(/ (/ t_2 (tan k)) (* (sin k) (/ (* t_m k) l)))
(* t_2 (/ (/ l (* t_m (* (tan k) (sin k)))) k))))))t\_m = fabs(t);
t\_s = copysign(1.0, t);
double code(double t_s, double t_m, double l, double k) {
double t_2 = (2.0 * l) / k;
double tmp;
if (t_m <= 3e+162) {
tmp = (t_2 / tan(k)) / (sin(k) * ((t_m * k) / l));
} else {
tmp = t_2 * ((l / (t_m * (tan(k) * sin(k)))) / k);
}
return t_s * tmp;
}
t\_m = abs(t)
t\_s = copysign(1.0d0, t)
real(8) function code(t_s, t_m, l, k)
real(8), intent (in) :: t_s
real(8), intent (in) :: t_m
real(8), intent (in) :: l
real(8), intent (in) :: k
real(8) :: t_2
real(8) :: tmp
t_2 = (2.0d0 * l) / k
if (t_m <= 3d+162) then
tmp = (t_2 / tan(k)) / (sin(k) * ((t_m * k) / l))
else
tmp = t_2 * ((l / (t_m * (tan(k) * sin(k)))) / k)
end if
code = t_s * tmp
end function
t\_m = Math.abs(t);
t\_s = Math.copySign(1.0, t);
public static double code(double t_s, double t_m, double l, double k) {
double t_2 = (2.0 * l) / k;
double tmp;
if (t_m <= 3e+162) {
tmp = (t_2 / Math.tan(k)) / (Math.sin(k) * ((t_m * k) / l));
} else {
tmp = t_2 * ((l / (t_m * (Math.tan(k) * Math.sin(k)))) / k);
}
return t_s * tmp;
}
t\_m = math.fabs(t) t\_s = math.copysign(1.0, t) def code(t_s, t_m, l, k): t_2 = (2.0 * l) / k tmp = 0 if t_m <= 3e+162: tmp = (t_2 / math.tan(k)) / (math.sin(k) * ((t_m * k) / l)) else: tmp = t_2 * ((l / (t_m * (math.tan(k) * math.sin(k)))) / k) return t_s * tmp
t\_m = abs(t) t\_s = copysign(1.0, t) function code(t_s, t_m, l, k) t_2 = Float64(Float64(2.0 * l) / k) tmp = 0.0 if (t_m <= 3e+162) tmp = Float64(Float64(t_2 / tan(k)) / Float64(sin(k) * Float64(Float64(t_m * k) / l))); else tmp = Float64(t_2 * Float64(Float64(l / Float64(t_m * Float64(tan(k) * sin(k)))) / k)); end return Float64(t_s * tmp) end
t\_m = abs(t); t\_s = sign(t) * abs(1.0); function tmp_2 = code(t_s, t_m, l, k) t_2 = (2.0 * l) / k; tmp = 0.0; if (t_m <= 3e+162) tmp = (t_2 / tan(k)) / (sin(k) * ((t_m * k) / l)); else tmp = t_2 * ((l / (t_m * (tan(k) * sin(k)))) / k); end tmp_2 = t_s * tmp; end
t\_m = N[Abs[t], $MachinePrecision]
t\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[t]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[t$95$s_, t$95$m_, l_, k_] := Block[{t$95$2 = N[(N[(2.0 * l), $MachinePrecision] / k), $MachinePrecision]}, N[(t$95$s * If[LessEqual[t$95$m, 3e+162], N[(N[(t$95$2 / N[Tan[k], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[k], $MachinePrecision] * N[(N[(t$95$m * k), $MachinePrecision] / l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$2 * N[(N[(l / N[(t$95$m * N[(N[Tan[k], $MachinePrecision] * N[Sin[k], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t\_m = \left|t\right|
\\
t\_s = \mathsf{copysign}\left(1, t\right)
\\
\begin{array}{l}
t_2 := \frac{2 \cdot \ell}{k}\\
t\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_m \leq 3 \cdot 10^{+162}:\\
\;\;\;\;\frac{\frac{t\_2}{\tan k}}{\sin k \cdot \frac{t\_m \cdot k}{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t\_2 \cdot \frac{\frac{\ell}{t\_m \cdot \left(\tan k \cdot \sin k\right)}}{k}\\
\end{array}
\end{array}
\end{array}
if t < 2.9999999999999998e162Initial program 44.4%
Taylor expanded in t around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6476.7
Applied rewrites76.7%
Applied rewrites87.1%
Applied rewrites94.3%
Applied rewrites98.1%
if 2.9999999999999998e162 < t Initial program 9.4%
Taylor expanded in t around 0
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower-sin.f6474.8
Applied rewrites74.8%
Applied rewrites71.0%
Applied rewrites94.5%
Applied rewrites95.0%
Final simplification97.4%
herbie shell --seed 2024222
(FPCore (t l k)
:name "Toniolo and Linder, Equation (10-)"
:precision binary64
(/ 2.0 (* (* (* (/ (pow t 3.0) (* l l)) (sin k)) (tan k)) (- (+ 1.0 (pow (/ k t) 2.0)) 1.0))))