
(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 22 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 (/ (- lambda1 lambda2) 2.0)))
(t_1
(fma
t_0
(* (cos phi1) (* t_0 (cos phi2)))
(pow
(fma
(sin (* phi1 0.5))
(cos (* phi2 0.5))
(* (cos (* phi1 0.5)) (- (sin (* phi2 0.5)))))
2.0))))
(* (atan2 (sqrt t_1) (sqrt (- 1.0 t_1))) (* 2.0 R))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = fma(t_0, (cos(phi1) * (t_0 * cos(phi2))), pow(fma(sin((phi1 * 0.5)), cos((phi2 * 0.5)), (cos((phi1 * 0.5)) * -sin((phi2 * 0.5)))), 2.0));
return atan2(sqrt(t_1), sqrt((1.0 - t_1))) * (2.0 * R);
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = fma(t_0, Float64(cos(phi1) * Float64(t_0 * cos(phi2))), (fma(sin(Float64(phi1 * 0.5)), cos(Float64(phi2 * 0.5)), Float64(cos(Float64(phi1 * 0.5)) * Float64(-sin(Float64(phi2 * 0.5))))) ^ 2.0)) return Float64(atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))) * Float64(2.0 * R)) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * (-N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(2.0 * R), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \mathsf{fma}\left(t_0, \cos \phi_1 \cdot \left(t_0 \cdot \cos \phi_2\right), {\left(\mathsf{fma}\left(\sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right) \cdot \left(-\sin \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{2}\right)\\
\tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}} \cdot \left(2 \cdot R\right)
\end{array}
\end{array}
Initial program 63.1%
Simplified63.1%
div-sub63.1%
sin-diff64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
Applied egg-rr64.2%
fma-neg64.2%
*-commutative64.2%
*-commutative64.2%
*-commutative64.2%
distribute-rgt-neg-in64.2%
*-commutative64.2%
Simplified64.2%
div-sub63.1%
sin-diff64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
Applied egg-rr79.6%
fma-neg64.2%
*-commutative64.2%
*-commutative64.2%
*-commutative64.2%
distribute-rgt-neg-in64.2%
*-commutative64.2%
Simplified79.7%
Final simplification79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (* phi2 0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* t_3 (* (cos phi1) (cos phi2)))))
(t_5 (sin (* phi1 0.5))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (fma t_5 t_0 (* t_1 (- t_2))) 2.0) t_4))
(sqrt (- 1.0 (+ t_4 (pow (- (* t_5 t_0) (* t_1 t_2)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin((phi2 * 0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * (t_3 * (cos(phi1) * cos(phi2)));
double t_5 = sin((phi1 * 0.5));
return R * (2.0 * atan2(sqrt((pow(fma(t_5, t_0, (t_1 * -t_2)), 2.0) + t_4)), sqrt((1.0 - (t_4 + pow(((t_5 * t_0) - (t_1 * t_2)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(phi2 * 0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(t_3 * Float64(cos(phi1) * cos(phi2)))) t_5 = sin(Float64(phi1 * 0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(t_5, t_0, Float64(t_1 * Float64(-t_2))) ^ 2.0) + t_4)), sqrt(Float64(1.0 - Float64(t_4 + (Float64(Float64(t_5 * t_0) - Float64(t_1 * t_2)) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[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[(t$95$3 * N[(t$95$3 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(t$95$5 * t$95$0 + N[(t$95$1 * (-t$95$2)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + N[Power[N[(N[(t$95$5 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\phi_2 \cdot 0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t_3 \cdot \left(t_3 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_5 := \sin \left(\phi_1 \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(t_5, t_0, t_1 \cdot \left(-t_2\right)\right)\right)}^{2} + t_4}}{\sqrt{1 - \left(t_4 + {\left(t_5 \cdot t_0 - t_1 \cdot t_2\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
Applied egg-rr64.2%
div-sub63.1%
sin-diff64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
Applied egg-rr79.6%
fma-neg64.2%
*-commutative64.2%
*-commutative64.2%
*-commutative64.2%
distribute-rgt-neg-in64.2%
*-commutative64.2%
Simplified79.6%
Final simplification79.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))) + Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) + math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) + (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
Applied egg-rr64.2%
div-sub63.1%
sin-diff64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
Applied egg-rr79.6%
Final simplification79.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (* phi2 0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (cos phi1) (* t_3 (cos phi2))))
(t_5 (sin (* phi1 0.5)))
(t_6 (pow (fma t_5 t_0 (* t_1 (- t_2))) 2.0)))
(if (<= (- lambda1 lambda2) -0.02)
(*
(* 2.0 R)
(atan2
(sqrt (fma t_3 t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (fma t_3 t_4 t_6)))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_6 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt
(-
1.0
(+
(* t_3 (* t_3 (* (cos phi1) (cos phi2))))
(pow (- (* t_5 t_0) (* t_1 t_2)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin((phi2 * 0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = cos(phi1) * (t_3 * cos(phi2));
double t_5 = sin((phi1 * 0.5));
double t_6 = pow(fma(t_5, t_0, (t_1 * -t_2)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -0.02) {
tmp = (2.0 * R) * atan2(sqrt(fma(t_3, t_4, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_3, t_4, t_6))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_6 + (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((1.0 - ((t_3 * (t_3 * (cos(phi1) * cos(phi2)))) + pow(((t_5 * t_0) - (t_1 * t_2)), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(phi2 * 0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(cos(phi1) * Float64(t_3 * cos(phi2))) t_5 = sin(Float64(phi1 * 0.5)) t_6 = fma(t_5, t_0, Float64(t_1 * Float64(-t_2))) ^ 2.0 tmp = 0.0 if (Float64(lambda1 - lambda2) <= -0.02) tmp = Float64(Float64(2.0 * R) * atan(sqrt(fma(t_3, t_4, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_3, t_4, t_6))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_6 + Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(1.0 - Float64(Float64(t_3 * Float64(t_3 * Float64(cos(phi1) * cos(phi2)))) + (Float64(Float64(t_5 * t_0) - Float64(t_1 * t_2)) ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[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[(N[Cos[phi1], $MachinePrecision] * N[(t$95$3 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Power[N[(t$95$5 * t$95$0 + N[(t$95$1 * (-t$95$2)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.02], N[(N[(2.0 * R), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(t$95$3 * t$95$4 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 * t$95$4 + t$95$6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$6 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$3 * N[(t$95$3 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(t$95$5 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\phi_2 \cdot 0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \cos \phi_1 \cdot \left(t_3 \cdot \cos \phi_2\right)\\
t_5 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_6 := {\left(\mathsf{fma}\left(t_5, t_0, t_1 \cdot \left(-t_2\right)\right)\right)}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.02:\\
\;\;\;\;\left(2 \cdot R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_3, t_4, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_3, t_4, t_6\right)}}\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_6 + \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{1 - \left(t_3 \cdot \left(t_3 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\left(t_5 \cdot t_0 - t_1 \cdot t_2\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -0.0200000000000000004Initial program 61.2%
Simplified61.2%
div-sub61.2%
sin-diff62.2%
div-inv62.2%
metadata-eval62.2%
div-inv62.2%
metadata-eval62.2%
div-inv62.2%
metadata-eval62.2%
div-inv62.2%
metadata-eval62.2%
Applied egg-rr62.2%
fma-neg62.2%
*-commutative62.2%
*-commutative62.2%
*-commutative62.2%
distribute-rgt-neg-in62.2%
*-commutative62.2%
Simplified62.2%
if -0.0200000000000000004 < (-.f64 lambda1 lambda2) Initial program 64.4%
div-sub64.5%
sin-diff65.6%
div-inv65.6%
metadata-eval65.6%
div-inv65.6%
metadata-eval65.6%
div-inv65.6%
metadata-eval65.6%
div-inv65.6%
metadata-eval65.6%
Applied egg-rr65.6%
div-sub64.5%
sin-diff65.6%
div-inv65.6%
metadata-eval65.6%
div-inv65.6%
metadata-eval65.6%
div-inv65.6%
metadata-eval65.6%
div-inv65.6%
metadata-eval65.6%
Applied egg-rr84.0%
fma-neg65.6%
*-commutative65.6%
*-commutative65.6%
*-commutative65.6%
distribute-rgt-neg-in65.6%
*-commutative65.6%
Simplified84.1%
Taylor expanded in phi2 around 0 68.0%
Final simplification65.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (* phi2 0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (cos phi1) (* t_3 (cos phi2))))
(t_5 (sin (* phi1 0.5)))
(t_6 (pow (fma t_5 t_0 (* t_1 (- t_2))) 2.0)))
(if (<= (- lambda1 lambda2) -40.0)
(*
(* 2.0 R)
(atan2
(sqrt (fma t_3 t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (fma t_3 t_4 t_6)))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_6 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt
(-
1.0
(+
(* t_3 (* t_3 (* (cos phi1) (cos phi2))))
(pow (- (* t_5 t_0) (* t_1 t_2)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin((phi2 * 0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = cos(phi1) * (t_3 * cos(phi2));
double t_5 = sin((phi1 * 0.5));
double t_6 = pow(fma(t_5, t_0, (t_1 * -t_2)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -40.0) {
tmp = (2.0 * R) * atan2(sqrt(fma(t_3, t_4, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_3, t_4, t_6))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_6 + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((1.0 - ((t_3 * (t_3 * (cos(phi1) * cos(phi2)))) + pow(((t_5 * t_0) - (t_1 * t_2)), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(phi2 * 0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(cos(phi1) * Float64(t_3 * cos(phi2))) t_5 = sin(Float64(phi1 * 0.5)) t_6 = fma(t_5, t_0, Float64(t_1 * Float64(-t_2))) ^ 2.0 tmp = 0.0 if (Float64(lambda1 - lambda2) <= -40.0) tmp = Float64(Float64(2.0 * R) * atan(sqrt(fma(t_3, t_4, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_3, t_4, t_6))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_6 + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(1.0 - Float64(Float64(t_3 * Float64(t_3 * Float64(cos(phi1) * cos(phi2)))) + (Float64(Float64(t_5 * t_0) - Float64(t_1 * t_2)) ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[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[(N[Cos[phi1], $MachinePrecision] * N[(t$95$3 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Power[N[(t$95$5 * t$95$0 + N[(t$95$1 * (-t$95$2)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -40.0], N[(N[(2.0 * R), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(t$95$3 * t$95$4 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 * t$95$4 + t$95$6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$6 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$3 * N[(t$95$3 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(t$95$5 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\phi_2 \cdot 0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \cos \phi_1 \cdot \left(t_3 \cdot \cos \phi_2\right)\\
t_5 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_6 := {\left(\mathsf{fma}\left(t_5, t_0, t_1 \cdot \left(-t_2\right)\right)\right)}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -40:\\
\;\;\;\;\left(2 \cdot R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_3, t_4, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_3, t_4, t_6\right)}}\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_6 + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{1 - \left(t_3 \cdot \left(t_3 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\left(t_5 \cdot t_0 - t_1 \cdot t_2\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -40Initial program 60.5%
Simplified60.5%
div-sub60.5%
sin-diff61.4%
div-inv61.4%
metadata-eval61.4%
div-inv61.4%
metadata-eval61.4%
div-inv61.4%
metadata-eval61.4%
div-inv61.4%
metadata-eval61.4%
Applied egg-rr61.4%
fma-neg61.4%
*-commutative61.4%
*-commutative61.4%
*-commutative61.4%
distribute-rgt-neg-in61.4%
*-commutative61.4%
Simplified61.4%
if -40 < (-.f64 lambda1 lambda2) Initial program 64.9%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr66.0%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr84.2%
fma-neg66.0%
*-commutative66.0%
*-commutative66.0%
*-commutative66.0%
distribute-rgt-neg-in66.0%
*-commutative66.0%
Simplified84.3%
Taylor expanded in phi1 around 0 67.7%
Final simplification65.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (* phi2 0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (cos phi1) (* t_3 (cos phi2))))
(t_5 (sin (* phi1 0.5)))
(t_6 (pow (fma t_5 t_0 (* t_1 (- t_2))) 2.0)))
(if (<= (- lambda1 lambda2) -40.0)
(*
(* 2.0 R)
(atan2
(sqrt (fma t_3 t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (fma t_3 t_4 t_6)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_6 (* t_3 (* t_3 (* (cos phi1) (cos phi2))))))
(sqrt
(-
1.0
(+
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (- (* t_5 t_0) (* t_1 t_2)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin((phi2 * 0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = cos(phi1) * (t_3 * cos(phi2));
double t_5 = sin((phi1 * 0.5));
double t_6 = pow(fma(t_5, t_0, (t_1 * -t_2)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -40.0) {
tmp = (2.0 * R) * atan2(sqrt(fma(t_3, t_4, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_3, t_4, t_6))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_6 + (t_3 * (t_3 * (cos(phi1) * cos(phi2)))))), sqrt((1.0 - ((cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(((t_5 * t_0) - (t_1 * t_2)), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(phi2 * 0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(cos(phi1) * Float64(t_3 * cos(phi2))) t_5 = sin(Float64(phi1 * 0.5)) t_6 = fma(t_5, t_0, Float64(t_1 * Float64(-t_2))) ^ 2.0 tmp = 0.0 if (Float64(lambda1 - lambda2) <= -40.0) tmp = Float64(Float64(2.0 * R) * atan(sqrt(fma(t_3, t_4, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_3, t_4, t_6))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_6 + Float64(t_3 * Float64(t_3 * Float64(cos(phi1) * cos(phi2)))))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (Float64(Float64(t_5 * t_0) - Float64(t_1 * t_2)) ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[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[(N[Cos[phi1], $MachinePrecision] * N[(t$95$3 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Power[N[(t$95$5 * t$95$0 + N[(t$95$1 * (-t$95$2)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -40.0], N[(N[(2.0 * R), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(t$95$3 * t$95$4 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 * t$95$4 + t$95$6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$6 + N[(t$95$3 * N[(t$95$3 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(t$95$5 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\phi_2 \cdot 0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \cos \phi_1 \cdot \left(t_3 \cdot \cos \phi_2\right)\\
t_5 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_6 := {\left(\mathsf{fma}\left(t_5, t_0, t_1 \cdot \left(-t_2\right)\right)\right)}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -40:\\
\;\;\;\;\left(2 \cdot R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_3, t_4, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_3, t_4, t_6\right)}}\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_6 + t_3 \cdot \left(t_3 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)}}{\sqrt{1 - \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\left(t_5 \cdot t_0 - t_1 \cdot t_2\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -40Initial program 60.5%
Simplified60.5%
div-sub60.5%
sin-diff61.4%
div-inv61.4%
metadata-eval61.4%
div-inv61.4%
metadata-eval61.4%
div-inv61.4%
metadata-eval61.4%
div-inv61.4%
metadata-eval61.4%
Applied egg-rr61.4%
fma-neg61.4%
*-commutative61.4%
*-commutative61.4%
*-commutative61.4%
distribute-rgt-neg-in61.4%
*-commutative61.4%
Simplified61.4%
if -40 < (-.f64 lambda1 lambda2) Initial program 64.9%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr66.0%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr84.2%
fma-neg66.0%
*-commutative66.0%
*-commutative66.0%
*-commutative66.0%
distribute-rgt-neg-in66.0%
*-commutative66.0%
Simplified84.3%
Taylor expanded in phi1 around 0 67.0%
Final simplification64.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (* t_0 (cos phi2)))))
(*
(* 2.0 R)
(atan2
(sqrt (fma t_0 t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(fma
t_0
t_1
(pow
(fma
(sin (* phi1 0.5))
(cos (* phi2 0.5))
(* (cos (* phi1 0.5)) (- (sin (* phi2 0.5)))))
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 = cos(phi1) * (t_0 * cos(phi2));
return (2.0 * R) * atan2(sqrt(fma(t_0, t_1, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_0, t_1, pow(fma(sin((phi1 * 0.5)), cos((phi2 * 0.5)), (cos((phi1 * 0.5)) * -sin((phi2 * 0.5)))), 2.0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * Float64(t_0 * cos(phi2))) return Float64(Float64(2.0 * R) * atan(sqrt(fma(t_0, t_1, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_0, t_1, (fma(sin(Float64(phi1 * 0.5)), cos(Float64(phi2 * 0.5)), Float64(cos(Float64(phi1 * 0.5)) * Float64(-sin(Float64(phi2 * 0.5))))) ^ 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[(N[Cos[phi1], $MachinePrecision] * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(2.0 * R), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(t$95$0 * t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * t$95$1 + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * (-N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $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)\\
t_1 := \cos \phi_1 \cdot \left(t_0 \cdot \cos \phi_2\right)\\
\left(2 \cdot R\right) \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, t_1, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_0, t_1, {\left(\mathsf{fma}\left(\sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right) \cdot \left(-\sin \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{2}\right)}}
\end{array}
\end{array}
Initial program 63.1%
Simplified63.1%
div-sub63.1%
sin-diff64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
Applied egg-rr64.2%
fma-neg64.2%
*-commutative64.2%
*-commutative64.2%
*-commutative64.2%
distribute-rgt-neg-in64.2%
*-commutative64.2%
Simplified64.2%
Final simplification64.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
t_1
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
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 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_1 + pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (t_1 + (((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 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 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (t_1 + Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (t_1 + math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_1 + (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (t_1 + (((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $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[(1.0 - N[(t$95$1 + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $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 := t_0 \cdot \left(t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t_1 + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
div-sub63.1%
sin-diff64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
div-inv64.2%
metadata-eval64.2%
Applied egg-rr64.2%
Final simplification64.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_1 t_0)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(pow
(pow
(-
1.0
(fma
t_0
(- 0.5 (* 0.5 (cos (- lambda1 lambda2))))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
3.0)
0.3333333333333333)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_1 * (t_1 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(pow(pow((1.0 - fma(t_0, (0.5 - (0.5 * cos((lambda1 - lambda2)))), pow(sin((0.5 * (phi1 - phi2))), 2.0))), 3.0), 0.3333333333333333))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_1 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((Float64(1.0 - fma(t_0, Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2)))), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))) ^ 3.0) ^ 0.3333333333333333))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$1 * 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[Power[N[Power[N[(1.0 - N[(t$95$0 * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_1 \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\left({\left(1 - \mathsf{fma}\left(t_0, 0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right)}^{3}\right)}^{0.3333333333333333}}}\right)
\end{array}
\end{array}
Initial program 63.1%
add-cbrt-cube63.1%
pow1/363.1%
Applied egg-rr63.2%
Final simplification63.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_1 t_0)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(exp
(log1p
(-
(fma
t_0
(+ 0.5 (* (cos (- lambda1 lambda2)) -0.5))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_1 * (t_1 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(exp(log1p(-fma(t_0, (0.5 + (cos((lambda1 - lambda2)) * -0.5)), pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_1 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(exp(log1p(Float64(-fma(t_0, Float64(0.5 + Float64(cos(Float64(lambda1 - lambda2)) * -0.5)), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$1 * 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[Exp[N[Log[1 + (-N[(t$95$0 * N[(0.5 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_1 \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{e^{\mathsf{log1p}\left(-\mathsf{fma}\left(t_0, 0.5 + \cos \left(\lambda_1 - \lambda_2\right) \cdot -0.5, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right)}}}\right)
\end{array}
\end{array}
Initial program 63.1%
add-exp-log63.1%
sub-neg63.1%
log1p-def63.1%
Applied egg-rr63.2%
fma-def63.2%
associate-*l*63.2%
fma-udef63.2%
fma-udef63.2%
associate-*l*63.2%
fma-def63.2%
Simplified63.2%
Final simplification63.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_1 t_0)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(+
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_0 (- (* 0.5 (cos (- lambda1 lambda2))) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_1 * (t_1 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) + (t_0 * ((0.5 * cos((lambda1 - lambda2))) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_1 * (t_1 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) + (t_0 * ((0.5d0 * cos((lambda1 - lambda2))) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_1 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) + (t_0 * ((0.5 * Math.cos((lambda1 - lambda2))) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_1 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) + (t_0 * ((0.5 * math.cos((lambda1 - lambda2))) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_1 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) + Float64(t_0 * Float64(Float64(0.5 * cos(Float64(lambda1 - lambda2))) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_1 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) + (t_0 * ((0.5 * cos((lambda1 - lambda2))) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$1 * 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[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_1 \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) + t_0 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 63.1%
associate--r+63.1%
sub-neg63.1%
div-inv63.1%
metadata-eval63.1%
associate-*l*63.1%
Applied egg-rr63.2%
Final simplification63.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_3 (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
(t_4 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2)))))
(if (<= phi2 -9.5e-6)
(* R (* 2.0 (atan2 t_3 t_4)))
(if (<= phi2 2.7e-5)
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_2))))))
(*
R
(* 2.0 (atan2 (sqrt (+ t_1 (pow (sin (* phi2 -0.5)) 2.0))) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_3 = sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_4 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)));
double tmp;
if (phi2 <= -9.5e-6) {
tmp = R * (2.0 * atan2(t_3, t_4));
} else if (phi2 <= 2.7e-5) {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi2 * -0.5)), 2.0))), t_4));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_3 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
t_4 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))
if (phi2 <= (-9.5d-6)) then
tmp = r * (2.0d0 * atan2(t_3, t_4))
else if (phi2 <= 2.7d-5) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_2)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_3 = Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_4 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)));
double tmp;
if (phi2 <= -9.5e-6) {
tmp = R * (2.0 * Math.atan2(t_3, t_4));
} else if (phi2 <= 2.7e-5) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_3 = math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) t_4 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))) tmp = 0 if phi2 <= -9.5e-6: tmp = R * (2.0 * math.atan2(t_3, t_4)) elif phi2 <= 2.7e-5: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_2))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi2 * -0.5)), 2.0))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_3 = sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) t_4 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2))) tmp = 0.0 if (phi2 <= -9.5e-6) tmp = Float64(R * Float64(2.0 * atan(t_3, t_4))); elseif (phi2 <= 2.7e-5) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_3 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); t_4 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))); tmp = 0.0; if (phi2 <= -9.5e-6) tmp = R * (2.0 * atan2(t_3, t_4)); elseif (phi2 <= 2.7e-5) tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_2))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi2 * -0.5)) ^ 2.0))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -9.5e-6], N[(R * N[(2.0 * N[ArcTan[t$95$3 / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 2.7e-5], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_3 := \sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
t_4 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_2}\\
\mathbf{if}\;\phi_2 \leq -9.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{t_4}\right)\\
\mathbf{elif}\;\phi_2 \leq 2.7 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{t_4}\right)\\
\end{array}
\end{array}
if phi2 < -9.5000000000000005e-6Initial program 45.4%
Taylor expanded in phi1 around 0 46.6%
associate--r+46.6%
unpow246.6%
1-sub-sin46.6%
unpow246.6%
sub-neg46.6%
mul-1-neg46.6%
+-commutative46.6%
+-commutative46.6%
distribute-lft-in46.6%
metadata-eval46.6%
associate-*r*46.6%
associate-*r*46.6%
metadata-eval46.6%
distribute-lft-in46.6%
Simplified46.6%
if -9.5000000000000005e-6 < phi2 < 2.6999999999999999e-5Initial program 79.5%
Taylor expanded in phi2 around 0 79.6%
associate--r+79.6%
unpow279.6%
*-commutative79.6%
*-commutative79.6%
1-sub-sin79.6%
*-commutative79.6%
*-commutative79.6%
unpow279.6%
*-commutative79.6%
*-commutative79.6%
unpow279.6%
associate-*l*79.6%
Simplified79.6%
if 2.6999999999999999e-5 < phi2 Initial program 46.4%
Taylor expanded in phi1 around 0 47.2%
associate--r+47.2%
unpow247.2%
1-sub-sin47.4%
unpow247.4%
sub-neg47.4%
mul-1-neg47.4%
+-commutative47.4%
+-commutative47.4%
distribute-lft-in47.4%
metadata-eval47.4%
associate-*r*47.4%
associate-*r*47.4%
metadata-eval47.4%
distribute-lft-in47.4%
Simplified47.4%
Taylor expanded in phi1 around 0 47.7%
Final simplification63.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= lambda1 -3.5e-7)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
t_1
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (- t_1 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 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(cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda1 <= -3.5e-7) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((t_1 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((t_1 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos((phi2 * (-0.5d0))) ** 2.0d0
if (lambda1 <= (-3.5d-7)) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((t_1 - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((t_1 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda1 <= -3.5e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((t_1 - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((t_1 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.cos((phi2 * -0.5)), 2.0) tmp = 0 if lambda1 <= -3.5e-7: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((t_1 - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((t_1 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (lambda1 <= -3.5e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(t_1 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(t_1 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if (lambda1 <= -3.5e-7) tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((t_1 - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((t_1 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda1, -3.5e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - 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[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $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 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -3.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{t_1 - \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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{t_1 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -3.49999999999999984e-7Initial program 48.9%
Taylor expanded in phi1 around 0 38.1%
associate--r+38.1%
unpow238.1%
1-sub-sin38.1%
unpow238.1%
sub-neg38.1%
mul-1-neg38.1%
+-commutative38.1%
+-commutative38.1%
distribute-lft-in38.1%
metadata-eval38.1%
associate-*r*38.1%
associate-*r*38.1%
metadata-eval38.1%
distribute-lft-in38.1%
Simplified38.1%
Taylor expanded in phi1 around 0 34.5%
if -3.49999999999999984e-7 < lambda1 Initial program 69.2%
Taylor expanded in phi1 around 0 53.3%
associate--r+53.3%
unpow253.3%
1-sub-sin53.3%
unpow253.3%
sub-neg53.3%
mul-1-neg53.3%
+-commutative53.3%
+-commutative53.3%
distribute-lft-in53.3%
metadata-eval53.3%
associate-*r*53.3%
associate-*r*53.3%
metadata-eval53.3%
distribute-lft-in53.3%
Simplified53.3%
Taylor expanded in lambda1 around 0 48.2%
*-commutative48.2%
Simplified48.2%
Taylor expanded in phi1 around 0 48.3%
Final simplification44.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= lambda1 -3.6e-6)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(*
(* (sin (/ (- lambda1 lambda2) 2.0)) (* (cos phi1) (cos phi2)))
(sin (* lambda1 0.5)))))
(sqrt
(-
t_1
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (- t_1 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 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 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda1 <= -3.6e-6) {
tmp = R * (2.0 * atan2(sqrt((t_0 + ((sin(((lambda1 - lambda2) / 2.0)) * (cos(phi1) * cos(phi2))) * sin((lambda1 * 0.5))))), sqrt((t_1 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((t_1 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos((phi2 * (-0.5d0))) ** 2.0d0
if (lambda1 <= (-3.6d-6)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + ((sin(((lambda1 - lambda2) / 2.0d0)) * (cos(phi1) * cos(phi2))) * sin((lambda1 * 0.5d0))))), sqrt((t_1 - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((t_1 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 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.pow(Math.cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda1 <= -3.6e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + ((Math.sin(((lambda1 - lambda2) / 2.0)) * (Math.cos(phi1) * Math.cos(phi2))) * Math.sin((lambda1 * 0.5))))), Math.sqrt((t_1 - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((t_1 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 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.pow(math.cos((phi2 * -0.5)), 2.0) tmp = 0 if lambda1 <= -3.6e-6: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + ((math.sin(((lambda1 - lambda2) / 2.0)) * (math.cos(phi1) * math.cos(phi2))) * math.sin((lambda1 * 0.5))))), math.sqrt((t_1 - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((t_1 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (lambda1 <= -3.6e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(Float64(sin(Float64(Float64(lambda1 - lambda2) / 2.0)) * Float64(cos(phi1) * cos(phi2))) * sin(Float64(lambda1 * 0.5))))), sqrt(Float64(t_1 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(t_1 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 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 = cos((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if (lambda1 <= -3.6e-6) tmp = R * (2.0 * atan2(sqrt((t_0 + ((sin(((lambda1 - lambda2) / 2.0)) * (cos(phi1) * cos(phi2))) * sin((lambda1 * 0.5))))), sqrt((t_1 - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((t_1 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 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[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda1, -3.6e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - 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$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $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 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -3.6 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \cdot \sin \left(\lambda_1 \cdot 0.5\right)}}{\sqrt{t_1 - \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_0 + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{t_1 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -3.59999999999999984e-6Initial program 48.9%
Taylor expanded in phi1 around 0 38.1%
associate--r+38.1%
unpow238.1%
1-sub-sin38.1%
unpow238.1%
sub-neg38.1%
mul-1-neg38.1%
+-commutative38.1%
+-commutative38.1%
distribute-lft-in38.1%
metadata-eval38.1%
associate-*r*38.1%
associate-*r*38.1%
metadata-eval38.1%
distribute-lft-in38.1%
Simplified38.1%
Taylor expanded in lambda2 around 0 36.7%
if -3.59999999999999984e-6 < lambda1 Initial program 69.2%
Taylor expanded in phi1 around 0 53.3%
associate--r+53.3%
unpow253.3%
1-sub-sin53.3%
unpow253.3%
sub-neg53.3%
mul-1-neg53.3%
+-commutative53.3%
+-commutative53.3%
distribute-lft-in53.3%
metadata-eval53.3%
associate-*r*53.3%
associate-*r*53.3%
metadata-eval53.3%
distribute-lft-in53.3%
Simplified53.3%
Taylor expanded in lambda1 around 0 48.2%
*-commutative48.2%
Simplified48.2%
Taylor expanded in phi1 around 0 48.3%
Final simplification44.8%
(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 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= lambda2 1.42e-6)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_1 (* (cos phi1) (cos phi2)))) t_0))
(sqrt (- t_2 (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (- t_2 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 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 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda2 <= 1.42e-6) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_1 * (cos(phi1) * cos(phi2)))) + t_0)), sqrt((t_2 - (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((t_2 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 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((phi2 * (-0.5d0))) ** 2.0d0
if (lambda2 <= 1.42d-6) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_1 * (cos(phi1) * cos(phi2)))) + t_0)), sqrt((t_2 - (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((t_2 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 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.pow(Math.cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda2 <= 1.42e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_1 * (Math.cos(phi1) * Math.cos(phi2)))) + t_0)), Math.sqrt((t_2 - (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((t_2 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 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.pow(math.cos((phi2 * -0.5)), 2.0) tmp = 0 if lambda2 <= 1.42e-6: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_1 * (math.cos(phi1) * math.cos(phi2)))) + t_0)), math.sqrt((t_2 - (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((t_2 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 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 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (lambda2 <= 1.42e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_1 * Float64(cos(phi1) * cos(phi2)))) + t_0)), sqrt(Float64(t_2 - Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(t_2 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 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((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if (lambda2 <= 1.42e-6) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_1 * (cos(phi1) * cos(phi2)))) + t_0)), sqrt((t_2 - (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((t_2 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 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[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda2, 1.42e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $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 \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\lambda_2 \leq 1.42 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + t_0}}{\sqrt{t_2 - \cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{t_2 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 1.42e-6Initial program 66.8%
Taylor expanded in phi1 around 0 50.7%
associate--r+50.7%
unpow250.7%
1-sub-sin50.7%
unpow250.7%
sub-neg50.7%
mul-1-neg50.7%
+-commutative50.7%
+-commutative50.7%
distribute-lft-in50.7%
metadata-eval50.7%
associate-*r*50.7%
associate-*r*50.7%
metadata-eval50.7%
distribute-lft-in50.7%
Simplified50.7%
Taylor expanded in lambda2 around 0 43.3%
*-commutative43.3%
Simplified43.3%
if 1.42e-6 < lambda2 Initial program 52.7%
Taylor expanded in phi1 around 0 43.1%
associate--r+43.1%
unpow243.1%
1-sub-sin43.2%
unpow243.2%
sub-neg43.2%
mul-1-neg43.2%
+-commutative43.2%
+-commutative43.2%
distribute-lft-in43.2%
metadata-eval43.2%
associate-*r*43.2%
associate-*r*43.2%
metadata-eval43.2%
distribute-lft-in43.2%
Simplified43.2%
Taylor expanded in lambda1 around 0 43.1%
*-commutative43.1%
Simplified43.1%
Taylor expanded in phi1 around 0 43.7%
Final simplification43.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))
(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) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + 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
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (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) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))) + 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): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) + 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) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) + (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) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (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_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(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{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(t_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\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}
\end{array}
Initial program 63.1%
Taylor expanded in phi1 around 0 48.7%
associate--r+48.7%
unpow248.7%
1-sub-sin48.7%
unpow248.7%
sub-neg48.7%
mul-1-neg48.7%
+-commutative48.7%
+-commutative48.7%
distribute-lft-in48.7%
metadata-eval48.7%
associate-*r*48.7%
associate-*r*48.7%
metadata-eval48.7%
distribute-lft-in48.7%
Simplified48.7%
Final simplification48.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= lambda1 -2.55)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(*
(cos phi1)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 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 tmp;
if (lambda1 <= -2.55) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((lambda2 * -0.5)), 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 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (lambda1 <= (-2.55d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0)))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 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 tmp;
if (lambda1 <= -2.55) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if lambda1 <= -2.55: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (lambda1 <= -2.55) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (lambda1 <= -2.55) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0)))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 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]}, If[LessEqual[lambda1, -2.55], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $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}\\
\mathbf{if}\;\lambda_1 \leq -2.55:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_1 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}}}{\sqrt{1 - {\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_0 + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -2.5499999999999998Initial program 48.7%
Taylor expanded in phi1 around 0 37.8%
associate--r+37.8%
unpow237.8%
1-sub-sin37.8%
unpow237.8%
sub-neg37.8%
mul-1-neg37.8%
+-commutative37.8%
+-commutative37.8%
distribute-lft-in37.8%
metadata-eval37.8%
associate-*r*37.8%
associate-*r*37.8%
metadata-eval37.8%
distribute-lft-in37.8%
Simplified37.8%
Taylor expanded in phi2 around 0 32.7%
Taylor expanded in phi2 around 0 32.8%
*-commutative32.8%
metadata-eval32.8%
div-inv32.8%
div-sub32.8%
sin-diff33.2%
Applied egg-rr33.2%
if -2.5499999999999998 < lambda1 Initial program 69.0%
Taylor expanded in phi1 around 0 53.1%
associate--r+53.1%
unpow253.1%
1-sub-sin53.2%
unpow253.2%
sub-neg53.2%
mul-1-neg53.2%
+-commutative53.2%
+-commutative53.2%
distribute-lft-in53.2%
metadata-eval53.2%
associate-*r*53.2%
associate-*r*53.2%
metadata-eval53.2%
distribute-lft-in53.2%
Simplified53.2%
Taylor expanded in lambda1 around 0 47.8%
*-commutative47.8%
Simplified47.8%
Taylor expanded in phi1 around 0 47.9%
Final simplification43.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(if (<= (- lambda1 lambda2) -50000000000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_0))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -50000000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_0 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((lambda2 * -0.5)), 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 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
if ((lambda1 - lambda2) <= (-50000000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 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.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -50000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (lambda1 - lambda2) <= -50000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -50000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_0)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); tmp = 0.0; if ((lambda1 - lambda2) <= -50000000000.0) tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_0)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -50000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + 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[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -50000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + {\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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -5e10Initial program 60.1%
Taylor expanded in phi1 around 0 46.5%
associate--r+46.4%
unpow246.4%
1-sub-sin46.5%
unpow246.5%
sub-neg46.5%
mul-1-neg46.5%
+-commutative46.5%
+-commutative46.5%
distribute-lft-in46.5%
metadata-eval46.5%
associate-*r*46.5%
associate-*r*46.5%
metadata-eval46.5%
distribute-lft-in46.5%
Simplified46.5%
Taylor expanded in phi2 around 0 35.7%
Taylor expanded in phi2 around 0 35.5%
Taylor expanded in phi2 around 0 36.1%
if -5e10 < (-.f64 lambda1 lambda2) Initial program 65.1%
Taylor expanded in phi1 around 0 50.2%
associate--r+50.2%
unpow250.2%
1-sub-sin50.3%
unpow250.3%
sub-neg50.3%
mul-1-neg50.3%
+-commutative50.3%
+-commutative50.3%
distribute-lft-in50.3%
metadata-eval50.3%
associate-*r*50.3%
associate-*r*50.3%
metadata-eval50.3%
distribute-lft-in50.3%
Simplified50.3%
Taylor expanded in lambda1 around 0 43.8%
*-commutative43.8%
Simplified43.8%
Taylor expanded in phi2 around 0 40.5%
Final simplification38.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= lambda1 -1300000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi1) t_1)))
(sqrt (pow (cos (* lambda1 0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi2) t_1)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 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 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (lambda1 <= -1300000.0) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * t_1))), sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * t_1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if (lambda1 <= (-1300000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * t_1))), sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * t_1))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (lambda1 <= -1300000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * t_1))), Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * t_1))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 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.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if lambda1 <= -1300000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * t_1))), math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * t_1))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 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) * 0.5)) ^ 2.0 tmp = 0.0 if (lambda1 <= -1300000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * t_1))), sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * t_1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 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) * 0.5)) ^ 2.0; tmp = 0.0; if (lambda1 <= -1300000.0) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * t_1))), sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * t_1))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda1, -1300000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $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[(lambda2 * -0.5), $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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -1300000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_1 \cdot t_1}}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot t_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.3e6Initial program 49.1%
Taylor expanded in phi1 around 0 38.0%
associate--r+38.0%
unpow238.0%
1-sub-sin38.0%
unpow238.0%
sub-neg38.0%
mul-1-neg38.0%
+-commutative38.0%
+-commutative38.0%
distribute-lft-in38.0%
metadata-eval38.0%
associate-*r*38.0%
associate-*r*38.0%
metadata-eval38.0%
distribute-lft-in38.0%
Simplified38.0%
Taylor expanded in phi2 around 0 32.8%
Taylor expanded in phi2 around 0 33.0%
Taylor expanded in lambda2 around 0 32.7%
unpow232.7%
1-sub-sin32.7%
unpow232.7%
Simplified32.7%
if -1.3e6 < lambda1 Initial program 68.7%
Taylor expanded in phi1 around 0 53.0%
associate--r+53.0%
unpow253.0%
1-sub-sin53.0%
unpow253.0%
sub-neg53.0%
mul-1-neg53.0%
+-commutative53.0%
+-commutative53.0%
distribute-lft-in53.0%
metadata-eval53.0%
associate-*r*53.0%
associate-*r*53.0%
metadata-eval53.0%
distribute-lft-in53.0%
Simplified53.0%
Taylor expanded in lambda1 around 0 47.6%
*-commutative47.6%
Simplified47.6%
Taylor expanded in phi1 around 0 47.8%
Final simplification43.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * pow(sin(((lambda1 - lambda2) * 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(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 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.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 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.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 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(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \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 63.1%
Taylor expanded in phi1 around 0 48.7%
associate--r+48.7%
unpow248.7%
1-sub-sin48.7%
unpow248.7%
sub-neg48.7%
mul-1-neg48.7%
+-commutative48.7%
+-commutative48.7%
distribute-lft-in48.7%
metadata-eval48.7%
associate-*r*48.7%
associate-*r*48.7%
metadata-eval48.7%
distribute-lft-in48.7%
Simplified48.7%
Taylor expanded in phi2 around 0 35.9%
Taylor expanded in phi2 around 0 35.8%
Final simplification35.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 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(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 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.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 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.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 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(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \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 63.1%
Taylor expanded in phi1 around 0 48.7%
associate--r+48.7%
unpow248.7%
1-sub-sin48.7%
unpow248.7%
sub-neg48.7%
mul-1-neg48.7%
+-commutative48.7%
+-commutative48.7%
distribute-lft-in48.7%
metadata-eval48.7%
associate-*r*48.7%
associate-*r*48.7%
metadata-eval48.7%
distribute-lft-in48.7%
Simplified48.7%
Taylor expanded in phi2 around 0 35.9%
Taylor expanded in phi1 around 0 36.2%
Final simplification36.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt(((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 63.1%
Taylor expanded in phi1 around 0 48.7%
associate--r+48.7%
unpow248.7%
1-sub-sin48.7%
unpow248.7%
sub-neg48.7%
mul-1-neg48.7%
+-commutative48.7%
+-commutative48.7%
distribute-lft-in48.7%
metadata-eval48.7%
associate-*r*48.7%
associate-*r*48.7%
metadata-eval48.7%
distribute-lft-in48.7%
Simplified48.7%
Taylor expanded in phi2 around 0 35.9%
Taylor expanded in phi2 around 0 35.8%
unpow235.8%
sin-mult35.1%
div-inv35.1%
metadata-eval35.1%
div-inv35.1%
metadata-eval35.1%
div-inv35.1%
metadata-eval35.1%
div-inv35.1%
metadata-eval35.1%
Applied egg-rr35.1%
div-sub35.1%
+-inverses35.1%
cos-035.1%
metadata-eval35.1%
distribute-lft-out35.1%
metadata-eval35.1%
*-rgt-identity35.1%
Simplified35.1%
Final simplification35.1%
herbie shell --seed 2023264
(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))))))))))