
(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 19 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 (* phi1 0.5)))
(t_1 (sin (* 0.5 phi2)))
(t_2 (cos (* phi1 0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (* (cos phi1) (cos phi2)) (* t_3 t_3)))
(t_5 (cos (* 0.5 phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (- (* t_5 t_0) (* t_1 t_2)) 2.0) t_4))
(sqrt (- (- 1.0 (pow (fma t_5 t_0 (* t_1 (- t_2))) 2.0)) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = sin((0.5 * phi2));
double t_2 = cos((phi1 * 0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = (cos(phi1) * cos(phi2)) * (t_3 * t_3);
double t_5 = cos((0.5 * phi2));
return R * (2.0 * atan2(sqrt((pow(((t_5 * t_0) - (t_1 * t_2)), 2.0) + t_4)), sqrt(((1.0 - pow(fma(t_5, t_0, (t_1 * -t_2)), 2.0)) - t_4))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = sin(Float64(0.5 * phi2)) t_2 = cos(Float64(phi1 * 0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_3 * t_3)) t_5 = cos(Float64(0.5 * phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_5 * t_0) - Float64(t_1 * t_2)) ^ 2.0) + t_4)), sqrt(Float64(Float64(1.0 - (fma(t_5, t_0, Float64(t_1 * Float64(-t_2))) ^ 2.0)) - t_4))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 * 0.5), $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] * N[(t$95$3 * 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[(N[Power[N[(N[(t$95$5 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(t$95$5 * t$95$0 + N[(t$95$1 * (-t$95$2)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(0.5 \cdot \phi_2\right)\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_3 \cdot t\_3\right)\\
t_5 := \cos \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_5 \cdot t\_0 - t\_1 \cdot t\_2\right)}^{2} + t\_4}}{\sqrt{\left(1 - {\left(\mathsf{fma}\left(t\_5, t\_0, t\_1 \cdot \left(-t\_2\right)\right)\right)}^{2}\right) - t\_4}}\right)
\end{array}
\end{array}
Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
div-sub61.9%
sin-diff62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
Applied egg-rr62.9%
div-sub61.9%
sin-diff62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
Applied egg-rr77.5%
Taylor expanded in phi1 around inf 77.5%
fma-neg77.5%
*-commutative77.5%
*-commutative77.5%
distribute-rgt-neg-in77.5%
*-commutative77.5%
Simplified77.5%
Final simplification77.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+ (- 1.0 t_1) (* t_0 (/ (- 1.0 (cos (- lambda1 lambda2))) -2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((1.0 - cos((lambda1 - lambda2))) / -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
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((1.0d0 - cos((lambda1 - lambda2))) / (-2.0d0)))))))
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.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((1.0 - Math.cos((lambda1 - lambda2))) / -2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((1.0 - math.cos((lambda1 - lambda2))) / -2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(1.0 - cos(Float64(lambda1 - lambda2))) / -2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((1.0 - cos((lambda1 - lambda2))) / -2.0)))))); 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[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(1.0 - N[Cos[N[(lambda1 - lambda2), $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 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) + t\_0 \cdot \frac{1 - \cos \left(\lambda_1 - \lambda_2\right)}{-2}}}\right)
\end{array}
\end{array}
Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
div-sub61.9%
sin-diff62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
Applied egg-rr62.9%
div-sub61.9%
sin-diff62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
Applied egg-rr77.5%
sin-mult48.9%
frac-2neg48.9%
Applied egg-rr77.5%
neg-sub048.9%
cos-048.9%
associate--r-48.9%
metadata-eval48.9%
Simplified77.5%
Final simplification77.5%
(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_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.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 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.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 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.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.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0)) - t_1))));
}
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_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - 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 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
div-sub61.9%
sin-diff62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
div-inv62.9%
metadata-eval62.9%
Applied egg-rr62.9%
Final simplification62.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (* phi2 -0.5)))
(t_2
(sqrt
(-
(pow t_1 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))
(t_3 (sin (* phi2 -0.5)))
(t_4 (cos (- lambda1 lambda2)))
(t_5 (* t_0 (/ (+ -1.0 t_4) -2.0)))
(t_6 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi2 -1.02e-5)
(*
R
(*
2.0
(atan2 (sqrt (+ t_5 (pow (+ t_3 (* 0.5 (* phi1 t_1))) 2.0))) t_2)))
(if (<= phi2 1.9e-40)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_6 t_6)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(+ (pow (cos (* phi1 0.5)) 2.0) (* t_0 (/ (- 1.0 t_4) -2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_5 (pow t_3 2.0))) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((phi2 * -0.5));
double t_2 = sqrt((pow(t_1, 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_3 = sin((phi2 * -0.5));
double t_4 = cos((lambda1 - lambda2));
double t_5 = t_0 * ((-1.0 + t_4) / -2.0);
double t_6 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi2 <= -1.02e-5) {
tmp = R * (2.0 * atan2(sqrt((t_5 + pow((t_3 + (0.5 * (phi1 * t_1))), 2.0))), t_2));
} else if (phi2 <= 1.9e-40) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_6 * t_6)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) + (t_0 * ((1.0 - t_4) / -2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_5 + pow(t_3, 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) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = cos((phi2 * (-0.5d0)))
t_2 = sqrt(((t_1 ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))
t_3 = sin((phi2 * (-0.5d0)))
t_4 = cos((lambda1 - lambda2))
t_5 = t_0 * (((-1.0d0) + t_4) / (-2.0d0))
t_6 = sin(((lambda1 - lambda2) / 2.0d0))
if (phi2 <= (-1.02d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + ((t_3 + (0.5d0 * (phi1 * t_1))) ** 2.0d0))), t_2))
else if (phi2 <= 1.9d-40) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_6 * t_6)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) + (t_0 * ((1.0d0 - t_4) / (-2.0d0)))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (t_3 ** 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.cos(phi1) * Math.cos(phi2);
double t_1 = Math.cos((phi2 * -0.5));
double t_2 = Math.sqrt((Math.pow(t_1, 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_3 = Math.sin((phi2 * -0.5));
double t_4 = Math.cos((lambda1 - lambda2));
double t_5 = t_0 * ((-1.0 + t_4) / -2.0);
double t_6 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi2 <= -1.02e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + Math.pow((t_3 + (0.5 * (phi1 * t_1))), 2.0))), t_2));
} else if (phi2 <= 1.9e-40) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_6 * t_6)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) + (t_0 * ((1.0 - t_4) / -2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + Math.pow(t_3, 2.0))), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.cos((phi2 * -0.5)) t_2 = math.sqrt((math.pow(t_1, 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))) t_3 = math.sin((phi2 * -0.5)) t_4 = math.cos((lambda1 - lambda2)) t_5 = t_0 * ((-1.0 + t_4) / -2.0) t_6 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi2 <= -1.02e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + math.pow((t_3 + (0.5 * (phi1 * t_1))), 2.0))), t_2)) elif phi2 <= 1.9e-40: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_6 * t_6)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) + (t_0 * ((1.0 - t_4) / -2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + math.pow(t_3, 2.0))), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(phi2 * -0.5)) t_2 = sqrt(Float64((t_1 ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))) t_3 = sin(Float64(phi2 * -0.5)) t_4 = cos(Float64(lambda1 - lambda2)) t_5 = Float64(t_0 * Float64(Float64(-1.0 + t_4) / -2.0)) t_6 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi2 <= -1.02e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + (Float64(t_3 + Float64(0.5 * Float64(phi1 * t_1))) ^ 2.0))), t_2))); elseif (phi2 <= 1.9e-40) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_6 * t_6)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) + Float64(t_0 * Float64(Float64(1.0 - t_4) / -2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + (t_3 ^ 2.0))), t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = cos((phi2 * -0.5)); t_2 = sqrt(((t_1 ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))); t_3 = sin((phi2 * -0.5)); t_4 = cos((lambda1 - lambda2)); t_5 = t_0 * ((-1.0 + t_4) / -2.0); t_6 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi2 <= -1.02e-5) tmp = R * (2.0 * atan2(sqrt((t_5 + ((t_3 + (0.5 * (phi1 * t_1))) ^ 2.0))), t_2)); elseif (phi2 <= 1.9e-40) tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_6 * t_6)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) + (t_0 * ((1.0 - t_4) / -2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_5 + (t_3 ^ 2.0))), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[t$95$1, 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$3 = N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$0 * N[(N[(-1.0 + t$95$4), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.02e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[Power[N[(t$95$3 + N[(0.5 * N[(phi1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.9e-40], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$6 * t$95$6), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(1.0 - t$95$4), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[Power[t$95$3, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_2 := \sqrt{{t\_1}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\\
t_3 := \sin \left(\phi_2 \cdot -0.5\right)\\
t_4 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_5 := t\_0 \cdot \frac{-1 + t\_4}{-2}\\
t_6 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -1.02 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + {\left(t\_3 + 0.5 \cdot \left(\phi_1 \cdot t\_1\right)\right)}^{2}}}{t\_2}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.9 \cdot 10^{-40}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_6 \cdot t\_6\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} + t\_0 \cdot \frac{1 - t\_4}{-2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + {t\_3}^{2}}}{t\_2}\right)\\
\end{array}
\end{array}
if phi2 < -1.0200000000000001e-5Initial program 49.4%
associate-*l*49.4%
Simplified49.4%
Taylor expanded in phi1 around 0 50.2%
Simplified50.2%
sin-mult50.3%
frac-2neg50.3%
Applied egg-rr50.3%
neg-sub050.3%
cos-050.3%
associate--r-50.3%
metadata-eval50.3%
Simplified50.3%
Taylor expanded in phi1 around 0 51.0%
if -1.0200000000000001e-5 < phi2 < 1.8999999999999999e-40Initial program 79.5%
associate-*l*79.5%
Simplified79.5%
Taylor expanded in phi2 around 0 79.5%
unpow279.5%
1-sub-sin79.7%
unpow279.7%
Simplified79.7%
sin-mult49.4%
frac-2neg49.4%
Applied egg-rr79.7%
neg-sub049.4%
cos-049.4%
associate--r-49.4%
metadata-eval49.4%
Simplified79.7%
if 1.8999999999999999e-40 < phi2 Initial program 44.9%
associate-*l*44.9%
Simplified44.9%
Taylor expanded in phi1 around 0 46.2%
Simplified46.2%
sin-mult46.3%
frac-2neg46.3%
Applied egg-rr46.3%
neg-sub046.3%
cos-046.3%
associate--r-46.3%
metadata-eval46.3%
Simplified46.3%
Taylor expanded in phi1 around 0 46.3%
Final simplification62.8%
(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)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(-
1.0
(+
t_1
(/
(- 1.0 (cos (- lambda1 lambda2)))
(/ 4.0 (+ (cos (+ phi1 phi2)) (cos (- phi1 phi2)))))))))))))
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);
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (t_1 + ((1.0 - cos((lambda1 - lambda2))) / (4.0 / (cos((phi1 + phi2)) + cos((phi1 - phi2))))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - (t_1 + ((1.0d0 - cos((lambda1 - lambda2))) / (4.0d0 / (cos((phi1 + phi2)) + cos((phi1 - phi2))))))))))
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);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - (t_1 + ((1.0 - Math.cos((lambda1 - lambda2))) / (4.0 / (Math.cos((phi1 + phi2)) + Math.cos((phi1 - phi2))))))))));
}
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) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - (t_1 + ((1.0 - math.cos((lambda1 - lambda2))) / (4.0 / (math.cos((phi1 + phi2)) + math.cos((phi1 - phi2))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - Float64(t_1 + Float64(Float64(1.0 - cos(Float64(lambda1 - lambda2))) / Float64(4.0 / Float64(cos(Float64(phi1 + phi2)) + cos(Float64(phi1 - phi2))))))))))) 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; tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (t_1 + ((1.0 - cos((lambda1 - lambda2))) / (4.0 / (cos((phi1 + phi2)) + cos((phi1 - phi2)))))))))); 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[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[(1.0 - N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(4.0 / N[(N[Cos[N[(phi1 + phi2), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{1 - \left(t\_1 + \frac{1 - \cos \left(\lambda_1 - \lambda_2\right)}{\frac{4}{\cos \left(\phi_1 + \phi_2\right) + \cos \left(\phi_1 - \phi_2\right)}}\right)}}\right)
\end{array}
\end{array}
Initial program 61.9%
associate-*r*61.9%
cos-mult62.4%
sin-mult62.4%
frac-times62.4%
Applied egg-rr62.4%
*-commutative62.4%
associate-/l*62.5%
cos-062.5%
+-commutative62.5%
Simplified62.5%
Final simplification62.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))))
(if (or (<= phi1 -65000.0) (not (<= phi1 2.3e-9)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (+ 0.5 (* (cos (- lambda1 lambda2)) -0.5)))))
(sqrt (- 1.0 (+ t_0 (* t_1 (* t_2 t_1))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_1)) t_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 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((phi1 <= -65000.0) || !(phi1 <= 2.3e-9)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (0.5 + (cos((lambda1 - lambda2)) * -0.5))))), sqrt((1.0 - (t_0 + (t_1 * (t_2 * t_1)))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt((pow(cos((phi2 * -0.5)), 2.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) :: t_2
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)
if ((phi1 <= (-65000.0d0)) .or. (.not. (phi1 <= 2.3d-9))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (0.5d0 + (cos((lambda1 - lambda2)) * (-0.5d0)))))), sqrt((1.0d0 - (t_0 + (t_1 * (t_2 * t_1)))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (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.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);
double tmp;
if ((phi1 <= -65000.0) || !(phi1 <= 2.3e-9)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (0.5 + (Math.cos((lambda1 - lambda2)) * -0.5))))), Math.sqrt((1.0 - (t_0 + (t_1 * (t_2 * t_1)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_1 * t_1)) + t_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))))));
}
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) tmp = 0 if (phi1 <= -65000.0) or not (phi1 <= 2.3e-9): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (0.5 + (math.cos((lambda1 - lambda2)) * -0.5))))), math.sqrt((1.0 - (t_0 + (t_1 * (t_2 * t_1))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_1 * t_1)) + t_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)))))) 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(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi1 <= -65000.0) || !(phi1 <= 2.3e-9)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(0.5 + Float64(cos(Float64(lambda1 - lambda2)) * -0.5))))), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_1 * Float64(t_2 * t_1)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_1)) + t_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
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); tmp = 0.0; if ((phi1 <= -65000.0) || ~((phi1 <= 2.3e-9))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (0.5 + (cos((lambda1 - lambda2)) * -0.5))))), sqrt((1.0 - (t_0 + (t_1 * (t_2 * t_1))))))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt(((cos((phi2 * -0.5)) ^ 2.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[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[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -65000.0], N[Not[LessEqual[phi1, 2.3e-9]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$1 * t$95$1), $MachinePrecision]), $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] * 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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -65000 \lor \neg \left(\phi_1 \leq 2.3 \cdot 10^{-9}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(0.5 + \cos \left(\lambda_1 - \lambda_2\right) \cdot -0.5\right)}}{\sqrt{1 - \left(t\_0 + t\_1 \cdot \left(t\_2 \cdot t\_1\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_1 \cdot t\_1\right) + t\_0}}{\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 < -65000 or 2.2999999999999999e-9 < phi1 Initial program 45.0%
associate-*r*45.0%
log1p-expm1-u45.0%
log1p-udef44.8%
*-commutative44.8%
associate-*l*44.8%
sqr-sin-a44.8%
cancel-sign-sub-inv44.8%
metadata-eval44.8%
cos-244.8%
cos-sum44.8%
Applied egg-rr44.8%
Taylor expanded in phi2 around 0 44.8%
if -65000 < phi1 < 2.2999999999999999e-9Initial program 76.1%
associate-*l*76.1%
Simplified76.1%
Taylor expanded in phi1 around 0 76.1%
Simplified76.1%
Final simplification61.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -0.00018) (not (<= phi2 1.9e-40)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (/ (+ -1.0 (cos (- lambda1 lambda2))) -2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_2)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) 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 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.00018) || !(phi2 <= 1.9e-40)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * ((-1.0 + cos((lambda1 - lambda2))) / -2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * 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 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-0.00018d0)) .or. (.not. (phi2 <= 1.9d-40))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (((-1.0d0) + cos((lambda1 - lambda2))) / (-2.0d0))) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * 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.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.00018) || !(phi2 <= 1.9e-40)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * ((-1.0 + Math.cos((lambda1 - lambda2))) / -2.0)) + 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)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_2)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * 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.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -0.00018) or not (phi2 <= 1.9e-40): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * ((-1.0 + math.cos((lambda1 - lambda2))) / -2.0)) + 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))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_2)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -0.00018) || !(phi2 <= 1.9e-40)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(-1.0 + cos(Float64(lambda1 - lambda2))) / -2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * 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 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -0.00018) || ~((phi2 <= 1.9e-40))) tmp = R * (2.0 * atan2(sqrt(((t_1 * ((-1.0 + cos((lambda1 - lambda2))) / -2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00018], N[Not[LessEqual[phi2, 1.9e-40]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[(-1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -2.0), $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] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $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 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -0.00018 \lor \neg \left(\phi_2 \leq 1.9 \cdot 10^{-40}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \frac{-1 + \cos \left(\lambda_1 - \lambda_2\right)}{-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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_0}}\right)\\
\end{array}
\end{array}
if phi2 < -1.80000000000000011e-4 or 1.8999999999999999e-40 < phi2 Initial program 47.5%
associate-*l*47.5%
Simplified47.5%
Taylor expanded in phi1 around 0 48.6%
Simplified48.6%
sin-mult48.6%
frac-2neg48.6%
Applied egg-rr48.6%
neg-sub048.6%
cos-048.6%
associate--r-48.6%
metadata-eval48.6%
Simplified48.6%
Taylor expanded in phi1 around 0 48.9%
if -1.80000000000000011e-4 < phi2 < 1.8999999999999999e-40Initial program 78.9%
associate-*l*78.9%
Simplified79.0%
Taylor expanded in phi2 around 0 79.0%
+-commutative79.0%
associate--r+79.0%
unpow279.0%
1-sub-sin79.1%
unpow279.1%
*-commutative79.1%
Simplified79.1%
Final simplification62.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (* t_0 (/ (+ -1.0 (cos (- lambda1 lambda2))) -2.0)))
(t_2 (cos (* phi2 -0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_5 (sqrt (- (pow t_2 2.0) (* (cos phi2) t_4))))
(t_6 (sin (* phi2 -0.5))))
(if (<= phi2 -5e-5)
(*
R
(*
2.0
(atan2 (sqrt (+ t_1 (pow (+ t_6 (* 0.5 (* phi1 t_2))) 2.0))) t_5)))
(if (<= phi2 1.9e-40)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_3 t_3)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_4))))))
(* R (* 2.0 (atan2 (sqrt (+ t_1 (pow t_6 2.0))) t_5)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = t_0 * ((-1.0 + cos((lambda1 - lambda2))) / -2.0);
double t_2 = cos((phi2 * -0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_5 = sqrt((pow(t_2, 2.0) - (cos(phi2) * t_4)));
double t_6 = sin((phi2 * -0.5));
double tmp;
if (phi2 <= -5e-5) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow((t_6 + (0.5 * (phi1 * t_2))), 2.0))), t_5));
} else if (phi2 <= 1.9e-40) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_3 * t_3)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_4)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(t_6, 2.0))), t_5));
}
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) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = t_0 * (((-1.0d0) + cos((lambda1 - lambda2))) / (-2.0d0))
t_2 = cos((phi2 * (-0.5d0)))
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_5 = sqrt(((t_2 ** 2.0d0) - (cos(phi2) * t_4)))
t_6 = sin((phi2 * (-0.5d0)))
if (phi2 <= (-5d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + ((t_6 + (0.5d0 * (phi1 * t_2))) ** 2.0d0))), t_5))
else if (phi2 <= 1.9d-40) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_3 * t_3)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_4)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_6 ** 2.0d0))), t_5))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = t_0 * ((-1.0 + Math.cos((lambda1 - lambda2))) / -2.0);
double t_2 = Math.cos((phi2 * -0.5));
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_5 = Math.sqrt((Math.pow(t_2, 2.0) - (Math.cos(phi2) * t_4)));
double t_6 = Math.sin((phi2 * -0.5));
double tmp;
if (phi2 <= -5e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow((t_6 + (0.5 * (phi1 * t_2))), 2.0))), t_5));
} else if (phi2 <= 1.9e-40) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_3 * t_3)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_4)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(t_6, 2.0))), t_5));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = t_0 * ((-1.0 + math.cos((lambda1 - lambda2))) / -2.0) t_2 = math.cos((phi2 * -0.5)) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_5 = math.sqrt((math.pow(t_2, 2.0) - (math.cos(phi2) * t_4))) t_6 = math.sin((phi2 * -0.5)) tmp = 0 if phi2 <= -5e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow((t_6 + (0.5 * (phi1 * t_2))), 2.0))), t_5)) elif phi2 <= 1.9e-40: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_3 * t_3)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_4))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(t_6, 2.0))), t_5)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(t_0 * Float64(Float64(-1.0 + cos(Float64(lambda1 - lambda2))) / -2.0)) t_2 = cos(Float64(phi2 * -0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_5 = sqrt(Float64((t_2 ^ 2.0) - Float64(cos(phi2) * t_4))) t_6 = sin(Float64(phi2 * -0.5)) tmp = 0.0 if (phi2 <= -5e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (Float64(t_6 + Float64(0.5 * Float64(phi1 * t_2))) ^ 2.0))), t_5))); elseif (phi2 <= 1.9e-40) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_3 * t_3)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_4)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (t_6 ^ 2.0))), t_5))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = t_0 * ((-1.0 + cos((lambda1 - lambda2))) / -2.0); t_2 = cos((phi2 * -0.5)); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_5 = sqrt(((t_2 ^ 2.0) - (cos(phi2) * t_4))); t_6 = sin((phi2 * -0.5)); tmp = 0.0; if (phi2 <= -5e-5) tmp = R * (2.0 * atan2(sqrt((t_1 + ((t_6 + (0.5 * (phi1 * t_2))) ^ 2.0))), t_5)); elseif (phi2 <= 1.9e-40) tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_3 * t_3)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_4))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_6 ^ 2.0))), t_5)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(-1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(N[Power[t$95$2, 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -5e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[(t$95$6 + N[(0.5 * N[(phi1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.9e-40], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[t$95$6, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := t\_0 \cdot \frac{-1 + \cos \left(\lambda_1 - \lambda_2\right)}{-2}\\
t_2 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_5 := \sqrt{{t\_2}^{2} - \cos \phi_2 \cdot t\_4}\\
t_6 := \sin \left(\phi_2 \cdot -0.5\right)\\
\mathbf{if}\;\phi_2 \leq -5 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\left(t\_6 + 0.5 \cdot \left(\phi_1 \cdot t\_2\right)\right)}^{2}}}{t\_5}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.9 \cdot 10^{-40}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_3 \cdot t\_3\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {t\_6}^{2}}}{t\_5}\right)\\
\end{array}
\end{array}
if phi2 < -5.00000000000000024e-5Initial program 49.4%
associate-*l*49.4%
Simplified49.4%
Taylor expanded in phi1 around 0 50.2%
Simplified50.2%
sin-mult50.3%
frac-2neg50.3%
Applied egg-rr50.3%
neg-sub050.3%
cos-050.3%
associate--r-50.3%
metadata-eval50.3%
Simplified50.3%
Taylor expanded in phi1 around 0 51.0%
if -5.00000000000000024e-5 < phi2 < 1.8999999999999999e-40Initial program 79.5%
associate-*l*79.5%
Simplified79.5%
Taylor expanded in phi2 around 0 79.5%
+-commutative79.5%
associate--r+79.5%
unpow279.5%
1-sub-sin79.7%
unpow279.7%
*-commutative79.7%
Simplified79.7%
if 1.8999999999999999e-40 < phi2 Initial program 44.9%
associate-*l*44.9%
Simplified44.9%
Taylor expanded in phi1 around 0 46.2%
Simplified46.2%
sin-mult46.3%
frac-2neg46.3%
Applied egg-rr46.3%
neg-sub046.3%
cos-046.3%
associate--r-46.3%
metadata-eval46.3%
Simplified46.3%
Taylor expanded in phi1 around 0 46.3%
Final simplification62.8%
(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)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(*
(cos phi2)
(* (cos phi1) (+ 0.5 (* (cos (- lambda1 lambda2)) -0.5))))))
(sqrt (- 1.0 (+ t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_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(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_1 + (cos(phi2) * (cos(phi1) * (0.5 + (cos((lambda1 - lambda2)) * -0.5)))))), sqrt((1.0 - (t_1 + (t_0 * ((cos(phi1) * cos(phi2)) * t_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
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi2) * (cos(phi1) * (0.5d0 + (cos((lambda1 - lambda2)) * (-0.5d0))))))), sqrt((1.0d0 - (t_1 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))))))
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);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi2) * (Math.cos(phi1) * (0.5 + (Math.cos((lambda1 - lambda2)) * -0.5)))))), Math.sqrt((1.0 - (t_1 + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))))));
}
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) return R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi2) * (math.cos(phi1) * (0.5 + (math.cos((lambda1 - lambda2)) * -0.5)))))), math.sqrt((1.0 - (t_1 + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi2) * Float64(cos(phi1) * Float64(0.5 + Float64(cos(Float64(lambda1 - lambda2)) * -0.5)))))), sqrt(Float64(1.0 - Float64(t_1 + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))))))) 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; tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi2) * (cos(phi1) * (0.5 + (cos((lambda1 - lambda2)) * -0.5)))))), sqrt((1.0 - (t_1 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))))))); 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[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \left(0.5 + \cos \left(\lambda_1 - \lambda_2\right) \cdot -0.5\right)\right)}}{\sqrt{1 - \left(t\_1 + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\right)}}\right)
\end{array}
\end{array}
Initial program 61.9%
associate-*r*61.9%
expm1-log1p-u61.9%
expm1-udef59.7%
Applied egg-rr59.7%
expm1-def59.9%
expm1-log1p60.0%
Simplified60.0%
Final simplification60.0%
(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))
(t_2 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) t_1))
(sqrt
(+ (- 1.0 t_1) (* t_2 (/ (- 1.0 (cos (- lambda1 lambda2))) -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(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) + (t_2 * ((1.0 - cos((lambda1 - lambda2))) / -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
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
code = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0d0 - t_1) + (t_2 * ((1.0d0 - cos((lambda1 - lambda2))) / (-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));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), Math.sqrt(((1.0 - t_1) + (t_2 * ((1.0 - Math.cos((lambda1 - lambda2))) / -2.0))))));
}
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) t_2 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), math.sqrt(((1.0 - t_1) + (t_2 * ((1.0 - math.cos((lambda1 - lambda2))) / -2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + t_1)), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_2 * Float64(Float64(1.0 - cos(Float64(lambda1 - lambda2))) / -2.0))))))) 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; t_2 = cos(phi1) * cos(phi2); tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) + (t_2 * ((1.0 - cos((lambda1 - lambda2))) / -2.0)))))); 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[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$2 * N[(N[(1.0 - N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -2.0), $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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_0 \cdot t\_0\right) + t\_1}}{\sqrt{\left(1 - t\_1\right) + t\_2 \cdot \frac{1 - \cos \left(\lambda_1 - \lambda_2\right)}{-2}}}\right)
\end{array}
\end{array}
Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
sin-mult48.9%
frac-2neg48.9%
Applied egg-rr61.9%
neg-sub048.9%
cos-048.9%
associate--r-48.9%
metadata-eval48.9%
Simplified61.9%
Final simplification61.9%
(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))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (cos (- lambda1 lambda2))))
(if (or (<= phi2 -0.00072) (not (<= phi2 1.9e-40)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (/ (+ -1.0 t_3) -2.0)) (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)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* (cos phi1) (+ 0.5 (* t_3 -0.5)))))
(sqrt (- 1.0 (+ t_1 (* t_0 (* t_2 t_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(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = cos((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.00072) || !(phi2 <= 1.9e-40)) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * ((-1.0 + t_3) / -2.0)) + 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))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (0.5 + (t_3 * -0.5))))), sqrt((1.0 - (t_1 + (t_0 * (t_2 * 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) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = cos((lambda1 - lambda2))
if ((phi2 <= (-0.00072d0)) .or. (.not. (phi2 <= 1.9d-40))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (((-1.0d0) + t_3) / (-2.0d0))) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi1) * (0.5d0 + (t_3 * (-0.5d0)))))), sqrt((1.0d0 - (t_1 + (t_0 * (t_2 * t_0)))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.00072) || !(phi2 <= 1.9e-40)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * ((-1.0 + t_3) / -2.0)) + Math.pow(Math.sin((phi2 * -0.5)), 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))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi1) * (0.5 + (t_3 * -0.5))))), Math.sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_0)))))));
}
return tmp;
}
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) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.00072) or not (phi2 <= 1.9e-40): tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * ((-1.0 + t_3) / -2.0)) + math.pow(math.sin((phi2 * -0.5)), 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)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi1) * (0.5 + (t_3 * -0.5))))), math.sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.00072) || !(phi2 <= 1.9e-40)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(Float64(-1.0 + t_3) / -2.0)) + (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))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * Float64(0.5 + Float64(t_3 * -0.5))))), sqrt(Float64(1.0 - Float64(t_1 + Float64(t_0 * Float64(t_2 * t_0)))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi2 <= -0.00072) || ~((phi2 <= 1.9e-40))) tmp = R * (2.0 * atan2(sqrt(((t_2 * ((-1.0 + t_3) / -2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (0.5 + (t_3 * -0.5))))), sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_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[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00072], N[Not[LessEqual[phi2, 1.9e-40]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(N[(-1.0 + t$95$3), $MachinePrecision] / -2.0), $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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 + N[(t$95$3 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$0), $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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.00072 \lor \neg \left(\phi_2 \leq 1.9 \cdot 10^{-40}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \frac{-1 + t\_3}{-2} + {\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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_1 \cdot \left(0.5 + t\_3 \cdot -0.5\right)}}{\sqrt{1 - \left(t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_0\right)\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -7.20000000000000045e-4 or 1.8999999999999999e-40 < phi2 Initial program 47.5%
associate-*l*47.5%
Simplified47.5%
Taylor expanded in phi1 around 0 48.6%
Simplified48.6%
sin-mult48.6%
frac-2neg48.6%
Applied egg-rr48.6%
neg-sub048.6%
cos-048.6%
associate--r-48.6%
metadata-eval48.6%
Simplified48.6%
Taylor expanded in phi1 around 0 48.9%
if -7.20000000000000045e-4 < phi2 < 1.8999999999999999e-40Initial program 78.9%
associate-*r*78.9%
log1p-expm1-u79.0%
log1p-udef74.4%
*-commutative74.4%
associate-*l*74.4%
sqr-sin-a74.4%
cancel-sign-sub-inv74.4%
metadata-eval74.4%
cos-274.3%
cos-sum74.4%
Applied egg-rr74.4%
Taylor expanded in phi2 around 0 74.7%
Final simplification60.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -0.00018) (not (<= phi2 8.8e-73)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (/ (+ -1.0 (cos (- lambda1 lambda2))) -2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_2)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (log (exp (- 1.0 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 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.00018) || !(phi2 <= 8.8e-73)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * ((-1.0 + cos((lambda1 - lambda2))) / -2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(log(exp((1.0 - 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 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-0.00018d0)) .or. (.not. (phi2 <= 8.8d-73))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (((-1.0d0) + cos((lambda1 - lambda2))) / (-2.0d0))) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(log(exp((1.0d0 - 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.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.00018) || !(phi2 <= 8.8e-73)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * ((-1.0 + Math.cos((lambda1 - lambda2))) / -2.0)) + 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)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_2)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.log(Math.exp((1.0 - 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.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -0.00018) or not (phi2 <= 8.8e-73): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * ((-1.0 + math.cos((lambda1 - lambda2))) / -2.0)) + 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))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_2)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.log(math.exp((1.0 - t_0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -0.00018) || !(phi2 <= 8.8e-73)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(-1.0 + cos(Float64(lambda1 - lambda2))) / -2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(log(exp(Float64(1.0 - 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 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -0.00018) || ~((phi2 <= 8.8e-73))) tmp = R * (2.0 * atan2(sqrt(((t_1 * ((-1.0 + cos((lambda1 - lambda2))) / -2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(log(exp((1.0 - 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00018], N[Not[LessEqual[phi2, 8.8e-73]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[(-1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -2.0), $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] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Log[N[Exp[N[(1.0 - t$95$0), $MachinePrecision]], $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 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -0.00018 \lor \neg \left(\phi_2 \leq 8.8 \cdot 10^{-73}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \frac{-1 + \cos \left(\lambda_1 - \lambda_2\right)}{-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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\log \left(e^{1 - t\_0}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -1.80000000000000011e-4 or 8.8000000000000001e-73 < phi2 Initial program 48.3%
associate-*l*48.3%
Simplified48.3%
Taylor expanded in phi1 around 0 48.7%
Simplified48.8%
sin-mult48.8%
frac-2neg48.8%
Applied egg-rr48.8%
neg-sub048.8%
cos-048.8%
associate--r-48.8%
metadata-eval48.8%
Simplified48.8%
Taylor expanded in phi1 around 0 49.1%
if -1.80000000000000011e-4 < phi2 < 8.8000000000000001e-73Initial program 78.6%
associate-*l*78.6%
Simplified78.6%
Taylor expanded in phi1 around 0 53.1%
Simplified53.1%
Taylor expanded in phi2 around 0 53.1%
add-log-exp53.1%
Applied egg-rr53.1%
Final simplification50.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -0.00018) (not (<= phi2 8.8e-73)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (/ (+ -1.0 (cos (- lambda1 lambda2))) -2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* t_2 t_2))
(pow
(+ (sin (* phi1 0.5)) (* -0.5 (* phi2 (cos (* phi1 0.5)))))
2.0)))
(sqrt (- 1.0 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 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.00018) || !(phi2 <= 8.8e-73)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * ((-1.0 + cos((lambda1 - lambda2))) / -2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + pow((sin((phi1 * 0.5)) + (-0.5 * (phi2 * cos((phi1 * 0.5))))), 2.0))), sqrt((1.0 - 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 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-0.00018d0)) .or. (.not. (phi2 <= 8.8d-73))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (((-1.0d0) + cos((lambda1 - lambda2))) / (-2.0d0))) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + ((sin((phi1 * 0.5d0)) + ((-0.5d0) * (phi2 * cos((phi1 * 0.5d0))))) ** 2.0d0))), sqrt((1.0d0 - 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.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.00018) || !(phi2 <= 8.8e-73)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * ((-1.0 + Math.cos((lambda1 - lambda2))) / -2.0)) + 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)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_2)) + Math.pow((Math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * Math.cos((phi1 * 0.5))))), 2.0))), Math.sqrt((1.0 - 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.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -0.00018) or not (phi2 <= 8.8e-73): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * ((-1.0 + math.cos((lambda1 - lambda2))) / -2.0)) + 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))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_2)) + math.pow((math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * math.cos((phi1 * 0.5))))), 2.0))), math.sqrt((1.0 - t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -0.00018) || !(phi2 <= 8.8e-73)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(-1.0 + cos(Float64(lambda1 - lambda2))) / -2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_2)) + (Float64(sin(Float64(phi1 * 0.5)) + Float64(-0.5 * Float64(phi2 * cos(Float64(phi1 * 0.5))))) ^ 2.0))), sqrt(Float64(1.0 - 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 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -0.00018) || ~((phi2 <= 8.8e-73))) tmp = R * (2.0 * atan2(sqrt(((t_1 * ((-1.0 + cos((lambda1 - lambda2))) / -2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + ((sin((phi1 * 0.5)) + (-0.5 * (phi2 * cos((phi1 * 0.5))))) ^ 2.0))), sqrt((1.0 - 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00018], N[Not[LessEqual[phi2, 8.8e-73]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[(-1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -2.0), $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] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $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 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -0.00018 \lor \neg \left(\phi_2 \leq 8.8 \cdot 10^{-73}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \frac{-1 + \cos \left(\lambda_1 - \lambda_2\right)}{-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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_2\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}}}{\sqrt{1 - t\_0}}\right)\\
\end{array}
\end{array}
if phi2 < -1.80000000000000011e-4 or 8.8000000000000001e-73 < phi2 Initial program 48.3%
associate-*l*48.3%
Simplified48.3%
Taylor expanded in phi1 around 0 48.7%
Simplified48.8%
sin-mult48.8%
frac-2neg48.8%
Applied egg-rr48.8%
neg-sub048.8%
cos-048.8%
associate--r-48.8%
metadata-eval48.8%
Simplified48.8%
Taylor expanded in phi1 around 0 49.1%
if -1.80000000000000011e-4 < phi2 < 8.8000000000000001e-73Initial program 78.6%
associate-*l*78.6%
Simplified78.6%
Taylor expanded in phi1 around 0 53.1%
Simplified53.1%
Taylor expanded in phi2 around 0 53.1%
Taylor expanded in phi2 around 0 53.1%
Final simplification50.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (/ (+ -1.0 (cos (- lambda1 lambda2))) -2.0))
(pow (sin (/ (- phi1 phi2) 2.0)) 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((((cos(phi1) * cos(phi2)) * ((-1.0 + cos((lambda1 - lambda2))) / -2.0)) + pow(sin(((phi1 - phi2) / 2.0)), 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((((cos(phi1) * cos(phi2)) * (((-1.0d0) + cos((lambda1 - lambda2))) / (-2.0d0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 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((((Math.cos(phi1) * Math.cos(phi2)) * ((-1.0 + Math.cos((lambda1 - lambda2))) / -2.0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 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((((math.cos(phi1) * math.cos(phi2)) * ((-1.0 + math.cos((lambda1 - lambda2))) / -2.0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 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(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(-1.0 + cos(Float64(lambda1 - lambda2))) / -2.0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 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((((cos(phi1) * cos(phi2)) * ((-1.0 + cos((lambda1 - lambda2))) / -2.0)) + (sin(((phi1 - phi2) / 2.0)) ^ 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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(-1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \frac{-1 + \cos \left(\lambda_1 - \lambda_2\right)}{-2} + {\sin \left(\frac{\phi_1 - \phi_2}{2}\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 61.9%
associate-*l*61.9%
Simplified61.9%
Taylor expanded in phi1 around 0 50.7%
Simplified50.7%
sin-mult48.9%
frac-2neg48.9%
Applied egg-rr48.9%
neg-sub048.9%
cos-048.9%
associate--r-48.9%
metadata-eval48.9%
Simplified48.9%
Final simplification48.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 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((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 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((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 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(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $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[(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{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
Taylor expanded in phi1 around 0 50.7%
Simplified50.7%
Taylor expanded in phi2 around 0 36.0%
Final simplification36.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))
(if (or (<= lambda2 -0.000125) (not (<= lambda2 2000.0)))
(* R (* 2.0 (atan2 t_0 (sqrt (pow (cos (* lambda2 -0.5)) 2.0)))))
(* R (* 2.0 (atan2 t_0 (sqrt (pow (cos (* 0.5 lambda1)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt(((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0)));
double tmp;
if ((lambda2 <= -0.000125) || !(lambda2 <= 2000.0)) {
tmp = R * (2.0 * atan2(t_0, sqrt(pow(cos((lambda2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(t_0, sqrt(pow(cos((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) :: tmp
t_0 = sqrt(((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0)))
if ((lambda2 <= (-0.000125d0)) .or. (.not. (lambda2 <= 2000.0d0))) then
tmp = r * (2.0d0 * atan2(t_0, sqrt((cos((lambda2 * (-0.5d0))) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(t_0, sqrt((cos((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.sqrt(((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0)));
double tmp;
if ((lambda2 <= -0.000125) || !(lambda2 <= 2000.0)) {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt(Math.pow(Math.cos((0.5 * lambda1)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt(((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))) tmp = 0 if (lambda2 <= -0.000125) or not (lambda2 <= 2000.0): tmp = R * (2.0 * math.atan2(t_0, math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(t_0, math.sqrt(math.pow(math.cos((0.5 * lambda1)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))) tmp = 0.0 if ((lambda2 <= -0.000125) || !(lambda2 <= 2000.0)) tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt((cos(Float64(0.5 * lambda1)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))); tmp = 0.0; if ((lambda2 <= -0.000125) || ~((lambda2 <= 2000.0))) tmp = R * (2.0 * atan2(t_0, sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(t_0, sqrt((cos((0.5 * lambda1)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.000125], N[Not[LessEqual[lambda2, 2000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[Power[N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}\\
\mathbf{if}\;\lambda_2 \leq -0.000125 \lor \neg \left(\lambda_2 \leq 2000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{{\cos \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < -1.25e-4 or 2e3 < lambda2 Initial program 49.3%
associate-*l*49.3%
Simplified49.3%
Taylor expanded in phi1 around 0 39.5%
Simplified39.5%
Taylor expanded in phi2 around 0 29.0%
Taylor expanded in phi2 around 0 28.8%
Taylor expanded in lambda1 around 0 29.0%
unpow229.0%
1-sub-sin29.1%
unpow229.1%
*-commutative29.1%
Simplified29.1%
if -1.25e-4 < lambda2 < 2e3Initial program 76.1%
associate-*l*76.2%
Simplified76.2%
Taylor expanded in phi1 around 0 63.3%
Simplified63.3%
Taylor expanded in phi2 around 0 43.9%
Taylor expanded in phi2 around 0 40.8%
Taylor expanded in lambda2 around 0 40.8%
unpow240.8%
1-sub-sin40.8%
unpow240.8%
Simplified40.8%
Final simplification34.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi1 0.5)) 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) {
return R * (2.0 * atan2(sqrt(((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi1 * 0.5)), 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
code = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 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) {
return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), 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.sqrt(((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))), 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(sqrt(Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), 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(sqrt(((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))), 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[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[(phi1 * 0.5), $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}
\\
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(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
Taylor expanded in phi1 around 0 50.7%
Simplified50.7%
Taylor expanded in phi2 around 0 36.0%
Taylor expanded in phi2 around 0 34.4%
Final simplification34.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))
(sqrt (pow (cos (* 0.5 lambda1)) 2.0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt(((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))), sqrt(pow(cos((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(sqrt(((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((cos((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.sqrt(((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(Math.pow(Math.cos((0.5 * lambda1)), 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(math.pow(math.cos((0.5 * lambda1)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt((cos(Float64(0.5 * lambda1)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((cos((0.5 * lambda1)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := 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[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
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(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)
\end{array}
Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
Taylor expanded in phi1 around 0 50.7%
Simplified50.7%
Taylor expanded in phi2 around 0 36.0%
Taylor expanded in phi2 around 0 34.4%
Taylor expanded in lambda2 around 0 29.7%
unpow229.7%
1-sub-sin29.7%
unpow229.7%
Simplified29.7%
Final simplification29.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2)))))
(*
R
(*
2.0
(atan2
(+
t_0
(* 0.5 (/ (pow phi1 2.0) (/ t_0 (+ 0.25 (* -0.5 (pow t_0 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((0.5 * (lambda1 - lambda2)));
return R * (2.0 * atan2((t_0 + (0.5 * (pow(phi1, 2.0) / (t_0 / (0.25 + (-0.5 * pow(t_0, 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((0.5d0 * (lambda1 - lambda2)))
code = r * (2.0d0 * atan2((t_0 + (0.5d0 * ((phi1 ** 2.0d0) / (t_0 / (0.25d0 + ((-0.5d0) * (t_0 ** 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((0.5 * (lambda1 - lambda2)));
return R * (2.0 * Math.atan2((t_0 + (0.5 * (Math.pow(phi1, 2.0) / (t_0 / (0.25 + (-0.5 * Math.pow(t_0, 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((0.5 * (lambda1 - lambda2))) return R * (2.0 * math.atan2((t_0 + (0.5 * (math.pow(phi1, 2.0) / (t_0 / (0.25 + (-0.5 * math.pow(t_0, 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(0.5 * Float64(lambda1 - lambda2))) return Float64(R * Float64(2.0 * atan(Float64(t_0 + Float64(0.5 * Float64((phi1 ^ 2.0) / Float64(t_0 / Float64(0.25 + Float64(-0.5 * (t_0 ^ 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((0.5 * (lambda1 - lambda2))); tmp = R * (2.0 * atan2((t_0 + (0.5 * ((phi1 ^ 2.0) / (t_0 / (0.25 + (-0.5 * (t_0 ^ 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[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[(t$95$0 + N[(0.5 * N[(N[Power[phi1, 2.0], $MachinePrecision] / N[(t$95$0 / N[(0.25 + N[(-0.5 * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0 + 0.5 \cdot \frac{{\phi_1}^{2}}{\frac{t\_0}{0.25 + -0.5 \cdot {t\_0}^{2}}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 61.9%
associate-*l*61.9%
Simplified61.9%
Taylor expanded in phi1 around 0 50.7%
Simplified50.7%
Taylor expanded in phi2 around 0 36.0%
Taylor expanded in phi2 around 0 34.4%
Taylor expanded in phi1 around 0 17.8%
associate-/l*17.8%
*-commutative17.8%
Simplified17.8%
Final simplification17.8%
herbie shell --seed 2024029
(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))))))))))