
(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
(*
(log1p
(expm1
(acos
(fma
(sin phi1)
(sin phi2)
(*
(cos phi1)
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return log1p(expm1(acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(log1p(expm1(acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Log[1 + N[(Exp[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[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{log1p}\left(\mathsf{expm1}\left(\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_1 \cdot \cos \lambda_2\right)\right)\right)\right)\right)\right) \cdot R
\end{array}
Initial program 75.7%
Simplified75.7%
cos-diff94.7%
+-commutative94.7%
Applied egg-rr94.7%
distribute-rgt-in94.7%
Applied egg-rr94.7%
log1p-expm1-u94.7%
distribute-rgt-out94.7%
Applied egg-rr94.7%
Final simplification94.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)
\end{array}
Initial program 75.7%
cos-diff94.7%
Applied egg-rr94.7%
cos-neg94.7%
*-commutative94.7%
fma-def94.7%
cos-neg94.7%
Simplified94.7%
Final simplification94.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(fma
(sin phi1)
(sin phi2)
(*
(cos phi1)
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(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[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\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_1 \cdot \cos \lambda_2\right)\right)\right)\right) \cdot R
\end{array}
Initial program 75.7%
Simplified75.7%
cos-diff94.7%
+-commutative94.7%
Applied egg-rr94.7%
Final simplification94.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (or (<= phi2 -8e-36) (not (<= phi2 9.8e-12)))
(*
R
(acos
(+
t_0
(* (* (cos phi1) (cos phi2)) (log (exp (cos (- lambda1 lambda2))))))))
(*
R
(acos
(+
t_0
(*
(cos phi1)
(fma
(cos lambda1)
(cos lambda2)
(* (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 ((phi2 <= -8e-36) || !(phi2 <= 9.8e-12)) {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * log(exp(cos((lambda1 - lambda2)))))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if ((phi2 <= -8e-36) || !(phi2 <= 9.8e-12)) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * log(exp(cos(Float64(lambda1 - lambda2)))))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(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]}, If[Or[LessEqual[phi2, -8e-36], N[Not[LessEqual[phi2, 9.8e-12]], $MachinePrecision]], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Log[N[Exp[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + 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]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -8 \cdot 10^{-36} \lor \neg \left(\phi_2 \leq 9.8 \cdot 10^{-12}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \log \left(e^{\cos \left(\lambda_1 - \lambda_2\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \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 < -7.9999999999999995e-36 or 9.79999999999999944e-12 < phi2 Initial program 78.6%
add-log-exp78.6%
Applied egg-rr78.6%
if -7.9999999999999995e-36 < phi2 < 9.79999999999999944e-12Initial program 72.0%
cos-diff91.0%
+-commutative91.0%
Applied egg-rr91.0%
Taylor expanded in phi2 around 0 91.0%
fma-def91.1%
Simplified91.1%
Final simplification84.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= phi2 -7.5e-7)
(* R (log (+ 1.0 (expm1 (acos (fma t_0 t_1 t_2))))))
(if (<= phi2 9.8e-12)
(*
R
(acos
(+
t_2
(*
(cos phi1)
(fma
(cos lambda1)
(cos lambda2)
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (+ t_2 (* t_1 (log (exp t_0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -7.5e-7) {
tmp = R * log((1.0 + expm1(acos(fma(t_0, t_1, t_2)))));
} else if (phi2 <= 9.8e-12) {
tmp = R * acos((t_2 + (cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos((t_2 + (t_1 * log(exp(t_0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -7.5e-7) tmp = Float64(R * log(Float64(1.0 + expm1(acos(fma(t_0, t_1, t_2)))))); elseif (phi2 <= 9.8e-12) tmp = Float64(R * acos(Float64(t_2 + Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(Float64(t_2 + Float64(t_1 * log(exp(t_0)))))); 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[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7.5e-7], N[(R * N[Log[N[(1.0 + N[(Exp[N[ArcCos[N[(t$95$0 * t$95$1 + t$95$2), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 9.8e-12], N[(R * N[ArcCos[N[(t$95$2 + 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]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$1 * N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -7.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \log \left(1 + \mathsf{expm1}\left(\cos^{-1} \left(\mathsf{fma}\left(t_0, t_1, t_2\right)\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 9.8 \cdot 10^{-12}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_2 + \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(t_2 + t_1 \cdot \log \left(e^{t_0}\right)\right)\\
\end{array}
\end{array}
if phi2 < -7.5000000000000002e-7Initial program 78.6%
log1p-expm1-u78.6%
log1p-udef78.5%
+-commutative78.5%
*-commutative78.5%
fma-def78.5%
Applied egg-rr78.5%
if -7.5000000000000002e-7 < phi2 < 9.79999999999999944e-12Initial program 71.9%
cos-diff90.6%
+-commutative90.6%
Applied egg-rr90.6%
Taylor expanded in phi2 around 0 90.6%
fma-def90.7%
Simplified90.7%
if 9.79999999999999944e-12 < phi2 Initial program 79.4%
add-log-exp79.4%
Applied egg-rr79.4%
Final simplification84.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))
(* (cos phi1) (cos phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) * (cos(phi1) * cos(phi2)))));
}
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)) + (((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) * (cos(phi1) * cos(phi2)))))
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.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))) * (Math.cos(phi1) * Math.cos(phi2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))) * (math.cos(phi1) * math.cos(phi2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) * Float64(cos(phi1) * cos(phi2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) * (cos(phi1) * cos(phi2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)
\end{array}
Initial program 75.7%
cos-diff94.7%
+-commutative94.7%
Applied egg-rr94.7%
Final simplification94.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (or (<= phi2 -8e-36) (not (<= phi2 9.8e-12)))
(*
R
(acos
(+
t_0
(* (* (cos phi1) (cos phi2)) (log (exp (cos (- lambda1 lambda2))))))))
(*
R
(acos
(+
t_0
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if ((phi2 <= -8e-36) || !(phi2 <= 9.8e-12)) {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * log(exp(cos((lambda1 - lambda2)))))));
} else {
tmp = R * acos((t_0 + (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) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if ((phi2 <= (-8d-36)) .or. (.not. (phi2 <= 9.8d-12))) then
tmp = r * acos((t_0 + ((cos(phi1) * cos(phi2)) * log(exp(cos((lambda1 - lambda2)))))))
else
tmp = r * acos((t_0 + (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 t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if ((phi2 <= -8e-36) || !(phi2 <= 9.8e-12)) {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.log(Math.exp(Math.cos((lambda1 - lambda2)))))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if (phi2 <= -8e-36) or not (phi2 <= 9.8e-12): tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.log(math.exp(math.cos((lambda1 - lambda2))))))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if ((phi2 <= -8e-36) || !(phi2 <= 9.8e-12)) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * log(exp(cos(Float64(lambda1 - lambda2)))))))); else tmp = Float64(R * acos(Float64(t_0 + 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) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if ((phi2 <= -8e-36) || ~((phi2 <= 9.8e-12))) tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * log(exp(cos((lambda1 - lambda2))))))); else tmp = R * acos((t_0 + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))); 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[Or[LessEqual[phi2, -8e-36], N[Not[LessEqual[phi2, 9.8e-12]], $MachinePrecision]], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Log[N[Exp[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + 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]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -8 \cdot 10^{-36} \lor \neg \left(\phi_2 \leq 9.8 \cdot 10^{-12}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \log \left(e^{\cos \left(\lambda_1 - \lambda_2\right)}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \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 < -7.9999999999999995e-36 or 9.79999999999999944e-12 < phi2 Initial program 78.6%
add-log-exp78.6%
Applied egg-rr78.6%
if -7.9999999999999995e-36 < phi2 < 9.79999999999999944e-12Initial program 72.0%
Taylor expanded in phi2 around 0 72.0%
sub-neg72.0%
remove-double-neg72.0%
mul-1-neg72.0%
distribute-neg-in72.0%
+-commutative72.0%
cos-neg72.0%
mul-1-neg72.0%
unsub-neg72.0%
Simplified72.0%
cos-diff91.0%
*-commutative91.0%
*-commutative91.0%
+-commutative91.0%
Applied egg-rr91.0%
Final simplification84.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (log (exp (cos (- lambda1 lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * log(exp(cos((lambda1 - 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)) * log(exp(cos((lambda1 - 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.log(Math.exp(Math.cos((lambda1 - 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.log(math.exp(math.cos((lambda1 - lambda2)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * log(exp(cos(Float64(lambda1 - lambda2)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * log(exp(cos((lambda1 - 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Log[N[Exp[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \log \left(e^{\cos \left(\lambda_1 - \lambda_2\right)}\right)\right)
\end{array}
Initial program 75.7%
add-log-exp75.8%
Applied egg-rr75.8%
Final simplification75.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= (cos (- lambda1 lambda2)) 0.9925)
(* R (acos (+ t_0 (* (cos phi1) (cos (- lambda2 lambda1))))))
(* R (acos (+ t_0 (* (cos phi1) (cos phi2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (cos((lambda1 - lambda2)) <= 0.9925) {
tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * cos(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(phi1) * sin(phi2)
if (cos((lambda1 - lambda2)) <= 0.9925d0) then
tmp = r * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))))
else
tmp = r * acos((t_0 + (cos(phi1) * cos(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(phi1) * Math.sin(phi2);
double tmp;
if (Math.cos((lambda1 - lambda2)) <= 0.9925) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if math.cos((lambda1 - lambda2)) <= 0.9925: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (cos(Float64(lambda1 - lambda2)) <= 0.9925) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (cos((lambda1 - lambda2)) <= 0.9925) tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1))))); else tmp = R * acos((t_0 + (cos(phi1) * cos(phi2)))); 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[N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision], 0.9925], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\cos \left(\lambda_1 - \lambda_2\right) \leq 0.9925:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if (cos.f64 (-.f64 lambda1 lambda2)) < 0.992500000000000049Initial program 73.7%
Taylor expanded in phi2 around 0 47.4%
sub-neg47.4%
remove-double-neg47.4%
mul-1-neg47.4%
distribute-neg-in47.4%
+-commutative47.4%
cos-neg47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
if 0.992500000000000049 < (cos.f64 (-.f64 lambda1 lambda2)) Initial program 80.5%
Taylor expanded in lambda2 around 0 77.5%
Taylor expanded in lambda1 around 0 75.8%
Final simplification56.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 500.0)
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos phi1) (* (cos phi2) (cos lambda1))))))
(*
R
(acos
(+
(/ (- (cos (- phi1 phi2)) (cos (+ phi1 phi2))) 2.0)
(* (cos phi1) (cos (- lambda2 lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 500.0) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda1)))));
} else {
tmp = R * acos((((cos((phi1 - phi2)) - cos((phi1 + phi2))) / 2.0) + (cos(phi1) * 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 <= 500.0d0) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda1)))))
else
tmp = r * acos((((cos((phi1 - phi2)) - cos((phi1 + phi2))) / 2.0d0) + (cos(phi1) * 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 <= 500.0) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((((Math.cos((phi1 - phi2)) - Math.cos((phi1 + phi2))) / 2.0) + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 500.0: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda1))))) else: tmp = R * math.acos((((math.cos((phi1 - phi2)) - math.cos((phi1 + phi2))) / 2.0) + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 500.0) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(Float64(Float64(cos(Float64(phi1 - phi2)) - cos(Float64(phi1 + phi2))) / 2.0) + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 500.0) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda1))))); else tmp = R * acos((((cos((phi1 - phi2)) - cos((phi1 + phi2))) / 2.0) + (cos(phi1) * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 500.0], 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[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] - N[Cos[N[(phi1 + phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 500:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\frac{\cos \left(\phi_1 - \phi_2\right) - \cos \left(\phi_1 + \phi_2\right)}{2} + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\end{array}
\end{array}
if lambda2 < 500Initial program 79.5%
Taylor expanded in lambda2 around 0 68.8%
*-commutative68.8%
associate-*l*68.8%
*-commutative68.8%
Simplified68.8%
if 500 < lambda2 Initial program 63.0%
Taylor expanded in phi2 around 0 34.5%
sub-neg34.5%
remove-double-neg34.5%
mul-1-neg34.5%
distribute-neg-in34.5%
+-commutative34.5%
cos-neg34.5%
mul-1-neg34.5%
unsub-neg34.5%
Simplified34.5%
sin-mult34.5%
Applied egg-rr34.5%
Final simplification60.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -2.5e-6)
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda1))))))
(* R (acos (+ t_0 (* (cos lambda2) (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -2.5e-6) {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))));
} else {
tmp = R * acos((t_0 + (cos(lambda2) * (cos(phi1) * cos(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(phi1) * sin(phi2)
if (lambda1 <= (-2.5d-6)) then
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))))
else
tmp = r * acos((t_0 + (cos(lambda2) * (cos(phi1) * cos(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(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -2.5e-6) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(lambda2) * (Math.cos(phi1) * Math.cos(phi2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -2.5e-6: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda1))))) else: tmp = R * math.acos((t_0 + (math.cos(lambda2) * (math.cos(phi1) * math.cos(phi2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -2.5e-6) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(lambda2) * Float64(cos(phi1) * cos(phi2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -2.5e-6) tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1))))); else tmp = R * acos((t_0 + (cos(lambda2) * (cos(phi1) * cos(phi2))))); 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[lambda1, -2.5e-6], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -2.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \lambda_2 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
\end{array}
\end{array}
if lambda1 < -2.5000000000000002e-6Initial program 60.8%
Taylor expanded in lambda2 around 0 60.4%
*-commutative60.4%
associate-*l*60.4%
*-commutative60.4%
Simplified60.4%
if -2.5000000000000002e-6 < lambda1 Initial program 82.3%
Taylor expanded in lambda1 around 0 68.7%
cos-neg68.7%
Simplified68.7%
Final simplification66.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - 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)) * cos((lambda1 - 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.cos((lambda1 - 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.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
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)
\end{array}
Initial program 75.7%
Final simplification75.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (cos (- lambda2 lambda1))))
(if (<= phi2 0.0005)
(* R (acos (fma (cos phi1) t_1 t_0)))
(* R (acos (+ t_0 (* (cos phi2) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 0.0005) {
tmp = R * acos(fma(cos(phi1), t_1, t_0));
} else {
tmp = R * acos((t_0 + (cos(phi2) * t_1)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 0.0005) tmp = Float64(R * acos(fma(cos(phi1), t_1, t_0))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi2) * t_1)))); 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[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.0005], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq 0.0005:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, t_1, t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot t_1\right)\\
\end{array}
\end{array}
if phi2 < 5.0000000000000001e-4Initial program 74.2%
Taylor expanded in phi2 around 0 53.1%
sub-neg53.1%
remove-double-neg53.1%
mul-1-neg53.1%
distribute-neg-in53.1%
+-commutative53.1%
cos-neg53.1%
mul-1-neg53.1%
unsub-neg53.1%
Simplified53.1%
Taylor expanded in phi1 around 0 53.1%
fma-def53.1%
Simplified53.1%
if 5.0000000000000001e-4 < phi2 Initial program 80.2%
Taylor expanded in phi1 around 0 51.4%
sub-neg51.4%
neg-mul-151.4%
neg-mul-151.4%
remove-double-neg51.4%
mul-1-neg51.4%
distribute-neg-in51.4%
+-commutative51.4%
cos-neg51.4%
mul-1-neg51.4%
unsub-neg51.4%
Simplified51.4%
Final simplification52.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -0.00015) (not (<= phi2 5.7)))
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos phi2)))))
(*
R
(acos (+ (* (cos phi1) (cos (- lambda2 lambda1))) (* (sin phi1) phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -0.00015) || !(phi2 <= 5.7)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2))));
} else {
tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * 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 ((phi2 <= (-0.00015d0)) .or. (.not. (phi2 <= 5.7d0))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2))))
else
tmp = r * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * phi2)))
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.00015) || !(phi2 <= 5.7)) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(phi2))));
} else {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos((lambda2 - lambda1))) + (Math.sin(phi1) * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -0.00015) or not (phi2 <= 5.7): tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos(phi2)))) else: tmp = R * math.acos(((math.cos(phi1) * math.cos((lambda2 - lambda1))) + (math.sin(phi1) * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -0.00015) || !(phi2 <= 5.7)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(phi2))))); else tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))) + Float64(sin(phi1) * phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -0.00015) || ~((phi2 <= 5.7))) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2)))); else tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -0.00015], N[Not[LessEqual[phi2, 5.7]], $MachinePrecision]], 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], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.00015 \lor \neg \left(\phi_2 \leq 5.7\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right) + \sin \phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi2 < -1.49999999999999987e-4 or 5.70000000000000018 < phi2 Initial program 79.1%
Taylor expanded in lambda2 around 0 52.1%
Taylor expanded in lambda1 around 0 41.7%
if -1.49999999999999987e-4 < phi2 < 5.70000000000000018Initial program 72.2%
Taylor expanded in phi2 around 0 71.0%
sub-neg71.0%
remove-double-neg71.0%
mul-1-neg71.0%
distribute-neg-in71.0%
+-commutative71.0%
cos-neg71.0%
mul-1-neg71.0%
unsub-neg71.0%
Simplified71.0%
Taylor expanded in phi2 around 0 71.0%
*-commutative71.0%
Simplified71.0%
Final simplification55.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 1.4e-5)
(* 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((lambda2 - lambda1));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= 1.4e-5) {
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((lambda2 - lambda1))
t_1 = sin(phi1) * sin(phi2)
if (phi2 <= 1.4d-5) 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((lambda2 - lambda1));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= 1.4e-5) {
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((lambda2 - lambda1)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= 1.4e-5: 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(lambda2 - lambda1)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= 1.4e-5) 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((lambda2 - lambda1)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= 1.4e-5) 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[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 1.4e-5], 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_2 - \lambda_1\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq 1.4 \cdot 10^{-5}:\\
\;\;\;\;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 < 1.39999999999999998e-5Initial program 74.2%
Taylor expanded in phi2 around 0 53.1%
sub-neg53.1%
remove-double-neg53.1%
mul-1-neg53.1%
distribute-neg-in53.1%
+-commutative53.1%
cos-neg53.1%
mul-1-neg53.1%
unsub-neg53.1%
Simplified53.1%
if 1.39999999999999998e-5 < phi2 Initial program 80.2%
Taylor expanded in phi1 around 0 51.4%
sub-neg51.4%
neg-mul-151.4%
neg-mul-151.4%
remove-double-neg51.4%
mul-1-neg51.4%
distribute-neg-in51.4%
+-commutative51.4%
cos-neg51.4%
mul-1-neg51.4%
unsub-neg51.4%
Simplified51.4%
Final simplification52.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 9.4e+27)
(*
R
(acos (+ (* (cos phi1) (cos (- lambda2 lambda1))) (* (sin phi1) phi2))))
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 9.4e+27) {
tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * phi2)));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * 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 <= 9.4d+27) then
tmp = r * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * phi2)))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * 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 <= 9.4e+27) {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos((lambda2 - lambda1))) + (Math.sin(phi1) * phi2)));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 9.4e+27: tmp = R * math.acos(((math.cos(phi1) * math.cos((lambda2 - lambda1))) + (math.sin(phi1) * phi2))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 9.4e+27) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))) + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 9.4e+27) tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * phi2))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 9.4e+27], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 9.4 \cdot 10^{+27}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right) + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < 9.39999999999999952e27Initial program 74.5%
Taylor expanded in phi2 around 0 51.8%
sub-neg51.8%
remove-double-neg51.8%
mul-1-neg51.8%
distribute-neg-in51.8%
+-commutative51.8%
cos-neg51.8%
mul-1-neg51.8%
unsub-neg51.8%
Simplified51.8%
Taylor expanded in phi2 around 0 47.4%
*-commutative47.4%
Simplified47.4%
if 9.39999999999999952e27 < phi2 Initial program 79.6%
Taylor expanded in phi2 around 0 17.2%
sub-neg17.2%
remove-double-neg17.2%
mul-1-neg17.2%
distribute-neg-in17.2%
+-commutative17.2%
cos-neg17.2%
mul-1-neg17.2%
unsub-neg17.2%
Simplified17.2%
Taylor expanded in lambda2 around 0 14.6%
cos-neg6.5%
Simplified14.6%
Final simplification39.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -9.5e-6)
(* R (acos (+ t_0 (* (cos phi1) (cos lambda1)))))
(* R (acos (+ t_0 (* (cos phi1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -9.5e-6) {
tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((t_0 + (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) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if (lambda1 <= (-9.5d-6)) then
tmp = r * acos((t_0 + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos((t_0 + (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 t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -9.5e-6) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -9.5e-6: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -9.5e-6) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -9.5e-6) tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1)))); else tmp = R * acos((t_0 + (cos(phi1) * cos(lambda2)))); 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[lambda1, -9.5e-6], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -9.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -9.5000000000000005e-6Initial program 60.8%
Taylor expanded in phi2 around 0 38.4%
sub-neg38.4%
remove-double-neg38.4%
mul-1-neg38.4%
distribute-neg-in38.4%
+-commutative38.4%
cos-neg38.4%
mul-1-neg38.4%
unsub-neg38.4%
Simplified38.4%
Taylor expanded in lambda2 around 0 38.0%
cos-neg16.6%
Simplified38.0%
if -9.5000000000000005e-6 < lambda1 Initial program 82.1%
Taylor expanded in phi2 around 0 46.0%
sub-neg46.0%
remove-double-neg46.0%
mul-1-neg46.0%
distribute-neg-in46.0%
+-commutative46.0%
cos-neg46.0%
mul-1-neg46.0%
unsub-neg46.0%
Simplified46.0%
Taylor expanded in lambda1 around 0 36.6%
Final simplification37.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 1.12e+28)
(*
R
(acos (+ (* (cos phi1) (cos (- lambda2 lambda1))) (* (sin phi1) phi2))))
(*
R
(acos
(+
(* phi1 (sin phi2))
(* (cos (- lambda1 lambda2)) (+ 1.0 (* -0.5 (* phi1 phi1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.12e+28) {
tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * phi2)));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi1 * phi1))))));
}
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.12d+28) then
tmp = r * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * phi2)))
else
tmp = r * acos(((phi1 * sin(phi2)) + (cos((lambda1 - lambda2)) * (1.0d0 + ((-0.5d0) * (phi1 * phi1))))))
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.12e+28) {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos((lambda2 - lambda1))) + (Math.sin(phi1) * phi2)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi1 * phi1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1.12e+28: tmp = R * math.acos(((math.cos(phi1) * math.cos((lambda2 - lambda1))) + (math.sin(phi1) * phi2))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi1 * phi1)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1.12e+28) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))) + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(Float64(lambda1 - lambda2)) * Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 1.12e+28) tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (sin(phi1) * phi2))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi1 * phi1)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.12e+28], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.12 \cdot 10^{+28}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right) + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\right)\\
\end{array}
\end{array}
if phi2 < 1.12e28Initial program 74.5%
Taylor expanded in phi2 around 0 51.8%
sub-neg51.8%
remove-double-neg51.8%
mul-1-neg51.8%
distribute-neg-in51.8%
+-commutative51.8%
cos-neg51.8%
mul-1-neg51.8%
unsub-neg51.8%
Simplified51.8%
Taylor expanded in phi2 around 0 47.4%
*-commutative47.4%
Simplified47.4%
if 1.12e28 < phi2 Initial program 79.6%
Taylor expanded in phi2 around 0 17.2%
sub-neg17.2%
remove-double-neg17.2%
mul-1-neg17.2%
distribute-neg-in17.2%
+-commutative17.2%
cos-neg17.2%
mul-1-neg17.2%
unsub-neg17.2%
Simplified17.2%
Taylor expanded in phi1 around 0 8.6%
Taylor expanded in phi1 around 0 8.6%
associate-*r*8.6%
distribute-rgt1-in8.6%
unpow28.6%
cos-neg8.6%
sub-neg8.6%
+-commutative8.6%
distribute-neg-in8.6%
remove-double-neg8.6%
sub-neg8.6%
Simplified8.6%
Final simplification38.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= phi1 -2.2e-24)
(* R (acos (+ (* (cos phi1) (cos lambda1)) t_0)))
(*
R
(acos
(+
t_0
(* (cos (- lambda1 lambda2)) (+ 1.0 (* -0.5 (* phi1 phi1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (phi1 <= -2.2e-24) {
tmp = R * acos(((cos(phi1) * cos(lambda1)) + t_0));
} else {
tmp = R * acos((t_0 + (cos((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi1 * phi1))))));
}
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 = phi1 * sin(phi2)
if (phi1 <= (-2.2d-24)) then
tmp = r * acos(((cos(phi1) * cos(lambda1)) + t_0))
else
tmp = r * acos((t_0 + (cos((lambda1 - lambda2)) * (1.0d0 + ((-0.5d0) * (phi1 * phi1))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * Math.sin(phi2);
double tmp;
if (phi1 <= -2.2e-24) {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos(lambda1)) + t_0));
} else {
tmp = R * Math.acos((t_0 + (Math.cos((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi1 * phi1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if phi1 <= -2.2e-24: tmp = R * math.acos(((math.cos(phi1) * math.cos(lambda1)) + t_0)) else: tmp = R * math.acos((t_0 + (math.cos((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi1 * phi1)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (phi1 <= -2.2e-24) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(lambda1)) + t_0))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(Float64(lambda1 - lambda2)) * Float64(1.0 + Float64(-0.5 * Float64(phi1 * phi1))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (phi1 <= -2.2e-24) tmp = R * acos(((cos(phi1) * cos(lambda1)) + t_0)); else tmp = R * acos((t_0 + (cos((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi1 * phi1)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.2e-24], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -2.2 \cdot 10^{-24}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1 + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + -0.5 \cdot \left(\phi_1 \cdot \phi_1\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -2.20000000000000002e-24Initial program 86.6%
Taylor expanded in phi2 around 0 52.2%
sub-neg52.2%
remove-double-neg52.2%
mul-1-neg52.2%
distribute-neg-in52.2%
+-commutative52.2%
cos-neg52.2%
mul-1-neg52.2%
unsub-neg52.2%
Simplified52.2%
Taylor expanded in phi1 around 0 22.6%
Taylor expanded in lambda2 around 0 17.4%
cos-neg17.4%
Simplified17.4%
if -2.20000000000000002e-24 < phi1 Initial program 72.4%
Taylor expanded in phi2 around 0 41.1%
sub-neg41.1%
remove-double-neg41.1%
mul-1-neg41.1%
distribute-neg-in41.1%
+-commutative41.1%
cos-neg41.1%
mul-1-neg41.1%
unsub-neg41.1%
Simplified41.1%
Taylor expanded in phi1 around 0 32.3%
Taylor expanded in phi1 around 0 23.4%
associate-*r*23.4%
distribute-rgt1-in23.4%
unpow223.4%
cos-neg23.4%
sub-neg23.4%
+-commutative23.4%
distribute-neg-in23.4%
remove-double-neg23.4%
sub-neg23.4%
Simplified23.4%
Final simplification22.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda1 -1.25e-6)
(* R (acos (+ (* (cos phi1) (cos lambda1)) t_0)))
(* R (acos (+ (* (cos phi1) (cos lambda2)) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda1 <= -1.25e-6) {
tmp = R * acos(((cos(phi1) * cos(lambda1)) + t_0));
} else {
tmp = R * acos(((cos(phi1) * cos(lambda2)) + 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 = phi1 * sin(phi2)
if (lambda1 <= (-1.25d-6)) then
tmp = r * acos(((cos(phi1) * cos(lambda1)) + t_0))
else
tmp = r * acos(((cos(phi1) * cos(lambda2)) + 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 = phi1 * Math.sin(phi2);
double tmp;
if (lambda1 <= -1.25e-6) {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos(lambda1)) + t_0));
} else {
tmp = R * Math.acos(((Math.cos(phi1) * Math.cos(lambda2)) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if lambda1 <= -1.25e-6: tmp = R * math.acos(((math.cos(phi1) * math.cos(lambda1)) + t_0)) else: tmp = R * math.acos(((math.cos(phi1) * math.cos(lambda2)) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda1 <= -1.25e-6) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(lambda1)) + t_0))); else tmp = Float64(R * acos(Float64(Float64(cos(phi1) * cos(lambda2)) + t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (lambda1 <= -1.25e-6) tmp = R * acos(((cos(phi1) * cos(lambda1)) + t_0)); else tmp = R * acos(((cos(phi1) * cos(lambda2)) + t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.25e-6], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.25 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1 + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2 + t_0\right)\\
\end{array}
\end{array}
if lambda1 < -1.2500000000000001e-6Initial program 60.8%
Taylor expanded in phi2 around 0 38.7%
sub-neg38.7%
remove-double-neg38.7%
mul-1-neg38.7%
distribute-neg-in38.7%
+-commutative38.7%
cos-neg38.7%
mul-1-neg38.7%
unsub-neg38.7%
Simplified38.7%
Taylor expanded in phi1 around 0 26.4%
Taylor expanded in lambda2 around 0 26.1%
cos-neg26.1%
Simplified26.1%
if -1.2500000000000001e-6 < lambda1 Initial program 82.3%
Taylor expanded in phi2 around 0 45.9%
sub-neg45.9%
remove-double-neg45.9%
mul-1-neg45.9%
distribute-neg-in45.9%
+-commutative45.9%
cos-neg45.9%
mul-1-neg45.9%
unsub-neg45.9%
Simplified45.9%
Taylor expanded in phi1 around 0 31.6%
Taylor expanded in lambda1 around 0 23.7%
*-commutative23.7%
Simplified23.7%
Final simplification24.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* (cos phi1) (cos (- lambda2 lambda1))) (* phi1 (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (phi1 * sin(phi2))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (phi1 * sin(phi2))))
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 - lambda1))) + (phi1 * Math.sin(phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.cos(phi1) * math.cos((lambda2 - lambda1))) + (phi1 * math.sin(phi2))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))) + Float64(phi1 * sin(phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((cos(phi1) * cos((lambda2 - lambda1))) + (phi1 * sin(phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)
\end{array}
Initial program 75.7%
Taylor expanded in phi2 around 0 43.7%
sub-neg43.7%
remove-double-neg43.7%
mul-1-neg43.7%
distribute-neg-in43.7%
+-commutative43.7%
cos-neg43.7%
mul-1-neg43.7%
unsub-neg43.7%
Simplified43.7%
Taylor expanded in phi1 around 0 30.0%
Final simplification30.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda1 -4.8e-6)
(* R (acos (+ (cos lambda1) t_0)))
(* R (acos (+ (cos lambda2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda1 <= -4.8e-6) {
tmp = R * acos((cos(lambda1) + t_0));
} else {
tmp = R * acos((cos(lambda2) + 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 = phi1 * sin(phi2)
if (lambda1 <= (-4.8d-6)) then
tmp = r * acos((cos(lambda1) + t_0))
else
tmp = r * acos((cos(lambda2) + 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 = phi1 * Math.sin(phi2);
double tmp;
if (lambda1 <= -4.8e-6) {
tmp = R * Math.acos((Math.cos(lambda1) + t_0));
} else {
tmp = R * Math.acos((Math.cos(lambda2) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if lambda1 <= -4.8e-6: tmp = R * math.acos((math.cos(lambda1) + t_0)) else: tmp = R * math.acos((math.cos(lambda2) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda1 <= -4.8e-6) tmp = Float64(R * acos(Float64(cos(lambda1) + t_0))); else tmp = Float64(R * acos(Float64(cos(lambda2) + t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (lambda1 <= -4.8e-6) tmp = R * acos((cos(lambda1) + t_0)); else tmp = R * acos((cos(lambda2) + t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -4.8e-6], N[(R * N[ArcCos[N[(N[Cos[lambda1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[lambda2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -4.8 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_2 + t_0\right)\\
\end{array}
\end{array}
if lambda1 < -4.7999999999999998e-6Initial program 60.8%
Taylor expanded in phi2 around 0 38.4%
sub-neg38.4%
remove-double-neg38.4%
mul-1-neg38.4%
distribute-neg-in38.4%
+-commutative38.4%
cos-neg38.4%
mul-1-neg38.4%
unsub-neg38.4%
Simplified38.4%
Taylor expanded in phi1 around 0 25.9%
Taylor expanded in phi1 around 0 17.0%
Taylor expanded in lambda2 around 0 16.6%
cos-neg16.6%
Simplified16.6%
if -4.7999999999999998e-6 < lambda1 Initial program 82.1%
Taylor expanded in phi2 around 0 46.0%
sub-neg46.0%
remove-double-neg46.0%
mul-1-neg46.0%
distribute-neg-in46.0%
+-commutative46.0%
cos-neg46.0%
mul-1-neg46.0%
unsub-neg46.0%
Simplified46.0%
Taylor expanded in phi1 around 0 31.8%
Taylor expanded in phi1 around 0 22.0%
Taylor expanded in lambda1 around 0 15.7%
Final simplification16.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (cos (- lambda2 lambda1)) (* phi1 (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos((lambda2 - lambda1)) + (phi1 * sin(phi2))));
}
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)) + (phi1 * sin(phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos((lambda2 - lambda1)) + (phi1 * Math.sin(phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos((lambda2 - lambda1)) + (phi1 * math.sin(phi2))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + Float64(phi1 * sin(phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * sin(phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)
\end{array}
Initial program 75.7%
Taylor expanded in phi2 around 0 43.7%
sub-neg43.7%
remove-double-neg43.7%
mul-1-neg43.7%
distribute-neg-in43.7%
+-commutative43.7%
cos-neg43.7%
mul-1-neg43.7%
unsub-neg43.7%
Simplified43.7%
Taylor expanded in phi1 around 0 30.0%
Taylor expanded in phi1 around 0 20.5%
Final simplification20.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (cos (- lambda2 lambda1)) (* phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)));
}
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)) + (phi1 * phi2)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos((lambda2 - lambda1)) + (phi1 * phi2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos((lambda2 - lambda1)) + (phi1 * phi2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + Float64(phi1 * phi2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)
\end{array}
Initial program 75.7%
Taylor expanded in phi2 around 0 43.7%
sub-neg43.7%
remove-double-neg43.7%
mul-1-neg43.7%
distribute-neg-in43.7%
+-commutative43.7%
cos-neg43.7%
mul-1-neg43.7%
unsub-neg43.7%
Simplified43.7%
Taylor expanded in phi1 around 0 30.0%
Taylor expanded in phi1 around 0 20.5%
Taylor expanded in phi2 around 0 18.3%
Final simplification18.3%
herbie shell --seed 2023282
(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))