
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 27 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= (+ t_0 (* t_1 (cos (- lambda1 lambda2)))) 0.9993)
(*
(acos
(+
(+ (exp (log1p t_0)) -1.0)
(*
t_1
(fma
(cos lambda2)
(cos lambda1)
(log (exp (* (sin lambda1) (sin lambda2))))))))
R)
(fma lambda2 R (- (* lambda1 R))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if ((t_0 + (t_1 * cos((lambda1 - lambda2)))) <= 0.9993) {
tmp = acos(((exp(log1p(t_0)) + -1.0) + (t_1 * fma(cos(lambda2), cos(lambda1), log(exp((sin(lambda1) * sin(lambda2)))))))) * R;
} else {
tmp = fma(lambda2, R, -(lambda1 * R));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (Float64(t_0 + Float64(t_1 * cos(Float64(lambda1 - lambda2)))) <= 0.9993) tmp = Float64(acos(Float64(Float64(exp(log1p(t_0)) + -1.0) + Float64(t_1 * fma(cos(lambda2), cos(lambda1), log(exp(Float64(sin(lambda1) * sin(lambda2)))))))) * R); else tmp = fma(lambda2, R, Float64(-Float64(lambda1 * R))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.9993], N[(N[ArcCos[N[(N[(N[Exp[N[Log[1 + t$95$0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] + N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[Log[N[Exp[N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(lambda2 * R + (-N[(lambda1 * R), $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;t_0 + t_1 \cdot \cos \left(\lambda_1 - \lambda_2\right) \leq 0.9993:\\
\;\;\;\;\cos^{-1} \left(\left(e^{\mathsf{log1p}\left(t_0\right)} + -1\right) + t_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \log \left(e^{\sin \lambda_1 \cdot \sin \lambda_2}\right)\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\lambda_2, R, -\lambda_1 \cdot R\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) < 0.999299999999999966Initial program 80.9%
cos-diff99.1%
Applied egg-rr99.1%
cos-neg99.1%
*-commutative99.1%
fma-def99.1%
cos-neg99.1%
Simplified99.1%
expm1-log1p-u99.1%
expm1-udef99.1%
Applied egg-rr99.1%
add-log-exp99.1%
Applied egg-rr99.1%
if 0.999299999999999966 < (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) Initial program 10.2%
fma-def10.2%
associate-*l*10.2%
Simplified10.2%
Taylor expanded in phi2 around 0 10.2%
sub-neg10.2%
+-commutative10.2%
neg-mul-110.2%
neg-mul-110.2%
remove-double-neg10.2%
mul-1-neg10.2%
distribute-neg-in10.2%
+-commutative10.2%
cos-neg10.2%
+-commutative10.2%
mul-1-neg10.2%
unsub-neg10.2%
Simplified10.2%
Taylor expanded in phi1 around 0 10.2%
Taylor expanded in lambda2 around 0 28.0%
fma-def28.0%
mul-1-neg28.0%
*-commutative28.0%
Simplified28.0%
Final simplification95.2%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= (+ t_0 (* t_1 (cos (- lambda1 lambda2)))) 0.9993)
(*
R
(acos
(+
(+ (exp (log1p t_0)) -1.0)
(*
t_1
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2)))))))
(fma lambda2 R (- (* lambda1 R))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if ((t_0 + (t_1 * cos((lambda1 - lambda2)))) <= 0.9993) {
tmp = R * acos(((exp(log1p(t_0)) + -1.0) + (t_1 * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = fma(lambda2, R, -(lambda1 * R));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (Float64(t_0 + Float64(t_1 * cos(Float64(lambda1 - lambda2)))) <= 0.9993) tmp = Float64(R * acos(Float64(Float64(exp(log1p(t_0)) + -1.0) + Float64(t_1 * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))))))); else tmp = fma(lambda2, R, Float64(-Float64(lambda1 * R))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.9993], N[(R * N[ArcCos[N[(N[(N[Exp[N[Log[1 + t$95$0], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] + N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda2 * R + (-N[(lambda1 * R), $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;t_0 + t_1 \cdot \cos \left(\lambda_1 - \lambda_2\right) \leq 0.9993:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(e^{\mathsf{log1p}\left(t_0\right)} + -1\right) + t_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\lambda_2, R, -\lambda_1 \cdot R\right)\\
\end{array}
\end{array}
if (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) < 0.999299999999999966Initial program 80.9%
cos-diff99.1%
Applied egg-rr99.1%
cos-neg99.1%
*-commutative99.1%
fma-def99.1%
cos-neg99.1%
Simplified99.1%
expm1-log1p-u99.1%
expm1-udef99.1%
Applied egg-rr99.1%
if 0.999299999999999966 < (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) Initial program 10.2%
fma-def10.2%
associate-*l*10.2%
Simplified10.2%
Taylor expanded in phi2 around 0 10.2%
sub-neg10.2%
+-commutative10.2%
neg-mul-110.2%
neg-mul-110.2%
remove-double-neg10.2%
mul-1-neg10.2%
distribute-neg-in10.2%
+-commutative10.2%
cos-neg10.2%
+-commutative10.2%
mul-1-neg10.2%
unsub-neg10.2%
Simplified10.2%
Taylor expanded in phi1 around 0 10.2%
Taylor expanded in lambda2 around 0 28.0%
fma-def28.0%
mul-1-neg28.0%
*-commutative28.0%
Simplified28.0%
Final simplification95.2%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= (acos (+ t_0 (* t_1 (cos (- lambda1 lambda2))))) 0.038)
(fma lambda2 R (- (* lambda1 R)))
(*
R
(acos
(+
t_0
(*
t_1
(fma
(cos lambda2)
(cos lambda1)
(* (sin lambda1) (sin lambda2))))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if (acos((t_0 + (t_1 * cos((lambda1 - lambda2))))) <= 0.038) {
tmp = fma(lambda2, R, -(lambda1 * R));
} else {
tmp = R * acos((t_0 + (t_1 * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (acos(Float64(t_0 + Float64(t_1 * cos(Float64(lambda1 - lambda2))))) <= 0.038) tmp = fma(lambda2, R, Float64(-Float64(lambda1 * R))); else tmp = Float64(R * acos(Float64(t_0 + Float64(t_1 * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.038], N[(lambda2 * R + (-N[(lambda1 * R), $MachinePrecision])), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\cos^{-1} \left(t_0 + t_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \leq 0.038:\\
\;\;\;\;\mathsf{fma}\left(\lambda_2, R, -\lambda_1 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + t_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\end{array}
\end{array}
if (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) < 0.0379999999999999991Initial program 10.2%
fma-def10.2%
associate-*l*10.2%
Simplified10.2%
Taylor expanded in phi2 around 0 10.2%
sub-neg10.2%
+-commutative10.2%
neg-mul-110.2%
neg-mul-110.2%
remove-double-neg10.2%
mul-1-neg10.2%
distribute-neg-in10.2%
+-commutative10.2%
cos-neg10.2%
+-commutative10.2%
mul-1-neg10.2%
unsub-neg10.2%
Simplified10.2%
Taylor expanded in phi1 around 0 10.2%
Taylor expanded in lambda2 around 0 28.0%
fma-def28.0%
mul-1-neg28.0%
*-commutative28.0%
Simplified28.0%
if 0.0379999999999999991 < (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) Initial program 80.9%
cos-diff99.1%
Applied egg-rr99.1%
cos-neg99.1%
*-commutative99.1%
fma-def99.1%
cos-neg99.1%
Simplified99.1%
Final simplification95.2%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= (acos (+ t_0 (* t_1 (cos (- lambda1 lambda2))))) 0.038)
(fma lambda2 R (- (* lambda1 R)))
(*
R
(acos
(+
t_0
(*
t_1
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if (acos((t_0 + (t_1 * cos((lambda1 - lambda2))))) <= 0.038) {
tmp = fma(lambda2, R, -(lambda1 * R));
} else {
tmp = R * acos((t_0 + (t_1 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (acos(Float64(t_0 + Float64(t_1 * cos(Float64(lambda1 - lambda2))))) <= 0.038) tmp = fma(lambda2, R, Float64(-Float64(lambda1 * R))); else tmp = Float64(R * acos(Float64(t_0 + Float64(t_1 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.038], N[(lambda2 * R + (-N[(lambda1 * R), $MachinePrecision])), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\cos^{-1} \left(t_0 + t_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \leq 0.038:\\
\;\;\;\;\mathsf{fma}\left(\lambda_2, R, -\lambda_1 \cdot R\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + t_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\end{array}
\end{array}
if (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) < 0.0379999999999999991Initial program 10.2%
fma-def10.2%
associate-*l*10.2%
Simplified10.2%
Taylor expanded in phi2 around 0 10.2%
sub-neg10.2%
+-commutative10.2%
neg-mul-110.2%
neg-mul-110.2%
remove-double-neg10.2%
mul-1-neg10.2%
distribute-neg-in10.2%
+-commutative10.2%
cos-neg10.2%
+-commutative10.2%
mul-1-neg10.2%
unsub-neg10.2%
Simplified10.2%
Taylor expanded in phi1 around 0 10.2%
Taylor expanded in lambda2 around 0 28.0%
fma-def28.0%
mul-1-neg28.0%
*-commutative28.0%
Simplified28.0%
if 0.0379999999999999991 < (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) Initial program 80.9%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
Final simplification95.2%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= phi2 -0.00033)
(*
R
(-
(/ PI 2.0)
(asin (+ t_0 (* (cos phi1) (* (cos phi2) (cos (- lambda2 lambda1))))))))
(if (<= phi2 6.5e+36)
(*
R
(acos
(+
(*
t_1
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))
(* (sin phi1) phi2))))
(*
R
(acos (+ t_0 (* t_1 (expm1 (log1p (cos (- lambda1 lambda2))))))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if (phi2 <= -0.00033) {
tmp = R * ((((double) M_PI) / 2.0) - asin((t_0 + (cos(phi1) * (cos(phi2) * cos((lambda2 - lambda1)))))));
} else if (phi2 <= 6.5e+36) {
tmp = R * acos(((t_1 * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2)))) + (sin(phi1) * phi2)));
} else {
tmp = R * acos((t_0 + (t_1 * expm1(log1p(cos((lambda1 - lambda2)))))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi2 <= -0.00033) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda2 - lambda1)))))))); elseif (phi2 <= 6.5e+36) tmp = Float64(R * acos(Float64(Float64(t_1 * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2)))) + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(Float64(t_0 + Float64(t_1 * expm1(log1p(cos(Float64(lambda1 - lambda2)))))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.00033], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.5e+36], N[(R * N[ArcCos[N[(N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[(Exp[N[Log[1 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00033:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 6.5 \cdot 10^{+36}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right) + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + t_1 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
\end{array}
\end{array}
if phi2 < -3.3e-4Initial program 83.2%
cos-diff98.9%
Applied egg-rr98.9%
cos-neg98.9%
*-commutative98.9%
fma-def98.9%
cos-neg98.9%
Simplified98.9%
expm1-log1p-u98.9%
expm1-udef98.8%
Applied egg-rr98.8%
add-log-exp98.9%
Applied egg-rr98.9%
acos-asin99.0%
expm1-def99.0%
expm1-log1p-u99.0%
associate-*l*99.0%
fma-udef98.9%
add-log-exp98.9%
*-commutative98.9%
cos-diff83.3%
Applied egg-rr83.3%
if -3.3e-4 < phi2 < 6.4999999999999998e36Initial program 74.9%
cos-diff90.4%
Applied egg-rr90.4%
cos-neg90.4%
*-commutative90.4%
fma-def90.4%
cos-neg90.4%
Simplified90.4%
Taylor expanded in phi2 around 0 89.7%
if 6.4999999999999998e36 < phi2 Initial program 75.4%
expm1-log1p-u75.5%
Applied egg-rr75.5%
Final simplification85.3%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.00037)
(*
R
(acos
(+
(* (* (cos phi1) (cos phi2)) t_0)
(log (exp (* (sin phi1) (sin phi2)))))))
(if (<= phi1 0.115)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(+ 1.0 (* -0.5 (* phi1 phi1)))
(*
(cos phi2)
(fma
(sin lambda2)
(sin lambda1)
(* (cos lambda2) (cos lambda1))))))))
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.00037) {
tmp = R * acos((((cos(phi1) * cos(phi2)) * t_0) + log(exp((sin(phi1) * sin(phi2))))));
} else if (phi1 <= 0.115) {
tmp = R * acos(((phi1 * sin(phi2)) + ((1.0 + (-0.5 * (phi1 * phi1))) * (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.00037) tmp = Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) + log(exp(Float64(sin(phi1) * sin(phi2))))))); elseif (phi1 <= 0.115) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))) * Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.00037], N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[Log[N[Exp[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.115], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.00037:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0 + \log \left(e^{\sin \phi_1 \cdot \sin \phi_2}\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.115:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right) \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -3.6999999999999999e-4Initial program 85.6%
add-cube-cbrt85.5%
pow385.5%
Applied egg-rr85.5%
rem-cube-cbrt85.6%
add-log-exp85.6%
Applied egg-rr85.6%
if -3.6999999999999999e-4 < phi1 < 0.115000000000000005Initial program 71.7%
cos-diff89.5%
Applied egg-rr89.5%
cos-neg89.5%
*-commutative89.5%
fma-def89.5%
cos-neg89.5%
Simplified89.5%
Taylor expanded in phi1 around 0 88.9%
associate-+r+88.9%
+-commutative88.9%
associate-*r*88.9%
distribute-lft1-in88.9%
unpow288.9%
+-commutative88.9%
fma-def88.9%
Simplified88.9%
if 0.115000000000000005 < phi1 Initial program 79.1%
fma-def79.1%
associate-*l*79.1%
Simplified79.1%
Final simplification85.8%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -7.2e-8)
(*
R
(acos
(+
(* (* (cos phi1) (cos phi2)) t_0)
(log (exp (* (sin phi1) (sin phi2)))))))
(if (<= phi1 1.2e+17)
(*
R
(acos
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -7.2e-8) {
tmp = R * acos((((cos(phi1) * cos(phi2)) * t_0) + log(exp((sin(phi1) * sin(phi2))))));
} else if (phi1 <= 1.2e+17) {
tmp = R * acos((cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -7.2e-8) tmp = Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) + log(exp(Float64(sin(phi1) * sin(phi2))))))); elseif (phi1 <= 1.2e+17) tmp = Float64(R * acos(Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -7.2e-8], N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] + N[Log[N[Exp[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.2e+17], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -7.2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0 + \log \left(e^{\sin \phi_1 \cdot \sin \phi_2}\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.2 \cdot 10^{+17}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.19999999999999962e-8Initial program 86.0%
add-cube-cbrt85.9%
pow385.9%
Applied egg-rr85.9%
rem-cube-cbrt86.0%
add-log-exp86.0%
Applied egg-rr86.0%
if -7.19999999999999962e-8 < phi1 < 1.2e17Initial program 71.4%
cos-diff89.6%
Applied egg-rr89.6%
cos-neg89.6%
*-commutative89.6%
fma-def89.6%
cos-neg89.6%
Simplified89.6%
Taylor expanded in phi1 around 0 85.0%
+-commutative85.0%
fma-def85.0%
Simplified85.0%
if 1.2e17 < phi1 Initial program 79.4%
fma-def79.4%
associate-*l*79.4%
Simplified79.4%
Final simplification84.1%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -7e-8)
(*
R
(-
(/ PI 2.0)
(asin
(+
(* (sin phi1) (sin phi2))
(* (cos phi1) (* (cos phi2) (cos (- lambda2 lambda1))))))))
(if (<= phi1 1.2e+17)
(*
R
(acos
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(* (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7e-8) {
tmp = R * ((((double) M_PI) / 2.0) - asin(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos((lambda2 - lambda1)))))));
} else if (phi1 <= 1.2e+17) {
tmp = R * acos((cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * cos((lambda1 - lambda2))))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -7e-8) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda2 - lambda1)))))))); elseif (phi1 <= 1.2e+17) tmp = Float64(R * acos(Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -7e-8], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.2e+17], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.2 \cdot 10^{+17}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.00000000000000048e-8Initial program 86.0%
cos-diff99.0%
Applied egg-rr99.0%
cos-neg99.0%
*-commutative99.0%
fma-def99.0%
cos-neg99.0%
Simplified99.0%
expm1-log1p-u99.0%
expm1-udef99.0%
Applied egg-rr99.0%
add-log-exp99.0%
Applied egg-rr99.0%
acos-asin99.0%
expm1-def98.9%
expm1-log1p-u98.9%
associate-*l*98.9%
fma-udef98.9%
add-log-exp98.9%
*-commutative98.9%
cos-diff85.9%
Applied egg-rr85.9%
if -7.00000000000000048e-8 < phi1 < 1.2e17Initial program 71.4%
cos-diff89.6%
Applied egg-rr89.6%
cos-neg89.6%
*-commutative89.6%
fma-def89.6%
cos-neg89.6%
Simplified89.6%
Taylor expanded in phi1 around 0 85.0%
+-commutative85.0%
fma-def85.0%
Simplified85.0%
if 1.2e17 < phi1 Initial program 79.4%
fma-def79.4%
associate-*l*79.4%
Simplified79.4%
Final simplification84.1%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -7e-8)
(*
R
(acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0))))
(if (<= phi1 1.2e+17)
(*
R
(acos
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -7e-8) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 1.2e+17) {
tmp = R * acos((cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -7e-8) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); elseif (phi1 <= 1.2e+17) tmp = Float64(R * acos(Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -7e-8], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.2e+17], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
\mathbf{elif}\;\phi_1 \leq 1.2 \cdot 10^{+17}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.00000000000000048e-8Initial program 86.0%
if -7.00000000000000048e-8 < phi1 < 1.2e17Initial program 71.4%
cos-diff89.6%
Applied egg-rr89.6%
cos-neg89.6%
*-commutative89.6%
fma-def89.6%
cos-neg89.6%
Simplified89.6%
Taylor expanded in phi1 around 0 85.0%
+-commutative85.0%
fma-def85.0%
Simplified85.0%
if 1.2e17 < phi1 Initial program 79.4%
fma-def79.4%
associate-*l*79.4%
Simplified79.4%
Final simplification84.1%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -7e-8) (not (<= phi1 1.2e+17)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi2)
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -7e-8) || !(phi1 <= 1.2e+17)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi2) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2)))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -7e-8) || !(phi1 <= 1.2e+17)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(cos(phi2) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -7e-8], N[Not[LessEqual[phi1, 1.2e+17]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 1.2 \cdot 10^{+17}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.00000000000000048e-8 or 1.2e17 < phi1 Initial program 83.1%
if -7.00000000000000048e-8 < phi1 < 1.2e17Initial program 71.4%
cos-diff89.6%
Applied egg-rr89.6%
cos-neg89.6%
*-commutative89.6%
fma-def89.6%
cos-neg89.6%
Simplified89.6%
Taylor expanded in phi1 around 0 85.0%
fma-def85.0%
Simplified85.0%
Final simplification84.1%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -7e-8) (not (<= phi1 1.2e+17)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -7e-8) || !(phi1 <= 1.2e+17)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1)))));
}
return tmp;
}
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -7e-8) || !(phi1 <= 1.2e+17)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))); end return tmp end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -7e-8], N[Not[LessEqual[phi1, 1.2e+17]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 1.2 \cdot 10^{+17}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.00000000000000048e-8 or 1.2e17 < phi1 Initial program 83.1%
if -7.00000000000000048e-8 < phi1 < 1.2e17Initial program 71.4%
cos-diff89.6%
Applied egg-rr89.6%
cos-neg89.6%
*-commutative89.6%
fma-def89.6%
cos-neg89.6%
Simplified89.6%
Taylor expanded in phi1 around 0 85.0%
+-commutative85.0%
fma-def85.0%
Simplified85.0%
Final simplification84.1%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda1))))))
(t_1
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi2 -1.35e-5)
t_0
(if (<= phi2 3.7e-5)
(* R (acos (* (cos phi1) t_1)))
(if (<= phi2 9.2e+228) (* R (acos (* (cos phi2) t_1))) t_0)))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
double t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1));
double tmp;
if (phi2 <= -1.35e-5) {
tmp = t_0;
} else if (phi2 <= 3.7e-5) {
tmp = R * acos((cos(phi1) * t_1));
} else if (phi2 <= 9.2e+228) {
tmp = R * acos((cos(phi2) * t_1));
} else {
tmp = t_0;
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))
if (phi2 <= (-1.35d-5)) then
tmp = t_0
else if (phi2 <= 3.7d-5) then
tmp = r * acos((cos(phi1) * t_1))
else if (phi2 <= 9.2d+228) then
tmp = r * acos((cos(phi2) * t_1))
else
tmp = t_0
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
double t_1 = (Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1));
double tmp;
if (phi2 <= -1.35e-5) {
tmp = t_0;
} else if (phi2 <= 3.7e-5) {
tmp = R * Math.acos((Math.cos(phi1) * t_1));
} else if (phi2 <= 9.2e+228) {
tmp = R * Math.acos((Math.cos(phi2) * t_1));
} else {
tmp = t_0;
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): t_0 = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) t_1 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi2 <= -1.35e-5: tmp = t_0 elif phi2 <= 3.7e-5: tmp = R * math.acos((math.cos(phi1) * t_1)) elif phi2 <= 9.2e+228: tmp = R * math.acos((math.cos(phi2) * t_1)) else: tmp = t_0 return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))) t_1 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi2 <= -1.35e-5) tmp = t_0; elseif (phi2 <= 3.7e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_1))); elseif (phi2 <= 9.2e+228) tmp = Float64(R * acos(Float64(cos(phi2) * t_1))); else tmp = t_0; end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
t_0 = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1));
tmp = 0.0;
if (phi2 <= -1.35e-5)
tmp = t_0;
elseif (phi2 <= 3.7e-5)
tmp = R * acos((cos(phi1) * t_1));
elseif (phi2 <= 9.2e+228)
tmp = R * acos((cos(phi2) * t_1));
else
tmp = t_0;
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.35e-5], t$95$0, If[LessEqual[phi2, 3.7e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 9.2e+228], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq -1.35 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_2 \leq 3.7 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t_1\right)\\
\mathbf{elif}\;\phi_2 \leq 9.2 \cdot 10^{+228}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if phi2 < -1.3499999999999999e-5 or 9.20000000000000052e228 < phi2 Initial program 81.9%
Taylor expanded in lambda2 around 0 62.9%
if -1.3499999999999999e-5 < phi2 < 3.69999999999999981e-5Initial program 75.6%
cos-diff90.2%
Applied egg-rr90.2%
cos-neg90.2%
*-commutative90.2%
fma-def90.3%
cos-neg90.3%
Simplified90.3%
Taylor expanded in phi2 around 0 90.0%
if 3.69999999999999981e-5 < phi2 < 9.20000000000000052e228Initial program 71.6%
cos-diff98.8%
Applied egg-rr98.8%
cos-neg98.8%
*-commutative98.8%
fma-def98.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in phi1 around 0 63.7%
Final simplification77.8%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (* (sin phi1) (sin phi2)))
(t_2
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi2 -5.5e-7)
(* R (acos (+ t_1 (* t_0 (cos lambda2)))))
(if (<= phi2 4.6e-5)
(* R (acos (* (cos phi1) t_2)))
(if (<= phi2 1.55e+231)
(* R (acos (* (cos phi2) t_2)))
(* R (acos (+ t_1 (* t_0 (cos lambda1))))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(phi1) * sin(phi2);
double t_2 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1));
double tmp;
if (phi2 <= -5.5e-7) {
tmp = R * acos((t_1 + (t_0 * cos(lambda2))));
} else if (phi2 <= 4.6e-5) {
tmp = R * acos((cos(phi1) * t_2));
} else if (phi2 <= 1.55e+231) {
tmp = R * acos((cos(phi2) * t_2));
} else {
tmp = R * acos((t_1 + (t_0 * cos(lambda1))));
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(phi1) * sin(phi2)
t_2 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))
if (phi2 <= (-5.5d-7)) then
tmp = r * acos((t_1 + (t_0 * cos(lambda2))))
else if (phi2 <= 4.6d-5) then
tmp = r * acos((cos(phi1) * t_2))
else if (phi2 <= 1.55d+231) then
tmp = r * acos((cos(phi2) * t_2))
else
tmp = r * acos((t_1 + (t_0 * cos(lambda1))))
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double t_2 = (Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1));
double tmp;
if (phi2 <= -5.5e-7) {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda2))));
} else if (phi2 <= 4.6e-5) {
tmp = R * Math.acos((Math.cos(phi1) * t_2));
} else if (phi2 <= 1.55e+231) {
tmp = R * Math.acos((Math.cos(phi2) * t_2));
} else {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda1))));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(phi1) * math.sin(phi2) t_2 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi2 <= -5.5e-7: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda2)))) elif phi2 <= 4.6e-5: tmp = R * math.acos((math.cos(phi1) * t_2)) elif phi2 <= 1.55e+231: tmp = R * math.acos((math.cos(phi2) * t_2)) else: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda1)))) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) t_2 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi2 <= -5.5e-7) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda2))))); elseif (phi2 <= 4.6e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_2))); elseif (phi2 <= 1.55e+231) tmp = Float64(R * acos(Float64(cos(phi2) * t_2))); else tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda1))))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
t_0 = cos(phi1) * cos(phi2);
t_1 = sin(phi1) * sin(phi2);
t_2 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1));
tmp = 0.0;
if (phi2 <= -5.5e-7)
tmp = R * acos((t_1 + (t_0 * cos(lambda2))));
elseif (phi2 <= 4.6e-5)
tmp = R * acos((cos(phi1) * t_2));
elseif (phi2 <= 1.55e+231)
tmp = R * acos((cos(phi2) * t_2));
else
tmp = R * acos((t_1 + (t_0 * cos(lambda1))));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -5.5e-7], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4.6e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.55e+231], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
t_2 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq -5.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + t_0 \cdot \cos \lambda_2\right)\\
\mathbf{elif}\;\phi_2 \leq 4.6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t_2\right)\\
\mathbf{elif}\;\phi_2 \leq 1.55 \cdot 10^{+231}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + t_0 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < -5.5000000000000003e-7Initial program 83.2%
Taylor expanded in lambda1 around 0 53.9%
cos-neg53.9%
Simplified53.9%
if -5.5000000000000003e-7 < phi2 < 4.6e-5Initial program 75.6%
cos-diff90.2%
Applied egg-rr90.2%
cos-neg90.2%
*-commutative90.2%
fma-def90.3%
cos-neg90.3%
Simplified90.3%
Taylor expanded in phi2 around 0 90.0%
if 4.6e-5 < phi2 < 1.54999999999999995e231Initial program 71.6%
cos-diff98.8%
Applied egg-rr98.8%
cos-neg98.8%
*-commutative98.8%
fma-def98.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in phi1 around 0 63.7%
if 1.54999999999999995e231 < phi2 Initial program 77.0%
Taylor expanded in lambda2 around 0 50.0%
Final simplification74.7%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -7e-8) (not (<= phi1 1.2e+17)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -7e-8) || !(phi1 <= 1.2e+17)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))));
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi1 <= (-7d-8)) .or. (.not. (phi1 <= 1.2d+17))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = r * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -7e-8) || !(phi1 <= 1.2e+17)) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -7e-8) or not (phi1 <= 1.2e+17): tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = R * math.acos((math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -7e-8) || !(phi1 <= 1.2e+17)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if ((phi1 <= -7e-8) || ~((phi1 <= 1.2e+17)))
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
else
tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -7e-8], N[Not[LessEqual[phi1, 1.2e+17]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 1.2 \cdot 10^{+17}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.00000000000000048e-8 or 1.2e17 < phi1 Initial program 83.1%
if -7.00000000000000048e-8 < phi1 < 1.2e17Initial program 71.4%
cos-diff89.6%
Applied egg-rr89.6%
cos-neg89.6%
*-commutative89.6%
fma-def89.6%
cos-neg89.6%
Simplified89.6%
Taylor expanded in phi1 around 0 85.0%
Final simplification84.1%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.00146)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))
(* R (acos (* (cos phi2) (cos (- lambda2 lambda1)))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00146) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos((cos(phi2) * cos((lambda2 - lambda1))));
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 0.00146d0) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))
else
tmp = r * acos((cos(phi2) * cos((lambda2 - lambda1))))
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00146) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos((lambda2 - lambda1))));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.00146: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))) else: tmp = R * math.acos((math.cos(phi2) * math.cos((lambda2 - lambda1)))) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.00146) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(Float64(lambda2 - lambda1))))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (phi2 <= 0.00146)
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))));
else
tmp = R * acos((cos(phi2) * cos((lambda2 - lambda1))));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.00146], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.00146:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < 0.0014599999999999999Initial program 78.0%
cos-diff93.0%
Applied egg-rr93.0%
cos-neg93.0%
*-commutative93.0%
fma-def93.0%
cos-neg93.0%
Simplified93.0%
Taylor expanded in phi2 around 0 67.7%
if 0.0014599999999999999 < phi2 Initial program 73.4%
fma-def73.4%
associate-*l*73.4%
Simplified73.4%
Taylor expanded in phi1 around 0 46.2%
sub-neg46.2%
+-commutative46.2%
neg-mul-146.2%
neg-mul-146.2%
remove-double-neg46.2%
mul-1-neg46.2%
distribute-neg-in46.2%
+-commutative46.2%
cos-neg46.2%
+-commutative46.2%
mul-1-neg46.2%
unsub-neg46.2%
Simplified46.2%
Final simplification63.3%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi2 4.4e-5)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1));
double tmp;
if (phi2 <= 4.4e-5) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((cos(phi2) * t_0));
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))
if (phi2 <= 4.4d-5) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((cos(phi2) * t_0))
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1));
double tmp;
if (phi2 <= 4.4e-5) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi2 <= 4.4e-5: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi2 <= 4.4e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1));
tmp = 0.0;
if (phi2 <= 4.4e-5)
tmp = R * acos((cos(phi1) * t_0));
else
tmp = R * acos((cos(phi2) * t_0));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 4.4e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq 4.4 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_0\right)\\
\end{array}
\end{array}
if phi2 < 4.3999999999999999e-5Initial program 78.0%
cos-diff93.0%
Applied egg-rr93.0%
cos-neg93.0%
*-commutative93.0%
fma-def93.0%
cos-neg93.0%
Simplified93.0%
Taylor expanded in phi2 around 0 67.7%
if 4.3999999999999999e-5 < phi2 Initial program 73.4%
cos-diff99.1%
Applied egg-rr99.1%
cos-neg99.1%
*-commutative99.1%
fma-def99.1%
cos-neg99.1%
Simplified99.1%
Taylor expanded in phi1 around 0 55.8%
Final simplification65.2%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi1 -0.0022)
(* R (- (/ PI 2.0) (asin (* (cos phi1) t_0))))
(* R (acos (* (cos phi2) t_0))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -0.0022) {
tmp = R * ((((double) M_PI) / 2.0) - asin((cos(phi1) * t_0)));
} else {
tmp = R * acos((cos(phi2) * t_0));
}
return tmp;
}
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -0.0022) {
tmp = R * ((Math.PI / 2.0) - Math.asin((Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -0.0022: tmp = R * ((math.pi / 2.0) - math.asin((math.cos(phi1) * t_0))) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -0.0022) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
t_0 = cos((lambda2 - lambda1));
tmp = 0.0;
if (phi1 <= -0.0022)
tmp = R * ((pi / 2.0) - asin((cos(phi1) * t_0)));
else
tmp = R * acos((cos(phi2) * t_0));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0022], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -0.0022:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\cos \phi_1 \cdot t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_0\right)\\
\end{array}
\end{array}
if phi1 < -0.00220000000000000013Initial program 85.2%
fma-def85.2%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in phi2 around 0 61.9%
sub-neg61.9%
+-commutative61.9%
neg-mul-161.9%
neg-mul-161.9%
remove-double-neg61.9%
mul-1-neg61.9%
distribute-neg-in61.9%
+-commutative61.9%
cos-neg61.9%
+-commutative61.9%
mul-1-neg61.9%
unsub-neg61.9%
Simplified61.9%
acos-asin61.9%
*-commutative61.9%
Applied egg-rr61.9%
if -0.00220000000000000013 < phi1 Initial program 74.3%
fma-def74.3%
associate-*l*74.3%
Simplified74.3%
Taylor expanded in phi1 around 0 54.3%
sub-neg54.3%
+-commutative54.3%
neg-mul-154.3%
neg-mul-154.3%
remove-double-neg54.3%
mul-1-neg54.3%
distribute-neg-in54.3%
+-commutative54.3%
cos-neg54.3%
+-commutative54.3%
mul-1-neg54.3%
unsub-neg54.3%
Simplified54.3%
Final simplification56.2%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi1 -0.0022)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0))))))assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -0.0022) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((cos(phi2) * t_0));
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
if (phi1 <= (-0.0022d0)) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((cos(phi2) * t_0))
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -0.0022) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -0.0022: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -0.0022) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
t_0 = cos((lambda2 - lambda1));
tmp = 0.0;
if (phi1 <= -0.0022)
tmp = R * acos((cos(phi1) * t_0));
else
tmp = R * acos((cos(phi2) * t_0));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0022], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -0.0022:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_0\right)\\
\end{array}
\end{array}
if phi1 < -0.00220000000000000013Initial program 85.2%
fma-def85.2%
associate-*l*85.2%
Simplified85.2%
Taylor expanded in phi2 around 0 61.9%
sub-neg61.9%
+-commutative61.9%
neg-mul-161.9%
neg-mul-161.9%
remove-double-neg61.9%
mul-1-neg61.9%
distribute-neg-in61.9%
+-commutative61.9%
cos-neg61.9%
+-commutative61.9%
mul-1-neg61.9%
unsub-neg61.9%
Simplified61.9%
if -0.00220000000000000013 < phi1 Initial program 74.3%
fma-def74.3%
associate-*l*74.3%
Simplified74.3%
Taylor expanded in phi1 around 0 54.3%
sub-neg54.3%
+-commutative54.3%
neg-mul-154.3%
neg-mul-154.3%
remove-double-neg54.3%
mul-1-neg54.3%
distribute-neg-in54.3%
+-commutative54.3%
cos-neg54.3%
+-commutative54.3%
mul-1-neg54.3%
unsub-neg54.3%
Simplified54.3%
Final simplification56.2%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 0.00115) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (cos lambda2)))))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 0.00115) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos(cos(lambda2));
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 0.00115d0) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos(cos(lambda2))
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 0.00115) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos(Math.cos(lambda2));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 0.00115: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos(math.cos(lambda2)) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 0.00115) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(cos(lambda2))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (lambda2 <= 0.00115)
tmp = R * acos((cos(phi1) * cos(lambda1)));
else
tmp = R * acos(cos(lambda2));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 0.00115], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 0.00115:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if lambda2 < 0.00115Initial program 81.0%
fma-def81.0%
associate-*l*81.0%
Simplified81.0%
Taylor expanded in phi2 around 0 50.1%
sub-neg50.1%
+-commutative50.1%
neg-mul-150.1%
neg-mul-150.1%
remove-double-neg50.1%
mul-1-neg50.1%
distribute-neg-in50.1%
+-commutative50.1%
cos-neg50.1%
+-commutative50.1%
mul-1-neg50.1%
unsub-neg50.1%
Simplified50.1%
Taylor expanded in lambda2 around 0 44.4%
cos-neg44.4%
*-commutative44.4%
Simplified44.4%
if 0.00115 < lambda2 Initial program 63.9%
fma-def63.9%
associate-*l*63.9%
Simplified63.9%
Taylor expanded in phi2 around 0 47.4%
sub-neg47.4%
+-commutative47.4%
neg-mul-147.4%
neg-mul-147.4%
remove-double-neg47.4%
mul-1-neg47.4%
distribute-neg-in47.4%
+-commutative47.4%
cos-neg47.4%
+-commutative47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
Taylor expanded in phi1 around 0 36.7%
Taylor expanded in lambda1 around 0 36.8%
Final simplification42.7%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -8.8e-5) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (* (cos phi1) (cos lambda2))))))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8.8e-5) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos((cos(phi1) * cos(lambda2)));
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-8.8d-5)) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos((cos(phi1) * cos(lambda2)))
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8.8e-5) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -8.8e-5: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -8.8e-5) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (lambda1 <= -8.8e-5)
tmp = R * acos((cos(phi1) * cos(lambda1)));
else
tmp = R * acos((cos(phi1) * cos(lambda2)));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -8.8e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -8.8 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -8.7999999999999998e-5Initial program 66.8%
fma-def66.8%
associate-*l*66.8%
Simplified66.8%
Taylor expanded in phi2 around 0 43.1%
sub-neg43.1%
+-commutative43.1%
neg-mul-143.1%
neg-mul-143.1%
remove-double-neg43.1%
mul-1-neg43.1%
distribute-neg-in43.1%
+-commutative43.1%
cos-neg43.1%
+-commutative43.1%
mul-1-neg43.1%
unsub-neg43.1%
Simplified43.1%
Taylor expanded in lambda2 around 0 43.4%
cos-neg43.4%
*-commutative43.4%
Simplified43.4%
if -8.7999999999999998e-5 < lambda1 Initial program 80.1%
fma-def80.1%
associate-*l*80.1%
Simplified80.1%
Taylor expanded in phi2 around 0 51.4%
sub-neg51.4%
+-commutative51.4%
neg-mul-151.4%
neg-mul-151.4%
remove-double-neg51.4%
mul-1-neg51.4%
distribute-neg-in51.4%
+-commutative51.4%
cos-neg51.4%
+-commutative51.4%
mul-1-neg51.4%
unsub-neg51.4%
Simplified51.4%
Taylor expanded in lambda1 around 0 39.9%
Final simplification40.7%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (* (cos phi1) (cos (- lambda2 lambda1))))))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos(phi1) * cos((lambda2 - lambda1))));
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos((cos(phi1) * cos((lambda2 - lambda1))))
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos(phi1) * Math.cos((lambda2 - lambda1))));
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos(phi1) * math.cos((lambda2 - lambda1))))
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))) end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp = code(R, lambda1, lambda2, phi1, phi2)
tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1))));
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)
\end{array}
Initial program 77.1%
fma-def77.1%
associate-*l*77.1%
Simplified77.1%
Taylor expanded in phi2 around 0 49.5%
sub-neg49.5%
+-commutative49.5%
neg-mul-149.5%
neg-mul-149.5%
remove-double-neg49.5%
mul-1-neg49.5%
distribute-neg-in49.5%
+-commutative49.5%
cos-neg49.5%
+-commutative49.5%
mul-1-neg49.5%
unsub-neg49.5%
Simplified49.5%
Final simplification49.5%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -1.75e-7) (* R (acos (cos lambda1))) (* R (- lambda2 lambda1))))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.75e-7) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * (lambda2 - lambda1);
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-1.75d-7)) then
tmp = r * acos(cos(lambda1))
else
tmp = r * (lambda2 - lambda1)
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.75e-7) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * (lambda2 - lambda1);
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -1.75e-7: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * (lambda2 - lambda1) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -1.75e-7) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * Float64(lambda2 - lambda1)); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (lambda1 <= -1.75e-7)
tmp = R * acos(cos(lambda1));
else
tmp = R * (lambda2 - lambda1);
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -1.75e-7], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.75 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\lambda_2 - \lambda_1\right)\\
\end{array}
\end{array}
if lambda1 < -1.74999999999999992e-7Initial program 66.5%
fma-def66.5%
associate-*l*66.5%
Simplified66.5%
Taylor expanded in phi2 around 0 43.2%
sub-neg43.2%
+-commutative43.2%
neg-mul-143.2%
neg-mul-143.2%
remove-double-neg43.2%
mul-1-neg43.2%
distribute-neg-in43.2%
+-commutative43.2%
cos-neg43.2%
+-commutative43.2%
mul-1-neg43.2%
unsub-neg43.2%
Simplified43.2%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in lambda2 around 0 30.2%
cos-neg30.2%
Simplified30.2%
if -1.74999999999999992e-7 < lambda1 Initial program 80.2%
fma-def80.2%
associate-*l*80.2%
Simplified80.2%
Taylor expanded in phi2 around 0 51.4%
sub-neg51.4%
+-commutative51.4%
neg-mul-151.4%
neg-mul-151.4%
remove-double-neg51.4%
mul-1-neg51.4%
distribute-neg-in51.4%
+-commutative51.4%
cos-neg51.4%
+-commutative51.4%
mul-1-neg51.4%
unsub-neg51.4%
Simplified51.4%
Taylor expanded in phi1 around 0 27.7%
Taylor expanded in lambda2 around 0 4.9%
neg-mul-14.9%
+-commutative4.9%
sub-neg4.9%
Simplified4.9%
Final simplification10.7%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -3.2e-6) (* R (acos (cos lambda1))) (* R (acos (cos lambda2)))))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -3.2e-6) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * acos(cos(lambda2));
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-3.2d-6)) then
tmp = r * acos(cos(lambda1))
else
tmp = r * acos(cos(lambda2))
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -3.2e-6) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * Math.acos(Math.cos(lambda2));
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -3.2e-6: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * math.acos(math.cos(lambda2)) return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -3.2e-6) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * acos(cos(lambda2))); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (lambda1 <= -3.2e-6)
tmp = R * acos(cos(lambda1));
else
tmp = R * acos(cos(lambda2));
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -3.2e-6], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -3.2 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if lambda1 < -3.1999999999999999e-6Initial program 66.5%
fma-def66.5%
associate-*l*66.5%
Simplified66.5%
Taylor expanded in phi2 around 0 43.2%
sub-neg43.2%
+-commutative43.2%
neg-mul-143.2%
neg-mul-143.2%
remove-double-neg43.2%
mul-1-neg43.2%
distribute-neg-in43.2%
+-commutative43.2%
cos-neg43.2%
+-commutative43.2%
mul-1-neg43.2%
unsub-neg43.2%
Simplified43.2%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in lambda2 around 0 30.2%
cos-neg30.2%
Simplified30.2%
if -3.1999999999999999e-6 < lambda1 Initial program 80.2%
fma-def80.2%
associate-*l*80.2%
Simplified80.2%
Taylor expanded in phi2 around 0 51.4%
sub-neg51.4%
+-commutative51.4%
neg-mul-151.4%
neg-mul-151.4%
remove-double-neg51.4%
mul-1-neg51.4%
distribute-neg-in51.4%
+-commutative51.4%
cos-neg51.4%
+-commutative51.4%
mul-1-neg51.4%
unsub-neg51.4%
Simplified51.4%
Taylor expanded in phi1 around 0 27.7%
Taylor expanded in lambda1 around 0 17.9%
Final simplification20.8%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos (- lambda2 lambda1)))))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos((lambda2 - lambda1)));
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(cos((lambda2 - lambda1)))
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos((lambda2 - lambda1)));
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos((lambda2 - lambda1)))
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(Float64(lambda2 - lambda1)))) end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp = code(R, lambda1, lambda2, phi1, phi2)
tmp = R * acos(cos((lambda2 - lambda1)));
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 77.1%
fma-def77.1%
associate-*l*77.1%
Simplified77.1%
Taylor expanded in phi2 around 0 49.5%
sub-neg49.5%
+-commutative49.5%
neg-mul-149.5%
neg-mul-149.5%
remove-double-neg49.5%
mul-1-neg49.5%
distribute-neg-in49.5%
+-commutative49.5%
cos-neg49.5%
+-commutative49.5%
mul-1-neg49.5%
unsub-neg49.5%
Simplified49.5%
Taylor expanded in phi1 around 0 28.5%
Final simplification28.5%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -8e-113) (- (* lambda1 R)) (* lambda2 R)))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8e-113) {
tmp = -(lambda1 * R);
} else {
tmp = lambda2 * R;
}
return tmp;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-8d-113)) then
tmp = -(lambda1 * r)
else
tmp = lambda2 * r
end if
code = tmp
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8e-113) {
tmp = -(lambda1 * R);
} else {
tmp = lambda2 * R;
}
return tmp;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -8e-113: tmp = -(lambda1 * R) else: tmp = lambda2 * R return tmp
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -8e-113) tmp = Float64(-Float64(lambda1 * R)); else tmp = Float64(lambda2 * R); end return tmp end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (lambda1 <= -8e-113)
tmp = -(lambda1 * R);
else
tmp = lambda2 * R;
end
tmp_2 = tmp;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -8e-113], (-N[(lambda1 * R), $MachinePrecision]), N[(lambda2 * R), $MachinePrecision]]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -8 \cdot 10^{-113}:\\
\;\;\;\;-\lambda_1 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\lambda_2 \cdot R\\
\end{array}
\end{array}
if lambda1 < -7.99999999999999983e-113Initial program 72.6%
fma-def72.6%
associate-*l*72.6%
Simplified72.6%
Taylor expanded in phi2 around 0 44.4%
sub-neg44.4%
+-commutative44.4%
neg-mul-144.4%
neg-mul-144.4%
remove-double-neg44.4%
mul-1-neg44.4%
distribute-neg-in44.4%
+-commutative44.4%
cos-neg44.4%
+-commutative44.4%
mul-1-neg44.4%
unsub-neg44.4%
Simplified44.4%
Taylor expanded in phi1 around 0 28.9%
Taylor expanded in lambda2 around 0 7.8%
neg-mul-17.8%
Simplified7.8%
if -7.99999999999999983e-113 < lambda1 Initial program 79.1%
fma-def79.2%
associate-*l*79.2%
Simplified79.2%
Taylor expanded in phi2 around 0 51.9%
sub-neg51.9%
+-commutative51.9%
neg-mul-151.9%
neg-mul-151.9%
remove-double-neg51.9%
mul-1-neg51.9%
distribute-neg-in51.9%
+-commutative51.9%
cos-neg51.9%
+-commutative51.9%
mul-1-neg51.9%
unsub-neg51.9%
Simplified51.9%
Taylor expanded in phi1 around 0 28.3%
Taylor expanded in lambda2 around inf 5.4%
Final simplification6.2%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (- lambda2 lambda1)))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (lambda2 - lambda1);
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (lambda2 - lambda1)
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (lambda2 - lambda1);
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): return R * (lambda2 - lambda1)
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(lambda2 - lambda1)) end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp = code(R, lambda1, lambda2, phi1, phi2)
tmp = R * (lambda2 - lambda1);
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
R \cdot \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 77.1%
fma-def77.1%
associate-*l*77.1%
Simplified77.1%
Taylor expanded in phi2 around 0 49.5%
sub-neg49.5%
+-commutative49.5%
neg-mul-149.5%
neg-mul-149.5%
remove-double-neg49.5%
mul-1-neg49.5%
distribute-neg-in49.5%
+-commutative49.5%
cos-neg49.5%
+-commutative49.5%
mul-1-neg49.5%
unsub-neg49.5%
Simplified49.5%
Taylor expanded in phi1 around 0 28.5%
Taylor expanded in lambda2 around 0 4.8%
neg-mul-14.8%
+-commutative4.8%
sub-neg4.8%
Simplified4.8%
Final simplification4.8%
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. (FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* lambda2 R))
assert(lambda1 < lambda2);
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return lambda2 * R;
}
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function.
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda2 * r
end function
assert lambda1 < lambda2;
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return lambda2 * R;
}
[lambda1, lambda2] = sort([lambda1, lambda2]) def code(R, lambda1, lambda2, phi1, phi2): return lambda2 * R
lambda1, lambda2 = sort([lambda1, lambda2]) function code(R, lambda1, lambda2, phi1, phi2) return Float64(lambda2 * R) end
lambda1, lambda2 = num2cell(sort([lambda1, lambda2])){:}
function tmp = code(R, lambda1, lambda2, phi1, phi2)
tmp = lambda2 * R;
end
NOTE: lambda1 and lambda2 should be sorted in increasing order before calling this function. code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(lambda2 * R), $MachinePrecision]
\begin{array}{l}
[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\
\\
\lambda_2 \cdot R
\end{array}
Initial program 77.1%
fma-def77.1%
associate-*l*77.1%
Simplified77.1%
Taylor expanded in phi2 around 0 49.5%
sub-neg49.5%
+-commutative49.5%
neg-mul-149.5%
neg-mul-149.5%
remove-double-neg49.5%
mul-1-neg49.5%
distribute-neg-in49.5%
+-commutative49.5%
cos-neg49.5%
+-commutative49.5%
mul-1-neg49.5%
unsub-neg49.5%
Simplified49.5%
Taylor expanded in phi1 around 0 28.5%
Taylor expanded in lambda2 around inf 5.0%
Final simplification5.0%
herbie shell --seed 2023240
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Spherical law of cosines"
:precision binary64
(* (acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))) R))