
(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 20 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 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 t_2)
(*
t_0
(/
(-
(- 1.0 (* (cos lambda1) (cos lambda2)))
(* (sin lambda2) (sin lambda1)))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) - (t_0 * (((1.0 - (cos(lambda1) * cos(lambda2))) - (sin(lambda2) * sin(lambda1))) / 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) - (t_0 * (((1.0d0 - (cos(lambda1) * cos(lambda2))) - (sin(lambda2) * sin(lambda1))) / 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) - (t_0 * (((1.0 - (Math.cos(lambda1) * Math.cos(lambda2))) - (Math.sin(lambda2) * Math.sin(lambda1))) / 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) - (t_0 * (((1.0 - (math.cos(lambda1) * math.cos(lambda2))) - (math.sin(lambda2) * math.sin(lambda1))) / 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) - Float64(t_0 * Float64(Float64(Float64(1.0 - Float64(cos(lambda1) * cos(lambda2))) - Float64(sin(lambda2) * sin(lambda1))) / 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) - (t_0 * (((1.0 - (cos(lambda1) * cos(lambda2))) - (sin(lambda2) * sin(lambda1))) / 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - N[(t$95$0 * N[(N[(N[(1.0 - N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - t_2\right) - t_0 \cdot \frac{\left(1 - \cos \lambda_1 \cdot \cos \lambda_2\right) - \sin \lambda_2 \cdot \sin \lambda_1}{2}}}\right)
\end{array}
\end{array}
Initial program 64.3%
associate-*l*64.3%
Simplified64.3%
sin-mult64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
Applied egg-rr64.3%
+-inverses64.3%
cos-064.3%
distribute-lft-out64.3%
metadata-eval64.3%
*-rgt-identity64.3%
Simplified64.3%
cos-diff64.9%
Applied egg-rr64.9%
associate--r+64.9%
*-commutative64.9%
cancel-sign-sub-inv64.9%
Applied egg-rr64.9%
Final simplification64.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 t_2)
(*
t_0
(/
(-
1.0
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) - (t_0 * ((1.0 - ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) / 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) - (t_0 * ((1.0d0 - ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) / 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) - (t_0 * ((1.0 - ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda2) * Math.sin(lambda1)))) / 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) - (t_0 * ((1.0 - ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda2) * math.sin(lambda1)))) / 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) - Float64(t_0 * Float64(Float64(1.0 - Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1)))) / 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) - (t_0 * ((1.0 - ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) / 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - N[(t$95$0 * N[(N[(1.0 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - t_2\right) - t_0 \cdot \frac{1 - \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right)}{2}}}\right)
\end{array}
\end{array}
Initial program 64.3%
associate-*l*64.3%
Simplified64.3%
sin-mult64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
Applied egg-rr64.3%
+-inverses64.3%
cos-064.3%
distribute-lft-out64.3%
metadata-eval64.3%
*-rgt-identity64.3%
Simplified64.3%
cos-diff64.9%
Applied egg-rr64.9%
Final simplification64.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 t_2)
(*
t_0
(/ (- 1.0 (+ (+ 1.0 (cos (- lambda1 lambda2))) -1.0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) - (t_0 * ((1.0 - ((1.0 + cos((lambda1 - lambda2))) + -1.0)) / 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) - (t_0 * ((1.0d0 - ((1.0d0 + cos((lambda1 - lambda2))) + (-1.0d0))) / 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) - (t_0 * ((1.0 - ((1.0 + Math.cos((lambda1 - lambda2))) + -1.0)) / 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) - (t_0 * ((1.0 - ((1.0 + math.cos((lambda1 - lambda2))) + -1.0)) / 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) - Float64(t_0 * Float64(Float64(1.0 - Float64(Float64(1.0 + cos(Float64(lambda1 - lambda2))) + -1.0)) / 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) - (t_0 * ((1.0 - ((1.0 + cos((lambda1 - lambda2))) + -1.0)) / 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - N[(t$95$0 * N[(N[(1.0 - N[(N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - t_2\right) - t_0 \cdot \frac{1 - \left(\left(1 + \cos \left(\lambda_1 - \lambda_2\right)\right) + -1\right)}{2}}}\right)
\end{array}
\end{array}
Initial program 64.3%
associate-*l*64.3%
Simplified64.3%
sin-mult64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
Applied egg-rr64.3%
+-inverses64.3%
cos-064.3%
distribute-lft-out64.3%
metadata-eval64.3%
*-rgt-identity64.3%
Simplified64.3%
expm1-log1p-u64.3%
expm1-udef64.3%
log1p-udef64.3%
add-exp-log64.3%
Applied egg-rr64.3%
Final simplification64.3%
(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 (* t_0 (/ (+ (cos (- lambda1 lambda2)) -1.0) 2.0))))
(if (or (<= phi1 -3.2e-13) (not (<= phi1 8.9e-10)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (+ (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (+ (pow (cos (* phi2 -0.5)) 2.0) t_3))))))))
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 = t_0 * ((cos((lambda1 - lambda2)) + -1.0) / 2.0);
double tmp;
if ((phi1 <= -3.2e-13) || !(phi1 <= 8.9e-10)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) + t_3))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 * (t_1 * t_1)
t_3 = t_0 * ((cos((lambda1 - lambda2)) + (-1.0d0)) / 2.0d0)
if ((phi1 <= (-3.2d-13)) .or. (.not. (phi1 <= 8.9d-10))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) + t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) + t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.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 = t_0 * ((Math.cos((lambda1 - lambda2)) + -1.0) / 2.0);
double tmp;
if ((phi1 <= -3.2e-13) || !(phi1 <= 8.9e-10)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) + t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) + t_3))));
}
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 = t_0 * ((math.cos((lambda1 - lambda2)) + -1.0) / 2.0) tmp = 0 if (phi1 <= -3.2e-13) or not (phi1 <= 8.9e-10): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) + t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) + t_3)))) 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(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / 2.0)) tmp = 0.0 if ((phi1 <= -3.2e-13) || !(phi1 <= 8.9e-10)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + t_3))))); 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 = t_0 * ((cos((lambda1 - lambda2)) + -1.0) / 2.0); tmp = 0.0; if ((phi1 <= -3.2e-13) || ~((phi1 <= 8.9e-10))) tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) + t_3)))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) + t_3)))); 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[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -3.2e-13], N[Not[LessEqual[phi1, 8.9e-10]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + 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] + t$95$3), $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 := t_0 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{2}\\
\mathbf{if}\;\phi_1 \leq -3.2 \cdot 10^{-13} \lor \neg \left(\phi_1 \leq 8.9 \cdot 10^{-10}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + t_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + t_3}}\right)\\
\end{array}
\end{array}
if phi1 < -3.2e-13 or 8.9e-10 < phi1 Initial program 52.4%
associate-*l*52.4%
Simplified52.4%
sin-mult52.4%
div-inv52.4%
metadata-eval52.4%
div-inv52.4%
metadata-eval52.4%
div-inv52.4%
metadata-eval52.4%
div-inv52.4%
metadata-eval52.4%
Applied egg-rr52.4%
+-inverses52.4%
cos-052.4%
distribute-lft-out52.4%
metadata-eval52.4%
*-rgt-identity52.4%
Simplified52.4%
Taylor expanded in phi2 around 0 52.4%
if -3.2e-13 < phi1 < 8.9e-10Initial program 78.6%
associate-*l*78.6%
Simplified78.6%
sin-mult78.7%
div-inv78.7%
metadata-eval78.7%
div-inv78.7%
metadata-eval78.7%
div-inv78.7%
metadata-eval78.7%
div-inv78.7%
metadata-eval78.7%
Applied egg-rr78.7%
+-inverses78.7%
cos-078.7%
distribute-lft-out78.7%
metadata-eval78.7%
*-rgt-identity78.7%
Simplified78.7%
Taylor expanded in phi1 around 0 77.1%
Taylor expanded in phi1 around 0 77.1%
unpow224.4%
1-sub-sin24.4%
unpow224.4%
Simplified77.1%
Final simplification63.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_0 (* t_2 t_2)))
(t_4 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -8.2e-6) (not (<= phi1 2e-9)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (+ (- 1.0 t_1) (* t_0 (/ (+ t_4 -1.0) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 t_3))
(sqrt
(-
(- 1.0 (pow (sin (* phi2 -0.5)) 2.0))
(* t_0 (/ (- 1.0 t_4) 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 - phi2) / 2.0)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -8.2e-6) || !(phi1 <= 2e-9)) {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - t_1) + (t_0 * ((t_4 + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt(((1.0 - pow(sin((phi2 * -0.5)), 2.0)) - (t_0 * ((1.0 - t_4) / 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) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_0 * (t_2 * t_2)
t_4 = cos((lambda1 - lambda2))
if ((phi1 <= (-8.2d-6)) .or. (.not. (phi1 <= 2d-9))) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 - t_1) + (t_0 * ((t_4 + (-1.0d0)) / 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_3)), sqrt(((1.0d0 - (sin((phi2 * (-0.5d0))) ** 2.0d0)) - (t_0 * ((1.0d0 - t_4) / 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 - phi2) / 2.0)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -8.2e-6) || !(phi1 <= 2e-9)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - t_1) + (t_0 * ((t_4 + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_3)), Math.sqrt(((1.0 - Math.pow(Math.sin((phi2 * -0.5)), 2.0)) - (t_0 * ((1.0 - t_4) / 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 - phi2) / 2.0)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_0 * (t_2 * t_2) t_4 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -8.2e-6) or not (phi1 <= 2e-9): tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - t_1) + (t_0 * ((t_4 + -1.0) / 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_3)), math.sqrt(((1.0 - math.pow(math.sin((phi2 * -0.5)), 2.0)) - (t_0 * ((1.0 - t_4) / 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_0 * Float64(t_2 * t_2)) t_4 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -8.2e-6) || !(phi1 <= 2e-9)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(t_4 + -1.0) / 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_3)), sqrt(Float64(Float64(1.0 - (sin(Float64(phi2 * -0.5)) ^ 2.0)) - Float64(t_0 * Float64(Float64(1.0 - t_4) / 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 - phi2) / 2.0)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_0 * (t_2 * t_2); t_4 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -8.2e-6) || ~((phi1 <= 2e-9))) tmp = R * (2.0 * atan2(sqrt((t_3 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - t_1) + (t_0 * ((t_4 + -1.0) / 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt(((1.0 - (sin((phi2 * -0.5)) ^ 2.0)) - (t_0 * ((1.0 - t_4) / 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[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -8.2e-6], N[Not[LessEqual[phi1, 2e-9]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(t$95$4 + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(N[(1.0 - t$95$4), $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{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_0 \cdot \left(t_2 \cdot t_2\right)\\
t_4 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -8.2 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 2 \cdot 10^{-9}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - t_1\right) + t_0 \cdot \frac{t_4 + -1}{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_3}}{\sqrt{\left(1 - {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right) - t_0 \cdot \frac{1 - t_4}{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -8.1999999999999994e-6 or 2.00000000000000012e-9 < phi1 Initial program 51.4%
associate-*l*51.4%
Simplified51.4%
sin-mult51.4%
div-inv51.4%
metadata-eval51.4%
div-inv51.4%
metadata-eval51.4%
div-inv51.4%
metadata-eval51.4%
div-inv51.4%
metadata-eval51.4%
Applied egg-rr51.4%
+-inverses51.4%
cos-051.4%
distribute-lft-out51.4%
metadata-eval51.4%
*-rgt-identity51.4%
Simplified51.4%
Taylor expanded in phi2 around 0 51.4%
if -8.1999999999999994e-6 < phi1 < 2.00000000000000012e-9Initial program 79.2%
associate-*l*79.2%
Simplified79.2%
sin-mult79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
Applied egg-rr79.2%
+-inverses79.2%
cos-079.2%
distribute-lft-out79.2%
metadata-eval79.2%
*-rgt-identity79.2%
Simplified79.2%
Taylor expanded in phi1 around 0 79.2%
Final simplification64.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* phi1 0.5)) 2.0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_2 (* t_3 t_3)))
(t_5 (sqrt (+ t_0 t_4)))
(t_6 (cos (- lambda1 lambda2)))
(t_7 (* t_2 (/ (+ t_6 -1.0) 2.0))))
(if (<= phi1 -1.8e-5)
(* R (* 2.0 (atan2 t_5 (sqrt (+ (- 1.0 t_1) t_7)))))
(if (<= phi1 2e-9)
(*
R
(*
2.0
(atan2
t_5
(sqrt
(-
(- 1.0 (pow (sin (* phi2 -0.5)) 2.0))
(* t_2 (/ (- 1.0 t_6) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_4 t_1)) (sqrt (+ (- 1.0 t_0) t_7)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(sin((phi1 * 0.5)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_2 * (t_3 * t_3);
double t_5 = sqrt((t_0 + t_4));
double t_6 = cos((lambda1 - lambda2));
double t_7 = t_2 * ((t_6 + -1.0) / 2.0);
double tmp;
if (phi1 <= -1.8e-5) {
tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - t_1) + t_7))));
} else if (phi1 <= 2e-9) {
tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - pow(sin((phi2 * -0.5)), 2.0)) - (t_2 * ((1.0 - t_6) / 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_4 + t_1)), sqrt(((1.0 - t_0) + t_7))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin((phi1 * 0.5d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = t_2 * (t_3 * t_3)
t_5 = sqrt((t_0 + t_4))
t_6 = cos((lambda1 - lambda2))
t_7 = t_2 * ((t_6 + (-1.0d0)) / 2.0d0)
if (phi1 <= (-1.8d-5)) then
tmp = r * (2.0d0 * atan2(t_5, sqrt(((1.0d0 - t_1) + t_7))))
else if (phi1 <= 2d-9) then
tmp = r * (2.0d0 * atan2(t_5, sqrt(((1.0d0 - (sin((phi2 * (-0.5d0))) ** 2.0d0)) - (t_2 * ((1.0d0 - t_6) / 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_4 + t_1)), sqrt(((1.0d0 - t_0) + t_7))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_2 * (t_3 * t_3);
double t_5 = Math.sqrt((t_0 + t_4));
double t_6 = Math.cos((lambda1 - lambda2));
double t_7 = t_2 * ((t_6 + -1.0) / 2.0);
double tmp;
if (phi1 <= -1.8e-5) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt(((1.0 - t_1) + t_7))));
} else if (phi1 <= 2e-9) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt(((1.0 - Math.pow(Math.sin((phi2 * -0.5)), 2.0)) - (t_2 * ((1.0 - t_6) / 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + t_1)), Math.sqrt(((1.0 - t_0) + t_7))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_2 * (t_3 * t_3) t_5 = math.sqrt((t_0 + t_4)) t_6 = math.cos((lambda1 - lambda2)) t_7 = t_2 * ((t_6 + -1.0) / 2.0) tmp = 0 if phi1 <= -1.8e-5: tmp = R * (2.0 * math.atan2(t_5, math.sqrt(((1.0 - t_1) + t_7)))) elif phi1 <= 2e-9: tmp = R * (2.0 * math.atan2(t_5, math.sqrt(((1.0 - math.pow(math.sin((phi2 * -0.5)), 2.0)) - (t_2 * ((1.0 - t_6) / 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + t_1)), math.sqrt(((1.0 - t_0) + t_7)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_2 * Float64(t_3 * t_3)) t_5 = sqrt(Float64(t_0 + t_4)) t_6 = cos(Float64(lambda1 - lambda2)) t_7 = Float64(t_2 * Float64(Float64(t_6 + -1.0) / 2.0)) tmp = 0.0 if (phi1 <= -1.8e-5) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(Float64(1.0 - t_1) + t_7))))); elseif (phi1 <= 2e-9) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(Float64(1.0 - (sin(Float64(phi2 * -0.5)) ^ 2.0)) - Float64(t_2 * Float64(Float64(1.0 - t_6) / 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + t_1)), sqrt(Float64(Float64(1.0 - t_0) + t_7))))); 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((phi1 * 0.5)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = t_2 * (t_3 * t_3); t_5 = sqrt((t_0 + t_4)); t_6 = cos((lambda1 - lambda2)); t_7 = t_2 * ((t_6 + -1.0) / 2.0); tmp = 0.0; if (phi1 <= -1.8e-5) tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - t_1) + t_7)))); elseif (phi1 <= 2e-9) tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - (sin((phi2 * -0.5)) ^ 2.0)) - (t_2 * ((1.0 - t_6) / 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_4 + t_1)), sqrt(((1.0 - t_0) + t_7)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(t$95$0 + t$95$4), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[(t$95$2 * N[(N[(t$95$6 + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.8e-5], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + t$95$7), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2e-9], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * N[(N[(1.0 - t$95$6), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] + t$95$7), $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(\phi_1 \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t_2 \cdot \left(t_3 \cdot t_3\right)\\
t_5 := \sqrt{t_0 + t_4}\\
t_6 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_7 := t_2 \cdot \frac{t_6 + -1}{2}\\
\mathbf{if}\;\phi_1 \leq -1.8 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_5}{\sqrt{\left(1 - t_1\right) + t_7}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_5}{\sqrt{\left(1 - {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right) - t_2 \cdot \frac{1 - t_6}{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4 + t_1}}{\sqrt{\left(1 - t_0\right) + t_7}}\right)\\
\end{array}
\end{array}
if phi1 < -1.80000000000000005e-5Initial program 46.5%
associate-*l*46.5%
Simplified46.5%
sin-mult46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
Applied egg-rr46.5%
+-inverses46.5%
cos-046.5%
distribute-lft-out46.5%
metadata-eval46.5%
*-rgt-identity46.5%
Simplified46.5%
Taylor expanded in phi2 around 0 46.7%
if -1.80000000000000005e-5 < phi1 < 2.00000000000000012e-9Initial program 79.2%
associate-*l*79.2%
Simplified79.2%
sin-mult79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
Applied egg-rr79.2%
+-inverses79.2%
cos-079.2%
distribute-lft-out79.2%
metadata-eval79.2%
*-rgt-identity79.2%
Simplified79.2%
Taylor expanded in phi1 around 0 79.2%
if 2.00000000000000012e-9 < phi1 Initial program 56.5%
associate-*l*56.5%
Simplified56.5%
sin-mult56.5%
div-inv56.5%
metadata-eval56.5%
div-inv56.5%
metadata-eval56.5%
div-inv56.5%
metadata-eval56.5%
div-inv56.5%
metadata-eval56.5%
Applied egg-rr56.5%
+-inverses56.5%
cos-056.5%
distribute-lft-out56.5%
metadata-eval56.5%
*-rgt-identity56.5%
Simplified56.5%
Taylor expanded in phi2 around 0 56.9%
Final simplification64.5%
(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_1 (* t_0 t_0)))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_4 (- 1.0 t_3)))
(if (<= (- lambda1 lambda2) -2.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (+ t_4 (* t_1 (/ (+ (cos (- lambda1 lambda2)) -1.0) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_3
(* t_1 (/ (- (* lambda1 (* lambda1 0.5)) (* lambda1 lambda2)) 2.0))))
(sqrt (- t_4 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = t_1 * (t_0 * t_0);
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = 1.0 - t_3;
double tmp;
if ((lambda1 - lambda2) <= -2.0) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((t_4 + (t_1 * ((cos((lambda1 - lambda2)) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + (t_1 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), sqrt((t_4 - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = t_1 * (t_0 * t_0)
t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_4 = 1.0d0 - t_3
if ((lambda1 - lambda2) <= (-2.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((t_4 + (t_1 * ((cos((lambda1 - lambda2)) + (-1.0d0)) / 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (t_1 * (((lambda1 * (lambda1 * 0.5d0)) - (lambda1 * lambda2)) / 2.0d0)))), sqrt((t_4 - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = t_1 * (t_0 * t_0);
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = 1.0 - t_3;
double tmp;
if ((lambda1 - lambda2) <= -2.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((t_4 + (t_1 * ((Math.cos((lambda1 - lambda2)) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (t_1 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), Math.sqrt((t_4 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = t_1 * (t_0 * t_0) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_4 = 1.0 - t_3 tmp = 0 if (lambda1 - lambda2) <= -2.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((t_4 + (t_1 * ((math.cos((lambda1 - lambda2)) + -1.0) / 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (t_1 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), math.sqrt((t_4 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(t_1 * Float64(t_0 * t_0)) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_4 = Float64(1.0 - t_3) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -2.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(t_4 + Float64(t_1 * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_1 * Float64(Float64(Float64(lambda1 * Float64(lambda1 * 0.5)) - Float64(lambda1 * lambda2)) / 2.0)))), sqrt(Float64(t_4 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = t_1 * (t_0 * t_0); t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_4 = 1.0 - t_3; tmp = 0.0; if ((lambda1 - lambda2) <= -2.0) tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((t_4 + (t_1 * ((cos((lambda1 - lambda2)) + -1.0) / 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (t_1 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), sqrt((t_4 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$3), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -2.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 + N[(t$95$1 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$1 * N[(N[(N[(lambda1 * N[(lambda1 * 0.5), $MachinePrecision]), $MachinePrecision] - N[(lambda1 * lambda2), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - 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 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := t_1 \cdot \left(t_0 \cdot t_0\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := 1 - t_3\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -2:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{t_4 + t_1 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_1 \cdot \frac{\lambda_1 \cdot \left(\lambda_1 \cdot 0.5\right) - \lambda_1 \cdot \lambda_2}{2}}}{\sqrt{t_4 - t_2}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -2Initial program 58.3%
associate-*l*58.3%
Simplified58.3%
sin-mult58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
Applied egg-rr58.3%
+-inverses58.3%
cos-058.3%
distribute-lft-out58.3%
metadata-eval58.3%
*-rgt-identity58.3%
Simplified58.3%
Taylor expanded in phi1 around 0 37.1%
if -2 < (-.f64 lambda1 lambda2) Initial program 68.1%
associate-*l*68.2%
Simplified68.1%
sin-mult68.2%
div-inv68.2%
metadata-eval68.2%
div-inv68.2%
metadata-eval68.2%
div-inv68.2%
metadata-eval68.2%
div-inv68.2%
metadata-eval68.2%
Applied egg-rr64.0%
+-inverses68.2%
cos-068.2%
distribute-lft-out68.2%
metadata-eval68.2%
*-rgt-identity68.2%
Simplified64.0%
Taylor expanded in lambda2 around 0 50.3%
+-commutative50.3%
mul-1-neg50.3%
unsub-neg50.3%
Simplified50.3%
Taylor expanded in lambda1 around 0 34.5%
+-commutative34.5%
mul-1-neg34.5%
unsub-neg34.5%
*-commutative34.5%
unpow234.5%
associate-*l*34.5%
Simplified34.5%
Final simplification35.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 3.8e-32)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_3))))
(sqrt (+ t_1 (* t_2 (/ (+ (cos lambda1) -1.0) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 (sin (* lambda2 -0.5))))))
(sqrt (+ t_1 (* t_2 (/ (+ (cos (- lambda1 lambda2)) -1.0) 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 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 3.8e-32) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * -0.5)))))), sqrt((t_1 + (t_2 * ((cos((lambda1 - lambda2)) + -1.0) / 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) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda2 <= 3.8d-32) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) + (-1.0d0)) / 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * (-0.5d0))))))), sqrt((t_1 + (t_2 * ((cos((lambda1 - lambda2)) + (-1.0d0)) / 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 = 1.0 - t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 3.8e-32) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda1) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * Math.sin((lambda2 * -0.5)))))), Math.sqrt((t_1 + (t_2 * ((Math.cos((lambda1 - lambda2)) + -1.0) / 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 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 3.8e-32: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), math.sqrt((t_1 + (t_2 * ((math.cos(lambda1) + -1.0) / 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * math.sin((lambda2 * -0.5)))))), math.sqrt((t_1 + (t_2 * ((math.cos((lambda1 - lambda2)) + -1.0) / 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= 3.8e-32) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda1) + -1.0) / 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * sin(Float64(lambda2 * -0.5)))))), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / 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 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda2 <= 3.8e-32) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) + -1.0) / 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * -0.5)))))), sqrt((t_1 + (t_2 * ((cos((lambda1 - lambda2)) + -1.0) / 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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 3.8e-32], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] + -1.0), $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$2 * N[(t$95$3 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := 1 - t_0\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 3.8 \cdot 10^{-32}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}}{\sqrt{t_1 + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{\sqrt{t_1 + t_2 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 3.80000000000000008e-32Initial program 71.6%
associate-*l*71.6%
Simplified71.5%
sin-mult71.6%
div-inv71.6%
metadata-eval71.6%
div-inv71.6%
metadata-eval71.6%
div-inv71.6%
metadata-eval71.6%
div-inv71.6%
metadata-eval71.6%
Applied egg-rr71.6%
+-inverses71.6%
cos-071.6%
distribute-lft-out71.6%
metadata-eval71.6%
*-rgt-identity71.6%
Simplified71.6%
Taylor expanded in lambda2 around 0 62.6%
if 3.80000000000000008e-32 < lambda2 Initial program 48.0%
associate-*l*48.0%
Simplified48.0%
sin-mult48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
Applied egg-rr48.1%
+-inverses48.1%
cos-048.1%
distribute-lft-out48.1%
metadata-eval48.1%
*-rgt-identity48.1%
Simplified48.1%
Taylor expanded in lambda1 around 0 46.7%
Final simplification57.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (sqrt (+ t_0 (* t_2 (* t_3 t_3))))))
(if (<= lambda1 -1.25e-5)
(*
R
(*
2.0
(atan2 t_4 (sqrt (+ t_1 (* t_2 (/ (+ (cos lambda1) -1.0) 2.0)))))))
(*
R
(*
2.0
(atan2 t_4 (sqrt (+ t_1 (* t_2 (/ (+ (cos lambda2) -1.0) 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 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3))));
double tmp;
if (lambda1 <= -1.25e-5) {
tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda2) + -1.0) / 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) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3))))
if (lambda1 <= (-1.25d-5)) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) + (-1.0d0)) / 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda2) + (-1.0d0)) / 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 = 1.0 - t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.sqrt((t_0 + (t_2 * (t_3 * t_3))));
double tmp;
if (lambda1 <= -1.25e-5) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda1) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda2) + -1.0) / 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 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.sqrt((t_0 + (t_2 * (t_3 * t_3)))) tmp = 0 if lambda1 <= -1.25e-5: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_1 + (t_2 * ((math.cos(lambda1) + -1.0) / 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_1 + (t_2 * ((math.cos(lambda2) + -1.0) / 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))) tmp = 0.0 if (lambda1 <= -1.25e-5) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda1) + -1.0) / 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda2) + -1.0) / 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 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3)))); tmp = 0.0; if (lambda1 <= -1.25e-5) tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) + -1.0) / 2.0)))))); else tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda2) + -1.0) / 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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.25e-5], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda2], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := 1 - t_0\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}\\
\mathbf{if}\;\lambda_1 \leq -1.25 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{t_1 + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{t_1 + t_2 \cdot \frac{\cos \lambda_2 + -1}{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.25000000000000006e-5Initial program 46.8%
associate-*l*46.8%
Simplified46.7%
sin-mult46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
Applied egg-rr46.8%
+-inverses46.8%
cos-046.8%
distribute-lft-out46.8%
metadata-eval46.8%
*-rgt-identity46.8%
Simplified46.8%
Taylor expanded in lambda2 around 0 46.7%
if -1.25000000000000006e-5 < lambda1 Initial program 70.6%
associate-*l*70.6%
Simplified70.6%
sin-mult70.7%
div-inv70.7%
metadata-eval70.7%
div-inv70.7%
metadata-eval70.7%
div-inv70.7%
metadata-eval70.7%
div-inv70.7%
metadata-eval70.7%
Applied egg-rr70.7%
+-inverses70.7%
cos-070.7%
distribute-lft-out70.7%
metadata-eval70.7%
*-rgt-identity70.7%
Simplified70.7%
Taylor expanded in lambda1 around 0 58.2%
cos-neg58.2%
Simplified58.2%
Final simplification55.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_2 (* t_3 t_3))))
(if (<= lambda2 0.00035)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_4))
(sqrt (+ t_1 (* t_2 (/ (+ (cos lambda1) -1.0) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (/ (- 1.0 (cos lambda2)) 2.0))))
(sqrt (- t_1 t_4))))))))
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 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_2 * (t_3 * t_3);
double tmp;
if (lambda2 <= 0.00035) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_4)), sqrt((t_1 + (t_2 * ((cos(lambda1) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * ((1.0 - cos(lambda2)) / 2.0)))), sqrt((t_1 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = t_2 * (t_3 * t_3)
if (lambda2 <= 0.00035d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_4)), sqrt((t_1 + (t_2 * ((cos(lambda1) + (-1.0d0)) / 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * ((1.0d0 - cos(lambda2)) / 2.0d0)))), sqrt((t_1 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_2 * (t_3 * t_3);
double tmp;
if (lambda2 <= 0.00035) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_4)), Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda1) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * ((1.0 - Math.cos(lambda2)) / 2.0)))), Math.sqrt((t_1 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_2 * (t_3 * t_3) tmp = 0 if lambda2 <= 0.00035: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_4)), math.sqrt((t_1 + (t_2 * ((math.cos(lambda1) + -1.0) / 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * ((1.0 - math.cos(lambda2)) / 2.0)))), math.sqrt((t_1 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_2 * Float64(t_3 * t_3)) tmp = 0.0 if (lambda2 <= 0.00035) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_4)), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda1) + -1.0) / 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(Float64(1.0 - cos(lambda2)) / 2.0)))), sqrt(Float64(t_1 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = t_2 * (t_3 * t_3); tmp = 0.0; if (lambda2 <= 0.00035) tmp = R * (2.0 * atan2(sqrt((t_0 + t_4)), sqrt((t_1 + (t_2 * ((cos(lambda1) + -1.0) / 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * ((1.0 - cos(lambda2)) / 2.0)))), sqrt((t_1 - t_4)))); 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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 0.00035], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] + -1.0), $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$2 * N[(N[(1.0 - N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - t$95$4), $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 := 1 - t_0\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t_2 \cdot \left(t_3 \cdot t_3\right)\\
\mathbf{if}\;\lambda_2 \leq 0.00035:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_4}}{\sqrt{t_1 + t_2 \cdot \frac{\cos \lambda_1 + -1}{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \frac{1 - \cos \lambda_2}{2}}}{\sqrt{t_1 - t_4}}\right)\\
\end{array}
\end{array}
if lambda2 < 3.49999999999999996e-4Initial program 71.0%
associate-*l*71.0%
Simplified71.0%
sin-mult71.1%
div-inv71.1%
metadata-eval71.1%
div-inv71.1%
metadata-eval71.1%
div-inv71.1%
metadata-eval71.1%
div-inv71.1%
metadata-eval71.1%
Applied egg-rr71.1%
+-inverses71.1%
cos-071.1%
distribute-lft-out71.1%
metadata-eval71.1%
*-rgt-identity71.1%
Simplified71.1%
Taylor expanded in lambda2 around 0 62.3%
if 3.49999999999999996e-4 < lambda2 Initial program 47.7%
associate-*l*47.7%
Simplified47.7%
sin-mult47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
Applied egg-rr47.8%
+-inverses47.7%
cos-047.7%
distribute-lft-out47.7%
metadata-eval47.7%
*-rgt-identity47.7%
Simplified47.8%
Taylor expanded in lambda1 around 0 47.5%
cos-neg47.3%
Simplified47.5%
Final simplification58.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(+ (- 1.0 t_2) (* t_0 (/ (+ (cos (- lambda1 lambda2)) -1.0) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) + -1.0) / 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) + (-1.0d0)) / 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) + (t_0 * ((Math.cos((lambda1 - lambda2)) + -1.0) / 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) + (t_0 * ((math.cos((lambda1 - lambda2)) + -1.0) / 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) + -1.0) / 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - t_2\right) + t_0 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{2}}}\right)
\end{array}
\end{array}
Initial program 64.3%
associate-*l*64.3%
Simplified64.3%
sin-mult64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
Applied egg-rr64.3%
+-inverses64.3%
cos-064.3%
distribute-lft-out64.3%
metadata-eval64.3%
*-rgt-identity64.3%
Simplified64.3%
Final simplification64.3%
(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 phi2) 2.0)) 2.0)))
(if (<= (- lambda1 lambda2) -2.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(+
(pow (cos (* phi2 -0.5)) 2.0)
(* t_0 (/ (+ (cos (- lambda1 lambda2)) -1.0) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_3
(* t_0 (/ (- (* lambda1 (* lambda1 0.5)) (* lambda1 lambda2)) 2.0))))
(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 - phi2) / 2.0)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -2.0) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) + (t_0 * ((cos((lambda1 - lambda2)) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + (t_0 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), 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 - phi2) / 2.0d0)) ** 2.0d0
if ((lambda1 - lambda2) <= (-2.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) + (t_0 * ((cos((lambda1 - lambda2)) + (-1.0d0)) / 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (t_0 * (((lambda1 * (lambda1 * 0.5d0)) - (lambda1 * lambda2)) / 2.0d0)))), 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 - phi2) / 2.0)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -2.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) + (t_0 * ((Math.cos((lambda1 - lambda2)) + -1.0) / 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (t_0 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), 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 - phi2) / 2.0)), 2.0) tmp = 0 if (lambda1 - lambda2) <= -2.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) + (t_0 * ((math.cos((lambda1 - lambda2)) + -1.0) / 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (t_0 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), 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 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (Float64(lambda1 - lambda2) <= -2.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_0 * Float64(Float64(Float64(lambda1 * Float64(lambda1 * 0.5)) - Float64(lambda1 * lambda2)) / 2.0)))), 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 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if ((lambda1 - lambda2) <= -2.0) tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) + (t_0 * ((cos((lambda1 - lambda2)) + -1.0) / 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (t_0 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), 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[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -2.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + 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[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$0 * N[(N[(N[(lambda1 * N[(lambda1 * 0.5), $MachinePrecision]), $MachinePrecision] - N[(lambda1 * lambda2), $MachinePrecision]), $MachinePrecision] / 2.0), $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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -2:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + t_0 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_0 \cdot \frac{\lambda_1 \cdot \left(\lambda_1 \cdot 0.5\right) - \lambda_1 \cdot \lambda_2}{2}}}{\sqrt{\left(1 - t_3\right) - t_2}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -2Initial program 58.3%
associate-*l*58.3%
Simplified58.3%
sin-mult58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
Applied egg-rr58.3%
+-inverses58.3%
cos-058.3%
distribute-lft-out58.3%
metadata-eval58.3%
*-rgt-identity58.3%
Simplified58.3%
Taylor expanded in phi1 around 0 37.1%
Taylor expanded in phi1 around 0 36.5%
unpow213.5%
1-sub-sin13.5%
unpow213.5%
Simplified36.5%
if -2 < (-.f64 lambda1 lambda2) Initial program 68.1%
associate-*l*68.2%
Simplified68.1%
sin-mult68.2%
div-inv68.2%
metadata-eval68.2%
div-inv68.2%
metadata-eval68.2%
div-inv68.2%
metadata-eval68.2%
div-inv68.2%
metadata-eval68.2%
Applied egg-rr64.0%
+-inverses68.2%
cos-068.2%
distribute-lft-out68.2%
metadata-eval68.2%
*-rgt-identity68.2%
Simplified64.0%
Taylor expanded in lambda2 around 0 50.3%
+-commutative50.3%
mul-1-neg50.3%
unsub-neg50.3%
Simplified50.3%
Taylor expanded in lambda1 around 0 34.5%
+-commutative34.5%
mul-1-neg34.5%
unsub-neg34.5%
*-commutative34.5%
unpow234.5%
associate-*l*34.5%
Simplified34.5%
Final simplification35.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_2
(* t_0 (/ (- (* lambda1 (* lambda1 0.5)) (* lambda1 lambda2)) 2.0))))
(sqrt (- (- 1.0 t_2) (* t_0 (* t_1 t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), sqrt(((1.0 - t_2) - (t_0 * (t_1 * 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
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (((lambda1 * (lambda1 * 0.5d0)) - (lambda1 * lambda2)) / 2.0d0)))), sqrt(((1.0d0 - t_2) - (t_0 * (t_1 * t_1))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), Math.sqrt(((1.0 - t_2) - (t_0 * (t_1 * t_1))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), math.sqrt(((1.0 - t_2) - (t_0 * (t_1 * t_1))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(Float64(Float64(lambda1 * Float64(lambda1 * 0.5)) - Float64(lambda1 * lambda2)) / 2.0)))), sqrt(Float64(Float64(1.0 - t_2) - Float64(t_0 * Float64(t_1 * t_1))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (((lambda1 * (lambda1 * 0.5)) - (lambda1 * lambda2)) / 2.0)))), sqrt(((1.0 - t_2) - (t_0 * (t_1 * t_1)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(N[(N[(lambda1 * N[(lambda1 * 0.5), $MachinePrecision]), $MachinePrecision] - N[(lambda1 * lambda2), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \frac{\lambda_1 \cdot \left(\lambda_1 \cdot 0.5\right) - \lambda_1 \cdot \lambda_2}{2}}}{\sqrt{\left(1 - t_2\right) - t_0 \cdot \left(t_1 \cdot t_1\right)}}\right)
\end{array}
\end{array}
Initial program 64.3%
associate-*l*64.3%
Simplified64.3%
sin-mult64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
Applied egg-rr61.7%
+-inverses64.3%
cos-064.3%
distribute-lft-out64.3%
metadata-eval64.3%
*-rgt-identity64.3%
Simplified61.7%
Taylor expanded in lambda2 around 0 43.2%
+-commutative43.2%
mul-1-neg43.2%
unsub-neg43.2%
Simplified43.2%
Taylor expanded in lambda1 around 0 25.8%
+-commutative25.8%
mul-1-neg25.8%
unsub-neg25.8%
*-commutative25.8%
unpow225.8%
associate-*l*25.8%
Simplified25.8%
Final simplification25.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_1 (* t_2 t_2))))
(if (or (<= phi1 -1.5e-5) (not (<= phi1 1.4e-59)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi1 0.5)) 2.0)
(* -0.5 (* lambda1 (* (cos phi1) lambda2)))))
(sqrt (- (- 1.0 t_0) t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (- t_0 (* t_1 (/ (* lambda1 lambda2) 2.0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_3))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * (t_2 * t_2);
double tmp;
if ((phi1 <= -1.5e-5) || !(phi1 <= 1.4e-59)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (-0.5 * (lambda1 * (cos(phi1) * lambda2))))), sqrt(((1.0 - t_0) - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 - (t_1 * ((lambda1 * lambda2) / 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_3))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_1 * (t_2 * t_2)
if ((phi1 <= (-1.5d-5)) .or. (.not. (phi1 <= 1.4d-59))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + ((-0.5d0) * (lambda1 * (cos(phi1) * lambda2))))), sqrt(((1.0d0 - t_0) - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 - (t_1 * ((lambda1 * lambda2) / 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * (t_2 * t_2);
double tmp;
if ((phi1 <= -1.5e-5) || !(phi1 <= 1.4e-59)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (-0.5 * (lambda1 * (Math.cos(phi1) * lambda2))))), Math.sqrt(((1.0 - t_0) - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 - (t_1 * ((lambda1 * lambda2) / 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_1 * (t_2 * t_2) tmp = 0 if (phi1 <= -1.5e-5) or not (phi1 <= 1.4e-59): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + (-0.5 * (lambda1 * (math.cos(phi1) * lambda2))))), math.sqrt(((1.0 - t_0) - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 - (t_1 * ((lambda1 * lambda2) / 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_1 * Float64(t_2 * t_2)) tmp = 0.0 if ((phi1 <= -1.5e-5) || !(phi1 <= 1.4e-59)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(-0.5 * Float64(lambda1 * Float64(cos(phi1) * lambda2))))), sqrt(Float64(Float64(1.0 - t_0) - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 - Float64(t_1 * Float64(Float64(lambda1 * lambda2) / 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_1 * (t_2 * t_2); tmp = 0.0; if ((phi1 <= -1.5e-5) || ~((phi1 <= 1.4e-59))) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + (-0.5 * (lambda1 * (cos(phi1) * lambda2))))), sqrt(((1.0 - t_0) - t_3)))); else tmp = R * (2.0 * atan2(sqrt((t_0 - (t_1 * ((lambda1 * lambda2) / 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -1.5e-5], N[Not[LessEqual[phi1, 1.4e-59]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(-0.5 * N[(lambda1 * N[(N[Cos[phi1], $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 - N[(t$95$1 * N[(N[(lambda1 * lambda2), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_1 \cdot \left(t_2 \cdot t_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.5 \cdot 10^{-5} \lor \neg \left(\phi_1 \leq 1.4 \cdot 10^{-59}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + -0.5 \cdot \left(\lambda_1 \cdot \left(\cos \phi_1 \cdot \lambda_2\right)\right)}}{\sqrt{\left(1 - t_0\right) - t_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 - t_1 \cdot \frac{\lambda_1 \cdot \lambda_2}{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_3}}\right)\\
\end{array}
\end{array}
if phi1 < -1.50000000000000004e-5 or 1.3999999999999999e-59 < phi1 Initial program 53.2%
associate-*l*53.2%
Simplified53.2%
sin-mult53.2%
div-inv53.2%
metadata-eval53.2%
div-inv53.2%
metadata-eval53.2%
div-inv53.2%
metadata-eval53.2%
div-inv53.2%
metadata-eval53.2%
Applied egg-rr53.2%
+-inverses53.2%
cos-053.2%
distribute-lft-out53.2%
metadata-eval53.2%
*-rgt-identity53.2%
Simplified53.2%
Taylor expanded in lambda2 around 0 40.0%
+-commutative40.0%
mul-1-neg40.0%
unsub-neg40.0%
Simplified40.0%
Taylor expanded in lambda1 around 0 24.0%
mul-1-neg24.0%
distribute-rgt-neg-in24.0%
Simplified24.0%
Taylor expanded in phi2 around 0 23.8%
associate-*r*23.8%
Simplified23.8%
if -1.50000000000000004e-5 < phi1 < 1.3999999999999999e-59Initial program 79.0%
associate-*l*79.0%
Simplified79.0%
sin-mult79.1%
div-inv79.1%
metadata-eval79.1%
div-inv79.1%
metadata-eval79.1%
div-inv79.1%
metadata-eval79.1%
div-inv79.1%
metadata-eval79.1%
Applied egg-rr72.9%
+-inverses79.1%
cos-079.1%
distribute-lft-out79.1%
metadata-eval79.1%
*-rgt-identity79.1%
Simplified72.9%
Taylor expanded in lambda2 around 0 47.4%
+-commutative47.4%
mul-1-neg47.4%
unsub-neg47.4%
Simplified47.4%
Taylor expanded in lambda1 around 0 26.0%
mul-1-neg26.0%
distribute-rgt-neg-in26.0%
Simplified26.0%
Taylor expanded in phi1 around 0 26.0%
unpow226.0%
1-sub-sin26.1%
unpow226.1%
Simplified26.1%
Final simplification24.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (- t_2 (* t_1 (/ (* lambda1 lambda2) 2.0))))
(sqrt (- (- 1.0 t_2) (* t_1 (* t_0 t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 - (t_1 * ((lambda1 * lambda2) / 2.0)))), sqrt(((1.0 - t_2) - (t_1 * (t_0 * t_0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 - (t_1 * ((lambda1 * lambda2) / 2.0d0)))), sqrt(((1.0d0 - t_2) - (t_1 * (t_0 * t_0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 - (t_1 * ((lambda1 * lambda2) / 2.0)))), Math.sqrt(((1.0 - t_2) - (t_1 * (t_0 * t_0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 - (t_1 * ((lambda1 * lambda2) / 2.0)))), math.sqrt(((1.0 - t_2) - (t_1 * (t_0 * t_0))))))
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 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 - Float64(t_1 * Float64(Float64(lambda1 * lambda2) / 2.0)))), sqrt(Float64(Float64(1.0 - t_2) - Float64(t_1 * Float64(t_0 * t_0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 - (t_1 * ((lambda1 * lambda2) / 2.0)))), sqrt(((1.0 - t_2) - (t_1 * (t_0 * t_0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 - N[(t$95$1 * N[(N[(lambda1 * lambda2), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - N[(t$95$1 * N[(t$95$0 * t$95$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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 - t_1 \cdot \frac{\lambda_1 \cdot \lambda_2}{2}}}{\sqrt{\left(1 - t_2\right) - t_1 \cdot \left(t_0 \cdot t_0\right)}}\right)
\end{array}
\end{array}
Initial program 64.3%
associate-*l*64.3%
Simplified64.3%
sin-mult64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
Applied egg-rr61.7%
+-inverses64.3%
cos-064.3%
distribute-lft-out64.3%
metadata-eval64.3%
*-rgt-identity64.3%
Simplified61.7%
Taylor expanded in lambda2 around 0 43.2%
+-commutative43.2%
mul-1-neg43.2%
unsub-neg43.2%
Simplified43.2%
Taylor expanded in lambda1 around 0 24.9%
mul-1-neg24.9%
distribute-rgt-neg-in24.9%
Simplified24.9%
Final simplification24.9%
(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_1 (* t_0 t_0)))
(t_3
(sqrt
(-
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (/ (* lambda1 lambda2) 2.0))))))
(if (<= phi2 -4.9e-5)
(* R (* 2.0 (atan2 t_3 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_2)))))
(* R (* 2.0 (atan2 t_3 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = t_1 * (t_0 * t_0);
double t_3 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) - (t_1 * ((lambda1 * lambda2) / 2.0))));
double tmp;
if (phi2 <= -4.9e-5) {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_2))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi1 * 0.5)), 2.0) - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = t_1 * (t_0 * t_0)
t_3 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) - (t_1 * ((lambda1 * lambda2) / 2.0d0))))
if (phi2 <= (-4.9d-5)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_2))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = t_1 * (t_0 * t_0);
double t_3 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) - (t_1 * ((lambda1 * lambda2) / 2.0))));
double tmp;
if (phi2 <= -4.9e-5) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = t_1 * (t_0 * t_0) t_3 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) - (t_1 * ((lambda1 * lambda2) / 2.0)))) tmp = 0 if phi2 <= -4.9e-5: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_2)))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(t_1 * Float64(t_0 * t_0)) t_3 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) - Float64(t_1 * Float64(Float64(lambda1 * lambda2) / 2.0)))) tmp = 0.0 if (phi2 <= -4.9e-5) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = t_1 * (t_0 * t_0); t_3 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) - (t_1 * ((lambda1 * lambda2) / 2.0)))); tmp = 0.0; if (phi2 <= -4.9e-5) tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_2)))); else tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(t$95$1 * N[(N[(lambda1 * lambda2), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.9e-5], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - 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 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := t_1 \cdot \left(t_0 \cdot t_0\right)\\
t_3 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} - t_1 \cdot \frac{\lambda_1 \cdot \lambda_2}{2}}\\
\mathbf{if}\;\phi_2 \leq -4.9 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t_2}}\right)\\
\end{array}
\end{array}
if phi2 < -4.9e-5Initial program 51.6%
associate-*l*51.6%
Simplified51.6%
sin-mult51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
Applied egg-rr51.7%
+-inverses51.7%
cos-051.7%
distribute-lft-out51.7%
metadata-eval51.7%
*-rgt-identity51.7%
Simplified51.7%
Taylor expanded in lambda2 around 0 36.7%
+-commutative36.7%
mul-1-neg36.7%
unsub-neg36.7%
Simplified36.7%
Taylor expanded in lambda1 around 0 26.7%
mul-1-neg26.7%
distribute-rgt-neg-in26.7%
Simplified26.7%
Taylor expanded in phi1 around 0 26.4%
unpow226.4%
1-sub-sin26.5%
unpow226.5%
Simplified26.5%
if -4.9e-5 < phi2 Initial program 69.5%
associate-*l*69.5%
Simplified69.4%
sin-mult69.5%
div-inv69.5%
metadata-eval69.5%
div-inv69.5%
metadata-eval69.5%
div-inv69.5%
metadata-eval69.5%
div-inv69.5%
metadata-eval69.5%
Applied egg-rr65.8%
+-inverses69.5%
cos-069.5%
distribute-lft-out69.5%
metadata-eval69.5%
*-rgt-identity69.5%
Simplified65.8%
Taylor expanded in lambda2 around 0 45.8%
+-commutative45.8%
mul-1-neg45.8%
unsub-neg45.8%
Simplified45.8%
Taylor expanded in lambda1 around 0 24.1%
mul-1-neg24.1%
distribute-rgt-neg-in24.1%
Simplified24.1%
Taylor expanded in phi2 around 0 23.0%
unpow223.0%
1-sub-sin23.0%
unpow223.0%
Simplified23.0%
Final simplification24.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (- t_1 (* t_0 (/ (* lambda1 lambda2) 2.0))))
(sqrt
(-
(- 1.0 t_1)
(*
t_0
(* (sin (/ (- lambda1 lambda2) 2.0)) (sin (* lambda2 -0.5)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_1 - (t_0 * ((lambda1 * lambda2) / 2.0)))), sqrt(((1.0 - t_1) - (t_0 * (sin(((lambda1 - lambda2) / 2.0)) * sin((lambda2 * -0.5))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_1 - (t_0 * ((lambda1 * lambda2) / 2.0d0)))), sqrt(((1.0d0 - t_1) - (t_0 * (sin(((lambda1 - lambda2) / 2.0d0)) * sin((lambda2 * (-0.5d0)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 - (t_0 * ((lambda1 * lambda2) / 2.0)))), Math.sqrt(((1.0 - t_1) - (t_0 * (Math.sin(((lambda1 - lambda2) / 2.0)) * Math.sin((lambda2 * -0.5))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_1 - (t_0 * ((lambda1 * lambda2) / 2.0)))), math.sqrt(((1.0 - t_1) - (t_0 * (math.sin(((lambda1 - lambda2) / 2.0)) * math.sin((lambda2 * -0.5))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 - Float64(t_0 * Float64(Float64(lambda1 * lambda2) / 2.0)))), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * Float64(sin(Float64(Float64(lambda1 - lambda2) / 2.0)) * sin(Float64(lambda2 * -0.5))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_1 - (t_0 * ((lambda1 * lambda2) / 2.0)))), sqrt(((1.0 - t_1) - (t_0 * (sin(((lambda1 - lambda2) / 2.0)) * sin((lambda2 * -0.5)))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 - N[(t$95$0 * N[(N[(lambda1 * lambda2), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 - t_0 \cdot \frac{\lambda_1 \cdot \lambda_2}{2}}}{\sqrt{\left(1 - t_1\right) - t_0 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}\right)
\end{array}
\end{array}
Initial program 64.3%
associate-*l*64.3%
Simplified64.3%
sin-mult64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
Applied egg-rr61.7%
+-inverses64.3%
cos-064.3%
distribute-lft-out64.3%
metadata-eval64.3%
*-rgt-identity64.3%
Simplified61.7%
Taylor expanded in lambda2 around 0 43.2%
+-commutative43.2%
mul-1-neg43.2%
unsub-neg43.2%
Simplified43.2%
Taylor expanded in lambda1 around 0 24.9%
mul-1-neg24.9%
distribute-rgt-neg-in24.9%
Simplified24.9%
Taylor expanded in lambda1 around 0 24.7%
Final simplification24.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))
(if (<= phi2 -1.4e-24)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* -0.5 (* (cos phi2) (* lambda1 lambda2)))))
t_1)))
(* R (* 2.0 (atan2 (sin (* (- phi1 phi2) 0.5)) 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 = sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double tmp;
if (phi2 <= -1.4e-24) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (-0.5 * (cos(phi2) * (lambda1 * lambda2))))), t_1));
} else {
tmp = R * (2.0 * atan2(sin(((phi1 - phi2) * 0.5)), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
if (phi2 <= (-1.4d-24)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + ((-0.5d0) * (cos(phi2) * (lambda1 * lambda2))))), t_1))
else
tmp = r * (2.0d0 * atan2(sin(((phi1 - phi2) * 0.5d0)), 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.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double tmp;
if (phi2 <= -1.4e-24) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (-0.5 * (Math.cos(phi2) * (lambda1 * lambda2))))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sin(((phi1 - phi2) * 0.5)), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) tmp = 0 if phi2 <= -1.4e-24: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (-0.5 * (math.cos(phi2) * (lambda1 * lambda2))))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sin(((phi1 - phi2) * 0.5)), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) tmp = 0.0 if (phi2 <= -1.4e-24) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(-0.5 * Float64(cos(phi2) * Float64(lambda1 * lambda2))))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sin(Float64(Float64(phi1 - phi2) * 0.5)), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); tmp = 0.0; if (phi2 <= -1.4e-24) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (-0.5 * (cos(phi2) * (lambda1 * lambda2))))), t_1)); else tmp = R * (2.0 * atan2(sin(((phi1 - phi2) * 0.5)), 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[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $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[phi2, -1.4e-24], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(-0.5 * N[(N[Cos[phi2], $MachinePrecision] * N[(lambda1 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}\\
\mathbf{if}\;\phi_2 \leq -1.4 \cdot 10^{-24}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + -0.5 \cdot \left(\cos \phi_2 \cdot \left(\lambda_1 \cdot \lambda_2\right)\right)}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{t_1}\right)\\
\end{array}
\end{array}
if phi2 < -1.4000000000000001e-24Initial program 53.4%
associate-*l*53.4%
Simplified53.5%
sin-mult53.5%
div-inv53.5%
metadata-eval53.5%
div-inv53.5%
metadata-eval53.5%
div-inv53.5%
metadata-eval53.5%
div-inv53.5%
metadata-eval53.5%
Applied egg-rr53.5%
+-inverses53.5%
cos-053.5%
distribute-lft-out53.5%
metadata-eval53.5%
*-rgt-identity53.5%
Simplified53.5%
Taylor expanded in lambda2 around 0 37.2%
+-commutative37.2%
mul-1-neg37.2%
unsub-neg37.2%
Simplified37.2%
Taylor expanded in lambda1 around 0 26.8%
mul-1-neg26.8%
distribute-rgt-neg-in26.8%
Simplified26.8%
Taylor expanded in phi1 around 0 25.1%
if -1.4000000000000001e-24 < phi2 Initial program 69.2%
associate-*l*69.2%
Simplified69.2%
sin-mult69.3%
div-inv69.3%
metadata-eval69.3%
div-inv69.3%
metadata-eval69.3%
div-inv69.3%
metadata-eval69.3%
div-inv69.3%
metadata-eval69.3%
Applied egg-rr65.4%
+-inverses69.3%
cos-069.3%
distribute-lft-out69.3%
metadata-eval69.3%
*-rgt-identity69.3%
Simplified65.4%
Taylor expanded in lambda2 around 0 45.9%
+-commutative45.9%
mul-1-neg45.9%
unsub-neg45.9%
Simplified45.9%
Taylor expanded in lambda1 around 0 24.0%
mul-1-neg24.0%
distribute-rgt-neg-in24.0%
Simplified24.0%
Taylor expanded in lambda2 around 0 16.7%
Final simplification19.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))
(if (<= phi2 -7e-16)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* -0.5 (* (cos phi2) (* lambda1 lambda2)))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi1 0.5)) 2.0)
(* -0.5 (* lambda1 (* (cos phi1) lambda2)))))
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 = sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double tmp;
if (phi2 <= -7e-16) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (-0.5 * (cos(phi2) * (lambda1 * lambda2))))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (-0.5 * (lambda1 * (cos(phi1) * lambda2))))), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
if (phi2 <= (-7d-16)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + ((-0.5d0) * (cos(phi2) * (lambda1 * lambda2))))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + ((-0.5d0) * (lambda1 * (cos(phi1) * lambda2))))), 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.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double tmp;
if (phi2 <= -7e-16) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (-0.5 * (Math.cos(phi2) * (lambda1 * lambda2))))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (-0.5 * (lambda1 * (Math.cos(phi1) * lambda2))))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) tmp = 0 if phi2 <= -7e-16: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (-0.5 * (math.cos(phi2) * (lambda1 * lambda2))))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + (-0.5 * (lambda1 * (math.cos(phi1) * lambda2))))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) tmp = 0.0 if (phi2 <= -7e-16) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(-0.5 * Float64(cos(phi2) * Float64(lambda1 * lambda2))))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(-0.5 * Float64(lambda1 * Float64(cos(phi1) * lambda2))))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); tmp = 0.0; if (phi2 <= -7e-16) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (-0.5 * (cos(phi2) * (lambda1 * lambda2))))), t_1)); else tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + (-0.5 * (lambda1 * (cos(phi1) * lambda2))))), 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[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $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[phi2, -7e-16], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(-0.5 * N[(N[Cos[phi2], $MachinePrecision] * N[(lambda1 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(-0.5 * N[(lambda1 * N[(N[Cos[phi1], $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}\\
\mathbf{if}\;\phi_2 \leq -7 \cdot 10^{-16}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + -0.5 \cdot \left(\cos \phi_2 \cdot \left(\lambda_1 \cdot \lambda_2\right)\right)}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + -0.5 \cdot \left(\lambda_1 \cdot \left(\cos \phi_1 \cdot \lambda_2\right)\right)}}{t_1}\right)\\
\end{array}
\end{array}
if phi2 < -7.00000000000000035e-16Initial program 52.9%
associate-*l*52.9%
Simplified52.9%
sin-mult52.9%
div-inv52.9%
metadata-eval52.9%
div-inv52.9%
metadata-eval52.9%
div-inv52.9%
metadata-eval52.9%
div-inv52.9%
metadata-eval52.9%
Applied egg-rr52.9%
+-inverses52.9%
cos-052.9%
distribute-lft-out52.9%
metadata-eval52.9%
*-rgt-identity52.9%
Simplified52.9%
Taylor expanded in lambda2 around 0 37.1%
+-commutative37.1%
mul-1-neg37.1%
unsub-neg37.1%
Simplified37.1%
Taylor expanded in lambda1 around 0 26.3%
mul-1-neg26.3%
distribute-rgt-neg-in26.3%
Simplified26.3%
Taylor expanded in phi1 around 0 25.9%
if -7.00000000000000035e-16 < phi2 Initial program 69.1%
associate-*l*69.1%
Simplified69.1%
sin-mult69.2%
div-inv69.2%
metadata-eval69.2%
div-inv69.2%
metadata-eval69.2%
div-inv69.2%
metadata-eval69.2%
div-inv69.2%
metadata-eval69.2%
Applied egg-rr65.4%
+-inverses69.2%
cos-069.2%
distribute-lft-out69.2%
metadata-eval69.2%
*-rgt-identity69.2%
Simplified65.4%
Taylor expanded in lambda2 around 0 45.8%
+-commutative45.8%
mul-1-neg45.8%
unsub-neg45.8%
Simplified45.8%
Taylor expanded in lambda1 around 0 24.2%
mul-1-neg24.2%
distribute-rgt-neg-in24.2%
Simplified24.2%
Taylor expanded in phi2 around 0 21.7%
associate-*r*21.7%
Simplified21.7%
Final simplification23.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sin (* (- phi1 phi2) 0.5))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* (cos phi1) (cos phi2)) (* t_0 t_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(sin(((phi1 - phi2) * 0.5)), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sin(((phi1 - phi2) * 0.5d0)), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sin(((phi1 - phi2) * 0.5)), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sin(((phi1 - phi2) * 0.5)), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sin(Float64(Float64(phi1 - phi2) * 0.5)), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sin(((phi1 - phi2) * 0.5)), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_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[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}}\right)
\end{array}
\end{array}
Initial program 64.3%
associate-*l*64.3%
Simplified64.3%
sin-mult64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
div-inv64.3%
metadata-eval64.3%
Applied egg-rr61.7%
+-inverses64.3%
cos-064.3%
distribute-lft-out64.3%
metadata-eval64.3%
*-rgt-identity64.3%
Simplified61.7%
Taylor expanded in lambda2 around 0 43.2%
+-commutative43.2%
mul-1-neg43.2%
unsub-neg43.2%
Simplified43.2%
Taylor expanded in lambda1 around 0 24.9%
mul-1-neg24.9%
distribute-rgt-neg-in24.9%
Simplified24.9%
Taylor expanded in lambda2 around 0 16.3%
Final simplification16.3%
herbie shell --seed 2023218
(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))))))))))