
(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 31 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}
(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.0)
(* (fabs (remainder phi1 (* 2.0 PI))) R)
(*
R
(acos
(fma
t_1
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2)))
t_0))))))
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.0) {
tmp = fabs(remainder(phi1, (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos(fma(t_1, fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))), t_0));
}
return tmp;
}
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.0], N[(N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\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:\\
\;\;\;\;\left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(t\_1, \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right), t\_0\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.0Initial program 14.1%
+-commutative14.1%
associate-*l*14.1%
fma-define14.1%
Simplified14.1%
Taylor expanded in lambda1 around 0 14.1%
+-commutative14.1%
*-commutative14.1%
fma-define14.1%
*-commutative14.1%
associate-*l*14.1%
cos-neg14.1%
Simplified14.1%
Taylor expanded in phi2 around 0 14.1%
Taylor expanded in lambda2 around 0 14.1%
acos-cos74.9%
Applied egg-rr74.9%
if 0.0 < (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 77.2%
Simplified77.2%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
add-log-exp99.1%
*-commutative99.1%
exp-prod99.1%
Applied egg-rr99.1%
Taylor expanded in phi1 around 0 99.1%
associate-*r*99.1%
fma-define99.1%
+-commutative99.1%
*-commutative99.1%
exp-prod99.1%
rem-log-exp99.1%
fma-define99.1%
*-commutative99.1%
Simplified99.1%
Final simplification98.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<=
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
0.0)
(* (fabs (remainder phi1 (* 2.0 PI))) R)
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(*
(cos phi1)
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) <= 0.0) {
tmp = fabs(remainder(phi1, (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))));
}
return tmp;
}
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[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], 0.0], N[(N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $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[(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]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\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) \leq 0:\\
\;\;\;\;\left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\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 \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\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.0Initial program 14.1%
+-commutative14.1%
associate-*l*14.1%
fma-define14.1%
Simplified14.1%
Taylor expanded in lambda1 around 0 14.1%
+-commutative14.1%
*-commutative14.1%
fma-define14.1%
*-commutative14.1%
associate-*l*14.1%
cos-neg14.1%
Simplified14.1%
Taylor expanded in phi2 around 0 14.1%
Taylor expanded in lambda2 around 0 14.1%
acos-cos74.9%
Applied egg-rr74.9%
if 0.0 < (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 77.2%
Simplified77.2%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
Final simplification98.2%
(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.0)
(* (fabs (remainder phi1 (* 2.0 PI))) R)
(*
R
(acos
(+
t_0
(*
t_1
(fma
(sin lambda2)
(sin lambda1)
(* (cos lambda2) (cos lambda1))))))))))
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.0) {
tmp = fabs(remainder(phi1, (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos((t_0 + (t_1 * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
}
return tmp;
}
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.0], N[(N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\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:\\
\;\;\;\;\left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + t\_1 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \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.0Initial program 14.1%
+-commutative14.1%
associate-*l*14.1%
fma-define14.1%
Simplified14.1%
Taylor expanded in lambda1 around 0 14.1%
+-commutative14.1%
*-commutative14.1%
fma-define14.1%
*-commutative14.1%
associate-*l*14.1%
cos-neg14.1%
Simplified14.1%
Taylor expanded in phi2 around 0 14.1%
Taylor expanded in lambda2 around 0 14.1%
acos-cos74.9%
Applied egg-rr74.9%
if 0.0 < (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 77.2%
add-sqr-sqrt50.3%
sqrt-unprod58.6%
pow258.6%
Applied egg-rr58.6%
sqrt-pow177.2%
metadata-eval77.2%
pow177.2%
cos-diff99.1%
+-commutative99.1%
*-commutative99.1%
fma-define99.1%
*-commutative99.1%
Applied egg-rr99.1%
Final simplification98.2%
(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.0)
(* (fabs (remainder phi1 (* 2.0 PI))) R)
(*
R
(acos
(+
t_0
(*
t_1
(fma
(cos lambda2)
(cos lambda1)
(* (sin lambda1) (sin 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.0) {
tmp = fabs(remainder(phi1, (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos((t_0 + (t_1 * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
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.0], N[(N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $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}
\\
\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:\\
\;\;\;\;\left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\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.0Initial program 14.1%
+-commutative14.1%
associate-*l*14.1%
fma-define14.1%
Simplified14.1%
Taylor expanded in lambda1 around 0 14.1%
+-commutative14.1%
*-commutative14.1%
fma-define14.1%
*-commutative14.1%
associate-*l*14.1%
cos-neg14.1%
Simplified14.1%
Taylor expanded in phi2 around 0 14.1%
Taylor expanded in lambda2 around 0 14.1%
acos-cos74.9%
Applied egg-rr74.9%
if 0.0 < (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 77.2%
add-sqr-sqrt50.3%
sqrt-unprod58.6%
pow258.6%
Applied egg-rr58.6%
sqrt-pow177.2%
metadata-eval77.2%
pow177.2%
cos-diff99.1%
*-commutative99.1%
fma-define99.1%
Applied egg-rr99.1%
Final simplification98.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<=
(acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
0.0)
(* (fabs (remainder phi1 (* 2.0 PI))) R)
(*
R
(acos
(+
t_0
(*
(cos phi2)
(*
(cos phi1)
(fma
(cos lambda2)
(cos lambda1)
(* (sin lambda1) (sin lambda2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) <= 0.0) {
tmp = fabs(remainder(phi1, (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos((t_0 + (cos(phi2) * (cos(phi1) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2)))))));
}
return tmp;
}
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], N[(N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \leq 0:\\
\;\;\;\;\left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\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.0Initial program 14.1%
+-commutative14.1%
associate-*l*14.1%
fma-define14.1%
Simplified14.1%
Taylor expanded in lambda1 around 0 14.1%
+-commutative14.1%
*-commutative14.1%
fma-define14.1%
*-commutative14.1%
associate-*l*14.1%
cos-neg14.1%
Simplified14.1%
Taylor expanded in phi2 around 0 14.1%
Taylor expanded in lambda2 around 0 14.1%
acos-cos74.9%
Applied egg-rr74.9%
if 0.0 < (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 77.2%
cos-diff99.1%
distribute-lft-in99.1%
Applied egg-rr99.1%
distribute-lft-out99.1%
*-commutative99.1%
associate-*l*99.1%
cos-neg99.1%
*-commutative99.1%
fma-define99.1%
cos-neg99.1%
Simplified99.1%
Final simplification98.2%
(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.0)
(* (fabs (remainder phi1 (* 2.0 PI))) R)
(*
R
(acos
(+
t_0
(*
t_1
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))))))
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.0) {
tmp = fabs(remainder(phi1, (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos((t_0 + (t_1 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (Math.acos((t_0 + (t_1 * Math.cos((lambda1 - lambda2))))) <= 0.0) {
tmp = Math.abs(Math.IEEEremainder(phi1, (2.0 * Math.PI))) * R;
} else {
tmp = R * Math.acos((t_0 + (t_1 * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = math.cos(phi1) * math.cos(phi2) tmp = 0 if math.acos((t_0 + (t_1 * math.cos((lambda1 - lambda2))))) <= 0.0: tmp = math.fabs(math.remainder(phi1, (2.0 * math.pi))) * R else: tmp = R * math.acos((t_0 + (t_1 * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) return tmp
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.0], N[(N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $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}
\\
\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:\\
\;\;\;\;\left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\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.0Initial program 14.1%
+-commutative14.1%
associate-*l*14.1%
fma-define14.1%
Simplified14.1%
Taylor expanded in lambda1 around 0 14.1%
+-commutative14.1%
*-commutative14.1%
fma-define14.1%
*-commutative14.1%
associate-*l*14.1%
cos-neg14.1%
Simplified14.1%
Taylor expanded in phi2 around 0 14.1%
Taylor expanded in lambda2 around 0 14.1%
acos-cos74.9%
Applied egg-rr74.9%
if 0.0 < (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 77.2%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
Final simplification98.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<=
(acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
0.0)
(* (fabs (remainder phi1 (* 2.0 PI))) R)
(*
R
(acos
(+
t_0
(*
(cos phi1)
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) <= 0.0) {
tmp = fabs(remainder(phi1, (2.0 * ((double) M_PI)))) * R;
} else {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) <= 0.0) {
tmp = Math.abs(Math.IEEEremainder(phi1, (2.0 * Math.PI))) * R;
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) <= 0.0: tmp = math.fabs(math.remainder(phi1, (2.0 * math.pi))) * R else: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))) return tmp
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], N[(N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * 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]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \leq 0:\\
\;\;\;\;\left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right| \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\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.0Initial program 14.1%
+-commutative14.1%
associate-*l*14.1%
fma-define14.1%
Simplified14.1%
Taylor expanded in lambda1 around 0 14.1%
+-commutative14.1%
*-commutative14.1%
fma-define14.1%
*-commutative14.1%
associate-*l*14.1%
cos-neg14.1%
Simplified14.1%
Taylor expanded in phi2 around 0 14.1%
Taylor expanded in lambda2 around 0 14.1%
acos-cos74.9%
Applied egg-rr74.9%
if 0.0 < (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 77.2%
Simplified77.2%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in phi1 around 0 99.1%
Final simplification98.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -3.8e-6)
(*
R
(-
(/ PI 2.0)
(asin (fma (sin phi2) (sin phi1) (* (* (cos phi1) (cos phi2)) t_0)))))
(if (<= phi2 3.55e-16)
(*
R
(acos
(+
(* (sin phi1) phi2)
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -3.8e-6) {
tmp = R * ((((double) M_PI) / 2.0) - asin(fma(sin(phi2), sin(phi1), ((cos(phi1) * cos(phi2)) * t_0))));
} else if (phi2 <= 3.55e-16) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -3.8e-6) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(fma(sin(phi2), sin(phi1), Float64(Float64(cos(phi1) * cos(phi2)) * t_0))))); elseif (phi2 <= 3.55e-16) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + 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
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -3.8e-6], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[Sin[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3.55e-16], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + 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]), $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}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -3.8 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\mathsf{fma}\left(\sin \phi_2, \sin \phi_1, \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 3.55 \cdot 10^{-16}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \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(\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 phi2 < -3.8e-6Initial program 75.6%
add-sqr-sqrt46.9%
sqrt-unprod56.8%
pow256.8%
Applied egg-rr56.8%
Applied egg-rr75.6%
if -3.8e-6 < phi2 < 3.55e-16Initial program 73.6%
Simplified73.6%
cos-diff92.3%
+-commutative92.3%
Applied egg-rr92.3%
add-log-exp92.3%
*-commutative92.3%
exp-prod92.3%
Applied egg-rr92.3%
Taylor expanded in phi1 around 0 92.3%
associate-*r*92.3%
fma-define92.3%
+-commutative92.3%
*-commutative92.3%
exp-prod92.3%
rem-log-exp92.3%
fma-define92.4%
*-commutative92.4%
Simplified92.4%
Taylor expanded in phi2 around 0 92.2%
if 3.55e-16 < phi2 Initial program 76.3%
Simplified76.4%
Final simplification84.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -6.2e-7)
(*
(acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0)))
R)
(if (<= phi2 3.55e-16)
(*
R
(acos
(+
(* (sin phi1) phi2)
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -6.2e-7) {
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0))) * R;
} else if (phi2 <= 3.55e-16) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -6.2e-7) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0))) * R); elseif (phi2 <= 3.55e-16) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + 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
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -6.2e-7], 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] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 3.55e-16], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + 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]), $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}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -6.2 \cdot 10^{-7}:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 3.55 \cdot 10^{-16}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \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(\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 phi2 < -6.1999999999999999e-7Initial program 76.0%
if -6.1999999999999999e-7 < phi2 < 3.55e-16Initial program 73.3%
Simplified73.3%
cos-diff92.3%
+-commutative92.3%
Applied egg-rr92.3%
add-log-exp92.3%
*-commutative92.3%
exp-prod92.3%
Applied egg-rr92.3%
Taylor expanded in phi1 around 0 92.3%
associate-*r*92.3%
fma-define92.3%
+-commutative92.3%
*-commutative92.3%
exp-prod92.3%
rem-log-exp92.3%
fma-define92.3%
*-commutative92.3%
Simplified92.3%
Taylor expanded in phi2 around 0 92.3%
if 3.55e-16 < phi2 Initial program 76.3%
Simplified76.4%
Final simplification84.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -9.5e-8)
(*
(acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0)))
R)
(if (<= phi2 3.55e-16)
(*
R
(acos
(*
(cos phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -9.5e-8) {
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0))) * R;
} else if (phi2 <= 3.55e-16) {
tmp = R * acos((cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -9.5e-8) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0))) * R); elseif (phi2 <= 3.55e-16) tmp = Float64(R * acos(Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -9.5e-8], 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] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 3.55e-16], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $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}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -9.5 \cdot 10^{-8}:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 3.55 \cdot 10^{-16}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\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 phi2 < -9.50000000000000036e-8Initial program 76.0%
if -9.50000000000000036e-8 < phi2 < 3.55e-16Initial program 73.3%
Simplified73.3%
cos-diff92.3%
+-commutative92.3%
Applied egg-rr92.3%
add-log-exp92.3%
*-commutative92.3%
exp-prod92.3%
Applied egg-rr92.3%
Taylor expanded in phi1 around 0 92.3%
associate-*r*92.3%
fma-define92.3%
+-commutative92.3%
*-commutative92.3%
exp-prod92.3%
rem-log-exp92.3%
fma-define92.3%
*-commutative92.3%
Simplified92.3%
Taylor expanded in phi2 around 0 92.3%
fma-define92.3%
Simplified92.3%
if 3.55e-16 < phi2 Initial program 76.3%
Simplified76.4%
Final simplification84.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -7.2e-8)
(* (acos (+ t_1 (* (* (cos phi1) (cos phi2)) t_0))) R)
(if (<= phi2 3.55e-16)
(*
R
(acos
(*
(cos phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -7.2e-8) {
tmp = acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0))) * R;
} else if (phi2 <= 3.55e-16) {
tmp = R * acos((cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -7.2e-8) tmp = Float64(acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * t_0))) * R); elseif (phi2 <= 3.55e-16) tmp = Float64(R * acos(Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7.2e-8], N[(N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 3.55e-16], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -7.2 \cdot 10^{-8}:\\
\;\;\;\;\cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 3.55 \cdot 10^{-16}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -7.19999999999999962e-8Initial program 76.0%
if -7.19999999999999962e-8 < phi2 < 3.55e-16Initial program 73.3%
Simplified73.3%
cos-diff92.3%
+-commutative92.3%
Applied egg-rr92.3%
add-log-exp92.3%
*-commutative92.3%
exp-prod92.3%
Applied egg-rr92.3%
Taylor expanded in phi1 around 0 92.3%
associate-*r*92.3%
fma-define92.3%
+-commutative92.3%
*-commutative92.3%
exp-prod92.3%
rem-log-exp92.3%
fma-define92.3%
*-commutative92.3%
Simplified92.3%
Taylor expanded in phi2 around 0 92.3%
fma-define92.3%
Simplified92.3%
if 3.55e-16 < phi2 Initial program 76.3%
+-commutative76.3%
associate-*l*76.3%
fma-define76.3%
Simplified76.3%
Final simplification84.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.35e-8) (not (<= phi2 3.55e-16)))
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R)
(*
R
(acos
(*
(cos phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.35e-8) || !(phi2 <= 3.55e-16)) {
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
} else {
tmp = R * acos((cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.35e-8) || !(phi2 <= 3.55e-16)) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R); else tmp = Float64(R * acos(Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.35e-8], N[Not[LessEqual[phi2, 3.55e-16]], $MachinePrecision]], 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], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.35 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 3.55 \cdot 10^{-16}\right):\\
\;\;\;\;\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\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -1.35000000000000001e-8 or 3.55e-16 < phi2 Initial program 76.1%
if -1.35000000000000001e-8 < phi2 < 3.55e-16Initial program 73.3%
Simplified73.3%
cos-diff92.3%
+-commutative92.3%
Applied egg-rr92.3%
add-log-exp92.3%
*-commutative92.3%
exp-prod92.3%
Applied egg-rr92.3%
Taylor expanded in phi1 around 0 92.3%
associate-*r*92.3%
fma-define92.3%
+-commutative92.3%
*-commutative92.3%
exp-prod92.3%
rem-log-exp92.3%
fma-define92.3%
*-commutative92.3%
Simplified92.3%
Taylor expanded in phi2 around 0 92.3%
fma-define92.3%
Simplified92.3%
Final simplification84.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.45e-6) (not (<= phi2 3.55e-16)))
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.45e-6) || !(phi2 <= 3.55e-16)) {
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
} else {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))));
}
return tmp;
}
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 <= (-1.45d-6)) .or. (.not. (phi2 <= 3.55d-16))) then
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
else
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.45e-6) || !(phi2 <= 3.55e-16)) {
tmp = Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
} else {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -1.45e-6) or not (phi2 <= 3.55e-16): tmp = math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R else: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.45e-6) || !(phi2 <= 3.55e-16)) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R); else tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -1.45e-6) || ~((phi2 <= 3.55e-16))) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; else tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.45e-6], N[Not[LessEqual[phi2, 3.55e-16]], $MachinePrecision]], 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], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.45 \cdot 10^{-6} \lor \neg \left(\phi_2 \leq 3.55 \cdot 10^{-16}\right):\\
\;\;\;\;\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\\
\mathbf{else}:\\
\;\;\;\;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)\\
\end{array}
\end{array}
if phi2 < -1.4500000000000001e-6 or 3.55e-16 < phi2 Initial program 76.1%
if -1.4500000000000001e-6 < phi2 < 3.55e-16Initial program 73.3%
Simplified73.3%
cos-diff92.3%
+-commutative92.3%
Applied egg-rr92.3%
add-log-exp92.3%
*-commutative92.3%
exp-prod92.3%
Applied egg-rr92.3%
Taylor expanded in phi1 around 0 92.3%
associate-*r*92.3%
fma-define92.3%
+-commutative92.3%
*-commutative92.3%
exp-prod92.3%
rem-log-exp92.3%
fma-define92.3%
*-commutative92.3%
Simplified92.3%
Taylor expanded in phi2 around 0 92.3%
Final simplification84.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -1.8e-5)
(* R (acos (+ t_1 (* t_0 (cos lambda2)))))
(if (<= phi2 0.0098)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))
(* R (acos (+ t_1 (* t_0 (cos lambda1)))))))))
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 tmp;
if (phi2 <= -1.8e-5) {
tmp = R * acos((t_1 + (t_0 * cos(lambda2))));
} else if (phi2 <= 0.0098) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos((t_1 + (t_0 * cos(lambda1))));
}
return tmp;
}
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 = cos(phi1) * cos(phi2)
t_1 = sin(phi1) * sin(phi2)
if (phi2 <= (-1.8d-5)) then
tmp = r * acos((t_1 + (t_0 * cos(lambda2))))
else if (phi2 <= 0.0098d0) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))
else
tmp = r * acos((t_1 + (t_0 * cos(lambda1))))
end if
code = tmp
end function
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 tmp;
if (phi2 <= -1.8e-5) {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda2))));
} else if (phi2 <= 0.0098) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= -1.8e-5: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda2)))) elif phi2 <= 0.0098: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))) else: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -1.8e-5) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda2))))); elseif (phi2 <= 0.0098) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= -1.8e-5) tmp = R * acos((t_1 + (t_0 * cos(lambda2)))); elseif (phi2 <= 0.0098) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))); else tmp = R * acos((t_1 + (t_0 * cos(lambda1)))); end tmp_2 = tmp; end
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]}, If[LessEqual[phi2, -1.8e-5], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.0098], 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[(t$95$1 + N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.8 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_2\right)\\
\mathbf{elif}\;\phi_2 \leq 0.0098:\\
\;\;\;\;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(t\_1 + t\_0 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < -1.80000000000000005e-5Initial program 75.6%
Taylor expanded in lambda1 around 0 54.7%
cos-neg54.7%
Simplified54.7%
if -1.80000000000000005e-5 < phi2 < 0.0097999999999999997Initial program 74.0%
Simplified74.0%
cos-diff92.5%
+-commutative92.5%
Applied egg-rr92.5%
add-log-exp92.5%
*-commutative92.5%
exp-prod92.5%
Applied egg-rr92.5%
Taylor expanded in phi1 around 0 92.5%
associate-*r*92.5%
fma-define92.5%
+-commutative92.5%
*-commutative92.5%
exp-prod92.5%
rem-log-exp92.5%
fma-define92.5%
*-commutative92.5%
Simplified92.5%
Taylor expanded in phi2 around 0 91.9%
if 0.0097999999999999997 < phi2 Initial program 75.4%
Taylor expanded in lambda2 around 0 57.5%
Final simplification74.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi2 -7e-5)
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda2))))))
(if (<= phi2 0.0098)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1))))))
(* R (acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos lambda1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -7e-5) {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2)))));
} else if (phi2 <= 0.0098) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
}
return tmp;
}
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(phi1) * sin(phi2)
if (phi2 <= (-7d-5)) then
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2)))))
else if (phi2 <= 0.0098d0) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))
else
tmp = r * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= -7e-5) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
} else if (phi2 <= 0.0098) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= -7e-5: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) elif phi2 <= 0.0098: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))) else: tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -7e-5) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); elseif (phi2 <= 0.0098) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= -7e-5) tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2))))); elseif (phi2 <= 0.0098) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))); else tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7e-5], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.0098], 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[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -7 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 0.0098:\\
\;\;\;\;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(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < -6.9999999999999994e-5Initial program 75.6%
Taylor expanded in lambda1 around 0 54.7%
cos-neg54.7%
Simplified54.7%
if -6.9999999999999994e-5 < phi2 < 0.0097999999999999997Initial program 74.0%
Simplified74.0%
cos-diff92.5%
+-commutative92.5%
Applied egg-rr92.5%
add-log-exp92.5%
*-commutative92.5%
exp-prod92.5%
Applied egg-rr92.5%
Taylor expanded in phi1 around 0 92.5%
associate-*r*92.5%
fma-define92.5%
+-commutative92.5%
*-commutative92.5%
exp-prod92.5%
rem-log-exp92.5%
fma-define92.5%
*-commutative92.5%
Simplified92.5%
Taylor expanded in phi2 around 0 91.9%
if 0.0097999999999999997 < phi2 Initial program 75.4%
Taylor expanded in lambda2 around 0 57.5%
Final simplification74.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi2 -3.4e-7)
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos phi1) (* (cos phi2) (cos lambda2))))))
(if (<= phi2 6.5e-15)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0)))))))
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 <= -3.4e-7) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2)))));
} else if (phi2 <= 6.5e-15) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((cos(phi2) * t_0));
}
return tmp;
}
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 <= (-3.4d-7)) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2)))))
else if (phi2 <= 6.5d-15) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((cos(phi2) * t_0))
end if
code = tmp
end function
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 <= -3.4e-7) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
} else if (phi2 <= 6.5e-15) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
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 <= -3.4e-7: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) elif phi2 <= 6.5e-15: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
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 <= -3.4e-7) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); elseif (phi2 <= 6.5e-15) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)); tmp = 0.0; if (phi2 <= -3.4e-7) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2))))); elseif (phi2 <= 6.5e-15) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((cos(phi2) * t_0)); end tmp_2 = tmp; end
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, -3.4e-7], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.5e-15], 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}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_2 \leq -3.4 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 6.5 \cdot 10^{-15}:\\
\;\;\;\;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 < -3.39999999999999974e-7Initial program 76.0%
Taylor expanded in lambda1 around 0 55.3%
cos-neg55.3%
Simplified55.3%
if -3.39999999999999974e-7 < phi2 < 6.49999999999999991e-15Initial program 73.3%
Simplified73.3%
cos-diff92.3%
+-commutative92.3%
Applied egg-rr92.3%
add-log-exp92.3%
*-commutative92.3%
exp-prod92.3%
Applied egg-rr92.3%
Taylor expanded in phi1 around 0 92.3%
associate-*r*92.3%
fma-define92.3%
+-commutative92.3%
*-commutative92.3%
exp-prod92.3%
rem-log-exp92.3%
fma-define92.3%
*-commutative92.3%
Simplified92.3%
Taylor expanded in phi2 around 0 92.3%
if 6.49999999999999991e-15 < phi2 Initial program 76.3%
Simplified76.4%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
add-log-exp99.2%
*-commutative99.2%
exp-prod99.1%
Applied egg-rr99.1%
Taylor expanded in phi1 around 0 99.0%
associate-*r*99.0%
fma-define99.0%
+-commutative99.0%
*-commutative99.0%
exp-prod99.0%
rem-log-exp99.0%
fma-define99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in phi1 around 0 64.9%
Final simplification75.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1)))))
(if (<= phi1 -1.25e-6)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0))))))
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 (phi1 <= -1.25e-6) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((cos(phi2) * t_0));
}
return tmp;
}
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 (phi1 <= (-1.25d-6)) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((cos(phi2) * t_0))
end if
code = tmp
end function
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 (phi1 <= -1.25e-6) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)) tmp = 0 if phi1 <= -1.25e-6: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))) tmp = 0.0 if (phi1 <= -1.25e-6) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)); tmp = 0.0; if (phi1 <= -1.25e-6) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((cos(phi2) * t_0)); end tmp_2 = tmp; end
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[phi1, -1.25e-6], 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}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_1 \leq -1.25 \cdot 10^{-6}:\\
\;\;\;\;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 < -1.2500000000000001e-6Initial program 80.8%
Simplified80.8%
cos-diff99.0%
+-commutative99.0%
Applied egg-rr99.0%
add-log-exp99.1%
*-commutative99.1%
exp-prod99.1%
Applied egg-rr99.1%
Taylor expanded in phi1 around 0 99.0%
associate-*r*99.1%
fma-define99.1%
+-commutative99.1%
*-commutative99.1%
exp-prod99.1%
rem-log-exp99.1%
fma-define99.1%
*-commutative99.1%
Simplified99.1%
Taylor expanded in phi2 around 0 67.5%
if -1.2500000000000001e-6 < phi1 Initial program 72.8%
Simplified72.8%
cos-diff94.7%
+-commutative94.7%
Applied egg-rr94.7%
add-log-exp94.7%
*-commutative94.7%
exp-prod94.7%
Applied egg-rr94.7%
Taylor expanded in phi1 around 0 94.7%
associate-*r*94.7%
fma-define94.7%
+-commutative94.7%
*-commutative94.7%
exp-prod94.7%
rem-log-exp94.7%
fma-define94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in phi1 around 0 72.4%
Final simplification71.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 6.5e-15)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (cos phi2) (cos (- lambda1 lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 6.5e-15) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
return tmp;
}
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 <= 6.5d-15) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 6.5e-15) {
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.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 6.5e-15: 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.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 6.5e-15) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 6.5e-15) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 6.5e-15], 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[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 6.5 \cdot 10^{-15}:\\
\;\;\;\;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(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < 6.49999999999999991e-15Initial program 74.3%
Simplified74.3%
cos-diff94.8%
+-commutative94.8%
Applied egg-rr94.8%
add-log-exp94.8%
*-commutative94.8%
exp-prod94.8%
Applied egg-rr94.8%
Taylor expanded in phi1 around 0 94.8%
associate-*r*94.8%
fma-define94.8%
+-commutative94.8%
*-commutative94.8%
exp-prod94.8%
rem-log-exp94.8%
fma-define94.9%
*-commutative94.9%
Simplified94.9%
Taylor expanded in phi2 around 0 66.0%
if 6.49999999999999991e-15 < phi2 Initial program 76.3%
Taylor expanded in phi1 around 0 52.0%
Final simplification62.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos phi2))))))
(t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 -3.2e-31)
t_0
(if (<= phi2 6.5e-15)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_1))))
(if (<= phi2 1.4e+160)
(* R (acos (+ (* (cos phi2) t_1) (* phi1 (sin phi2)))))
t_0)))))
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))));
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -3.2e-31) {
tmp = t_0;
} else if (phi2 <= 6.5e-15) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1)));
} else if (phi2 <= 1.4e+160) {
tmp = R * acos(((cos(phi2) * t_1) + (phi1 * sin(phi2))));
} else {
tmp = t_0;
}
return tmp;
}
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))))
t_1 = cos((lambda1 - lambda2))
if (phi2 <= (-3.2d-31)) then
tmp = t_0
else if (phi2 <= 6.5d-15) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1)))
else if (phi2 <= 1.4d+160) then
tmp = r * acos(((cos(phi2) * t_1) + (phi1 * sin(phi2))))
else
tmp = t_0
end if
code = tmp
end function
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))));
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -3.2e-31) {
tmp = t_0;
} else if (phi2 <= 6.5e-15) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_1)));
} else if (phi2 <= 1.4e+160) {
tmp = R * Math.acos(((Math.cos(phi2) * t_1) + (phi1 * Math.sin(phi2))));
} else {
tmp = t_0;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos(phi2)))) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= -3.2e-31: tmp = t_0 elif phi2 <= 6.5e-15: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_1))) elif phi2 <= 1.4e+160: tmp = R * math.acos(((math.cos(phi2) * t_1) + (phi1 * math.sin(phi2)))) else: tmp = t_0 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(phi2))))) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -3.2e-31) tmp = t_0; elseif (phi2 <= 6.5e-15) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_1)))); elseif (phi2 <= 1.4e+160) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_1) + Float64(phi1 * sin(phi2))))); else tmp = t_0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2)))); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -3.2e-31) tmp = t_0; elseif (phi2 <= 6.5e-15) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1))); elseif (phi2 <= 1.4e+160) tmp = R * acos(((cos(phi2) * t_1) + (phi1 * sin(phi2)))); else tmp = t_0; end tmp_2 = tmp; end
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[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -3.2e-31], t$95$0, If[LessEqual[phi2, 6.5e-15], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.4e+160], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \phi_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{-31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 6.5 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_1\right)\\
\mathbf{elif}\;\phi_2 \leq 1.4 \cdot 10^{+160}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_1 + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -3.20000000000000018e-31 or 1.4e160 < phi2 Initial program 75.7%
+-commutative75.7%
associate-*l*75.7%
fma-define75.7%
Simplified75.7%
Taylor expanded in lambda1 around 0 58.1%
+-commutative58.1%
*-commutative58.1%
fma-define58.1%
*-commutative58.1%
associate-*l*58.1%
cos-neg58.1%
Simplified58.1%
Taylor expanded in lambda2 around 0 41.1%
if -3.20000000000000018e-31 < phi2 < 6.49999999999999991e-15Initial program 72.8%
+-commutative72.8%
associate-*l*72.8%
fma-define72.8%
Simplified72.8%
Taylor expanded in phi2 around 0 72.8%
if 6.49999999999999991e-15 < phi2 < 1.4e160Initial program 78.5%
+-commutative78.5%
associate-*l*78.5%
fma-define78.6%
Simplified78.6%
Taylor expanded in phi1 around 0 45.3%
Final simplification56.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -3.2e-31)
(* R (acos (+ t_1 (* (cos phi1) (cos phi2)))))
(if (<= phi2 6.5e-15)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(* R (acos (+ t_1 (* (cos phi2) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -3.2e-31) {
tmp = R * acos((t_1 + (cos(phi1) * cos(phi2))));
} else if (phi2 <= 6.5e-15) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else {
tmp = R * acos((t_1 + (cos(phi2) * t_0)));
}
return tmp;
}
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 = cos((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
if (phi2 <= (-3.2d-31)) then
tmp = r * acos((t_1 + (cos(phi1) * cos(phi2))))
else if (phi2 <= 6.5d-15) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else
tmp = r * acos((t_1 + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= -3.2e-31) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * Math.cos(phi2))));
} else if (phi2 <= 6.5e-15) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= -3.2e-31: tmp = R * math.acos((t_1 + (math.cos(phi1) * math.cos(phi2)))) elif phi2 <= 6.5e-15: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) else: tmp = R * math.acos((t_1 + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -3.2e-31) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * cos(phi2))))); elseif (phi2 <= 6.5e-15) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= -3.2e-31) tmp = R * acos((t_1 + (cos(phi1) * cos(phi2)))); elseif (phi2 <= 6.5e-15) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); else tmp = R * acos((t_1 + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -3.2e-31], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.5e-15], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{-31}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\mathbf{elif}\;\phi_2 \leq 6.5 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < -3.20000000000000018e-31Initial program 76.7%
+-commutative76.7%
associate-*l*76.6%
fma-define76.6%
Simplified76.6%
Taylor expanded in lambda1 around 0 56.4%
+-commutative56.4%
*-commutative56.4%
fma-define56.4%
*-commutative56.4%
associate-*l*56.4%
cos-neg56.4%
Simplified56.4%
Taylor expanded in lambda2 around 0 39.0%
if -3.20000000000000018e-31 < phi2 < 6.49999999999999991e-15Initial program 72.8%
+-commutative72.8%
associate-*l*72.8%
fma-define72.8%
Simplified72.8%
Taylor expanded in phi2 around 0 72.8%
if 6.49999999999999991e-15 < phi2 Initial program 76.3%
Taylor expanded in phi1 around 0 52.0%
Final simplification57.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 6.5e-15)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(* R (acos (+ t_1 (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= 6.5e-15) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else {
tmp = R * acos((t_1 + (cos(phi2) * t_0)));
}
return tmp;
}
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 = cos((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
if (phi2 <= 6.5d-15) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else
tmp = r * acos((t_1 + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= 6.5e-15) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= 6.5e-15: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) else: tmp = R * math.acos((t_1 + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= 6.5e-15) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= 6.5e-15) tmp = R * acos((t_1 + (cos(phi1) * t_0))); else tmp = R * acos((t_1 + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 6.5e-15], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq 6.5 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 6.49999999999999991e-15Initial program 74.3%
Taylor expanded in phi2 around 0 53.7%
*-commutative53.7%
Simplified53.7%
if 6.49999999999999991e-15 < phi2 Initial program 76.3%
Taylor expanded in phi1 around 0 52.0%
Final simplification53.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -4.5e-15)
(* R (acos (* (cos phi1) (cos lambda2))))
(if (<= phi1 -2e-144)
(* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos lambda1)))))
(if (<= phi1 2.9e-163)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))
(* R (acos (* (cos phi2) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -4.5e-15) {
tmp = R * acos((cos(phi1) * cos(lambda2)));
} else if (phi1 <= -2e-144) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))));
} else if (phi1 <= 2.9e-163) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * acos((cos(phi2) * cos(lambda2)));
}
return tmp;
}
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 <= (-4.5d-15)) then
tmp = r * acos((cos(phi1) * cos(lambda2)))
else if (phi1 <= (-2d-144)) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))))
else if (phi1 <= 2.9d-163) then
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)))
else
tmp = r * acos((cos(phi2) * cos(lambda2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -4.5e-15) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
} else if (phi1 <= -2e-144) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos(lambda1))));
} else if (phi1 <= 2.9e-163) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -4.5e-15: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) elif phi1 <= -2e-144: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos(lambda1)))) elif phi1 <= 2.9e-163: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) else: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -4.5e-15) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); elseif (phi1 <= -2e-144) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(lambda1))))); elseif (phi1 <= 2.9e-163) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -4.5e-15) tmp = R * acos((cos(phi1) * cos(lambda2))); elseif (phi1 <= -2e-144) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1)))); elseif (phi1 <= 2.9e-163) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2))); else tmp = R * acos((cos(phi2) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -4.5e-15], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, -2e-144], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.9e-163], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -4.5 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\mathbf{elif}\;\phi_1 \leq -2 \cdot 10^{-144}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \lambda_1\right)\\
\mathbf{elif}\;\phi_1 \leq 2.9 \cdot 10^{-163}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi1 < -4.4999999999999998e-15Initial program 79.1%
+-commutative79.1%
associate-*l*79.1%
fma-define79.1%
Simplified79.1%
Taylor expanded in lambda1 around 0 58.9%
+-commutative58.9%
*-commutative58.9%
fma-define58.9%
*-commutative58.9%
associate-*l*58.9%
cos-neg58.9%
Simplified58.9%
Taylor expanded in phi2 around 0 43.5%
if -4.4999999999999998e-15 < phi1 < -1.9999999999999999e-144Initial program 60.1%
+-commutative60.1%
associate-*l*60.1%
fma-define60.1%
Simplified60.1%
Taylor expanded in phi1 around 0 60.1%
Taylor expanded in lambda2 around 0 35.4%
*-commutative35.4%
Simplified35.4%
if -1.9999999999999999e-144 < phi1 < 2.9000000000000001e-163Initial program 74.5%
+-commutative74.5%
associate-*l*74.5%
fma-define74.5%
Simplified74.5%
Taylor expanded in phi1 around 0 74.5%
Taylor expanded in phi2 around 0 69.9%
*-commutative69.9%
Simplified69.9%
if 2.9000000000000001e-163 < phi1 Initial program 77.3%
+-commutative77.3%
associate-*l*77.3%
fma-define77.3%
Simplified77.3%
Taylor expanded in lambda1 around 0 60.3%
+-commutative60.3%
*-commutative60.3%
fma-define60.3%
*-commutative60.3%
associate-*l*60.3%
cos-neg60.3%
Simplified60.3%
Taylor expanded in phi1 around 0 29.3%
Final simplification44.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.00152)
(* R (acos (* (cos phi1) (cos lambda2))))
(*
R
(acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00152) {
tmp = R * acos((cos(phi1) * cos(lambda2)));
} else {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
}
return tmp;
}
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 <= (-0.00152d0)) then
tmp = r * acos((cos(phi1) * cos(lambda2)))
else
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00152) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.00152: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) else: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.00152) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.00152) tmp = R * acos((cos(phi1) * cos(lambda2))); else tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.00152], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.00152:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -0.0015200000000000001Initial program 80.8%
+-commutative80.8%
associate-*l*80.7%
fma-define80.8%
Simplified80.8%
Taylor expanded in lambda1 around 0 59.6%
+-commutative59.6%
*-commutative59.6%
fma-define59.6%
*-commutative59.6%
associate-*l*59.6%
cos-neg59.6%
Simplified59.6%
Taylor expanded in phi2 around 0 44.9%
if -0.0015200000000000001 < phi1 Initial program 72.8%
+-commutative72.8%
associate-*l*72.8%
fma-define72.8%
Simplified72.8%
Taylor expanded in phi1 around 0 50.8%
Final simplification49.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -2.7e-6)
(* R (acos (* (cos phi1) (cos lambda2))))
(if (<= phi1 1.02e-161)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))
(* R (acos (* (cos phi2) (cos lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -2.7e-6) {
tmp = R * acos((cos(phi1) * cos(lambda2)));
} else if (phi1 <= 1.02e-161) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * acos((cos(phi2) * cos(lambda2)));
}
return tmp;
}
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 <= (-2.7d-6)) then
tmp = r * acos((cos(phi1) * cos(lambda2)))
else if (phi1 <= 1.02d-161) then
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)))
else
tmp = r * acos((cos(phi2) * cos(lambda2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -2.7e-6) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
} else if (phi1 <= 1.02e-161) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -2.7e-6: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) elif phi1 <= 1.02e-161: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) else: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -2.7e-6) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); elseif (phi1 <= 1.02e-161) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -2.7e-6) tmp = R * acos((cos(phi1) * cos(lambda2))); elseif (phi1 <= 1.02e-161) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2))); else tmp = R * acos((cos(phi2) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -2.7e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.02e-161], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -2.7 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\mathbf{elif}\;\phi_1 \leq 1.02 \cdot 10^{-161}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi1 < -2.69999999999999998e-6Initial program 80.8%
+-commutative80.8%
associate-*l*80.7%
fma-define80.8%
Simplified80.8%
Taylor expanded in lambda1 around 0 59.6%
+-commutative59.6%
*-commutative59.6%
fma-define59.6%
*-commutative59.6%
associate-*l*59.6%
cos-neg59.6%
Simplified59.6%
Taylor expanded in phi2 around 0 44.9%
if -2.69999999999999998e-6 < phi1 < 1.0199999999999999e-161Initial program 68.9%
+-commutative68.9%
associate-*l*68.9%
fma-define68.9%
Simplified68.9%
Taylor expanded in phi1 around 0 68.8%
Taylor expanded in phi2 around 0 59.0%
*-commutative59.0%
Simplified59.0%
if 1.0199999999999999e-161 < phi1 Initial program 77.3%
+-commutative77.3%
associate-*l*77.3%
fma-define77.3%
Simplified77.3%
Taylor expanded in lambda1 around 0 60.3%
+-commutative60.3%
*-commutative60.3%
fma-define60.3%
*-commutative60.3%
associate-*l*60.3%
cos-neg60.3%
Simplified60.3%
Taylor expanded in phi1 around 0 29.3%
Final simplification45.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.00098)
(* R (acos (* (cos phi1) (cos lambda2))))
(if (<= phi1 -7e-134)
(* R (acos (+ (cos (- lambda1 lambda2)) (* phi1 (sin phi2)))))
(* R (acos (* (cos phi2) (cos lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00098) {
tmp = R * acos((cos(phi1) * cos(lambda2)));
} else if (phi1 <= -7e-134) {
tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((cos(phi2) * cos(lambda2)));
}
return tmp;
}
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 <= (-0.00098d0)) then
tmp = r * acos((cos(phi1) * cos(lambda2)))
else if (phi1 <= (-7d-134)) then
tmp = r * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2))))
else
tmp = r * acos((cos(phi2) * cos(lambda2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00098) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
} else if (phi1 <= -7e-134) {
tmp = R * Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.00098: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) elif phi1 <= -7e-134: tmp = R * math.acos((math.cos((lambda1 - lambda2)) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.00098) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); elseif (phi1 <= -7e-134) tmp = Float64(R * acos(Float64(cos(Float64(lambda1 - lambda2)) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.00098) tmp = R * acos((cos(phi1) * cos(lambda2))); elseif (phi1 <= -7e-134) tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2)))); else tmp = R * acos((cos(phi2) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.00098], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, -7e-134], N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.00098:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\mathbf{elif}\;\phi_1 \leq -7 \cdot 10^{-134}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi1 < -9.7999999999999997e-4Initial program 80.8%
+-commutative80.8%
associate-*l*80.7%
fma-define80.8%
Simplified80.8%
Taylor expanded in lambda1 around 0 59.6%
+-commutative59.6%
*-commutative59.6%
fma-define59.6%
*-commutative59.6%
associate-*l*59.6%
cos-neg59.6%
Simplified59.6%
Taylor expanded in phi2 around 0 44.9%
if -9.7999999999999997e-4 < phi1 < -6.9999999999999997e-134Initial program 55.2%
+-commutative55.2%
associate-*l*55.2%
fma-define55.2%
Simplified55.2%
Taylor expanded in phi1 around 0 54.9%
Taylor expanded in phi2 around 0 36.5%
if -6.9999999999999997e-134 < phi1 Initial program 76.5%
+-commutative76.5%
associate-*l*76.5%
fma-define76.5%
Simplified76.5%
Taylor expanded in lambda1 around 0 56.7%
+-commutative56.7%
*-commutative56.7%
fma-define56.7%
*-commutative56.7%
associate-*l*56.7%
cos-neg56.7%
Simplified56.7%
Taylor expanded in phi1 around 0 39.4%
Final simplification40.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -1.05e-6) (* R (acos (* (cos phi1) (cos lambda2)))) (* R (acos (* (cos phi2) (cos lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1.05e-6) {
tmp = R * acos((cos(phi1) * cos(lambda2)));
} else {
tmp = R * acos((cos(phi2) * cos(lambda2)));
}
return tmp;
}
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 <= (-1.05d-6)) then
tmp = r * acos((cos(phi1) * cos(lambda2)))
else
tmp = r * acos((cos(phi2) * cos(lambda2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1.05e-6) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -1.05e-6: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) else: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -1.05e-6) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -1.05e-6) tmp = R * acos((cos(phi1) * cos(lambda2))); else tmp = R * acos((cos(phi2) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -1.05e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.05 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi1 < -1.0499999999999999e-6Initial program 80.8%
+-commutative80.8%
associate-*l*80.7%
fma-define80.8%
Simplified80.8%
Taylor expanded in lambda1 around 0 59.6%
+-commutative59.6%
*-commutative59.6%
fma-define59.6%
*-commutative59.6%
associate-*l*59.6%
cos-neg59.6%
Simplified59.6%
Taylor expanded in phi2 around 0 44.9%
if -1.0499999999999999e-6 < phi1 Initial program 72.8%
+-commutative72.8%
associate-*l*72.8%
fma-define72.8%
Simplified72.8%
Taylor expanded in lambda1 around 0 54.7%
+-commutative54.7%
*-commutative54.7%
fma-define54.7%
*-commutative54.7%
associate-*l*54.7%
cos-neg54.7%
Simplified54.7%
Taylor expanded in phi1 around 0 40.2%
Final simplification41.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (* (cos phi1) (cos lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos(phi1) * cos(lambda2)));
}
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)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos(phi1) * math.cos(lambda2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos(phi1) * cos(lambda2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)
\end{array}
Initial program 74.7%
+-commutative74.7%
associate-*l*74.7%
fma-define74.7%
Simplified74.7%
Taylor expanded in lambda1 around 0 55.9%
+-commutative55.9%
*-commutative55.9%
fma-define55.9%
*-commutative55.9%
associate-*l*55.9%
cos-neg55.9%
Simplified55.9%
Taylor expanded in phi2 around 0 36.1%
Final simplification36.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -0.4) (* R (acos (cos phi1))) (* R (acos (cos lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.4) {
tmp = R * acos(cos(phi1));
} else {
tmp = R * acos(cos(lambda2));
}
return tmp;
}
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 <= (-0.4d0)) then
tmp = r * acos(cos(phi1))
else
tmp = r * acos(cos(lambda2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.4) {
tmp = R * Math.acos(Math.cos(phi1));
} else {
tmp = R * Math.acos(Math.cos(lambda2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.4: tmp = R * math.acos(math.cos(phi1)) else: tmp = R * math.acos(math.cos(lambda2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.4) tmp = Float64(R * acos(cos(phi1))); else tmp = Float64(R * acos(cos(lambda2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -0.4) tmp = R * acos(cos(phi1)); else tmp = R * acos(cos(lambda2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.4], N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.4:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if phi1 < -0.40000000000000002Initial program 80.5%
+-commutative80.5%
associate-*l*80.4%
fma-define80.5%
Simplified80.5%
Taylor expanded in lambda1 around 0 58.9%
+-commutative58.9%
*-commutative58.9%
fma-define59.0%
*-commutative59.0%
associate-*l*59.0%
cos-neg59.0%
Simplified59.0%
Taylor expanded in phi2 around 0 44.0%
Taylor expanded in lambda2 around 0 35.4%
if -0.40000000000000002 < phi1 Initial program 72.9%
+-commutative72.9%
associate-*l*72.9%
fma-define72.9%
Simplified72.9%
Taylor expanded in lambda1 around 0 54.9%
+-commutative54.9%
*-commutative54.9%
fma-define54.9%
*-commutative54.9%
associate-*l*54.9%
cos-neg54.9%
Simplified54.9%
Taylor expanded in phi2 around 0 33.6%
Taylor expanded in phi1 around 0 23.4%
Final simplification26.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos phi1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos(phi1));
}
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))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos(phi1));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos(phi1))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(phi1))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos(phi1)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \phi_1
\end{array}
Initial program 74.7%
+-commutative74.7%
associate-*l*74.7%
fma-define74.7%
Simplified74.7%
Taylor expanded in lambda1 around 0 55.9%
+-commutative55.9%
*-commutative55.9%
fma-define55.9%
*-commutative55.9%
associate-*l*55.9%
cos-neg55.9%
Simplified55.9%
Taylor expanded in phi2 around 0 36.1%
Taylor expanded in lambda2 around 0 19.0%
Final simplification19.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos 1.0)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(1.0);
}
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(1.0d0)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(1.0);
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(1.0)
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(1.0)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(1.0); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} 1
\end{array}
Initial program 74.7%
+-commutative74.7%
associate-*l*74.7%
fma-define74.7%
Simplified74.7%
Taylor expanded in lambda1 around 0 55.9%
+-commutative55.9%
*-commutative55.9%
fma-define55.9%
*-commutative55.9%
associate-*l*55.9%
cos-neg55.9%
Simplified55.9%
Taylor expanded in phi2 around 0 36.1%
Taylor expanded in lambda2 around 0 19.0%
Taylor expanded in phi1 around 0 4.4%
Final simplification4.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* phi1 R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return phi1 * 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 = phi1 * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return phi1 * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return phi1 * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(phi1 * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = phi1 * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(phi1 * R), $MachinePrecision]
\begin{array}{l}
\\
\phi_1 \cdot R
\end{array}
Initial program 74.7%
+-commutative74.7%
associate-*l*74.7%
fma-define74.7%
Simplified74.7%
Taylor expanded in lambda1 around 0 55.9%
+-commutative55.9%
*-commutative55.9%
fma-define55.9%
*-commutative55.9%
associate-*l*55.9%
cos-neg55.9%
Simplified55.9%
Taylor expanded in phi2 around 0 36.1%
Taylor expanded in lambda2 around 0 19.0%
Taylor expanded in phi1 around 0 5.0%
herbie shell --seed 2024150
(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))