
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 26 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 phi1)))
(t_1 (cos (* 0.5 phi1)))
(t_2 (cos (* 0.5 phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (* (cos phi1) (cos phi2)) t_3)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (fma t_2 t_0 (* t_1 (sin (* phi2 -0.5)))) 2.0)
(* t_4 (expm1 (log1p (sin (* 0.5 (- lambda1 lambda2))))))))
(sqrt
(-
1.0
(+
(pow (fma t_0 t_2 (* t_1 (- (sin (* 0.5 phi2))))) 2.0)
(* t_3 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * phi1));
double t_1 = cos((0.5 * phi1));
double t_2 = cos((0.5 * phi2));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = (cos(phi1) * cos(phi2)) * t_3;
return R * (2.0 * atan2(sqrt((pow(fma(t_2, t_0, (t_1 * sin((phi2 * -0.5)))), 2.0) + (t_4 * expm1(log1p(sin((0.5 * (lambda1 - lambda2)))))))), sqrt((1.0 - (pow(fma(t_0, t_2, (t_1 * -sin((0.5 * phi2)))), 2.0) + (t_3 * t_4))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * phi1)) t_1 = cos(Float64(0.5 * phi1)) t_2 = cos(Float64(0.5 * phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(Float64(cos(phi1) * cos(phi2)) * t_3) return Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(t_2, t_0, Float64(t_1 * sin(Float64(phi2 * -0.5)))) ^ 2.0) + Float64(t_4 * expm1(log1p(sin(Float64(0.5 * Float64(lambda1 - lambda2)))))))), sqrt(Float64(1.0 - Float64((fma(t_0, t_2, Float64(t_1 * Float64(-sin(Float64(0.5 * phi2))))) ^ 2.0) + Float64(t_3 * t_4))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(t$95$2 * t$95$0 + N[(t$95$1 * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$4 * N[(Exp[N[Log[1 + N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$0 * t$95$2 + N[(t$95$1 * (-N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$3 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \phi_1\right)\\
t_1 := \cos \left(0.5 \cdot \phi_1\right)\\
t_2 := \cos \left(0.5 \cdot \phi_2\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(t\_2, t\_0, t\_1 \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2} + t\_4 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)\right)}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_0, t\_2, t\_1 \cdot \left(-\sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)}^{2} + t\_3 \cdot t\_4\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr79.5%
fma-neg79.5%
*-commutative79.5%
*-commutative79.5%
*-commutative79.5%
distribute-rgt-neg-in79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in phi1 around inf 79.5%
fma-neg79.6%
distribute-rgt-neg-in79.6%
sin-neg79.6%
distribute-lft-neg-in79.6%
metadata-eval79.6%
*-commutative79.6%
Simplified79.6%
add-sqr-sqrt40.5%
sqrt-prod56.8%
expm1-log1p-u56.8%
sqrt-prod40.5%
add-sqr-sqrt79.6%
div-inv79.6%
metadata-eval79.6%
Applied egg-rr79.6%
Final simplification79.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 phi1)))
(t_1 (cos (* 0.5 phi1)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* (* (cos phi1) (cos phi2)) t_2)))
(t_4 (cos (* 0.5 phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (fma t_4 t_0 (* t_1 (sin (* phi2 -0.5)))) 2.0) t_3))
(sqrt
(-
1.0
(+ (pow (fma t_0 t_4 (* t_1 (- (sin (* 0.5 phi2))))) 2.0) t_3))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * phi1));
double t_1 = cos((0.5 * phi1));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * ((cos(phi1) * cos(phi2)) * t_2);
double t_4 = cos((0.5 * phi2));
return R * (2.0 * atan2(sqrt((pow(fma(t_4, t_0, (t_1 * sin((phi2 * -0.5)))), 2.0) + t_3)), sqrt((1.0 - (pow(fma(t_0, t_4, (t_1 * -sin((0.5 * phi2)))), 2.0) + t_3)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * phi1)) t_1 = cos(Float64(0.5 * phi1)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) t_4 = cos(Float64(0.5 * phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(t_4, t_0, Float64(t_1 * sin(Float64(phi2 * -0.5)))) ^ 2.0) + t_3)), sqrt(Float64(1.0 - Float64((fma(t_0, t_4, Float64(t_1 * Float64(-sin(Float64(0.5 * phi2))))) ^ 2.0) + t_3)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(t$95$4 * t$95$0 + N[(t$95$1 * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$0 * t$95$4 + N[(t$95$1 * (-N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \phi_1\right)\\
t_1 := \cos \left(0.5 \cdot \phi_1\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right)\\
t_4 := \cos \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(t\_4, t\_0, t\_1 \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2} + t\_3}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_0, t\_4, t\_1 \cdot \left(-\sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)}^{2} + t\_3\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr79.5%
fma-neg79.5%
*-commutative79.5%
*-commutative79.5%
*-commutative79.5%
distribute-rgt-neg-in79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in phi1 around inf 79.5%
fma-neg79.6%
distribute-rgt-neg-in79.6%
sin-neg79.6%
distribute-lft-neg-in79.6%
metadata-eval79.6%
*-commutative79.6%
Simplified79.6%
Final simplification79.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 phi1)))
(t_1 (cos (* 0.5 phi2)))
(t_2 (cos (* 0.5 phi1)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (pow (fma t_2 (sin (* phi2 -0.5)) (* t_0 t_1)) 2.0)))
(sqrt
(-
1.0
(+ (pow (fma t_0 t_1 (* t_2 (- (sin (* 0.5 phi2))))) 2.0) t_4))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * phi1));
double t_1 = cos((0.5 * phi2));
double t_2 = cos((0.5 * phi1));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
return R * (2.0 * atan2(sqrt((t_4 + pow(fma(t_2, sin((phi2 * -0.5)), (t_0 * t_1)), 2.0))), sqrt((1.0 - (pow(fma(t_0, t_1, (t_2 * -sin((0.5 * phi2)))), 2.0) + t_4)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * phi1)) t_1 = cos(Float64(0.5 * phi2)) t_2 = cos(Float64(0.5 * phi1)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (fma(t_2, sin(Float64(phi2 * -0.5)), Float64(t_0 * t_1)) ^ 2.0))), sqrt(Float64(1.0 - Float64((fma(t_0, t_1, Float64(t_2 * Float64(-sin(Float64(0.5 * phi2))))) ^ 2.0) + t_4)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[(t$95$2 * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$0 * t$95$1 + N[(t$95$2 * (-N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \phi_1\right)\\
t_1 := \cos \left(0.5 \cdot \phi_2\right)\\
t_2 := \cos \left(0.5 \cdot \phi_1\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\left(\mathsf{fma}\left(t\_2, \sin \left(\phi_2 \cdot -0.5\right), t\_0 \cdot t\_1\right)\right)}^{2}}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_0, t\_1, t\_2 \cdot \left(-\sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)}^{2} + t\_4\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr79.5%
fma-neg79.5%
*-commutative79.5%
*-commutative79.5%
*-commutative79.5%
distribute-rgt-neg-in79.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in phi1 around inf 79.5%
fma-neg79.6%
distribute-rgt-neg-in79.6%
sin-neg79.6%
distribute-lft-neg-in79.6%
metadata-eval79.6%
*-commutative79.6%
Simplified79.6%
Taylor expanded in phi2 around inf 79.5%
fma-define79.5%
*-commutative79.5%
*-commutative79.5%
Simplified79.5%
Final simplification79.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* 0.5 phi1)))
(t_1 (sin (* 0.5 phi2)))
(t_2 (sin (* 0.5 phi1)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3)))
(t_5 (cos (* 0.5 phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (pow (- (* t_2 t_5) (* t_0 t_1)) 2.0)))
(sqrt (- 1.0 (+ (pow (fma t_2 t_5 (* t_0 (- t_1))) 2.0) t_4))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((0.5 * phi1));
double t_1 = sin((0.5 * phi2));
double t_2 = sin((0.5 * phi1));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
double t_5 = cos((0.5 * phi2));
return R * (2.0 * atan2(sqrt((t_4 + pow(((t_2 * t_5) - (t_0 * t_1)), 2.0))), sqrt((1.0 - (pow(fma(t_2, t_5, (t_0 * -t_1)), 2.0) + t_4)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(0.5 * phi1)) t_1 = sin(Float64(0.5 * phi2)) t_2 = sin(Float64(0.5 * phi1)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) t_5 = cos(Float64(0.5 * phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (Float64(Float64(t_2 * t_5) - Float64(t_0 * t_1)) ^ 2.0))), sqrt(Float64(1.0 - Float64((fma(t_2, t_5, Float64(t_0 * Float64(-t_1))) ^ 2.0) + t_4)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[(N[(t$95$2 * t$95$5), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$2 * t$95$5 + N[(t$95$0 * (-t$95$1)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot \phi_1\right)\\
t_1 := \sin \left(0.5 \cdot \phi_2\right)\\
t_2 := \sin \left(0.5 \cdot \phi_1\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
t_5 := \cos \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\left(t\_2 \cdot t\_5 - t\_0 \cdot t\_1\right)}^{2}}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_2, t\_5, t\_0 \cdot \left(-t\_1\right)\right)\right)}^{2} + t\_4\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr79.5%
fma-neg79.5%
*-commutative79.5%
*-commutative79.5%
*-commutative79.5%
distribute-rgt-neg-in79.5%
*-commutative79.5%
Simplified79.5%
Final simplification79.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(-
(* (sin (* 0.5 phi1)) (cos (* 0.5 phi2)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sqrt (+ (* t_0 (* (* (cos phi1) (cos phi2)) t_0)) t_1))))
(if (or (<= lambda2 -1.2e-5) (not (<= lambda2 5.4)))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* -0.5 lambda2)) 2.0)))
t_1))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
t_1
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((sin((0.5 * phi1)) * cos((0.5 * phi2))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1));
double tmp;
if ((lambda2 <= -1.2e-5) || !(lambda2 <= 5.4)) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((-0.5 * lambda2)), 2.0))) + t_1)))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.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) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = ((sin((0.5d0 * phi1)) * cos((0.5d0 * phi2))) - (cos((0.5d0 * phi1)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1))
if ((lambda2 <= (-1.2d-5)) .or. (.not. (lambda2 <= 5.4d0))) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin(((-0.5d0) * lambda2)) ** 2.0d0))) + t_1)))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))))
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 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.sin((0.5 * phi1)) * Math.cos((0.5 * phi2))) - (Math.cos((0.5 * phi1)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + t_1));
double tmp;
if ((lambda2 <= -1.2e-5) || !(lambda2 <= 5.4)) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * lambda2)), 2.0))) + t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.sin((0.5 * phi1)) * math.cos((0.5 * phi2))) - (math.cos((0.5 * phi1)) * math.sin((0.5 * phi2)))), 2.0) t_2 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + t_1)) tmp = 0 if (lambda2 <= -1.2e-5) or not (lambda2 <= 5.4): tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((-0.5 * lambda2)), 2.0))) + t_1))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(sin(Float64(0.5 * phi1)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + t_1)) tmp = 0.0 if ((lambda2 <= -1.2e-5) || !(lambda2 <= 5.4)) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(-0.5 * lambda2)) ^ 2.0))) + t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = ((sin((0.5 * phi1)) * cos((0.5 * phi2))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1)); tmp = 0.0; if ((lambda2 <= -1.2e-5) || ~((lambda2 <= 5.4))) tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin((-0.5 * lambda2)) ^ 2.0))) + t_1))))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.2e-5], N[Not[LessEqual[lambda2, 5.4]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + t\_1}\\
\mathbf{if}\;\lambda_2 \leq -1.2 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 5.4\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \lambda_2\right)}^{2}\right) + t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -1.2e-5 or 5.4000000000000004 < lambda2 Initial program 51.0%
div-sub51.0%
sin-diff52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
Applied egg-rr52.0%
div-sub51.0%
sin-diff52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
Applied egg-rr63.4%
fma-neg63.3%
*-commutative63.3%
*-commutative63.3%
*-commutative63.3%
distribute-rgt-neg-in63.3%
*-commutative63.3%
Simplified63.3%
Taylor expanded in lambda1 around 0 63.0%
if -1.2e-5 < lambda2 < 5.4000000000000004Initial program 77.1%
div-sub77.1%
sin-diff78.1%
div-inv78.1%
metadata-eval78.1%
div-inv78.1%
metadata-eval78.1%
div-inv78.1%
metadata-eval78.1%
div-inv78.1%
metadata-eval78.1%
Applied egg-rr78.1%
div-sub77.1%
sin-diff78.1%
div-inv78.1%
metadata-eval78.1%
div-inv78.1%
metadata-eval78.1%
div-inv78.1%
metadata-eval78.1%
div-inv78.1%
metadata-eval78.1%
Applied egg-rr98.1%
fma-neg98.1%
*-commutative98.1%
*-commutative98.1%
*-commutative98.1%
distribute-rgt-neg-in98.1%
*-commutative98.1%
Simplified98.1%
Taylor expanded in lambda2 around 0 98.1%
Final simplification79.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2
(pow
(-
(* (sin (* 0.5 phi1)) (cos (* 0.5 phi2)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 phi2))))
2.0))
(t_3 (sqrt (+ (* t_0 (* t_1 t_0)) t_2))))
(if (or (<= lambda1 -24000000.0) (not (<= lambda1 3.4e-11)))
(*
R
(*
2.0
(atan2
t_3
(sqrt
(+
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_1 (- (* 0.5 (cos (- lambda1 lambda2))) 0.5)))))))
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
1.0
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* -0.5 lambda2)) 2.0)))
t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = pow(((sin((0.5 * phi1)) * cos((0.5 * phi2))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))), 2.0);
double t_3 = sqrt(((t_0 * (t_1 * t_0)) + t_2));
double tmp;
if ((lambda1 <= -24000000.0) || !(lambda1 <= 3.4e-11)) {
tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) + (t_1 * ((0.5 * cos((lambda1 - lambda2))) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((-0.5 * lambda2)), 2.0))) + t_2)))));
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = ((sin((0.5d0 * phi1)) * cos((0.5d0 * phi2))) - (cos((0.5d0 * phi1)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_3 = sqrt(((t_0 * (t_1 * t_0)) + t_2))
if ((lambda1 <= (-24000000.0d0)) .or. (.not. (lambda1 <= 3.4d-11))) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) + (t_1 * ((0.5d0 * cos((lambda1 - lambda2))) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin(((-0.5d0) * lambda2)) ** 2.0d0))) + t_2)))))
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 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.pow(((Math.sin((0.5 * phi1)) * Math.cos((0.5 * phi2))) - (Math.cos((0.5 * phi1)) * Math.sin((0.5 * phi2)))), 2.0);
double t_3 = Math.sqrt(((t_0 * (t_1 * t_0)) + t_2));
double tmp;
if ((lambda1 <= -24000000.0) || !(lambda1 <= 3.4e-11)) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) + (t_1 * ((0.5 * Math.cos((lambda1 - lambda2))) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * lambda2)), 2.0))) + t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.pow(((math.sin((0.5 * phi1)) * math.cos((0.5 * phi2))) - (math.cos((0.5 * phi1)) * math.sin((0.5 * phi2)))), 2.0) t_3 = math.sqrt(((t_0 * (t_1 * t_0)) + t_2)) tmp = 0 if (lambda1 <= -24000000.0) or not (lambda1 <= 3.4e-11): tmp = R * (2.0 * math.atan2(t_3, math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) + (t_1 * ((0.5 * math.cos((lambda1 - lambda2))) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((-0.5 * lambda2)), 2.0))) + t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(Float64(sin(Float64(0.5 * phi1)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_3 = sqrt(Float64(Float64(t_0 * Float64(t_1 * t_0)) + t_2)) tmp = 0.0 if ((lambda1 <= -24000000.0) || !(lambda1 <= 3.4e-11)) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) + Float64(t_1 * Float64(Float64(0.5 * cos(Float64(lambda1 - lambda2))) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(-0.5 * lambda2)) ^ 2.0))) + t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = ((sin((0.5 * phi1)) * cos((0.5 * phi2))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))) ^ 2.0; t_3 = sqrt(((t_0 * (t_1 * t_0)) + t_2)); tmp = 0.0; if ((lambda1 <= -24000000.0) || ~((lambda1 <= 3.4e-11))) tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) + (t_1 * ((0.5 * cos((lambda1 - lambda2))) - 0.5)))))); else tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin((-0.5 * lambda2)) ^ 2.0))) + t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -24000000.0], N[Not[LessEqual[lambda1, 3.4e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_3 := \sqrt{t\_0 \cdot \left(t\_1 \cdot t\_0\right) + t\_2}\\
\mathbf{if}\;\lambda_1 \leq -24000000 \lor \neg \left(\lambda_1 \leq 3.4 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) + t\_1 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \lambda_2\right)}^{2}\right) + t\_2\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -2.4e7 or 3.3999999999999999e-11 < lambda1 Initial program 49.5%
div-sub49.5%
sin-diff50.7%
div-inv50.7%
metadata-eval50.7%
div-inv50.7%
metadata-eval50.7%
div-inv50.7%
metadata-eval50.7%
div-inv50.7%
metadata-eval50.7%
Applied egg-rr50.7%
associate--r+50.7%
sub-neg50.7%
div-inv50.7%
metadata-eval50.7%
associate-*l*50.7%
sqr-sin-a50.7%
cos-250.7%
cos-sum50.7%
add-log-exp3.2%
add-log-exp3.2%
Applied egg-rr50.7%
if -2.4e7 < lambda1 < 3.3999999999999999e-11Initial program 76.3%
div-sub76.3%
sin-diff77.2%
div-inv77.2%
metadata-eval77.2%
div-inv77.2%
metadata-eval77.2%
div-inv77.2%
metadata-eval77.2%
div-inv77.2%
metadata-eval77.2%
Applied egg-rr77.2%
div-sub76.3%
sin-diff77.2%
div-inv77.2%
metadata-eval77.2%
div-inv77.2%
metadata-eval77.2%
div-inv77.2%
metadata-eval77.2%
div-inv77.2%
metadata-eval77.2%
Applied egg-rr98.0%
fma-neg98.0%
*-commutative98.0%
*-commutative98.0%
*-commutative98.0%
distribute-rgt-neg-in98.0%
*-commutative98.0%
Simplified98.0%
Taylor expanded in lambda1 around 0 97.4%
Final simplification74.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow
(-
(* (sin (* 0.5 phi1)) (cos (* 0.5 phi2)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 phi2))))
2.0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(((sin((0.5 * phi1)) * cos((0.5 * phi2))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))), 2.0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (((sin((0.5d0 * phi1)) * cos((0.5d0 * phi2))) - (cos((0.5d0 * phi1)) * sin((0.5d0 * phi2)))) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(((Math.sin((0.5 * phi1)) * Math.cos((0.5 * phi2))) - (Math.cos((0.5 * phi1)) * Math.sin((0.5 * phi2)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(((math.sin((0.5 * phi1)) * math.cos((0.5 * phi2))) - (math.cos((0.5 * phi1)) * math.sin((0.5 * phi2)))), 2.0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (Float64(Float64(sin(Float64(0.5 * phi1)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (((sin((0.5 * phi1)) * cos((0.5 * phi2))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))) ^ 2.0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr79.5%
Final simplification79.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* t_0 t_1))
(pow
(-
(* (sin (* 0.5 phi1)) (cos (* 0.5 phi2)))
(* (cos (* 0.5 phi1)) (sin (* 0.5 phi2))))
2.0)))
(sqrt
(+
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_0 (- (* 0.5 (cos (- lambda1 lambda2))) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + pow(((sin((0.5 * phi1)) * cos((0.5 * phi2))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))), 2.0))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) + (t_0 * ((0.5 * cos((lambda1 - lambda2))) - 0.5))))));
}
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
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (((sin((0.5d0 * phi1)) * cos((0.5d0 * phi2))) - (cos((0.5d0 * phi1)) * sin((0.5d0 * phi2)))) ** 2.0d0))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) + (t_0 * ((0.5d0 * cos((lambda1 - lambda2))) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_1)) + Math.pow(((Math.sin((0.5 * phi1)) * Math.cos((0.5 * phi2))) - (Math.cos((0.5 * phi1)) * Math.sin((0.5 * phi2)))), 2.0))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) + (t_0 * ((0.5 * Math.cos((lambda1 - lambda2))) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_1)) + math.pow(((math.sin((0.5 * phi1)) * math.cos((0.5 * phi2))) - (math.cos((0.5 * phi1)) * math.sin((0.5 * phi2)))), 2.0))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) + (t_0 * ((0.5 * math.cos((lambda1 - lambda2))) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (Float64(Float64(sin(Float64(0.5 * phi1)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) ^ 2.0))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) + Float64(t_0 * Float64(Float64(0.5 * cos(Float64(lambda1 - lambda2))) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (((sin((0.5 * phi1)) * cos((0.5 * phi2))) - (cos((0.5 * phi1)) * sin((0.5 * phi2)))) ^ 2.0))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) + (t_0 * ((0.5 * cos((lambda1 - lambda2))) - 0.5)))))); 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_1\right) + {\left(\sin \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) + t\_0 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
div-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
associate--r+64.1%
sub-neg64.1%
div-inv64.1%
metadata-eval64.1%
associate-*l*64.1%
sqr-sin-a64.2%
cos-264.2%
cos-sum64.2%
add-log-exp18.8%
add-log-exp18.8%
Applied egg-rr64.2%
Final simplification64.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (or (<= phi1 -7500000000000.0) (not (<= phi1 1.12e+18)))
(*
R
(*
2.0
(atan2 t_1 (sqrt (- (pow (cos (* 0.5 phi1)) 2.0) (* (cos phi1) t_2))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi1 <= -7500000000000.0) || !(phi1 <= 1.12e+18)) {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((0.5 * phi1)), 2.0) - (cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)))));
}
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) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if ((phi1 <= (-7500000000000.0d0)) .or. (.not. (phi1 <= 1.12d+18))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((0.5d0 * phi1)) ** 2.0d0) - (cos(phi1) * t_2)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))))
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 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi1 <= -7500000000000.0) || !(phi1 <= 1.12e+18)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((0.5 * phi1)), 2.0) - (Math.cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if (phi1 <= -7500000000000.0) or not (phi1 <= 1.12e+18): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((0.5 * phi1)), 2.0) - (math.cos(phi1) * t_2))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if ((phi1 <= -7500000000000.0) || !(phi1 <= 1.12e+18)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(0.5 * phi1)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if ((phi1 <= -7500000000000.0) || ~((phi1 <= 1.12e+18))) tmp = R * (2.0 * atan2(t_1, sqrt(((cos((0.5 * phi1)) ^ 2.0) - (cos(phi1) * t_2))))); else tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -7500000000000.0], N[Not[LessEqual[phi1, 1.12e+18]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -7500000000000 \lor \neg \left(\phi_1 \leq 1.12 \cdot 10^{+18}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_2}}\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12 or 1.12e18 < phi1 Initial program 44.3%
Taylor expanded in phi2 around 0 44.9%
+-commutative44.9%
associate--r+44.9%
unpow244.9%
1-sub-sin45.0%
unpow245.0%
*-commutative45.0%
Simplified45.0%
if -7.5e12 < phi1 < 1.12e18Initial program 78.1%
Taylor expanded in phi1 around 0 78.2%
+-commutative78.2%
associate--r+78.2%
unpow278.2%
1-sub-sin78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
Final simplification63.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (<= phi1 -7500000000000.0)
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* 0.5 phi1)) 2.0)))))))
(if (<= phi1 1.12e+18)
(*
R
(*
2.0
(atan2
t_2
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt (- (pow (cos (* 0.5 phi1)) 2.0) (* (cos phi1) t_1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((0.5 * phi1)), 2.0))))));
} else if (phi1 <= 1.12e+18) {
tmp = R * (2.0 * atan2(t_2, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((pow(cos((0.5 * phi1)), 2.0) - (cos(phi1) * t_1)))));
}
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) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_2 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if (phi1 <= (-7500000000000.0d0)) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - ((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((0.5d0 * phi1)) ** 2.0d0))))))
else if (phi1 <= 1.12d+18) then
tmp = r * (2.0d0 * atan2(t_2, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_1)))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt(((cos((0.5d0 * phi1)) ** 2.0d0) - (cos(phi1) * t_1)))))
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 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((0.5 * phi1)), 2.0))))));
} else if (phi1 <= 1.12e+18) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((Math.pow(Math.cos((0.5 * phi1)), 2.0) - (Math.cos(phi1) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_2 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if phi1 <= -7500000000000.0: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((0.5 * phi1)), 2.0)))))) elif phi1 <= 1.12e+18: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((math.pow(math.cos((0.5 * phi1)), 2.0) - (math.cos(phi1) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_2 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if (phi1 <= -7500000000000.0) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(0.5 * phi1)) ^ 2.0))))))); elseif (phi1 <= 1.12e+18) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64((cos(Float64(0.5 * phi1)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_2 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if (phi1 <= -7500000000000.0) tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((0.5 * phi1)) ^ 2.0)))))); elseif (phi1 <= 1.12e+18) tmp = R * (2.0 * atan2(t_2, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); else tmp = R * (2.0 * atan2(t_2, sqrt(((cos((0.5 * phi1)) ^ 2.0) - (cos(phi1) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -7500000000000.0], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.12e+18], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_2 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\phi_1 \leq -7500000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.12 \cdot 10^{+18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot t\_1}}\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12Initial program 43.4%
Taylor expanded in phi2 around 0 43.7%
if -7.5e12 < phi1 < 1.12e18Initial program 78.1%
Taylor expanded in phi1 around 0 78.2%
+-commutative78.2%
associate--r+78.2%
unpow278.2%
1-sub-sin78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
if 1.12e18 < phi1 Initial program 45.1%
Taylor expanded in phi2 around 0 45.9%
+-commutative45.9%
associate--r+45.9%
unpow245.9%
1-sub-sin46.1%
unpow246.1%
*-commutative46.1%
Simplified46.1%
Final simplification63.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) t_1))
(t_3 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_4 (sqrt (+ t_0 (* t_2 (sin (* 0.5 lambda1)))))))
(if (<= phi1 -7500000000000.0)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* 0.5 phi1)) 2.0)))))))
(if (<= phi1 1.12e+18)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 t_2) t_0))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_3))))))
(*
R
(*
2.0
(atan2
t_4
(sqrt (- (pow (cos (* 0.5 phi1)) 2.0) (* (cos phi1) t_3))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * t_1;
double t_3 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_4 = sqrt((t_0 + (t_2 * sin((0.5 * lambda1)))));
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((0.5 * phi1)), 2.0))))));
} else if (phi1 <= 1.12e+18) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * t_2) + t_0)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_3)))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((pow(cos((0.5 * phi1)), 2.0) - (cos(phi1) * t_3)))));
}
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) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * t_1
t_3 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_4 = sqrt((t_0 + (t_2 * sin((0.5d0 * lambda1)))))
if (phi1 <= (-7500000000000.0d0)) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((0.5d0 * phi1)) ** 2.0d0))))))
else if (phi1 <= 1.12d+18) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * t_2) + t_0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_3)))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt(((cos((0.5d0 * phi1)) ** 2.0d0) - (cos(phi1) * t_3)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * t_1;
double t_3 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_4 = Math.sqrt((t_0 + (t_2 * Math.sin((0.5 * lambda1)))));
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((0.5 * phi1)), 2.0))))));
} else if (phi1 <= 1.12e+18) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * t_2) + t_0)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_3)))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((Math.pow(Math.cos((0.5 * phi1)), 2.0) - (Math.cos(phi1) * t_3)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * t_1 t_3 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_4 = math.sqrt((t_0 + (t_2 * math.sin((0.5 * lambda1))))) tmp = 0 if phi1 <= -7500000000000.0: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((0.5 * phi1)), 2.0)))))) elif phi1 <= 1.12e+18: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * t_2) + t_0)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_3))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((math.pow(math.cos((0.5 * phi1)), 2.0) - (math.cos(phi1) * t_3))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * t_1) t_3 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_4 = sqrt(Float64(t_0 + Float64(t_2 * sin(Float64(0.5 * lambda1))))) tmp = 0.0 if (phi1 <= -7500000000000.0) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(0.5 * phi1)) ^ 2.0))))))); elseif (phi1 <= 1.12e+18) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * t_2) + t_0)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_3)))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64((cos(Float64(0.5 * phi1)) ^ 2.0) - Float64(cos(phi1) * t_3)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * t_1; t_3 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_4 = sqrt((t_0 + (t_2 * sin((0.5 * lambda1))))); tmp = 0.0; if (phi1 <= -7500000000000.0) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((0.5 * phi1)) ^ 2.0)))))); elseif (phi1 <= 1.12e+18) tmp = R * (2.0 * atan2(sqrt(((t_1 * t_2) + t_0)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_3))))); else tmp = R * (2.0 * atan2(t_4, sqrt(((cos((0.5 * phi1)) ^ 2.0) - (cos(phi1) * t_3))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -7500000000000.0], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.12e+18], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * t$95$2), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\\
t_3 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_4 := \sqrt{t\_0 + t\_2 \cdot \sin \left(0.5 \cdot \lambda_1\right)}\\
\mathbf{if}\;\phi_1 \leq -7500000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.12 \cdot 10^{+18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot t\_2 + t\_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot t\_3}}\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12Initial program 43.4%
Taylor expanded in lambda2 around 0 30.9%
Taylor expanded in phi2 around 0 31.1%
if -7.5e12 < phi1 < 1.12e18Initial program 78.1%
Taylor expanded in phi1 around 0 78.2%
+-commutative78.2%
associate--r+78.2%
unpow278.2%
1-sub-sin78.3%
unpow278.3%
*-commutative78.3%
Simplified78.3%
if 1.12e18 < phi1 Initial program 45.1%
Taylor expanded in lambda2 around 0 31.4%
Taylor expanded in phi2 around 0 32.3%
+-commutative45.9%
associate--r+45.9%
unpow245.9%
1-sub-sin46.1%
unpow246.1%
*-commutative46.1%
Simplified32.3%
Final simplification57.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) t_1)))
(if (or (<= phi1 -7500000000000.0) (not (<= phi1 38000.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_2 (sin (* 0.5 lambda1)))))
(sqrt (- (pow (cos (* 0.5 phi1)) 2.0) (* (cos phi1) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 t_2) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * t_1;
double tmp;
if ((phi1 <= -7500000000000.0) || !(phi1 <= 38000.0)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * sin((0.5 * lambda1))))), sqrt((pow(cos((0.5 * phi1)), 2.0) - (cos(phi1) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * t_2) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (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) :: t_2
real(8) :: tmp
t_0 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * t_1
if ((phi1 <= (-7500000000000.0d0)) .or. (.not. (phi1 <= 38000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_2 * sin((0.5d0 * lambda1))))), sqrt(((cos((0.5d0 * phi1)) ** 2.0d0) - (cos(phi1) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (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.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * t_1;
double tmp;
if ((phi1 <= -7500000000000.0) || !(phi1 <= 38000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * Math.sin((0.5 * lambda1))))), Math.sqrt((Math.pow(Math.cos((0.5 * phi1)), 2.0) - (Math.cos(phi1) * t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * t_1 tmp = 0 if (phi1 <= -7500000000000.0) or not (phi1 <= 38000.0): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * math.sin((0.5 * lambda1))))), math.sqrt((math.pow(math.cos((0.5 * phi1)), 2.0) - (math.cos(phi1) * t_0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * t_1) tmp = 0.0 if ((phi1 <= -7500000000000.0) || !(phi1 <= 38000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_2 * sin(Float64(0.5 * lambda1))))), sqrt(Float64((cos(Float64(0.5 * phi1)) ^ 2.0) - Float64(cos(phi1) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * t_1; tmp = 0.0; if ((phi1 <= -7500000000000.0) || ~((phi1 <= 38000.0))) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_2 * sin((0.5 * lambda1))))), sqrt(((cos((0.5 * phi1)) ^ 2.0) - (cos(phi1) * t_0))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * t_2) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi1, -7500000000000.0], N[Not[LessEqual[phi1, 38000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$2 * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\\
\mathbf{if}\;\phi_1 \leq -7500000000000 \lor \neg \left(\phi_1 \leq 38000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_2 \cdot \sin \left(0.5 \cdot \lambda_1\right)}}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_0}}\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12 or 38000 < phi1 Initial program 43.7%
Taylor expanded in lambda2 around 0 30.9%
Taylor expanded in phi2 around 0 31.4%
+-commutative44.3%
associate--r+44.3%
unpow244.3%
1-sub-sin44.3%
unpow244.3%
*-commutative44.3%
Simplified31.4%
if -7.5e12 < phi1 < 38000Initial program 79.4%
Taylor expanded in phi1 around 0 79.4%
+-commutative79.4%
associate--r+79.5%
unpow279.5%
1-sub-sin79.5%
unpow279.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in phi1 around 0 78.8%
Final simplification57.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sin (* -0.5 lambda2))))
(if (or (<= phi1 -2.3e+27) (not (<= phi1 650000.0)))
(*
(atan2
(sqrt
(fma
t_0
(* t_2 (+ t_2 (* lambda1 (cos (* -0.5 lambda2)))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))
(* R 2.0))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_1)) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sin((-0.5 * lambda2));
double tmp;
if ((phi1 <= -2.3e+27) || !(phi1 <= 650000.0)) {
tmp = atan2(sqrt(fma(t_0, (t_2 * (t_2 + (lambda1 * cos((-0.5 * lambda2))))), pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))) * (R * 2.0);
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(-0.5 * lambda2)) tmp = 0.0 if ((phi1 <= -2.3e+27) || !(phi1 <= 650000.0)) tmp = Float64(atan(sqrt(fma(t_0, Float64(t_2 * Float64(t_2 + Float64(lambda1 * cos(Float64(-0.5 * lambda2))))), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))) * Float64(R * 2.0)); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -2.3e+27], N[Not[LessEqual[phi1, 650000.0]], $MachinePrecision]], N[(N[ArcTan[N[Sqrt[N[(t$95$0 * N[(t$95$2 * N[(t$95$2 + N[(lambda1 * N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sin \left(-0.5 \cdot \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.3 \cdot 10^{+27} \lor \neg \left(\phi_1 \leq 650000\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_0, t\_2 \cdot \left(t\_2 + \lambda_1 \cdot \cos \left(-0.5 \cdot \lambda_2\right)\right), {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}} \cdot \left(R \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_1\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -2.3000000000000001e27 or 6.5e5 < phi1 Initial program 43.8%
associate-*r*43.8%
*-commutative43.8%
Simplified43.8%
Taylor expanded in lambda1 around 0 38.4%
+-commutative38.4%
unpow238.4%
associate-*r*38.4%
distribute-rgt-out38.4%
Simplified38.4%
Taylor expanded in lambda1 around 0 35.3%
+-commutative38.4%
unpow238.4%
associate-*r*38.4%
distribute-rgt-out38.4%
Simplified35.3%
Taylor expanded in lambda2 around 0 25.2%
if -2.3000000000000001e27 < phi1 < 6.5e5Initial program 78.3%
Taylor expanded in phi1 around 0 77.8%
+-commutative77.8%
associate--r+77.8%
unpow277.8%
1-sub-sin77.9%
unpow277.9%
*-commutative77.9%
Simplified77.9%
Taylor expanded in phi1 around 0 77.1%
Final simplification54.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) t_0))
(t_2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (sin (* 0.5 lambda1))))))
(t_3 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (<= phi1 -7500000000000.0)
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* 0.5 phi1)) 2.0)))))))
(if (<= phi1 38000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_3))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt (- (pow (cos (* 0.5 phi1)) 2.0) (* (cos phi1) t_3))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * t_0;
double t_2 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * sin((0.5 * lambda1)))));
double t_3 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((0.5 * phi1)), 2.0))))));
} else if (phi1 <= 38000.0) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_3)))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((pow(cos((0.5 * phi1)), 2.0) - (cos(phi1) * t_3)))));
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * t_0
t_2 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * sin((0.5d0 * lambda1)))))
t_3 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if (phi1 <= (-7500000000000.0d0)) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - ((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((0.5d0 * phi1)) ** 2.0d0))))))
else if (phi1 <= 38000.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_3)))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt(((cos((0.5d0 * phi1)) ** 2.0d0) - (cos(phi1) * t_3)))))
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 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * t_0;
double t_2 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * Math.sin((0.5 * lambda1)))));
double t_3 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((0.5 * phi1)), 2.0))))));
} else if (phi1 <= 38000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_3)))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((Math.pow(Math.cos((0.5 * phi1)), 2.0) - (Math.cos(phi1) * t_3)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * t_0 t_2 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * math.sin((0.5 * lambda1))))) t_3 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if phi1 <= -7500000000000.0: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((0.5 * phi1)), 2.0)))))) elif phi1 <= 38000.0: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_3))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((math.pow(math.cos((0.5 * phi1)), 2.0) - (math.cos(phi1) * t_3))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * t_0) t_2 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * sin(Float64(0.5 * lambda1))))) t_3 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if (phi1 <= -7500000000000.0) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(0.5 * phi1)) ^ 2.0))))))); elseif (phi1 <= 38000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_3)))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64((cos(Float64(0.5 * phi1)) ^ 2.0) - Float64(cos(phi1) * t_3)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * t_0; t_2 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * sin((0.5 * lambda1))))); t_3 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if (phi1 <= -7500000000000.0) tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((0.5 * phi1)) ^ 2.0)))))); elseif (phi1 <= 38000.0) tmp = R * (2.0 * atan2(sqrt(((t_0 * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_3))))); else tmp = R * (2.0 * atan2(t_2, sqrt(((cos((0.5 * phi1)) ^ 2.0) - (cos(phi1) * t_3))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -7500000000000.0], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 38000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\\
t_2 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1 \cdot \sin \left(0.5 \cdot \lambda_1\right)}\\
t_3 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -7500000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 38000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{{\cos \left(0.5 \cdot \phi_1\right)}^{2} - \cos \phi_1 \cdot t\_3}}\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12Initial program 43.4%
Taylor expanded in lambda2 around 0 30.9%
Taylor expanded in phi2 around 0 31.1%
if -7.5e12 < phi1 < 38000Initial program 79.4%
Taylor expanded in phi1 around 0 79.4%
+-commutative79.4%
associate--r+79.5%
unpow279.5%
1-sub-sin79.5%
unpow279.5%
*-commutative79.5%
Simplified79.5%
Taylor expanded in phi1 around 0 78.8%
if 38000 < phi1 Initial program 43.9%
Taylor expanded in lambda2 around 0 30.8%
Taylor expanded in phi2 around 0 31.7%
+-commutative44.7%
associate--r+44.7%
unpow244.7%
1-sub-sin44.8%
unpow244.8%
*-commutative44.8%
Simplified31.8%
Final simplification57.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(+ (- 1.0 t_2) (* t_0 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) + (t_0 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) + (t_0 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 - t\_2\right) + t\_0 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
associate-*l*63.1%
Simplified63.1%
sin-mult63.1%
cos-sum63.1%
cos-263.1%
div-sub63.1%
+-inverses63.1%
Applied egg-rr63.1%
cos-063.1%
metadata-eval63.1%
Simplified63.1%
Final simplification63.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (or (<= phi2 -4.5e-5) (not (<= phi2 1.7e-6)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos phi2) 2.0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(pow
(+ (sin (* 0.5 phi1)) (* -0.5 (* phi2 (cos (* 0.5 phi1)))))
2.0)))
(sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi2 <= -4.5e-5) || !(phi2 <= 1.7e-6)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos(phi2) / 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow((sin((0.5 * phi1)) + (-0.5 * (phi2 * cos((0.5 * phi1))))), 2.0))), sqrt((1.0 - t_2))));
}
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) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if ((phi2 <= (-4.5d-5)) .or. (.not. (phi2 <= 1.7d-6))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos(phi2) / 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + ((sin((0.5d0 * phi1)) + ((-0.5d0) * (phi2 * cos((0.5d0 * phi1))))) ** 2.0d0))), sqrt((1.0d0 - t_2))))
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 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi2 <= -4.5e-5) || !(phi2 <= 1.7e-6)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos(phi2) / 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow((Math.sin((0.5 * phi1)) + (-0.5 * (phi2 * Math.cos((0.5 * phi1))))), 2.0))), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if (phi2 <= -4.5e-5) or not (phi2 <= 1.7e-6): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos(phi2) / 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow((math.sin((0.5 * phi1)) + (-0.5 * (phi2 * math.cos((0.5 * phi1))))), 2.0))), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if ((phi2 <= -4.5e-5) || !(phi2 <= 1.7e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(phi2) / 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (Float64(sin(Float64(0.5 * phi1)) + Float64(-0.5 * Float64(phi2 * cos(Float64(0.5 * phi1))))) ^ 2.0))), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if ((phi2 <= -4.5e-5) || ~((phi2 <= 1.7e-6))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos(phi2) / 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + ((sin((0.5 * phi1)) + (-0.5 * (phi2 * cos((0.5 * phi1))))) ^ 2.0))), sqrt((1.0 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.5e-5], N[Not[LessEqual[phi2, 1.7e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[phi2], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -4.5 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 1.7 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \phi_2}{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\left(\sin \left(0.5 \cdot \phi_1\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(0.5 \cdot \phi_1\right)\right)\right)}^{2}}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if phi2 < -4.50000000000000028e-5 or 1.70000000000000003e-6 < phi2 Initial program 48.5%
Taylor expanded in phi1 around 0 48.9%
+-commutative48.9%
associate--r+48.9%
unpow248.9%
1-sub-sin49.0%
unpow249.0%
*-commutative49.0%
Simplified49.0%
unpow249.0%
sin-mult48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
Applied egg-rr48.9%
div-sub48.9%
+-inverses48.9%
cos-048.9%
metadata-eval48.9%
distribute-lft-out48.9%
metadata-eval48.9%
*-rgt-identity48.9%
Simplified48.9%
Taylor expanded in phi1 around 0 48.9%
cos-neg48.9%
Simplified48.9%
if -4.50000000000000028e-5 < phi2 < 1.70000000000000003e-6Initial program 82.4%
Taylor expanded in phi1 around 0 56.7%
+-commutative56.7%
associate--r+56.7%
unpow256.7%
1-sub-sin56.7%
unpow256.7%
*-commutative56.7%
Simplified56.7%
Taylor expanded in phi2 around 0 56.3%
Taylor expanded in phi2 around 0 56.3%
Final simplification52.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_2 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_3 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))))
(if (<= phi2 -4.2e-5)
(*
R
(* 2.0 (atan2 (sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0)))) t_3)))
(if (<= phi2 1.9e-6)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_2
(pow
(+ (sin (* 0.5 phi1)) (* -0.5 (* phi2 (cos (* 0.5 phi1)))))
2.0)))
(sqrt (- 1.0 t_1)))))
(* R (* 2.0 (atan2 (sqrt (+ t_2 (- 0.5 (/ (cos phi2) 2.0)))) t_3)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_3 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)));
double tmp;
if (phi2 <= -4.2e-5) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_3));
} else if (phi2 <= 1.9e-6) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow((sin((0.5 * phi1)) + (-0.5 * (phi2 * cos((0.5 * phi1))))), 2.0))), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos(phi2) / 2.0)))), t_3));
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_3 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_1)))
if (phi2 <= (-4.2d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), t_3))
else if (phi2 <= 1.9d-6) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + ((sin((0.5d0 * phi1)) + ((-0.5d0) * (phi2 * cos((0.5d0 * phi1))))) ** 2.0d0))), sqrt((1.0d0 - t_1))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos(phi2) / 2.0d0)))), t_3))
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 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_3 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)));
double tmp;
if (phi2 <= -4.2e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_3));
} else if (phi2 <= 1.9e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((Math.sin((0.5 * phi1)) + (-0.5 * (phi2 * Math.cos((0.5 * phi1))))), 2.0))), Math.sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos(phi2) / 2.0)))), t_3));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_2 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_3 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))) tmp = 0 if phi2 <= -4.2e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_3)) elif phi2 <= 1.9e-6: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((math.sin((0.5 * phi1)) + (-0.5 * (phi2 * math.cos((0.5 * phi1))))), 2.0))), math.sqrt((1.0 - t_1)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos(phi2) / 2.0)))), t_3)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_2 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_3 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1))) tmp = 0.0 if (phi2 <= -4.2e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_3))); elseif (phi2 <= 1.9e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(sin(Float64(0.5 * phi1)) + Float64(-0.5 * Float64(phi2 * cos(Float64(0.5 * phi1))))) ^ 2.0))), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(phi2) / 2.0)))), t_3))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_3 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))); tmp = 0.0; if (phi2 <= -4.2e-5) tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_3)); elseif (phi2 <= 1.9e-6) tmp = R * (2.0 * atan2(sqrt((t_2 + ((sin((0.5 * phi1)) + (-0.5 * (phi2 * cos((0.5 * phi1))))) ^ 2.0))), sqrt((1.0 - t_1)))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos(phi2) / 2.0)))), t_3)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.2e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.9e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[phi2], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_2 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_3 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_1}\\
\mathbf{if}\;\phi_2 \leq -4.2 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_3}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\left(\sin \left(0.5 \cdot \phi_1\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(0.5 \cdot \phi_1\right)\right)\right)}^{2}}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \phi_2}{2}\right)}}{t\_3}\right)\\
\end{array}
\end{array}
if phi2 < -4.19999999999999977e-5Initial program 48.2%
Taylor expanded in phi1 around 0 49.0%
+-commutative49.0%
associate--r+49.0%
unpow249.0%
1-sub-sin49.1%
unpow249.1%
*-commutative49.1%
Simplified49.1%
unpow249.1%
sin-mult49.1%
div-inv49.1%
metadata-eval49.1%
div-inv49.1%
metadata-eval49.1%
div-inv49.1%
metadata-eval49.1%
div-inv49.1%
metadata-eval49.1%
Applied egg-rr49.1%
div-sub49.1%
+-inverses49.1%
cos-049.1%
metadata-eval49.1%
distribute-lft-out49.1%
metadata-eval49.1%
*-rgt-identity49.1%
Simplified49.1%
if -4.19999999999999977e-5 < phi2 < 1.9e-6Initial program 82.4%
Taylor expanded in phi1 around 0 56.7%
+-commutative56.7%
associate--r+56.7%
unpow256.7%
1-sub-sin56.7%
unpow256.7%
*-commutative56.7%
Simplified56.7%
Taylor expanded in phi2 around 0 56.3%
Taylor expanded in phi2 around 0 56.3%
if 1.9e-6 < phi2 Initial program 48.9%
Taylor expanded in phi1 around 0 48.8%
+-commutative48.8%
associate--r+48.8%
unpow248.8%
1-sub-sin48.8%
unpow248.8%
*-commutative48.8%
Simplified48.8%
unpow248.8%
sin-mult48.8%
div-inv48.8%
metadata-eval48.8%
div-inv48.8%
metadata-eval48.8%
div-inv48.8%
metadata-eval48.8%
div-inv48.8%
metadata-eval48.8%
Applied egg-rr48.8%
div-sub48.8%
+-inverses48.8%
cos-048.8%
metadata-eval48.8%
distribute-lft-out48.8%
metadata-eval48.8%
*-rgt-identity48.8%
Simplified48.8%
Taylor expanded in phi1 around 0 48.9%
cos-neg48.9%
Simplified48.9%
Final simplification52.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* -0.5 lambda2))))
(if (or (<= lambda1 -2.6e-6) (not (<= lambda1 8.2e-64)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* 0.5 phi1)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
(atan2
(sqrt
(fma
(* (cos phi1) (cos phi2))
(* t_0 (+ t_0 (* lambda1 (cos (* -0.5 lambda2)))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))
(* R 2.0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((-0.5 * lambda2));
double tmp;
if ((lambda1 <= -2.6e-6) || !(lambda1 <= 8.2e-64)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((0.5 * phi1)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = atan2(sqrt(fma((cos(phi1) * cos(phi2)), (t_0 * (t_0 + (lambda1 * cos((-0.5 * lambda2))))), pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))) * (R * 2.0);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * lambda2)) tmp = 0.0 if ((lambda1 <= -2.6e-6) || !(lambda1 <= 8.2e-64)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(0.5 * phi1)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(atan(sqrt(fma(Float64(cos(phi1) * cos(phi2)), Float64(t_0 * Float64(t_0 + Float64(lambda1 * cos(Float64(-0.5 * lambda2))))), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))) * Float64(R * 2.0)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -2.6e-6], N[Not[LessEqual[lambda1, 8.2e-64]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * N[(t$95$0 + N[(lambda1 * N[Cos[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(-0.5 \cdot \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -2.6 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 8.2 \cdot 10^{-64}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(0.5 \cdot \phi_1\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_0 \cdot \left(t\_0 + \lambda_1 \cdot \cos \left(-0.5 \cdot \lambda_2\right)\right), {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}} \cdot \left(R \cdot 2\right)\\
\end{array}
\end{array}
if lambda1 < -2.60000000000000009e-6 or 8.2000000000000001e-64 < lambda1 Initial program 51.7%
Taylor expanded in phi1 around 0 47.2%
+-commutative47.2%
associate--r+47.2%
unpow247.2%
1-sub-sin47.2%
unpow247.2%
*-commutative47.2%
Simplified47.2%
Taylor expanded in phi2 around 0 35.9%
Taylor expanded in phi2 around 0 36.5%
if -2.60000000000000009e-6 < lambda1 < 8.2000000000000001e-64Initial program 77.3%
associate-*r*77.3%
*-commutative77.3%
Simplified77.2%
Taylor expanded in lambda1 around 0 76.4%
+-commutative76.4%
unpow276.4%
associate-*r*76.4%
distribute-rgt-out76.4%
Simplified76.4%
Taylor expanded in lambda1 around 0 76.4%
+-commutative76.4%
unpow276.4%
associate-*r*76.4%
distribute-rgt-out76.4%
Simplified76.4%
Taylor expanded in lambda2 around 0 45.9%
Final simplification40.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (+ (sin (* 0.5 phi1)) (* -0.5 (* phi2 (cos (* 0.5 phi1))))) 2.0)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow((sin((0.5 * phi1)) + (-0.5 * (phi2 * cos((0.5 * phi1))))), 2.0))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + ((sin((0.5d0 * phi1)) + ((-0.5d0) * (phi2 * cos((0.5d0 * phi1))))) ** 2.0d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow((Math.sin((0.5 * phi1)) + (-0.5 * (phi2 * Math.cos((0.5 * phi1))))), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow((math.sin((0.5 * phi1)) + (-0.5 * (phi2 * math.cos((0.5 * phi1))))), 2.0))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (Float64(sin(Float64(0.5 * phi1)) + Float64(-0.5 * Float64(phi2 * cos(Float64(0.5 * phi1))))) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + ((sin((0.5 * phi1)) + (-0.5 * (phi2 * cos((0.5 * phi1))))) ^ 2.0))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\left(\sin \left(0.5 \cdot \phi_1\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(0.5 \cdot \phi_1\right)\right)\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 63.1%
Taylor expanded in phi1 around 0 52.2%
+-commutative52.2%
associate--r+52.2%
unpow252.2%
1-sub-sin52.3%
unpow252.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in phi2 around 0 35.5%
Taylor expanded in phi2 around 0 35.4%
Final simplification35.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* 0.25 (pow phi2 2.0))
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt(((0.25 * pow(phi2, 2.0)) + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((0.25d0 * (phi2 ** 2.0d0)) + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt(((0.25 * Math.pow(phi2, 2.0)) + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt(((0.25 * math.pow(phi2, 2.0)) + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.25 * (phi2 ^ 2.0)) + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((0.25 * (phi2 ^ 2.0)) + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.25 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{0.25 \cdot {\phi_2}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 63.1%
Taylor expanded in phi1 around 0 52.2%
+-commutative52.2%
associate--r+52.2%
unpow252.2%
1-sub-sin52.3%
unpow252.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in phi2 around 0 35.5%
Taylor expanded in phi1 around 0 34.2%
Final simplification34.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 63.1%
Taylor expanded in phi1 around 0 52.2%
+-commutative52.2%
associate--r+52.2%
unpow252.2%
1-sub-sin52.3%
unpow252.3%
*-commutative52.3%
Simplified52.3%
unpow252.3%
sin-mult49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
Applied egg-rr49.0%
div-sub49.0%
+-inverses49.0%
cos-049.0%
metadata-eval49.0%
distribute-lft-out49.0%
metadata-eval49.0%
*-rgt-identity49.0%
Simplified49.0%
Taylor expanded in phi2 around 0 32.6%
Final simplification32.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* 0.5 phi1)))
(t_1
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))
(t_2 (sin (* 0.5 phi1))))
(if (<= phi2 1.55e-75)
(* R (* 2.0 (atan2 (+ t_2 (* -0.5 (* phi2 t_0))) t_1)))
(* R (* 2.0 (atan2 (* phi2 (- (* 0.5 t_0) (/ t_2 phi2))) t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((0.5 * phi1));
double t_1 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_2 = sin((0.5 * phi1));
double tmp;
if (phi2 <= 1.55e-75) {
tmp = R * (2.0 * atan2((t_2 + (-0.5 * (phi2 * t_0))), t_1));
} else {
tmp = R * (2.0 * atan2((phi2 * ((0.5 * t_0) - (t_2 / phi2))), t_1));
}
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) :: t_2
real(8) :: tmp
t_0 = cos((0.5d0 * phi1))
t_1 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))
t_2 = sin((0.5d0 * phi1))
if (phi2 <= 1.55d-75) then
tmp = r * (2.0d0 * atan2((t_2 + ((-0.5d0) * (phi2 * t_0))), t_1))
else
tmp = r * (2.0d0 * atan2((phi2 * ((0.5d0 * t_0) - (t_2 / phi2))), t_1))
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((0.5 * phi1));
double t_1 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_2 = Math.sin((0.5 * phi1));
double tmp;
if (phi2 <= 1.55e-75) {
tmp = R * (2.0 * Math.atan2((t_2 + (-0.5 * (phi2 * t_0))), t_1));
} else {
tmp = R * (2.0 * Math.atan2((phi2 * ((0.5 * t_0) - (t_2 / phi2))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((0.5 * phi1)) t_1 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))) t_2 = math.sin((0.5 * phi1)) tmp = 0 if phi2 <= 1.55e-75: tmp = R * (2.0 * math.atan2((t_2 + (-0.5 * (phi2 * t_0))), t_1)) else: tmp = R * (2.0 * math.atan2((phi2 * ((0.5 * t_0) - (t_2 / phi2))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(0.5 * phi1)) t_1 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))) t_2 = sin(Float64(0.5 * phi1)) tmp = 0.0 if (phi2 <= 1.55e-75) tmp = Float64(R * Float64(2.0 * atan(Float64(t_2 + Float64(-0.5 * Float64(phi2 * t_0))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(Float64(phi2 * Float64(Float64(0.5 * t_0) - Float64(t_2 / phi2))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((0.5 * phi1)); t_1 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))); t_2 = sin((0.5 * phi1)); tmp = 0.0; if (phi2 <= 1.55e-75) tmp = R * (2.0 * atan2((t_2 + (-0.5 * (phi2 * t_0))), t_1)); else tmp = R * (2.0 * atan2((phi2 * ((0.5 * t_0) - (t_2 / phi2))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 1.55e-75], N[(R * N[(2.0 * N[ArcTan[N[(t$95$2 + N[(-0.5 * N[(phi2 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(phi2 * N[(N[(0.5 * t$95$0), $MachinePrecision] - N[(t$95$2 / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot \phi_1\right)\\
t_1 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\\
t_2 := \sin \left(0.5 \cdot \phi_1\right)\\
\mathbf{if}\;\phi_2 \leq 1.55 \cdot 10^{-75}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2 + -0.5 \cdot \left(\phi_2 \cdot t\_0\right)}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_2 \cdot \left(0.5 \cdot t\_0 - \frac{t\_2}{\phi_2}\right)}{t\_1}\right)\\
\end{array}
\end{array}
if phi2 < 1.55000000000000003e-75Initial program 67.1%
Taylor expanded in phi1 around 0 52.6%
+-commutative52.6%
associate--r+52.6%
unpow252.6%
1-sub-sin52.7%
unpow252.7%
*-commutative52.7%
Simplified52.7%
Taylor expanded in phi2 around 0 38.9%
Taylor expanded in lambda2 around 0 32.8%
Taylor expanded in lambda1 around 0 14.6%
if 1.55000000000000003e-75 < phi2 Initial program 54.3%
Taylor expanded in phi1 around 0 51.4%
+-commutative51.4%
associate--r+51.4%
unpow251.4%
1-sub-sin51.4%
unpow251.4%
*-commutative51.4%
Simplified51.4%
Taylor expanded in phi2 around 0 28.1%
Taylor expanded in phi2 around inf 20.5%
+-commutative20.5%
mul-1-neg20.5%
unsub-neg20.5%
Simplified20.5%
Final simplification16.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* 0.5 phi1)))
(t_1
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(if (<= phi2 1.5e-75)
(* R (* 2.0 (atan2 (+ (sin (* 0.5 phi1)) (* -0.5 (* phi2 t_0))) t_1)))
(* R (* 2.0 (atan2 (* t_0 (* 0.5 phi2)) t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((0.5 * phi1));
double t_1 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double tmp;
if (phi2 <= 1.5e-75) {
tmp = R * (2.0 * atan2((sin((0.5 * phi1)) + (-0.5 * (phi2 * t_0))), t_1));
} else {
tmp = R * (2.0 * atan2((t_0 * (0.5 * phi2)), t_1));
}
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((0.5d0 * phi1))
t_1 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))
if (phi2 <= 1.5d-75) then
tmp = r * (2.0d0 * atan2((sin((0.5d0 * phi1)) + ((-0.5d0) * (phi2 * t_0))), t_1))
else
tmp = r * (2.0d0 * atan2((t_0 * (0.5d0 * phi2)), t_1))
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((0.5 * phi1));
double t_1 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double tmp;
if (phi2 <= 1.5e-75) {
tmp = R * (2.0 * Math.atan2((Math.sin((0.5 * phi1)) + (-0.5 * (phi2 * t_0))), t_1));
} else {
tmp = R * (2.0 * Math.atan2((t_0 * (0.5 * phi2)), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((0.5 * phi1)) t_1 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))) tmp = 0 if phi2 <= 1.5e-75: tmp = R * (2.0 * math.atan2((math.sin((0.5 * phi1)) + (-0.5 * (phi2 * t_0))), t_1)) else: tmp = R * (2.0 * math.atan2((t_0 * (0.5 * phi2)), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(0.5 * phi1)) t_1 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))) tmp = 0.0 if (phi2 <= 1.5e-75) tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(0.5 * phi1)) + Float64(-0.5 * Float64(phi2 * t_0))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(Float64(t_0 * Float64(0.5 * phi2)), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((0.5 * phi1)); t_1 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))); tmp = 0.0; if (phi2 <= 1.5e-75) tmp = R * (2.0 * atan2((sin((0.5 * phi1)) + (-0.5 * (phi2 * t_0))), t_1)); else tmp = R * (2.0 * atan2((t_0 * (0.5 * phi2)), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 1.5e-75], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(t$95$0 * N[(0.5 * phi2), $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot \phi_1\right)\\
t_1 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\\
\mathbf{if}\;\phi_2 \leq 1.5 \cdot 10^{-75}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \phi_1\right) + -0.5 \cdot \left(\phi_2 \cdot t\_0\right)}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0 \cdot \left(0.5 \cdot \phi_2\right)}{t\_1}\right)\\
\end{array}
\end{array}
if phi2 < 1.4999999999999999e-75Initial program 67.1%
Taylor expanded in phi1 around 0 52.6%
+-commutative52.6%
associate--r+52.6%
unpow252.6%
1-sub-sin52.7%
unpow252.7%
*-commutative52.7%
Simplified52.7%
Taylor expanded in phi2 around 0 38.9%
Taylor expanded in lambda2 around 0 32.8%
Taylor expanded in lambda1 around 0 14.6%
if 1.4999999999999999e-75 < phi2 Initial program 54.3%
Taylor expanded in phi1 around 0 51.4%
+-commutative51.4%
associate--r+51.4%
unpow251.4%
1-sub-sin51.4%
unpow251.4%
*-commutative51.4%
Simplified51.4%
Taylor expanded in phi2 around 0 28.1%
Taylor expanded in phi2 around inf 19.1%
associate-*r*19.1%
*-commutative19.1%
Simplified19.1%
Final simplification16.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (cos (* phi2 -0.5)) 2.0)) (t_1 (cos (* 0.5 phi1))))
(if (<= phi2 5.9e-205)
(*
R
(*
2.0
(atan2
(* t_1 (* phi2 -0.5))
(sqrt (- t_0 (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))))
(*
R
(*
2.0
(atan2
(* t_1 (* 0.5 phi2))
(sqrt
(-
t_0
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(cos((phi2 * -0.5)), 2.0);
double t_1 = cos((0.5 * phi1));
double tmp;
if (phi2 <= 5.9e-205) {
tmp = R * (2.0 * atan2((t_1 * (phi2 * -0.5)), sqrt((t_0 - (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))));
} else {
tmp = R * (2.0 * atan2((t_1 * (0.5 * phi2)), sqrt((t_0 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.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((phi2 * (-0.5d0))) ** 2.0d0
t_1 = cos((0.5d0 * phi1))
if (phi2 <= 5.9d-205) then
tmp = r * (2.0d0 * atan2((t_1 * (phi2 * (-0.5d0))), sqrt((t_0 - (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2((t_1 * (0.5d0 * phi2)), sqrt((t_0 - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double t_1 = Math.cos((0.5 * phi1));
double tmp;
if (phi2 <= 5.9e-205) {
tmp = R * (2.0 * Math.atan2((t_1 * (phi2 * -0.5)), Math.sqrt((t_0 - (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2((t_1 * (0.5 * phi2)), Math.sqrt((t_0 - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.cos((phi2 * -0.5)), 2.0) t_1 = math.cos((0.5 * phi1)) tmp = 0 if phi2 <= 5.9e-205: tmp = R * (2.0 * math.atan2((t_1 * (phi2 * -0.5)), math.sqrt((t_0 - (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))) else: tmp = R * (2.0 * math.atan2((t_1 * (0.5 * phi2)), math.sqrt((t_0 - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) ^ 2.0 t_1 = cos(Float64(0.5 * phi1)) tmp = 0.0 if (phi2 <= 5.9e-205) tmp = Float64(R * Float64(2.0 * atan(Float64(t_1 * Float64(phi2 * -0.5)), sqrt(Float64(t_0 - Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(t_1 * Float64(0.5 * phi2)), sqrt(Float64(t_0 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)) ^ 2.0; t_1 = cos((0.5 * phi1)); tmp = 0.0; if (phi2 <= 5.9e-205) tmp = R * (2.0 * atan2((t_1 * (phi2 * -0.5)), sqrt((t_0 - (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))); else tmp = R * (2.0 * atan2((t_1 * (0.5 * phi2)), sqrt((t_0 - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 5.9e-205], N[(R * N[(2.0 * N[ArcTan[N[(t$95$1 * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(t$95$1 * N[(0.5 * phi2), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := \cos \left(0.5 \cdot \phi_1\right)\\
\mathbf{if}\;\phi_2 \leq 5.9 \cdot 10^{-205}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1 \cdot \left(\phi_2 \cdot -0.5\right)}{\sqrt{t\_0 - \cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1 \cdot \left(0.5 \cdot \phi_2\right)}{\sqrt{t\_0 - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < 5.89999999999999974e-205Initial program 65.8%
Taylor expanded in phi1 around 0 52.5%
+-commutative52.5%
associate--r+52.5%
unpow252.5%
1-sub-sin52.5%
unpow252.5%
*-commutative52.5%
Simplified52.5%
Taylor expanded in phi2 around 0 36.8%
Taylor expanded in phi2 around -inf 13.9%
associate-*r*13.9%
*-commutative13.9%
Simplified13.9%
Taylor expanded in lambda2 around 0 13.9%
*-commutative13.9%
Simplified13.9%
if 5.89999999999999974e-205 < phi2 Initial program 59.0%
Taylor expanded in phi1 around 0 51.9%
+-commutative51.9%
associate--r+51.9%
unpow251.9%
1-sub-sin51.9%
unpow251.9%
*-commutative51.9%
Simplified51.9%
Taylor expanded in phi2 around 0 33.6%
Taylor expanded in phi2 around inf 15.9%
associate-*r*15.9%
*-commutative15.9%
Simplified15.9%
Final simplification14.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* (cos (* 0.5 phi1)) (* phi2 -0.5))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((cos((0.5 * phi1)) * (phi2 * -0.5)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2((cos((0.5d0 * phi1)) * (phi2 * (-0.5d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((Math.cos((0.5 * phi1)) * (phi2 * -0.5)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((math.cos((0.5 * phi1)) * (phi2 * -0.5)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(cos(Float64(0.5 * phi1)) * Float64(phi2 * -0.5)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((cos((0.5 * phi1)) * (phi2 * -0.5)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\phi_2 \cdot -0.5\right)}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)
\end{array}
Initial program 63.1%
Taylor expanded in phi1 around 0 52.2%
+-commutative52.2%
associate--r+52.2%
unpow252.2%
1-sub-sin52.3%
unpow252.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in phi2 around 0 35.5%
Taylor expanded in phi2 around -inf 10.5%
associate-*r*10.5%
*-commutative10.5%
Simplified10.5%
Taylor expanded in lambda2 around 0 10.5%
*-commutative10.5%
Simplified10.5%
Final simplification10.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* (cos (* 0.5 phi1)) (* phi2 -0.5))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((cos((0.5 * phi1)) * (phi2 * -0.5)), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2((cos((0.5d0 * phi1)) * (phi2 * (-0.5d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((Math.cos((0.5 * phi1)) * (phi2 * -0.5)), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((math.cos((0.5 * phi1)) * (phi2 * -0.5)), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(cos(Float64(0.5 * phi1)) * Float64(phi2 * -0.5)), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((cos((0.5 * phi1)) * (phi2 * -0.5)), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\cos \left(0.5 \cdot \phi_1\right) \cdot \left(\phi_2 \cdot -0.5\right)}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 63.1%
Taylor expanded in phi1 around 0 52.2%
+-commutative52.2%
associate--r+52.2%
unpow252.2%
1-sub-sin52.3%
unpow252.3%
*-commutative52.3%
Simplified52.3%
Taylor expanded in phi2 around 0 35.5%
Taylor expanded in phi2 around -inf 10.5%
associate-*r*10.5%
*-commutative10.5%
Simplified10.5%
Taylor expanded in phi2 around 0 10.5%
Final simplification10.5%
herbie shell --seed 2024092
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Distance on a great circle"
:precision binary64
(* R (* 2.0 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))) (sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))))))))