
(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 24 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
(*
R
(acos
(fma
(* (cos phi1) (cos phi2))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))
(* (sin phi1) (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma((cos(phi1) * cos(phi2)), ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))), (sin(phi1) * sin(phi2))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(Float64(cos(phi1) * cos(phi2)), Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))), Float64(sin(phi1) * sin(phi2))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2, \sin \phi_1 \cdot \sin \phi_2\right)\right)
\end{array}
Initial program 72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
associate-*l*72.1%
associate-*l*72.1%
*-commutative72.1%
cos-neg72.1%
sub-neg72.1%
+-commutative72.1%
distribute-neg-out72.1%
remove-double-neg72.1%
sub-neg72.1%
Simplified72.1%
cos-diff94.3%
+-commutative94.3%
*-commutative94.3%
*-commutative94.3%
Applied egg-rr94.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(cos phi1)
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * 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(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := 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[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right)
\end{array}
Initial program 72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
associate-*l*72.1%
associate-*l*72.1%
*-commutative72.1%
cos-neg72.1%
sub-neg72.1%
+-commutative72.1%
distribute-neg-out72.1%
remove-double-neg72.1%
sub-neg72.1%
Simplified72.1%
cos-diff94.3%
+-commutative94.3%
*-commutative94.3%
*-commutative94.3%
Applied egg-rr94.3%
Taylor expanded in phi1 around 0 94.3%
Final simplification94.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (* (cos phi1) (cos phi2))))
(if (<= phi2 -5.2e-8)
(* R (acos (fma t_1 (expm1 (log1p (cos (- lambda2 lambda1)))) t_0)))
(if (<= phi2 1.5e-10)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))
(*
R
(acos (+ (expm1 (log1p t_0)) (* t_1 (cos (- lambda1 lambda2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if (phi2 <= -5.2e-8) {
tmp = R * acos(fma(t_1, expm1(log1p(cos((lambda2 - lambda1)))), t_0));
} else if (phi2 <= 1.5e-10) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos((expm1(log1p(t_0)) + (t_1 * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi2 <= -5.2e-8) tmp = Float64(R * acos(fma(t_1, expm1(log1p(cos(Float64(lambda2 - lambda1)))), t_0))); elseif (phi2 <= 1.5e-10) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(Float64(expm1(log1p(t_0)) + Float64(t_1 * cos(Float64(lambda1 - lambda2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -5.2e-8], N[(R * N[ArcCos[N[(t$95$1 * N[(Exp[N[Log[1 + N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.5e-10], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision] + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $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}\;\phi_2 \leq -5.2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(t\_1, \mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\lambda_2 - \lambda_1\right)\right)\right), t\_0\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.5 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{expm1}\left(\mathsf{log1p}\left(t\_0\right)\right) + t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -5.2000000000000002e-8Initial program 69.1%
*-commutative69.1%
*-commutative69.1%
*-commutative69.1%
*-commutative69.1%
associate-*l*69.1%
associate-*l*69.1%
*-commutative69.1%
cos-neg69.1%
sub-neg69.1%
+-commutative69.1%
distribute-neg-out69.1%
remove-double-neg69.1%
sub-neg69.1%
Simplified69.2%
expm1-log1p-u69.2%
expm1-undefine69.1%
Applied egg-rr69.1%
expm1-define69.2%
Simplified69.2%
if -5.2000000000000002e-8 < phi2 < 1.5e-10Initial program 69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
associate-*l*69.3%
associate-*l*69.3%
*-commutative69.3%
cos-neg69.3%
sub-neg69.3%
+-commutative69.3%
distribute-neg-out69.3%
remove-double-neg69.3%
sub-neg69.3%
Simplified69.3%
Taylor expanded in phi2 around 0 69.3%
cos-diff90.0%
+-commutative90.0%
*-commutative90.0%
*-commutative90.0%
Applied egg-rr90.0%
if 1.5e-10 < phi2 Initial program 80.3%
expm1-log1p-u80.3%
expm1-undefine80.3%
Applied egg-rr80.3%
expm1-define80.3%
Simplified80.3%
Final simplification83.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))
(t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -1.8e-8)
(* R (acos (+ t_1 t_0)))
(if (<= phi2 1e-10)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))
(* R (acos (+ (expm1 (log1p t_1)) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -1.8e-8) {
tmp = R * acos((t_1 + t_0));
} else if (phi2 <= 1e-10) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos((expm1(log1p(t_1)) + t_0));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= -1.8e-8) {
tmp = R * Math.acos((t_1 + t_0));
} else if (phi2 <= 1e-10) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
} else {
tmp = R * Math.acos((Math.expm1(Math.log1p(t_1)) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= -1.8e-8: tmp = R * math.acos((t_1 + t_0)) elif phi2 <= 1e-10: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) else: tmp = R * math.acos((math.expm1(math.log1p(t_1)) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -1.8e-8) tmp = Float64(R * acos(Float64(t_1 + t_0))); elseif (phi2 <= 1e-10) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(Float64(expm1(log1p(t_1)) + t_0))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.8e-8], N[(R * N[ArcCos[N[(t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1e-10], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(Exp[N[Log[1 + t$95$1], $MachinePrecision]] - 1), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0\right)\\
\mathbf{elif}\;\phi_2 \leq 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{expm1}\left(\mathsf{log1p}\left(t\_1\right)\right) + t\_0\right)\\
\end{array}
\end{array}
if phi2 < -1.79999999999999991e-8Initial program 69.1%
if -1.79999999999999991e-8 < phi2 < 1.00000000000000004e-10Initial program 69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
associate-*l*69.3%
associate-*l*69.3%
*-commutative69.3%
cos-neg69.3%
sub-neg69.3%
+-commutative69.3%
distribute-neg-out69.3%
remove-double-neg69.3%
sub-neg69.3%
Simplified69.3%
Taylor expanded in phi2 around 0 69.3%
cos-diff90.0%
+-commutative90.0%
*-commutative90.0%
*-commutative90.0%
Applied egg-rr90.0%
if 1.00000000000000004e-10 < phi2 Initial program 80.3%
expm1-log1p-u80.3%
expm1-undefine80.3%
Applied egg-rr80.3%
expm1-define80.3%
Simplified80.3%
Final simplification83.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -8e-8)
(* R (acos (+ t_1 (* t_0 (cos (- lambda1 lambda2))))))
(if (<= phi2 1.5e-10)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))
(* R (acos (fma t_0 (cos (- lambda2 lambda1)) t_1)))))))
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 <= -8e-8) {
tmp = R * acos((t_1 + (t_0 * cos((lambda1 - lambda2)))));
} else if (phi2 <= 1.5e-10) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(fma(t_0, cos((lambda2 - lambda1)), t_1));
}
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 <= -8e-8) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(Float64(lambda1 - lambda2)))))); elseif (phi2 <= 1.5e-10) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(fma(t_0, cos(Float64(lambda2 - lambda1)), t_1))); end return 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, -8e-8], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.5e-10], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$1), $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 -8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.5 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(t\_0, \cos \left(\lambda_2 - \lambda_1\right), t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -8.0000000000000002e-8Initial program 69.1%
if -8.0000000000000002e-8 < phi2 < 1.5e-10Initial program 69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
associate-*l*69.3%
associate-*l*69.3%
*-commutative69.3%
cos-neg69.3%
sub-neg69.3%
+-commutative69.3%
distribute-neg-out69.3%
remove-double-neg69.3%
sub-neg69.3%
Simplified69.3%
Taylor expanded in phi2 around 0 69.3%
cos-diff90.0%
+-commutative90.0%
*-commutative90.0%
*-commutative90.0%
Applied egg-rr90.0%
if 1.5e-10 < phi2 Initial program 80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
associate-*l*80.3%
associate-*l*80.3%
*-commutative80.3%
cos-neg80.3%
sub-neg80.3%
+-commutative80.3%
distribute-neg-out80.3%
remove-double-neg80.3%
sub-neg80.3%
Simplified80.3%
Final simplification83.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -1e-6)
(*
R
(acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0))))
(if (<= phi2 6.5e-11)
(*
R
(acos
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi2) (* (cos phi1) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -1e-6) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0)));
} else if (phi2 <= 6.5e-11) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi2) * (cos(phi1) * t_0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1e-6) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); elseif (phi2 <= 6.5e-11) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi2) * Float64(cos(phi1) * 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, -1e-6], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.5e-11], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $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 -1 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\mathbf{elif}\;\phi_2 \leq 6.5 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t\_0\right)\right)\right)\\
\end{array}
\end{array}
if phi2 < -9.99999999999999955e-7Initial program 68.6%
if -9.99999999999999955e-7 < phi2 < 6.49999999999999953e-11Initial program 69.5%
*-commutative69.5%
*-commutative69.5%
*-commutative69.5%
*-commutative69.5%
associate-*l*69.5%
associate-*l*69.5%
*-commutative69.5%
cos-neg69.5%
sub-neg69.5%
+-commutative69.5%
distribute-neg-out69.5%
remove-double-neg69.5%
sub-neg69.5%
Simplified69.5%
Taylor expanded in phi2 around 0 69.2%
cos-diff90.0%
+-commutative90.0%
*-commutative90.0%
*-commutative90.0%
Applied egg-rr89.7%
if 6.49999999999999953e-11 < phi2 Initial program 80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
associate-*l*80.3%
associate-*l*80.3%
*-commutative80.3%
cos-neg80.3%
sub-neg80.3%
+-commutative80.3%
distribute-neg-out80.3%
remove-double-neg80.3%
sub-neg80.3%
Simplified80.3%
Taylor expanded in phi1 around 0 80.3%
+-commutative80.3%
fma-define80.2%
*-commutative80.2%
associate-*l*80.3%
*-commutative80.3%
sub-neg80.3%
neg-mul-180.3%
cos-neg80.3%
neg-mul-180.3%
+-commutative80.3%
distribute-neg-in80.3%
remove-double-neg80.3%
sub-neg80.3%
Simplified80.3%
Final simplification83.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -2.3e-8) (not (<= phi2 1.5e-10)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -2.3e-8) || !(phi2 <= 1.5e-10)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * 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 ((phi2 <= (-2.3d-8)) .or. (.not. (phi2 <= 1.5d-10))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * 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 ((phi2 <= -2.3e-8) || !(phi2 <= 1.5e-10)) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -2.3e-8) or not (phi2 <= 1.5e-10): tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -2.3e-8) || !(phi2 <= 1.5e-10)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -2.3e-8) || ~((phi2 <= 1.5e-10))) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -2.3e-8], N[Not[LessEqual[phi2, 1.5e-10]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -2.3 \cdot 10^{-8} \lor \neg \left(\phi_2 \leq 1.5 \cdot 10^{-10}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < -2.3000000000000001e-8 or 1.5e-10 < phi2 Initial program 75.3%
if -2.3000000000000001e-8 < phi2 < 1.5e-10Initial program 69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
*-commutative69.3%
associate-*l*69.3%
associate-*l*69.3%
*-commutative69.3%
cos-neg69.3%
sub-neg69.3%
+-commutative69.3%
distribute-neg-out69.3%
remove-double-neg69.3%
sub-neg69.3%
Simplified69.3%
Taylor expanded in phi2 around 0 69.3%
cos-diff90.0%
+-commutative90.0%
*-commutative90.0%
*-commutative90.0%
Applied egg-rr90.0%
Final simplification83.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -1.4e-5)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 3e-5)
(* R (acos (* (cos phi2) t_0)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi1 <= -1.4e-5) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 3e-5) {
tmp = R * acos((cos(phi2) * t_0));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * 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) :: t_0
real(8) :: tmp
t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi1 <= (-1.4d-5)) then
tmp = r * acos((cos(phi1) * t_0))
else if (phi1 <= 3d-5) then
tmp = r * acos((cos(phi2) * t_0))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * 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 t_0 = (Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi1 <= -1.4e-5) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else if (phi1 <= 3e-5) {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)) tmp = 0 if phi1 <= -1.4e-5: tmp = R * math.acos((math.cos(phi1) * t_0)) elif phi1 <= 3e-5: tmp = R * math.acos((math.cos(phi2) * t_0)) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi1 <= -1.4e-5) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 3e-5) tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)); tmp = 0.0; if (phi1 <= -1.4e-5) tmp = R * acos((cos(phi1) * t_0)); elseif (phi1 <= 3e-5) tmp = R * acos((cos(phi2) * t_0)); else tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda2)))); 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[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.4e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3e-5], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -1.4 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 3 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi1 < -1.39999999999999998e-5Initial program 79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
associate-*l*79.0%
associate-*l*79.1%
*-commutative79.1%
cos-neg79.1%
sub-neg79.1%
+-commutative79.1%
distribute-neg-out79.1%
remove-double-neg79.1%
sub-neg79.1%
Simplified79.1%
Taylor expanded in phi2 around 0 49.9%
cos-diff99.3%
+-commutative99.3%
*-commutative99.3%
*-commutative99.3%
Applied egg-rr63.2%
if -1.39999999999999998e-5 < phi1 < 3.00000000000000008e-5Initial program 64.4%
*-commutative64.4%
*-commutative64.4%
*-commutative64.4%
*-commutative64.4%
associate-*l*64.4%
associate-*l*64.4%
*-commutative64.4%
cos-neg64.4%
sub-neg64.4%
+-commutative64.4%
distribute-neg-out64.4%
remove-double-neg64.4%
sub-neg64.4%
Simplified64.4%
cos-diff89.7%
+-commutative89.7%
*-commutative89.7%
*-commutative89.7%
Applied egg-rr89.7%
Taylor expanded in phi1 around 0 89.5%
if 3.00000000000000008e-5 < phi1 Initial program 80.9%
*-commutative80.9%
*-commutative80.9%
*-commutative80.9%
*-commutative80.9%
associate-*l*80.9%
associate-*l*80.9%
*-commutative80.9%
cos-neg80.9%
sub-neg80.9%
+-commutative80.9%
distribute-neg-out80.9%
remove-double-neg80.9%
sub-neg80.9%
Simplified80.9%
Taylor expanded in lambda1 around 0 57.4%
Final simplification75.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -1.5e-6)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 5.3e-7)
(* R (acos (* (cos phi2) t_0)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi1 <= -1.5e-6) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 5.3e-7) {
tmp = R * acos((cos(phi2) * t_0));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((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(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi1 <= (-1.5d-6)) then
tmp = r * acos((cos(phi1) * t_0))
else if (phi1 <= 5.3d-7) then
tmp = r * acos((cos(phi2) * t_0))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((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(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi1 <= -1.5e-6) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else if (phi1 <= 5.3e-7) {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)) tmp = 0 if phi1 <= -1.5e-6: tmp = R * math.acos((math.cos(phi1) * t_0)) elif phi1 <= 5.3e-7: tmp = R * math.acos((math.cos(phi2) * t_0)) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi1 <= -1.5e-6) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 5.3e-7) tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)); tmp = 0.0; if (phi1 <= -1.5e-6) tmp = R * acos((cos(phi1) * t_0)); elseif (phi1 <= 5.3e-7) tmp = R * acos((cos(phi2) * t_0)); else tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1)))); 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[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.5e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 5.3e-7], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -1.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 5.3 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi1 < -1.5e-6Initial program 79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
associate-*l*79.0%
associate-*l*79.1%
*-commutative79.1%
cos-neg79.1%
sub-neg79.1%
+-commutative79.1%
distribute-neg-out79.1%
remove-double-neg79.1%
sub-neg79.1%
Simplified79.1%
Taylor expanded in phi2 around 0 49.9%
cos-diff99.3%
+-commutative99.3%
*-commutative99.3%
*-commutative99.3%
Applied egg-rr63.2%
if -1.5e-6 < phi1 < 5.3e-7Initial program 64.4%
*-commutative64.4%
*-commutative64.4%
*-commutative64.4%
*-commutative64.4%
associate-*l*64.4%
associate-*l*64.4%
*-commutative64.4%
cos-neg64.4%
sub-neg64.4%
+-commutative64.4%
distribute-neg-out64.4%
remove-double-neg64.4%
sub-neg64.4%
Simplified64.4%
cos-diff89.7%
+-commutative89.7%
*-commutative89.7%
*-commutative89.7%
Applied egg-rr89.7%
Taylor expanded in phi1 around 0 89.5%
if 5.3e-7 < phi1 Initial program 80.9%
*-commutative80.9%
*-commutative80.9%
*-commutative80.9%
*-commutative80.9%
associate-*l*80.9%
associate-*l*80.9%
*-commutative80.9%
cos-neg80.9%
sub-neg80.9%
+-commutative80.9%
distribute-neg-out80.9%
remove-double-neg80.9%
sub-neg80.9%
Simplified80.9%
cos-diff98.8%
+-commutative98.8%
*-commutative98.8%
*-commutative98.8%
Applied egg-rr98.8%
Taylor expanded in lambda2 around 0 62.8%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -6e-6)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 0.085)
(* R (acos (* (cos phi2) t_0)))
(* R (acos (+ (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi1 <= -6e-6) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 0.085) {
tmp = R * acos((cos(phi2) * t_0));
} else {
tmp = R * acos(((cos(phi1) * cos(phi2)) + (sin(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) :: t_0
real(8) :: tmp
t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi1 <= (-6d-6)) then
tmp = r * acos((cos(phi1) * t_0))
else if (phi1 <= 0.085d0) then
tmp = r * acos((cos(phi2) * t_0))
else
tmp = r * acos(((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2))))
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(lambda1) * Math.cos(lambda2));
double tmp;
if (phi1 <= -6e-6) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else if (phi1 <= 0.085) {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
} else {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos(phi2)) + (Math.sin(phi1) * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)) tmp = 0 if phi1 <= -6e-6: tmp = R * math.acos((math.cos(phi1) * t_0)) elif phi1 <= 0.085: tmp = R * math.acos((math.cos(phi2) * t_0)) else: tmp = R * math.acos(((math.cos(phi1) * math.cos(phi2)) + (math.sin(phi1) * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi1 <= -6e-6) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 0.085) tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); else tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(phi2)) + Float64(sin(phi1) * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)); tmp = 0.0; if (phi1 <= -6e-6) tmp = R * acos((cos(phi1) * t_0)); elseif (phi1 <= 0.085) tmp = R * acos((cos(phi2) * t_0)); else tmp = R * acos(((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2)))); 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[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -6e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.085], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -6 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.085:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \phi_2 + \sin \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -6.0000000000000002e-6Initial program 79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
associate-*l*79.0%
associate-*l*79.1%
*-commutative79.1%
cos-neg79.1%
sub-neg79.1%
+-commutative79.1%
distribute-neg-out79.1%
remove-double-neg79.1%
sub-neg79.1%
Simplified79.1%
Taylor expanded in phi2 around 0 49.9%
cos-diff99.3%
+-commutative99.3%
*-commutative99.3%
*-commutative99.3%
Applied egg-rr63.2%
if -6.0000000000000002e-6 < phi1 < 0.0850000000000000061Initial program 64.5%
*-commutative64.5%
*-commutative64.5%
*-commutative64.5%
*-commutative64.5%
associate-*l*64.5%
associate-*l*64.5%
*-commutative64.5%
cos-neg64.5%
sub-neg64.5%
+-commutative64.5%
distribute-neg-out64.5%
remove-double-neg64.5%
sub-neg64.5%
Simplified64.5%
cos-diff89.6%
+-commutative89.6%
*-commutative89.6%
*-commutative89.6%
Applied egg-rr89.6%
Taylor expanded in phi1 around 0 88.8%
if 0.0850000000000000061 < phi1 Initial program 81.0%
*-commutative81.0%
*-commutative81.0%
*-commutative81.0%
*-commutative81.0%
associate-*l*81.0%
associate-*l*81.0%
*-commutative81.0%
cos-neg81.0%
sub-neg81.0%
+-commutative81.0%
distribute-neg-out81.0%
remove-double-neg81.0%
sub-neg81.0%
Simplified81.0%
Taylor expanded in lambda1 around 0 57.0%
Taylor expanded in lambda2 around 0 38.7%
Final simplification70.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 1.5e-10)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(* R (acos (* (cos phi2) (cos (- lambda2 lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.5e-10) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos((cos(phi2) * cos((lambda2 - 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.5d-10) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
else
tmp = r * acos((cos(phi2) * cos((lambda2 - 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.5e-10) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos((lambda2 - lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1.5e-10: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) else: tmp = R * math.acos((math.cos(phi2) * math.cos((lambda2 - lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1.5e-10) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(Float64(cos(phi2) * cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 1.5e-10) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * acos((cos(phi2) * cos((lambda2 - lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.5e-10], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.5 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < 1.5e-10Initial program 69.2%
*-commutative69.2%
*-commutative69.2%
*-commutative69.2%
*-commutative69.2%
associate-*l*69.2%
associate-*l*69.2%
*-commutative69.2%
cos-neg69.2%
sub-neg69.2%
+-commutative69.2%
distribute-neg-out69.2%
remove-double-neg69.2%
sub-neg69.2%
Simplified69.3%
Taylor expanded in phi2 around 0 55.2%
cos-diff92.6%
+-commutative92.6%
*-commutative92.6%
*-commutative92.6%
Applied egg-rr70.3%
if 1.5e-10 < phi2 Initial program 80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
associate-*l*80.3%
associate-*l*80.3%
*-commutative80.3%
cos-neg80.3%
sub-neg80.3%
+-commutative80.3%
distribute-neg-out80.3%
remove-double-neg80.3%
sub-neg80.3%
Simplified80.3%
Taylor expanded in phi1 around 0 48.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))))
(if (<= phi1 -7.8e-5)
(* R (acos (* (cos phi1) (cos (- lambda2 lambda1)))))
(if (<= phi1 21000000000000.0)
(* R (acos (+ (* t_0 (cos (- lambda1 lambda2))) (* phi1 (sin phi2)))))
(* R (acos (+ t_0 (* (sin phi1) (sin phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double tmp;
if (phi1 <= -7.8e-5) {
tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1))));
} else if (phi1 <= 21000000000000.0) {
tmp = R * acos(((t_0 * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_0 + (sin(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) :: t_0
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
if (phi1 <= (-7.8d-5)) then
tmp = r * acos((cos(phi1) * cos((lambda2 - lambda1))))
else if (phi1 <= 21000000000000.0d0) then
tmp = r * acos(((t_0 * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
else
tmp = r * acos((t_0 + (sin(phi1) * sin(phi2))))
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 tmp;
if (phi1 <= -7.8e-5) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos((lambda2 - lambda1))));
} else if (phi1 <= 21000000000000.0) {
tmp = R * Math.acos(((t_0 * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos((t_0 + (Math.sin(phi1) * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) tmp = 0 if phi1 <= -7.8e-5: tmp = R * math.acos((math.cos(phi1) * math.cos((lambda2 - lambda1)))) elif phi1 <= 21000000000000.0: tmp = R * math.acos(((t_0 * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos((t_0 + (math.sin(phi1) * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi1 <= -7.8e-5) tmp = Float64(R * acos(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))); elseif (phi1 <= 21000000000000.0) tmp = Float64(R * acos(Float64(Float64(t_0 * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(sin(phi1) * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); tmp = 0.0; if (phi1 <= -7.8e-5) tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1)))); elseif (phi1 <= 21000000000000.0) tmp = R * acos(((t_0 * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); else tmp = R * acos((t_0 + (sin(phi1) * sin(phi2)))); 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]}, If[LessEqual[phi1, -7.8e-5], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 21000000000000.0], N[(R * N[ArcCos[N[(N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -7.8 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 21000000000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \sin \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -7.7999999999999999e-5Initial program 78.8%
*-commutative78.8%
*-commutative78.8%
*-commutative78.8%
*-commutative78.8%
associate-*l*78.7%
associate-*l*78.8%
*-commutative78.8%
cos-neg78.8%
sub-neg78.8%
+-commutative78.8%
distribute-neg-out78.8%
remove-double-neg78.8%
sub-neg78.8%
Simplified78.8%
Taylor expanded in phi2 around 0 49.1%
if -7.7999999999999999e-5 < phi1 < 2.1e13Initial program 65.3%
Taylor expanded in phi1 around 0 64.6%
if 2.1e13 < phi1 Initial program 80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
associate-*l*80.3%
associate-*l*80.3%
*-commutative80.3%
cos-neg80.3%
sub-neg80.3%
+-commutative80.3%
distribute-neg-out80.3%
remove-double-neg80.3%
sub-neg80.3%
Simplified80.3%
Taylor expanded in lambda1 around 0 58.3%
Taylor expanded in lambda2 around 0 39.3%
Final simplification55.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi1 -5.5e-6)
(* R (acos (* (cos phi1) t_0)))
(if (<= phi1 0.00195)
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2)))))
(* R (acos (+ (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -5.5e-6) {
tmp = R * acos((cos(phi1) * t_0));
} else if (phi1 <= 0.00195) {
tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))));
} else {
tmp = R * acos(((cos(phi1) * cos(phi2)) + (sin(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) :: t_0
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
if (phi1 <= (-5.5d-6)) then
tmp = r * acos((cos(phi1) * t_0))
else if (phi1 <= 0.00195d0) then
tmp = r * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))))
else
tmp = r * acos(((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2))))
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((lambda2 - lambda1));
double tmp;
if (phi1 <= -5.5e-6) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else if (phi1 <= 0.00195) {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos(phi2)) + (Math.sin(phi1) * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -5.5e-6: tmp = R * math.acos((math.cos(phi1) * t_0)) elif phi1 <= 0.00195: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos(((math.cos(phi1) * math.cos(phi2)) + (math.sin(phi1) * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -5.5e-6) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); elseif (phi1 <= 0.00195) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(phi2)) + Float64(sin(phi1) * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi1 <= -5.5e-6) tmp = R * acos((cos(phi1) * t_0)); elseif (phi1 <= 0.00195) tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2)))); else tmp = R * acos(((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5.5e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00195], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -5.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00195:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \phi_2 + \sin \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -5.4999999999999999e-6Initial program 79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
associate-*l*79.0%
associate-*l*79.1%
*-commutative79.1%
cos-neg79.1%
sub-neg79.1%
+-commutative79.1%
distribute-neg-out79.1%
remove-double-neg79.1%
sub-neg79.1%
Simplified79.1%
Taylor expanded in phi2 around 0 49.9%
if -5.4999999999999999e-6 < phi1 < 0.0019499999999999999Initial program 64.5%
*-commutative64.5%
*-commutative64.5%
*-commutative64.5%
*-commutative64.5%
associate-*l*64.5%
associate-*l*64.5%
*-commutative64.5%
cos-neg64.5%
sub-neg64.5%
+-commutative64.5%
distribute-neg-out64.5%
remove-double-neg64.5%
sub-neg64.5%
Simplified64.5%
Taylor expanded in phi1 around 0 64.0%
if 0.0019499999999999999 < phi1 Initial program 81.0%
*-commutative81.0%
*-commutative81.0%
*-commutative81.0%
*-commutative81.0%
associate-*l*81.0%
associate-*l*81.0%
*-commutative81.0%
cos-neg81.0%
sub-neg81.0%
+-commutative81.0%
distribute-neg-out81.0%
remove-double-neg81.0%
sub-neg81.0%
Simplified81.0%
Taylor expanded in lambda1 around 0 57.0%
Taylor expanded in lambda2 around 0 38.7%
Final simplification54.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -7.2e-7)
(* R (acos (* (cos phi1) (cos lambda1))))
(if (<= lambda1 -3.8e-67)
(* R (acos (* (cos phi2) (cos lambda2))))
(* R (acos (* (cos phi1) (cos lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -7.2e-7) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else if (lambda1 <= -3.8e-67) {
tmp = R * acos((cos(phi2) * cos(lambda2)));
} else {
tmp = R * acos((cos(phi1) * 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 (lambda1 <= (-7.2d-7)) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else if (lambda1 <= (-3.8d-67)) then
tmp = r * acos((cos(phi2) * cos(lambda2)))
else
tmp = r * acos((cos(phi1) * 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 (lambda1 <= -7.2e-7) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else if (lambda1 <= -3.8e-67) {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
} else {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -7.2e-7: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) elif lambda1 <= -3.8e-67: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) else: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -7.2e-7) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); elseif (lambda1 <= -3.8e-67) tmp = Float64(R * acos(Float64(cos(phi2) * cos(lambda2)))); else tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -7.2e-7) tmp = R * acos((cos(phi1) * cos(lambda1))); elseif (lambda1 <= -3.8e-67) tmp = R * acos((cos(phi2) * cos(lambda2))); else tmp = R * acos((cos(phi1) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -7.2e-7], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, -3.8e-67], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -7.2 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{elif}\;\lambda_1 \leq -3.8 \cdot 10^{-67}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -7.19999999999999989e-7Initial program 57.7%
*-commutative57.7%
*-commutative57.7%
*-commutative57.7%
*-commutative57.7%
associate-*l*57.7%
associate-*l*57.7%
*-commutative57.7%
cos-neg57.7%
sub-neg57.7%
+-commutative57.7%
distribute-neg-out57.7%
remove-double-neg57.7%
sub-neg57.7%
Simplified57.7%
Taylor expanded in phi2 around 0 41.8%
Taylor expanded in lambda2 around 0 42.0%
cos-neg42.0%
Simplified42.0%
if -7.19999999999999989e-7 < lambda1 < -3.79999999999999988e-67Initial program 93.0%
*-commutative93.0%
*-commutative93.0%
*-commutative93.0%
*-commutative93.0%
associate-*l*93.0%
associate-*l*93.0%
*-commutative93.0%
cos-neg93.0%
sub-neg93.0%
+-commutative93.0%
distribute-neg-out93.0%
remove-double-neg93.0%
sub-neg93.0%
Simplified93.0%
Taylor expanded in lambda1 around 0 93.0%
Taylor expanded in phi1 around 0 54.9%
*-commutative54.9%
Simplified54.9%
if -3.79999999999999988e-67 < lambda1 Initial program 76.4%
*-commutative76.4%
*-commutative76.4%
*-commutative76.4%
*-commutative76.4%
associate-*l*76.4%
associate-*l*76.4%
*-commutative76.4%
cos-neg76.4%
sub-neg76.4%
+-commutative76.4%
distribute-neg-out76.4%
remove-double-neg76.4%
sub-neg76.4%
Simplified76.4%
Taylor expanded in phi2 around 0 47.0%
Taylor expanded in lambda1 around 0 38.6%
*-commutative38.6%
Simplified38.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= (cos (- lambda1 lambda2)) 0.994) (* R (acos (cos (- lambda2 lambda1)))) (* R (fabs (remainder (- lambda1 lambda2) (* 2.0 PI))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (cos((lambda1 - lambda2)) <= 0.994) {
tmp = R * acos(cos((lambda2 - lambda1)));
} else {
tmp = R * fabs(remainder((lambda1 - lambda2), (2.0 * ((double) M_PI))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (Math.cos((lambda1 - lambda2)) <= 0.994) {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
} else {
tmp = R * Math.abs(Math.IEEEremainder((lambda1 - lambda2), (2.0 * Math.PI)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if math.cos((lambda1 - lambda2)) <= 0.994: tmp = R * math.acos(math.cos((lambda2 - lambda1))) else: tmp = R * math.fabs(math.remainder((lambda1 - lambda2), (2.0 * math.pi))) return tmp
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision], 0.994], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Abs[N[With[{TMP1 = N[(lambda1 - lambda2), $MachinePrecision], TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \left(\lambda_1 - \lambda_2\right) \leq 0.994:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left|\left(\left(\lambda_1 - \lambda_2\right) \mathsf{rem} \left(2 \cdot \pi\right)\right)\right|\\
\end{array}
\end{array}
if (cos.f64 (-.f64 lambda1 lambda2)) < 0.99399999999999999Initial program 70.2%
*-commutative70.2%
*-commutative70.2%
*-commutative70.2%
*-commutative70.2%
associate-*l*70.2%
associate-*l*70.2%
*-commutative70.2%
cos-neg70.2%
sub-neg70.2%
+-commutative70.2%
distribute-neg-out70.2%
remove-double-neg70.2%
sub-neg70.2%
Simplified70.3%
Taylor expanded in phi2 around 0 50.5%
Taylor expanded in phi1 around 0 35.4%
if 0.99399999999999999 < (cos.f64 (-.f64 lambda1 lambda2)) Initial program 77.7%
*-commutative77.7%
*-commutative77.7%
*-commutative77.7%
*-commutative77.7%
associate-*l*77.7%
associate-*l*77.7%
*-commutative77.7%
cos-neg77.7%
sub-neg77.7%
+-commutative77.7%
distribute-neg-out77.7%
remove-double-neg77.7%
sub-neg77.7%
Simplified77.7%
Taylor expanded in phi2 around 0 31.7%
Taylor expanded in phi1 around 0 5.6%
acos-cos-s5.6%
acos-cos5.6%
cos-diff5.6%
*-commutative5.6%
*-commutative5.6%
cos-diff5.6%
acos-cos-s12.4%
Applied egg-rr12.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi1 -3e-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 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -3e-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 = cos((lambda2 - lambda1))
if (phi1 <= (-3d-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.cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -3e-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.cos((lambda2 - lambda1)) tmp = 0 if phi1 <= -3e-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 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -3e-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 = cos((lambda2 - lambda1)); tmp = 0.0; if (phi1 <= -3e-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[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3e-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 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -3 \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 < -3.0000000000000001e-6Initial program 79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
*-commutative79.1%
associate-*l*79.0%
associate-*l*79.1%
*-commutative79.1%
cos-neg79.1%
sub-neg79.1%
+-commutative79.1%
distribute-neg-out79.1%
remove-double-neg79.1%
sub-neg79.1%
Simplified79.1%
Taylor expanded in phi2 around 0 49.9%
if -3.0000000000000001e-6 < phi1 Initial program 69.7%
*-commutative69.7%
*-commutative69.7%
*-commutative69.7%
*-commutative69.7%
associate-*l*69.7%
associate-*l*69.7%
*-commutative69.7%
cos-neg69.7%
sub-neg69.7%
+-commutative69.7%
distribute-neg-out69.7%
remove-double-neg69.7%
sub-neg69.7%
Simplified69.7%
Taylor expanded in phi1 around 0 49.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 0.00088) (* R (acos (* (cos phi1) (cos (- lambda2 lambda1))))) (* R (acos (* (cos phi2) (cos lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00088) {
tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1))));
} 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 (phi2 <= 0.00088d0) then
tmp = r * acos((cos(phi1) * cos((lambda2 - lambda1))))
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 (phi2 <= 0.00088) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos((lambda2 - lambda1))));
} else {
tmp = R * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.00088: tmp = R * math.acos((math.cos(phi1) * math.cos((lambda2 - lambda1)))) else: tmp = R * math.acos((math.cos(phi2) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.00088) tmp = Float64(R * acos(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))); 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 (phi2 <= 0.00088) tmp = R * acos((cos(phi1) * cos((lambda2 - lambda1)))); else tmp = R * acos((cos(phi2) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.00088], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $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_2 \leq 0.00088:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < 8.80000000000000031e-4Initial program 69.2%
*-commutative69.2%
*-commutative69.2%
*-commutative69.2%
*-commutative69.2%
associate-*l*69.2%
associate-*l*69.2%
*-commutative69.2%
cos-neg69.2%
sub-neg69.2%
+-commutative69.2%
distribute-neg-out69.2%
remove-double-neg69.2%
sub-neg69.2%
Simplified69.3%
Taylor expanded in phi2 around 0 55.2%
if 8.80000000000000031e-4 < phi2 Initial program 80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
*-commutative80.3%
associate-*l*80.3%
associate-*l*80.3%
*-commutative80.3%
cos-neg80.3%
sub-neg80.3%
+-commutative80.3%
distribute-neg-out80.3%
remove-double-neg80.3%
sub-neg80.3%
Simplified80.3%
Taylor expanded in lambda1 around 0 62.9%
Taylor expanded in phi1 around 0 40.9%
*-commutative40.9%
Simplified40.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 3.2e+22) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (* (cos phi1) (cos lambda2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 3.2e+22) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos((cos(phi1) * 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 (lambda2 <= 3.2d+22) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos((cos(phi1) * 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 (lambda2 <= 3.2e+22) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 3.2e+22: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 3.2e+22) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 3.2e+22) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos((cos(phi1) * cos(lambda2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 3.2e+22], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 3.2 \cdot 10^{+22}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 3.2e22Initial program 76.9%
*-commutative76.9%
*-commutative76.9%
*-commutative76.9%
*-commutative76.9%
associate-*l*76.9%
associate-*l*76.9%
*-commutative76.9%
cos-neg76.9%
sub-neg76.9%
+-commutative76.9%
distribute-neg-out76.9%
remove-double-neg76.9%
sub-neg76.9%
Simplified76.9%
Taylor expanded in phi2 around 0 46.4%
Taylor expanded in lambda2 around 0 36.1%
cos-neg36.1%
Simplified36.1%
if 3.2e22 < lambda2 Initial program 56.2%
*-commutative56.2%
*-commutative56.2%
*-commutative56.2%
*-commutative56.2%
associate-*l*56.2%
associate-*l*56.2%
*-commutative56.2%
cos-neg56.2%
sub-neg56.2%
+-commutative56.2%
distribute-neg-out56.2%
remove-double-neg56.2%
sub-neg56.2%
Simplified56.2%
Taylor expanded in phi2 around 0 43.9%
Taylor expanded in lambda1 around 0 44.2%
*-commutative44.2%
Simplified44.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 8500000000000.0) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (cos (- lambda2 lambda1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 8500000000000.0) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos(cos((lambda2 - 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 (lambda2 <= 8500000000000.0d0) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos(cos((lambda2 - lambda1)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 8500000000000.0) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 8500000000000.0: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos(math.cos((lambda2 - lambda1))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 8500000000000.0) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 8500000000000.0) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos(cos((lambda2 - lambda1))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 8500000000000.0], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 8500000000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\end{array}
\end{array}
if lambda2 < 8.5e12Initial program 77.7%
*-commutative77.7%
*-commutative77.7%
*-commutative77.7%
*-commutative77.7%
associate-*l*77.7%
associate-*l*77.7%
*-commutative77.7%
cos-neg77.7%
sub-neg77.7%
+-commutative77.7%
distribute-neg-out77.7%
remove-double-neg77.7%
sub-neg77.7%
Simplified77.7%
Taylor expanded in phi2 around 0 47.0%
Taylor expanded in lambda2 around 0 36.4%
cos-neg36.4%
Simplified36.4%
if 8.5e12 < lambda2 Initial program 55.3%
*-commutative55.3%
*-commutative55.3%
*-commutative55.3%
*-commutative55.3%
associate-*l*55.2%
associate-*l*55.3%
*-commutative55.3%
cos-neg55.3%
sub-neg55.3%
+-commutative55.3%
distribute-neg-out55.3%
remove-double-neg55.3%
sub-neg55.3%
Simplified55.3%
Taylor expanded in phi2 around 0 42.4%
Taylor expanded in phi1 around 0 32.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 3.2e-13) (* R (acos (cos lambda1))) (* R (acos (cos lambda2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 3.2e-13) {
tmp = R * acos(cos(lambda1));
} 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 (lambda2 <= 3.2d-13) then
tmp = r * acos(cos(lambda1))
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 (lambda2 <= 3.2e-13) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * Math.acos(Math.cos(lambda2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 3.2e-13: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * math.acos(math.cos(lambda2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 3.2e-13) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * acos(cos(lambda2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 3.2e-13) tmp = R * acos(cos(lambda1)); else tmp = R * acos(cos(lambda2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 3.2e-13], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 3.2 \cdot 10^{-13}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if lambda2 < 3.2e-13Initial program 78.2%
*-commutative78.2%
*-commutative78.2%
*-commutative78.2%
*-commutative78.2%
associate-*l*78.2%
associate-*l*78.2%
*-commutative78.2%
cos-neg78.2%
sub-neg78.2%
+-commutative78.2%
distribute-neg-out78.2%
remove-double-neg78.2%
sub-neg78.2%
Simplified78.2%
Taylor expanded in phi2 around 0 47.0%
Taylor expanded in phi1 around 0 26.7%
Taylor expanded in lambda2 around 0 19.2%
cos-neg19.2%
Simplified19.2%
if 3.2e-13 < lambda2 Initial program 55.0%
*-commutative55.0%
*-commutative55.0%
*-commutative55.0%
*-commutative55.0%
associate-*l*54.9%
associate-*l*55.0%
*-commutative55.0%
cos-neg55.0%
sub-neg55.0%
+-commutative55.0%
distribute-neg-out55.0%
remove-double-neg55.0%
sub-neg55.0%
Simplified55.0%
Taylor expanded in phi2 around 0 42.7%
Taylor expanded in phi1 around 0 31.8%
Taylor expanded in lambda1 around 0 31.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos (- lambda2 lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos((lambda2 - lambda1)));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(cos((lambda2 - lambda1)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos((lambda2 - lambda1)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos((lambda2 - lambda1)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(Float64(lambda2 - lambda1)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos((lambda2 - lambda1))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
associate-*l*72.1%
associate-*l*72.1%
*-commutative72.1%
cos-neg72.1%
sub-neg72.1%
+-commutative72.1%
distribute-neg-out72.1%
remove-double-neg72.1%
sub-neg72.1%
Simplified72.1%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi1 around 0 28.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos lambda1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos(lambda1));
}
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(lambda1))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos(lambda1));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos(lambda1))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(lambda1))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos(lambda1)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \lambda_1
\end{array}
Initial program 72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
associate-*l*72.1%
associate-*l*72.1%
*-commutative72.1%
cos-neg72.1%
sub-neg72.1%
+-commutative72.1%
distribute-neg-out72.1%
remove-double-neg72.1%
sub-neg72.1%
Simplified72.1%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi1 around 0 28.0%
Taylor expanded in lambda2 around 0 17.6%
cos-neg17.6%
Simplified17.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (- lambda2 lambda1)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (lambda2 - lambda1);
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (lambda2 - lambda1)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (lambda2 - lambda1);
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (lambda2 - lambda1)
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(lambda2 - lambda1)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (lambda2 - lambda1); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
associate-*l*72.1%
associate-*l*72.1%
*-commutative72.1%
cos-neg72.1%
sub-neg72.1%
+-commutative72.1%
distribute-neg-out72.1%
remove-double-neg72.1%
sub-neg72.1%
Simplified72.1%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi1 around 0 28.0%
Taylor expanded in lambda2 around 0 4.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R lambda2))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * 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 * lambda2
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * lambda2;
}
def code(R, lambda1, lambda2, phi1, phi2): return R * lambda2
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * lambda2) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * lambda2; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * lambda2), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \lambda_2
\end{array}
Initial program 72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
*-commutative72.1%
associate-*l*72.1%
associate-*l*72.1%
*-commutative72.1%
cos-neg72.1%
sub-neg72.1%
+-commutative72.1%
distribute-neg-out72.1%
remove-double-neg72.1%
sub-neg72.1%
Simplified72.1%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi1 around 0 28.0%
Taylor expanded in lambda2 around inf 4.3%
*-commutative4.3%
Simplified4.3%
Final simplification4.3%
herbie shell --seed 2024109
(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))