
(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 24 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 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+
(- 1.0 t_1)
(*
t_0
(-
(/
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda2) (sin lambda1)))
2.0)
0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda2) * Math.sin(lambda1))) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda2) * math.sin(lambda1))) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1))) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\left(1 - t_1\right) + t_0 \cdot \left(\frac{\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 62.9%
associate-*l*62.9%
Simplified62.9%
div-sub62.9%
sin-diff64.2%
Applied egg-rr64.2%
div-sub62.9%
sin-diff64.2%
Applied egg-rr78.6%
sin-mult78.6%
div-inv78.6%
metadata-eval78.6%
div-inv78.6%
metadata-eval78.6%
cos-sum78.6%
cos-278.6%
div-inv78.6%
metadata-eval78.6%
Applied egg-rr78.6%
div-sub78.6%
+-inverses78.6%
+-inverses78.6%
+-inverses78.6%
cos-078.6%
metadata-eval78.6%
Simplified78.6%
cos-diff79.3%
Applied egg-rr79.3%
Final simplification79.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (* t_0 (* t_1 t_0)))
(t_3 (* t_1 (* t_0 t_0)))
(t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_5 (+ t_4 t_2)))
(if (<= (* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_5))))) 1e+300)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_4))
(sqrt (- (- 1.0 (+ 0.5 (* -0.5 (cos (- phi2 phi1))))) t_3)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_2))
(sqrt (pow (cos (* 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 = cos(phi1) * cos(phi2);
double t_2 = t_0 * (t_1 * t_0);
double t_3 = t_1 * (t_0 * t_0);
double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = t_4 + t_2;
double tmp;
if ((R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5))))) <= 1e+300) {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_4)), sqrt(((1.0 - (0.5 + (-0.5 * cos((phi2 - phi1))))) - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_2)), sqrt(pow(cos((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) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = t_0 * (t_1 * t_0)
t_3 = t_1 * (t_0 * t_0)
t_4 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_5 = t_4 + t_2
if ((r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_5))))) <= 1d+300) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_4)), sqrt(((1.0d0 - (0.5d0 + ((-0.5d0) * cos((phi2 - phi1))))) - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_2)), sqrt((cos((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.cos(phi1) * Math.cos(phi2);
double t_2 = t_0 * (t_1 * t_0);
double t_3 = t_1 * (t_0 * t_0);
double t_4 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = t_4 + t_2;
double tmp;
if ((R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_5))))) <= 1e+300) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_4)), Math.sqrt(((1.0 - (0.5 + (-0.5 * Math.cos((phi2 - phi1))))) - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_2)), Math.sqrt(Math.pow(Math.cos((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.cos(phi1) * math.cos(phi2) t_2 = t_0 * (t_1 * t_0) t_3 = t_1 * (t_0 * t_0) t_4 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_5 = t_4 + t_2 tmp = 0 if (R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_5))))) <= 1e+300: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_4)), math.sqrt(((1.0 - (0.5 + (-0.5 * math.cos((phi2 - phi1))))) - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_2)), math.sqrt(math.pow(math.cos((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 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(t_0 * Float64(t_1 * t_0)) t_3 = Float64(t_1 * Float64(t_0 * t_0)) t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_5 = Float64(t_4 + t_2) tmp = 0.0 if (Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_5))))) <= 1e+300) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_4)), sqrt(Float64(Float64(1.0 - Float64(0.5 + Float64(-0.5 * cos(Float64(phi2 - phi1))))) - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_2)), sqrt((cos(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(phi1) * cos(phi2); t_2 = t_0 * (t_1 * t_0); t_3 = t_1 * (t_0 * t_0); t_4 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_5 = t_4 + t_2; tmp = 0.0; if ((R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_5))))) <= 1e+300) tmp = R * (2.0 * atan2(sqrt((t_3 + t_4)), sqrt(((1.0 - (0.5 + (-0.5 * cos((phi2 - phi1))))) - t_3)))); else tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_2)), sqrt((cos((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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 + t$95$2), $MachinePrecision]}, If[LessEqual[N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+300], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(0.5 + N[(-0.5 * N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := t_0 \cdot \left(t_1 \cdot t_0\right)\\
t_3 := t_1 \cdot \left(t_0 \cdot t_0\right)\\
t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_5 := t_4 + t_2\\
\mathbf{if}\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_5}}{\sqrt{1 - t_5}}\right) \leq 10^{+300}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_4}}{\sqrt{\left(1 - \left(0.5 + -0.5 \cdot \cos \left(\phi_2 - \phi_1\right)\right)\right) - t_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t_2}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (*.f64 R (*.f64 2 (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) 2)) 2) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))))) (sqrt.f64 (-.f64 1 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) 2)) 2) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))))))))) < 1.0000000000000001e300Initial program 68.1%
associate-*l*68.1%
Simplified68.1%
unpow241.9%
sqr-sin-a39.9%
div-inv39.9%
metadata-eval39.9%
Applied egg-rr68.2%
*-commutative39.9%
*-commutative39.9%
sub-neg39.9%
mul-1-neg39.9%
distribute-lft-in39.9%
associate-*r*39.9%
metadata-eval39.9%
metadata-eval39.9%
associate-*r*39.9%
distribute-lft-in39.9%
+-commutative39.9%
mul-1-neg39.9%
sub-neg39.9%
*-commutative39.9%
Simplified68.2%
if 1.0000000000000001e300 < (*.f64 R (*.f64 2 (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) 2)) 2) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))))) (sqrt.f64 (-.f64 1 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) 2)) 2) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))))))))) Initial program 1.2%
Taylor expanded in phi1 around 0 11.0%
associate--r+11.0%
unpow211.0%
1-sub-sin11.0%
unpow211.0%
sub-neg11.0%
mul-1-neg11.0%
+-commutative11.0%
Simplified11.0%
Taylor expanded in phi2 around 0 10.6%
sub-neg10.6%
mul-1-neg10.6%
distribute-lft-in10.6%
metadata-eval10.6%
associate-*r*10.6%
associate-*r*10.6%
metadata-eval10.6%
distribute-lft-in10.6%
+-commutative10.6%
mul-1-neg10.6%
sub-neg10.6%
Simplified10.6%
Taylor expanded in lambda1 around 0 10.8%
unpow210.8%
1-sub-sin10.8%
unpow210.8%
Simplified10.8%
div-sub1.2%
sin-diff10.6%
Applied egg-rr20.6%
Final simplification64.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_0 (* t_1 t_1)))
(t_3
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(if (<= (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_1 (* t_0 t_1))) 0.002)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_2))
(sqrt
(+
(pow (cos (* phi2 0.5)) 2.0)
(* t_0 (- (/ (cos (- lambda2 lambda1)) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (+ 0.5 (* -0.5 (cos (- phi2 phi1))))))
(sqrt (- (- 1.0 t_3) t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double tmp;
if ((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_1))) <= 0.002) {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((pow(cos((phi2 * 0.5)), 2.0) + (t_0 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 + (-0.5 * cos((phi2 - phi1)))))), sqrt(((1.0 - t_3) - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 * (t_1 * t_1)
t_3 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
if (((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (t_0 * t_1))) <= 0.002d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_2)), sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) + (t_0 * ((cos((lambda2 - lambda1)) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 + ((-0.5d0) * cos((phi2 - phi1)))))), sqrt(((1.0d0 - t_3) - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double tmp;
if ((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_1))) <= 0.002) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_2)), Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) + (t_0 * ((Math.cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 + (-0.5 * Math.cos((phi2 - phi1)))))), Math.sqrt(((1.0 - t_3) - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_0 * (t_1 * t_1) t_3 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) tmp = 0 if (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_1))) <= 0.002: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_2)), math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) + (t_0 * ((math.cos((lambda2 - lambda1)) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 + (-0.5 * math.cos((phi2 - phi1)))))), math.sqrt(((1.0 - t_3) - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_0 * Float64(t_1 * t_1)) t_3 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 tmp = 0.0 if (Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_0 * t_1))) <= 0.002) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_2)), sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(Float64(lambda2 - lambda1)) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 + Float64(-0.5 * cos(Float64(phi2 - phi1)))))), sqrt(Float64(Float64(1.0 - t_3) - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_0 * (t_1 * t_1); t_3 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; tmp = 0.0; if (((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (t_0 * t_1))) <= 0.002) tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt(((cos((phi2 * 0.5)) ^ 2.0) + (t_0 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 + (-0.5 * cos((phi2 - phi1)))))), sqrt(((1.0 - t_3) - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.002], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 + N[(-0.5 * N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$3), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t_0 \cdot \left(t_1 \cdot t_1\right)\\
t_3 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
\mathbf{if}\;{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(t_0 \cdot t_1\right) \leq 0.002:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_2}}{\sqrt{{\cos \left(\phi_2 \cdot 0.5\right)}^{2} + t_0 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + \left(0.5 + -0.5 \cdot \cos \left(\phi_2 - \phi_1\right)\right)}}{\sqrt{\left(1 - t_3\right) - t_2}}\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) 2)) 2) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)))) < 2e-3Initial program 62.1%
associate-*l*62.3%
Simplified62.3%
div-sub62.3%
sin-diff62.3%
Applied egg-rr62.3%
div-sub62.3%
sin-diff62.3%
Applied egg-rr88.7%
sin-mult88.7%
div-inv88.7%
metadata-eval88.7%
div-inv88.7%
metadata-eval88.7%
cos-sum88.7%
cos-288.7%
div-inv88.7%
metadata-eval88.7%
Applied egg-rr88.7%
div-sub88.7%
+-inverses88.7%
+-inverses88.7%
+-inverses88.7%
cos-088.7%
metadata-eval88.7%
Simplified88.7%
Taylor expanded in phi1 around 0 69.5%
unpow269.5%
*-commutative69.5%
*-commutative69.5%
1-sub-sin69.5%
*-commutative69.5%
*-commutative69.5%
unpow269.5%
Simplified69.5%
if 2e-3 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) 2)) 2) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)))) Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
div-sub63.0%
sin-diff64.4%
Applied egg-rr64.4%
unpow238.2%
sqr-sin-a38.1%
div-inv38.1%
metadata-eval38.1%
Applied egg-rr64.4%
*-commutative38.1%
*-commutative38.1%
sub-neg38.1%
mul-1-neg38.1%
distribute-lft-in38.1%
associate-*r*38.1%
metadata-eval38.1%
metadata-eval38.1%
associate-*r*38.1%
distribute-lft-in38.1%
+-commutative38.1%
mul-1-neg38.1%
sub-neg38.1%
*-commutative38.1%
Simplified64.4%
Final simplification64.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (* t_2 (* t_1 t_1)))
(t_4 (- 1.0 t_0)))
(if (<= lambda1 -1.55e-109)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- t_4 t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_1 (sin (* lambda2 -0.5))))))
(sqrt (+ t_4 (* t_2 (- (/ (cos (- lambda2 lambda1)) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = t_2 * (t_1 * t_1);
double t_4 = 1.0 - t_0;
double tmp;
if (lambda1 <= -1.55e-109) {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((t_4 - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_1 * sin((lambda2 * -0.5)))))), sqrt((t_4 + (t_2 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
t_3 = t_2 * (t_1 * t_1)
t_4 = 1.0d0 - t_0
if (lambda1 <= (-1.55d-109)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((t_4 - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_1 * sin((lambda2 * (-0.5d0))))))), sqrt((t_4 + (t_2 * ((cos((lambda2 - lambda1)) / 2.0d0) - 0.5d0))))))
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 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = t_2 * (t_1 * t_1);
double t_4 = 1.0 - t_0;
double tmp;
if (lambda1 <= -1.55e-109) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((t_4 - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_1 * Math.sin((lambda2 * -0.5)))))), Math.sqrt((t_4 + (t_2 * ((Math.cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = t_2 * (t_1 * t_1) t_4 = 1.0 - t_0 tmp = 0 if lambda1 <= -1.55e-109: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((t_4 - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_1 * math.sin((lambda2 * -0.5)))))), math.sqrt((t_4 + (t_2 * ((math.cos((lambda2 - lambda1)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64(t_2 * Float64(t_1 * t_1)) t_4 = Float64(1.0 - t_0) tmp = 0.0 if (lambda1 <= -1.55e-109) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(t_4 - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_1 * sin(Float64(lambda2 * -0.5)))))), sqrt(Float64(t_4 + Float64(t_2 * Float64(Float64(cos(Float64(lambda2 - lambda1)) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); t_3 = t_2 * (t_1 * t_1); t_4 = 1.0 - t_0; tmp = 0.0; if (lambda1 <= -1.55e-109) tmp = R * (2.0 * atan2(sqrt((t_3 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((t_4 - t_3)))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_1 * sin((lambda2 * -0.5)))))), sqrt((t_4 + (t_2 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$0), $MachinePrecision]}, If[LessEqual[lambda1, -1.55e-109], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$1 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 + N[(t$95$2 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := t_2 \cdot \left(t_1 \cdot t_1\right)\\
t_4 := 1 - t_0\\
\mathbf{if}\;\lambda_1 \leq -1.55 \cdot 10^{-109}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{t_4 - t_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_1 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{\sqrt{t_4 + t_2 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.55e-109Initial program 61.8%
associate-*l*61.9%
Simplified61.9%
div-sub61.9%
sin-diff63.5%
Applied egg-rr63.5%
if -1.55e-109 < lambda1 Initial program 63.6%
associate-*l*63.6%
Simplified63.5%
div-sub63.5%
sin-diff64.6%
Applied egg-rr64.6%
div-sub63.5%
sin-diff64.6%
Applied egg-rr82.7%
sin-mult82.7%
div-inv82.7%
metadata-eval82.7%
div-inv82.7%
metadata-eval82.7%
cos-sum82.7%
cos-282.7%
div-inv82.7%
metadata-eval82.7%
Applied egg-rr82.7%
div-sub82.7%
+-inverses82.7%
+-inverses82.7%
+-inverses82.7%
cos-082.7%
metadata-eval82.7%
Simplified82.7%
Taylor expanded in lambda1 around 0 67.2%
Final simplification65.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (- 1.0 t_0))
(t_3 (* (cos phi1) (cos phi2))))
(if (<= lambda2 1e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_3 (* t_1 t_1))))
(sqrt (+ t_2 (* t_3 (- (/ (cos lambda1) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_3 (* t_1 (sin (* lambda2 -0.5))))))
(sqrt (+ t_2 (* t_3 (- (/ (cos (- lambda2 lambda1)) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = 1.0 - t_0;
double t_3 = cos(phi1) * cos(phi2);
double tmp;
if (lambda2 <= 1e-5) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * (t_1 * t_1)))), sqrt((t_2 + (t_3 * ((cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * (t_1 * sin((lambda2 * -0.5)))))), sqrt((t_2 + (t_3 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = 1.0d0 - t_0
t_3 = cos(phi1) * cos(phi2)
if (lambda2 <= 1d-5) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_3 * (t_1 * t_1)))), sqrt((t_2 + (t_3 * ((cos(lambda1) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_3 * (t_1 * sin((lambda2 * (-0.5d0))))))), sqrt((t_2 + (t_3 * ((cos((lambda2 - lambda1)) / 2.0d0) - 0.5d0))))))
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 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = 1.0 - t_0;
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (lambda2 <= 1e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_3 * (t_1 * t_1)))), Math.sqrt((t_2 + (t_3 * ((Math.cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_3 * (t_1 * Math.sin((lambda2 * -0.5)))))), Math.sqrt((t_2 + (t_3 * ((Math.cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = 1.0 - t_0 t_3 = math.cos(phi1) * math.cos(phi2) tmp = 0 if lambda2 <= 1e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_3 * (t_1 * t_1)))), math.sqrt((t_2 + (t_3 * ((math.cos(lambda1) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_3 * (t_1 * math.sin((lambda2 * -0.5)))))), math.sqrt((t_2 + (t_3 * ((math.cos((lambda2 - lambda1)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(1.0 - t_0) t_3 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (lambda2 <= 1e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_3 * Float64(t_1 * t_1)))), sqrt(Float64(t_2 + Float64(t_3 * Float64(Float64(cos(lambda1) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_3 * Float64(t_1 * sin(Float64(lambda2 * -0.5)))))), sqrt(Float64(t_2 + Float64(t_3 * Float64(Float64(cos(Float64(lambda2 - lambda1)) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = 1.0 - t_0; t_3 = cos(phi1) * cos(phi2); tmp = 0.0; if (lambda2 <= 1e-5) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * (t_1 * t_1)))), sqrt((t_2 + (t_3 * ((cos(lambda1) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * (t_1 * sin((lambda2 * -0.5)))))), sqrt((t_2 + (t_3 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 1e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$3 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 + N[(t$95$3 * N[(N[(N[Cos[lambda1], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$3 * N[(t$95$1 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 + N[(t$95$3 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := 1 - t_0\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{t_2 + t_3 \cdot \left(\frac{\cos \lambda_1}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3 \cdot \left(t_1 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{\sqrt{t_2 + t_3 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 1.00000000000000008e-5Initial program 68.3%
associate-*l*68.3%
Simplified68.3%
div-sub68.3%
sin-diff69.7%
Applied egg-rr69.7%
div-sub68.3%
sin-diff69.7%
Applied egg-rr86.9%
sin-mult86.9%
div-inv86.9%
metadata-eval86.9%
div-inv86.9%
metadata-eval86.9%
cos-sum86.9%
cos-286.9%
div-inv86.9%
metadata-eval86.9%
Applied egg-rr86.9%
div-sub86.9%
+-inverses86.9%
+-inverses86.9%
+-inverses86.9%
cos-086.9%
metadata-eval86.9%
Simplified86.9%
Taylor expanded in lambda2 around 0 75.7%
cos-neg75.7%
Simplified75.7%
if 1.00000000000000008e-5 < lambda2 Initial program 48.2%
associate-*l*48.3%
Simplified48.3%
div-sub48.3%
sin-diff49.1%
Applied egg-rr49.1%
div-sub48.3%
sin-diff49.1%
Applied egg-rr56.1%
sin-mult56.2%
div-inv56.2%
metadata-eval56.2%
div-inv56.2%
metadata-eval56.2%
cos-sum56.1%
cos-256.2%
div-inv56.2%
metadata-eval56.2%
Applied egg-rr56.2%
div-sub56.2%
+-inverses56.2%
+-inverses56.2%
+-inverses56.2%
cos-056.2%
metadata-eval56.2%
Simplified56.2%
Taylor expanded in lambda1 around 0 54.8%
Final simplification70.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+ (- 1.0 t_1) (* t_0 (- (/ (cos (- lambda2 lambda1)) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((cos((lambda2 - lambda1)) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((Math.cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((math.cos((lambda2 - lambda1)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(cos(Float64(lambda2 - lambda1)) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\left(1 - t_1\right) + t_0 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 62.9%
associate-*l*62.9%
Simplified62.9%
div-sub62.9%
sin-diff64.2%
Applied egg-rr64.2%
div-sub62.9%
sin-diff64.2%
Applied egg-rr78.6%
sin-mult78.6%
div-inv78.6%
metadata-eval78.6%
div-inv78.6%
metadata-eval78.6%
cos-sum78.6%
cos-278.6%
div-inv78.6%
metadata-eval78.6%
Applied egg-rr78.6%
div-sub78.6%
+-inverses78.6%
+-inverses78.6%
+-inverses78.6%
cos-078.6%
metadata-eval78.6%
Simplified78.6%
Final simplification78.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t_1}}\right)
\end{array}
\end{array}
Initial program 62.9%
associate-*l*62.9%
Simplified62.9%
div-sub62.9%
sin-diff64.2%
Applied egg-rr64.2%
Final simplification64.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt (- (- 1.0 (+ 0.5 (* -0.5 (cos (- phi2 phi1))))) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt(((1.0 - (0.5 + (-0.5 * cos((phi2 - phi1))))) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_1)), sqrt(((1.0d0 - (0.5d0 + ((-0.5d0) * cos((phi2 - phi1))))) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1)), Math.sqrt(((1.0 - (0.5 + (-0.5 * Math.cos((phi2 - phi1))))) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_1)), math.sqrt(((1.0 - (0.5 + (-0.5 * math.cos((phi2 - phi1))))) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - Float64(0.5 + Float64(-0.5 * cos(Float64(phi2 - phi1))))) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(((1.0 - (0.5 + (-0.5 * cos((phi2 - phi1))))) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(0.5 + N[(-0.5 * N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t_1}}{\sqrt{\left(1 - \left(0.5 + -0.5 \cdot \cos \left(\phi_2 - \phi_1\right)\right)\right) - t_1}}\right)
\end{array}
\end{array}
Initial program 62.9%
associate-*l*62.9%
Simplified62.9%
div-sub62.9%
sin-diff64.2%
Applied egg-rr64.0%
unpow240.0%
sqr-sin-a38.2%
div-inv38.2%
metadata-eval38.2%
Applied egg-rr64.1%
*-commutative38.2%
*-commutative38.2%
sub-neg38.2%
mul-1-neg38.2%
distribute-lft-in38.2%
associate-*r*38.2%
metadata-eval38.2%
metadata-eval38.2%
associate-*r*38.2%
distribute-lft-in38.2%
+-commutative38.2%
mul-1-neg38.2%
sub-neg38.2%
*-commutative38.2%
Simplified64.1%
Final simplification64.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))
(if (<= phi1 -3.8e-7)
(*
R
(*
2.0
(atan2 t_2 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(- 1.0 (+ (pow (sin (* phi2 -0.5)) 2.0) (* (cos phi2) 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(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double tmp;
if (phi1 <= -3.8e-7) {
tmp = R * (2.0 * atan2(t_2, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * t_1))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
if (phi1 <= (-3.8d-7)) then
tmp = r * (2.0d0 * atan2(t_2, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - ((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * t_1))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double tmp;
if (phi1 <= -3.8e-7) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * t_1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) tmp = 0 if phi1 <= -3.8e-7: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * t_1)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) tmp = 0.0 if (phi1 <= -3.8e-7) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * t_1))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); tmp = 0.0; if (phi1 <= -3.8e-7) tmp = R * (2.0 * atan2(t_2, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * t_1)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3.8e-7], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}\\
\mathbf{if}\;\phi_1 \leq -3.8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left({\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot t_1\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3.80000000000000015e-7Initial program 50.0%
associate-*l*50.1%
Simplified50.0%
div-sub50.0%
sin-diff52.7%
Applied egg-rr52.1%
Taylor expanded in phi2 around 0 52.7%
unpow252.7%
1-sub-sin52.9%
unpow252.9%
Simplified52.9%
Taylor expanded in phi2 around 0 54.6%
if -3.80000000000000015e-7 < phi1 Initial program 68.3%
associate-*l*68.3%
Simplified68.3%
div-sub68.3%
sin-diff69.0%
Applied egg-rr69.0%
Taylor expanded in phi1 around 0 60.3%
Final simplification58.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (cos (* phi2 -0.5))))
(if (<= phi1 -3.8e-7)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_1 (* t_0 t_0))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* t_1 t_0))
(pow (+ (sin (* phi2 -0.5)) (* 0.5 (* phi1 t_2))) 2.0)))
(sqrt
(-
(pow t_2 2.0)
(* (cos phi2) (pow (sin (* (- lambda2 lambda1) -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) * cos(phi2);
double t_2 = cos((phi2 * -0.5));
double tmp;
if (phi1 <= -3.8e-7) {
tmp = R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_1 * (t_0 * t_0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + pow((sin((phi2 * -0.5)) + (0.5 * (phi1 * t_2))), 2.0))), sqrt((pow(t_2, 2.0) - (cos(phi2) * pow(sin(((lambda2 - lambda1) * -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(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = cos((phi2 * (-0.5d0)))
if (phi1 <= (-3.8d-7)) then
tmp = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (t_1 * (t_0 * t_0)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + ((sin((phi2 * (-0.5d0))) + (0.5d0 * (phi1 * t_2))) ** 2.0d0))), sqrt(((t_2 ** 2.0d0) - (cos(phi2) * (sin(((lambda2 - lambda1) * (-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.cos(phi1) * Math.cos(phi2);
double t_2 = Math.cos((phi2 * -0.5));
double tmp;
if (phi1 <= -3.8e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (t_1 * (t_0 * t_0)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_0)) + Math.pow((Math.sin((phi2 * -0.5)) + (0.5 * (phi1 * t_2))), 2.0))), Math.sqrt((Math.pow(t_2, 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda2 - lambda1) * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.cos((phi2 * -0.5)) tmp = 0 if phi1 <= -3.8e-7: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (t_1 * (t_0 * t_0)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_0)) + math.pow((math.sin((phi2 * -0.5)) + (0.5 * (phi1 * t_2))), 2.0))), math.sqrt((math.pow(t_2, 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda2 - lambda1) * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = cos(Float64(phi2 * -0.5)) tmp = 0.0 if (phi1 <= -3.8e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_1 * Float64(t_0 * t_0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_0)) + (Float64(sin(Float64(phi2 * -0.5)) + Float64(0.5 * Float64(phi1 * t_2))) ^ 2.0))), sqrt(Float64((t_2 ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda2 - lambda1) * -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(phi1) * cos(phi2); t_2 = cos((phi2 * -0.5)); tmp = 0.0; if (phi1 <= -3.8e-7) tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (t_1 * (t_0 * t_0)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + ((sin((phi2 * -0.5)) + (0.5 * (phi1 * t_2))) ^ 2.0))), sqrt(((t_2 ^ 2.0) - (cos(phi2) * (sin(((lambda2 - lambda1) * -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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3.8e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $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]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(phi1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$2, 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -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 \phi_1 \cdot \cos \phi_2\\
t_2 := \cos \left(\phi_2 \cdot -0.5\right)\\
\mathbf{if}\;\phi_1 \leq -3.8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t_1 \cdot \left(t_0 \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(t_1 \cdot t_0\right) + {\left(\sin \left(\phi_2 \cdot -0.5\right) + 0.5 \cdot \left(\phi_1 \cdot t_2\right)\right)}^{2}}}{\sqrt{{t_2}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -3.80000000000000015e-7Initial program 50.0%
associate-*l*50.1%
Simplified50.0%
div-sub50.0%
sin-diff52.7%
Applied egg-rr52.1%
Taylor expanded in phi2 around 0 52.7%
unpow252.7%
1-sub-sin52.9%
unpow252.9%
Simplified52.9%
Taylor expanded in phi2 around 0 54.6%
if -3.80000000000000015e-7 < phi1 Initial program 68.3%
Taylor expanded in phi1 around 0 59.5%
associate--r+59.5%
unpow259.5%
1-sub-sin59.6%
unpow259.6%
sub-neg59.6%
mul-1-neg59.6%
+-commutative59.6%
Simplified59.6%
Taylor expanded in phi1 around 0 59.4%
Final simplification58.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi1 -3.8e-7)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_2 (* t_0 t_2))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -3.8e-7) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_0 * t_2)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda2 - lambda1) * -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 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if (phi1 <= (-3.8d-7)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_2 * (t_0 * t_2)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda2 - lambda1) * (-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.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -3.8e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_2 * (t_0 * t_2)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda2 - lambda1) * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi1 <= -3.8e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_2 * (t_0 * t_2)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda2 - lambda1) * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi1 <= -3.8e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * Float64(t_0 * t_2)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi1 <= -3.8e-7) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_0 * t_2)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda2 - lambda1) * -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[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3.8e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $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]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(t$95$0 * t$95$2), $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[(N[(lambda2 - lambda1), $MachinePrecision] * -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 \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -3.8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_2 \cdot \left(t_0 \cdot t_2\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -3.80000000000000015e-7Initial program 50.0%
associate-*l*50.1%
Simplified50.0%
div-sub50.0%
sin-diff52.7%
Applied egg-rr52.1%
Taylor expanded in phi2 around 0 52.7%
unpow252.7%
1-sub-sin52.9%
unpow252.9%
Simplified52.9%
Taylor expanded in phi2 around 0 54.6%
if -3.80000000000000015e-7 < phi1 Initial program 68.3%
Taylor expanded in phi1 around 0 59.5%
associate--r+59.5%
unpow259.5%
1-sub-sin59.6%
unpow259.6%
sub-neg59.6%
mul-1-neg59.6%
+-commutative59.6%
Simplified59.6%
div-sub68.3%
sin-diff69.0%
Applied egg-rr60.3%
Final simplification58.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) t_1))
(sqrt
(+ (- 1.0 t_1) (* t_2 (- (/ (cos (- lambda2 lambda1)) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) + (t_2 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
code = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0d0 - t_1) + (t_2 * ((cos((lambda2 - lambda1)) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), Math.sqrt(((1.0 - t_1) + (t_2 * ((Math.cos((lambda2 - lambda1)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), math.sqrt(((1.0 - t_1) + (t_2 * ((math.cos((lambda2 - lambda1)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + t_1)), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_2 * Float64(Float64(cos(Float64(lambda2 - lambda1)) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) + (t_2 * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(t_0 \cdot t_0\right) + t_1}}{\sqrt{\left(1 - t_1\right) + t_2 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 62.9%
associate-*l*62.9%
Simplified62.9%
sin-mult78.6%
div-inv78.6%
metadata-eval78.6%
div-inv78.6%
metadata-eval78.6%
cos-sum78.6%
cos-278.6%
div-inv78.6%
metadata-eval78.6%
Applied egg-rr62.9%
div-sub78.6%
+-inverses78.6%
+-inverses78.6%
+-inverses78.6%
cos-078.6%
metadata-eval78.6%
Simplified62.9%
Final simplification62.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi2 8.5e-9)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_1 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_1)) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi2 <= 8.5e-9) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda2 - lambda1) * -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 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if (phi2 <= 8.5d-9) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda2 - lambda1) * (-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.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi2 <= 8.5e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_1)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda2 - lambda1) * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi2 <= 8.5e-9: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_1)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda2 - lambda1) * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi2 <= 8.5e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi2 <= 8.5e-9) tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda2 - lambda1) * -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[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 8.5e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -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 \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq 8.5 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(t_1 \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_0 \cdot t_1\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < 8.5e-9Initial program 68.9%
associate-*l*68.9%
Simplified68.9%
div-sub68.9%
sin-diff69.8%
Applied egg-rr69.8%
Taylor expanded in phi2 around 0 60.1%
associate--r+60.1%
*-commutative60.1%
unpow260.1%
1-sub-sin60.2%
*-commutative60.2%
*-commutative60.2%
unpow260.2%
*-commutative60.2%
Simplified60.2%
if 8.5e-9 < phi2 Initial program 45.1%
Taylor expanded in phi1 around 0 46.6%
associate--r+46.6%
unpow246.6%
1-sub-sin46.7%
unpow246.7%
sub-neg46.7%
mul-1-neg46.7%
+-commutative46.7%
Simplified46.7%
Taylor expanded in phi1 around 0 46.9%
Final simplification56.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) t_0)))
(if (<= phi1 -3.6e-9)
(*
R
(*
2.0
(atan2
(sqrt
(+
(+ 0.5 (* -0.5 (cos (- phi2 phi1))))
(* t_1 (sin (* lambda1 0.5)))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda2 lambda1) -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) * cos(phi2)) * t_0;
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * (2.0 * atan2(sqrt(((0.5 + (-0.5 * cos((phi2 - phi1)))) + (t_1 * sin((lambda1 * 0.5))))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda2 - lambda1) * -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(phi1) * cos(phi2)) * t_0
if (phi1 <= (-3.6d-9)) then
tmp = r * (2.0d0 * atan2(sqrt(((0.5d0 + ((-0.5d0) * cos((phi2 - phi1)))) + (t_1 * sin((lambda1 * 0.5d0))))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda2 - lambda1) * (-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.cos(phi1) * Math.cos(phi2)) * t_0;
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((0.5 + (-0.5 * Math.cos((phi2 - phi1)))) + (t_1 * Math.sin((lambda1 * 0.5))))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda2 - lambda1) * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * t_0 tmp = 0 if phi1 <= -3.6e-9: tmp = R * (2.0 * math.atan2(math.sqrt(((0.5 + (-0.5 * math.cos((phi2 - phi1)))) + (t_1 * math.sin((lambda1 * 0.5))))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda2 - lambda1) * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * t_0) tmp = 0.0 if (phi1 <= -3.6e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 + Float64(-0.5 * cos(Float64(phi2 - phi1)))) + Float64(t_1 * sin(Float64(lambda1 * 0.5))))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda2 - lambda1) * -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(phi1) * cos(phi2)) * t_0; tmp = 0.0; if (phi1 <= -3.6e-9) tmp = R * (2.0 * atan2(sqrt(((0.5 + (-0.5 * cos((phi2 - phi1)))) + (t_1 * sin((lambda1 * 0.5))))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda2 - lambda1) * -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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[LessEqual[phi1, -3.6e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 + N[(-0.5 * N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -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 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\\
\mathbf{if}\;\phi_1 \leq -3.6 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 + -0.5 \cdot \cos \left(\phi_2 - \phi_1\right)\right) + t_1 \cdot \sin \left(\lambda_1 \cdot 0.5\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -3.6e-9Initial program 48.9%
Taylor expanded in lambda2 around 0 37.1%
Taylor expanded in phi2 around 0 39.1%
unpow239.1%
sqr-sin-a39.1%
div-inv39.1%
metadata-eval39.1%
Applied egg-rr39.1%
*-commutative39.1%
*-commutative39.1%
sub-neg39.1%
mul-1-neg39.1%
distribute-lft-in39.1%
associate-*r*39.1%
metadata-eval39.1%
metadata-eval39.1%
associate-*r*39.1%
distribute-lft-in39.1%
+-commutative39.1%
mul-1-neg39.1%
sub-neg39.1%
*-commutative39.1%
Simplified39.1%
if -3.6e-9 < phi1 Initial program 69.1%
Taylor expanded in phi1 around 0 60.2%
associate--r+60.2%
unpow260.2%
1-sub-sin60.3%
unpow260.3%
sub-neg60.3%
mul-1-neg60.3%
+-commutative60.3%
Simplified60.3%
Taylor expanded in phi1 around 0 57.8%
Final simplification52.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi1 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) t_1)))
(if (<= phi1 -3.6e-9)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (sin (* lambda1 0.5)))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 t_2) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi1 * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * t_1;
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5))))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * t_2) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda2 - lambda1) * -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 * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * t_1
if (phi1 <= (-3.6d-9)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5d0))))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda2 - lambda1) * (-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 * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * t_1;
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * Math.sin((lambda1 * 0.5))))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda2 - lambda1) * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * t_1 tmp = 0 if phi1 <= -3.6e-9: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * math.sin((lambda1 * 0.5))))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + t_0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda2 - lambda1) * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * t_1) tmp = 0.0 if (phi1 <= -3.6e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * sin(Float64(lambda1 * 0.5))))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * t_1; tmp = 0.0; if (phi1 <= -3.6e-9) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5))))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + t_0))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * t_2) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda2 - lambda1) * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[phi1, -3.6e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\\
\mathbf{if}\;\phi_1 \leq -3.6 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \sin \left(\lambda_1 \cdot 0.5\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + t_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot t_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -3.6e-9Initial program 48.9%
Taylor expanded in lambda2 around 0 37.1%
Taylor expanded in phi2 around 0 39.1%
Taylor expanded in phi2 around 0 39.9%
if -3.6e-9 < phi1 Initial program 69.1%
Taylor expanded in phi1 around 0 60.2%
associate--r+60.2%
unpow260.2%
1-sub-sin60.3%
unpow260.3%
sub-neg60.3%
mul-1-neg60.3%
+-commutative60.3%
Simplified60.3%
Taylor expanded in phi1 around 0 57.8%
Final simplification52.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (* lambda1 0.5)))
(t_2 (* (cos phi1) (cos phi2))))
(if (<= phi1 -3.6e-9)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_1 (* t_2 t_1))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_2 t_0)) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda2 lambda1) -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 = sin((lambda1 * 0.5));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_1)))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_2 * t_0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda2 - lambda1) * -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(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((lambda1 * 0.5d0))
t_2 = cos(phi1) * cos(phi2)
if (phi1 <= (-3.6d-9)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (t_2 * t_1)))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_2 * t_0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda2 - lambda1) * (-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.sin((lambda1 * 0.5));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_1)))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_2 * t_0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda2 - lambda1) * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sin((lambda1 * 0.5)) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if phi1 <= -3.6e-9: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_1)))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_2 * t_0)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda2 - lambda1) * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(lambda1 * 0.5)) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi1 <= -3.6e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_2 * t_1)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_2 * t_0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda2 - lambda1) * -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 = sin((lambda1 * 0.5)); t_2 = cos(phi1) * cos(phi2); tmp = 0.0; if (phi1 <= -3.6e-9) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (t_2 * t_1)))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_2 * t_0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda2 - lambda1) * -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[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.6e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] * -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 := \sin \left(\lambda_1 \cdot 0.5\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -3.6 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(t_2 \cdot t_1\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(t_2 \cdot t_0\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -3.6e-9Initial program 48.9%
Taylor expanded in lambda2 around 0 37.1%
Taylor expanded in phi2 around 0 39.1%
Taylor expanded in lambda2 around 0 39.6%
if -3.6e-9 < phi1 Initial program 69.1%
Taylor expanded in phi1 around 0 60.2%
associate--r+60.2%
unpow260.2%
1-sub-sin60.3%
unpow260.3%
sub-neg60.3%
mul-1-neg60.3%
+-commutative60.3%
Simplified60.3%
Taylor expanded in phi1 around 0 57.8%
Final simplification52.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) t_0))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= phi1 -4.5e-10)
(*
R
(*
2.0
(atan2
(sqrt
(+
(+ 0.5 (* -0.5 (cos (- phi2 phi1))))
(* t_1 (sin (* lambda1 0.5)))))
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 t_1)
(pow
(+ (sin (* phi2 -0.5)) (* 0.5 (* phi1 (cos (* phi2 -0.5)))))
2.0)))
(sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * t_0;
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (phi1 <= -4.5e-10) {
tmp = R * (2.0 * atan2(sqrt(((0.5 + (-0.5 * cos((phi2 - phi1)))) + (t_1 * sin((lambda1 * 0.5))))), sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * t_1) + pow((sin((phi2 * -0.5)) + (0.5 * (phi1 * cos((phi2 * -0.5))))), 2.0))), sqrt((1.0 - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * t_0
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if (phi1 <= (-4.5d-10)) then
tmp = r * (2.0d0 * atan2(sqrt(((0.5d0 + ((-0.5d0) * cos((phi2 - phi1)))) + (t_1 * sin((lambda1 * 0.5d0))))), sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * t_1) + ((sin((phi2 * (-0.5d0))) + (0.5d0 * (phi1 * cos((phi2 * (-0.5d0)))))) ** 2.0d0))), sqrt((1.0d0 - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * t_0;
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (phi1 <= -4.5e-10) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((0.5 + (-0.5 * Math.cos((phi2 - phi1)))) + (t_1 * Math.sin((lambda1 * 0.5))))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * t_1) + Math.pow((Math.sin((phi2 * -0.5)) + (0.5 * (phi1 * Math.cos((phi2 * -0.5))))), 2.0))), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * t_0 t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if phi1 <= -4.5e-10: tmp = R * (2.0 * math.atan2(math.sqrt(((0.5 + (-0.5 * math.cos((phi2 - phi1)))) + (t_1 * math.sin((lambda1 * 0.5))))), math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * t_1) + math.pow((math.sin((phi2 * -0.5)) + (0.5 * (phi1 * math.cos((phi2 * -0.5))))), 2.0))), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * t_0) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if (phi1 <= -4.5e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 + Float64(-0.5 * cos(Float64(phi2 - phi1)))) + Float64(t_1 * sin(Float64(lambda1 * 0.5))))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * t_1) + (Float64(sin(Float64(phi2 * -0.5)) + Float64(0.5 * Float64(phi1 * cos(Float64(phi2 * -0.5))))) ^ 2.0))), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * t_0; t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if (phi1 <= -4.5e-10) tmp = R * (2.0 * atan2(sqrt(((0.5 + (-0.5 * cos((phi2 - phi1)))) + (t_1 * sin((lambda1 * 0.5))))), sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * t_1) + ((sin((phi2 * -0.5)) + (0.5 * (phi1 * cos((phi2 * -0.5))))) ^ 2.0))), sqrt((1.0 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -4.5e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 + N[(-0.5 * N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * t$95$1), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(phi1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -4.5 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 + -0.5 \cdot \cos \left(\phi_2 - \phi_1\right)\right) + t_1 \cdot \sin \left(\lambda_1 \cdot 0.5\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot t_1 + {\left(\sin \left(\phi_2 \cdot -0.5\right) + 0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}}}{\sqrt{1 - t_2}}\right)\\
\end{array}
\end{array}
if phi1 < -4.5e-10Initial program 49.6%
Taylor expanded in lambda2 around 0 37.9%
Taylor expanded in phi2 around 0 39.9%
unpow239.9%
sqr-sin-a39.8%
div-inv39.8%
metadata-eval39.8%
Applied egg-rr39.8%
*-commutative39.8%
*-commutative39.8%
sub-neg39.8%
mul-1-neg39.8%
distribute-lft-in39.8%
associate-*r*39.8%
metadata-eval39.8%
metadata-eval39.8%
associate-*r*39.8%
distribute-lft-in39.8%
+-commutative39.8%
mul-1-neg39.8%
sub-neg39.8%
*-commutative39.8%
Simplified39.8%
if -4.5e-10 < phi1 Initial program 68.9%
Taylor expanded in phi1 around 0 60.0%
associate--r+60.0%
unpow260.0%
1-sub-sin60.0%
unpow260.0%
sub-neg60.0%
mul-1-neg60.0%
+-commutative60.0%
Simplified60.0%
Taylor expanded in phi2 around 0 40.2%
sub-neg40.2%
mul-1-neg40.2%
distribute-lft-in40.2%
metadata-eval40.2%
associate-*r*40.2%
associate-*r*40.2%
metadata-eval40.2%
distribute-lft-in40.2%
+-commutative40.2%
mul-1-neg40.2%
sub-neg40.2%
Simplified40.2%
Taylor expanded in phi1 around 0 40.0%
Final simplification40.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (+ 0.5 (* -0.5 (cos (- phi2 phi1)))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) t_1)))
(if (<= phi1 -3.6e-9)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (sin (* lambda1 0.5)))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 t_2)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda2 lambda1) -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 + (-0.5 * cos((phi2 - phi1)));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * t_1;
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5))))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_2))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda2 - lambda1) * -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 = 0.5d0 + ((-0.5d0) * cos((phi2 - phi1)))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * t_1
if (phi1 <= (-3.6d-9)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5d0))))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * t_2))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda2 - lambda1) * (-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 = 0.5 + (-0.5 * Math.cos((phi2 - phi1)));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * t_1;
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * Math.sin((lambda1 * 0.5))))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * t_2))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda2 - lambda1) * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 + (-0.5 * math.cos((phi2 - phi1))) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * t_1 tmp = 0 if phi1 <= -3.6e-9: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * math.sin((lambda1 * 0.5))))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * t_2))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda2 - lambda1) * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 + Float64(-0.5 * cos(Float64(phi2 - phi1)))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * t_1) tmp = 0.0 if (phi1 <= -3.6e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * sin(Float64(lambda1 * 0.5))))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * t_2))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda2 - lambda1) * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 + (-0.5 * cos((phi2 - phi1))); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * t_1; tmp = 0.0; if (phi1 <= -3.6e-9) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5))))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_2))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda2 - lambda1) * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 + N[(-0.5 * N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[phi1, -3.6e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 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[(t$95$1 * t$95$2), $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[(N[(lambda2 - lambda1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + -0.5 \cdot \cos \left(\phi_2 - \phi_1\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\\
\mathbf{if}\;\phi_1 \leq -3.6 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \sin \left(\lambda_1 \cdot 0.5\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot t_2}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_2 - \lambda_1\right) \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -3.6e-9Initial program 48.9%
Taylor expanded in lambda2 around 0 37.1%
Taylor expanded in phi2 around 0 39.1%
unpow239.1%
sqr-sin-a39.1%
div-inv39.1%
metadata-eval39.1%
Applied egg-rr39.1%
*-commutative39.1%
*-commutative39.1%
sub-neg39.1%
mul-1-neg39.1%
distribute-lft-in39.1%
associate-*r*39.1%
metadata-eval39.1%
metadata-eval39.1%
associate-*r*39.1%
distribute-lft-in39.1%
+-commutative39.1%
mul-1-neg39.1%
sub-neg39.1%
*-commutative39.1%
Simplified39.1%
if -3.6e-9 < phi1 Initial program 69.1%
Taylor expanded in phi1 around 0 60.2%
associate--r+60.2%
unpow260.2%
1-sub-sin60.3%
unpow260.3%
sub-neg60.3%
mul-1-neg60.3%
+-commutative60.3%
Simplified60.3%
unpow240.4%
sqr-sin-a37.8%
div-inv37.8%
metadata-eval37.8%
Applied egg-rr57.9%
*-commutative37.8%
*-commutative37.8%
sub-neg37.8%
mul-1-neg37.8%
distribute-lft-in37.8%
associate-*r*37.8%
metadata-eval37.8%
metadata-eval37.8%
associate-*r*37.8%
distribute-lft-in37.8%
+-commutative37.8%
mul-1-neg37.8%
sub-neg37.8%
*-commutative37.8%
Simplified57.9%
Final simplification52.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- lambda1 lambda2) 0.5))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))
(expm1 (log1p t_0)))))
(sqrt (- 1.0 (pow t_0 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * expm1(log1p(t_0))))), sqrt((1.0 - pow(t_0, 2.0)))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) * 0.5));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0))) * Math.expm1(Math.log1p(t_0))))), Math.sqrt((1.0 - Math.pow(t_0, 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) * 0.5)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0))) * math.expm1(math.log1p(t_0))))), math.sqrt((1.0 - math.pow(t_0, 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) * expm1(log1p(t_0))))), sqrt(Float64(1.0 - (t_0 ^ 2.0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(Exp[N[Log[1 + t$95$0], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t_0\right)\right)}}{\sqrt{1 - {t_0}^{2}}}\right)
\end{array}
\end{array}
Initial program 62.9%
Taylor expanded in phi1 around 0 47.8%
associate--r+47.8%
unpow247.8%
1-sub-sin47.9%
unpow247.9%
sub-neg47.9%
mul-1-neg47.9%
+-commutative47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 34.2%
sub-neg34.2%
mul-1-neg34.2%
distribute-lft-in34.2%
metadata-eval34.2%
associate-*r*34.2%
associate-*r*34.2%
metadata-eval34.2%
distribute-lft-in34.2%
+-commutative34.2%
mul-1-neg34.2%
sub-neg34.2%
Simplified34.2%
expm1-log1p-u34.2%
div-inv34.2%
metadata-eval34.2%
Applied egg-rr34.2%
Final simplification34.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(log1p
(expm1 (- 1.0 (pow (sin (* (- lambda1 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));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(log1p(expm1((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt(Math.log1p(Math.expm1((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt(math.log1p(math.expm1((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(log1p(expm1(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Log[1 + N[(Exp[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]] - 1), $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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{\mathsf{log1p}\left(\mathsf{expm1}\left(1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\right)}}\right)
\end{array}
\end{array}
Initial program 62.9%
Taylor expanded in phi1 around 0 47.8%
associate--r+47.8%
unpow247.8%
1-sub-sin47.9%
unpow247.9%
sub-neg47.9%
mul-1-neg47.9%
+-commutative47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 34.2%
sub-neg34.2%
mul-1-neg34.2%
distribute-lft-in34.2%
metadata-eval34.2%
associate-*r*34.2%
associate-*r*34.2%
metadata-eval34.2%
distribute-lft-in34.2%
+-commutative34.2%
mul-1-neg34.2%
sub-neg34.2%
Simplified34.2%
log1p-expm1-u34.2%
Applied egg-rr34.2%
Final simplification34.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 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));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 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));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 62.9%
Taylor expanded in phi1 around 0 47.8%
associate--r+47.8%
unpow247.8%
1-sub-sin47.9%
unpow247.9%
sub-neg47.9%
mul-1-neg47.9%
+-commutative47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 34.2%
sub-neg34.2%
mul-1-neg34.2%
distribute-lft-in34.2%
metadata-eval34.2%
associate-*r*34.2%
associate-*r*34.2%
metadata-eval34.2%
distribute-lft-in34.2%
+-commutative34.2%
mul-1-neg34.2%
sub-neg34.2%
Simplified34.2%
Final simplification34.2%
(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))))
(if (<= lambda2 1.22e-57)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(sqrt (pow (cos (* lambda1 0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (pow (cos (* 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 tmp;
if (lambda2 <= 1.22e-57) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt(pow(cos((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) / 2.0d0))
if (lambda2 <= 1.22d-57) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((cos((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 tmp;
if (lambda2 <= 1.22e-57) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * 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(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt(Math.pow(Math.cos((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)) tmp = 0 if lambda2 <= 1.22e-57: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * 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(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt(math.pow(math.cos((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)) tmp = 0.0 if (lambda2 <= 1.22e-57) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))), sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((cos(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)); tmp = 0.0; if (lambda2 <= 1.22e-57) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((cos((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]}, If[LessEqual[lambda2, 1.22e-57], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $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[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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)\\
\mathbf{if}\;\lambda_2 \leq 1.22 \cdot 10^{-57}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)}}{\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_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 1.2200000000000001e-57Initial program 67.7%
Taylor expanded in phi1 around 0 49.6%
associate--r+49.6%
unpow249.6%
1-sub-sin49.7%
unpow249.7%
sub-neg49.7%
mul-1-neg49.7%
+-commutative49.7%
Simplified49.7%
Taylor expanded in phi2 around 0 35.7%
sub-neg35.7%
mul-1-neg35.7%
distribute-lft-in35.7%
metadata-eval35.7%
associate-*r*35.7%
associate-*r*35.7%
metadata-eval35.7%
distribute-lft-in35.7%
+-commutative35.7%
mul-1-neg35.7%
sub-neg35.7%
Simplified35.7%
Taylor expanded in lambda2 around 0 34.3%
unpow234.3%
1-sub-sin34.3%
unpow234.3%
Simplified34.3%
if 1.2200000000000001e-57 < lambda2 Initial program 51.8%
Taylor expanded in phi1 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.7%
unpow243.7%
sub-neg43.7%
mul-1-neg43.7%
+-commutative43.7%
Simplified43.7%
Taylor expanded in phi2 around 0 30.8%
sub-neg30.8%
mul-1-neg30.8%
distribute-lft-in30.8%
metadata-eval30.8%
associate-*r*30.8%
associate-*r*30.8%
metadata-eval30.8%
distribute-lft-in30.8%
+-commutative30.8%
mul-1-neg30.8%
sub-neg30.8%
Simplified30.8%
Taylor expanded in lambda1 around 0 29.9%
unpow229.9%
1-sub-sin30.0%
unpow230.0%
Simplified30.0%
Taylor expanded in phi2 around 0 30.4%
*-commutative30.4%
unpow230.4%
associate-*l*30.4%
sub-neg30.4%
mul-1-neg30.4%
distribute-lft-in30.4%
metadata-eval30.4%
associate-*r*30.4%
neg-mul-130.4%
associate-*r*30.4%
metadata-eval30.4%
distribute-lft-in30.4%
neg-mul-130.4%
Simplified30.4%
Final simplification33.1%
(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 (pow (cos (* lambda2 -0.5)) 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(pow(cos((lambda2 * -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
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((cos((lambda2 * (-0.5d0))) ** 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(Math.pow(Math.cos((lambda2 * -0.5)), 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(math.pow(math.cos((lambda2 * -0.5)), 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((cos(Float64(lambda2 * -0.5)) ^ 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((cos((lambda2 * -0.5)) ^ 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[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)
\end{array}
Initial program 62.9%
Taylor expanded in phi1 around 0 47.8%
associate--r+47.8%
unpow247.8%
1-sub-sin47.9%
unpow247.9%
sub-neg47.9%
mul-1-neg47.9%
+-commutative47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 34.2%
sub-neg34.2%
mul-1-neg34.2%
distribute-lft-in34.2%
metadata-eval34.2%
associate-*r*34.2%
associate-*r*34.2%
metadata-eval34.2%
distribute-lft-in34.2%
+-commutative34.2%
mul-1-neg34.2%
sub-neg34.2%
Simplified34.2%
Taylor expanded in lambda1 around 0 29.2%
unpow229.2%
1-sub-sin29.2%
unpow229.2%
Simplified29.2%
Taylor expanded in phi1 around 0 29.9%
sub-neg29.9%
mul-1-neg29.9%
distribute-lft-in29.9%
metadata-eval29.9%
associate-*r*29.9%
neg-mul-129.9%
associate-*r*29.9%
metadata-eval29.9%
distribute-lft-in29.9%
neg-mul-129.9%
Simplified29.9%
Final simplification29.9%
(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 (pow (cos (* lambda2 -0.5)) 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(pow(cos((lambda2 * -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
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((cos((lambda2 * (-0.5d0))) ** 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(Math.pow(Math.cos((lambda2 * -0.5)), 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(math.pow(math.cos((lambda2 * -0.5)), 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((cos(Float64(lambda2 * -0.5)) ^ 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((cos((lambda2 * -0.5)) ^ 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[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)
\end{array}
Initial program 62.9%
Taylor expanded in phi1 around 0 47.8%
associate--r+47.8%
unpow247.8%
1-sub-sin47.9%
unpow247.9%
sub-neg47.9%
mul-1-neg47.9%
+-commutative47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 34.2%
sub-neg34.2%
mul-1-neg34.2%
distribute-lft-in34.2%
metadata-eval34.2%
associate-*r*34.2%
associate-*r*34.2%
metadata-eval34.2%
distribute-lft-in34.2%
+-commutative34.2%
mul-1-neg34.2%
sub-neg34.2%
Simplified34.2%
Taylor expanded in lambda1 around 0 29.2%
unpow229.2%
1-sub-sin29.2%
unpow229.2%
Simplified29.2%
Taylor expanded in phi2 around 0 29.3%
*-commutative29.3%
unpow229.3%
associate-*l*29.3%
sub-neg29.3%
mul-1-neg29.3%
distribute-lft-in29.3%
metadata-eval29.3%
associate-*r*29.3%
neg-mul-129.3%
associate-*r*29.3%
metadata-eval29.3%
distribute-lft-in29.3%
neg-mul-129.3%
Simplified29.3%
Final simplification29.3%
herbie shell --seed 2023185
(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))))))))))