
(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
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(-
(- 1.0 t_1)
(*
t_0
(log
(exp
(+
0.5
(*
-0.5
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))))))))))))))
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 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - (t_0 * log(exp((0.5 + (-0.5 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) - (t_0 * log(exp((0.5d0 + ((-0.5d0) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))))))))))))
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 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) - (t_0 * Math.log(Math.exp((0.5 + (-0.5 * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) - (t_0 * math.log(math.exp((0.5 + (-0.5 * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * log(exp(Float64(0.5 + Float64(-0.5 * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))))))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - (t_0 * log(exp((0.5 + (-0.5 * ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[Log[N[Exp[N[(0.5 + N[(-0.5 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\left(1 - t_1\right) - t_0 \cdot \log \left(e^{0.5 + -0.5 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}\right)}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
div-sub60.2%
sin-diff61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr61.1%
div-sub60.2%
sin-diff61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr77.3%
add-log-exp77.3%
sqr-sin-a77.4%
cancel-sign-sub-inv77.4%
metadata-eval77.4%
cos-277.4%
cos-sum77.4%
add-log-exp26.8%
add-log-exp26.8%
sum-log26.4%
exp-sqrt26.4%
exp-sqrt26.4%
add-sqr-sqrt26.4%
add-log-exp77.4%
Applied egg-rr77.4%
cos-diff78.0%
Applied egg-rr78.0%
Final simplification78.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(-
(- 1.0 t_1)
(* t_0 (log (exp (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))))
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 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - (t_0 * log(exp((0.5 + (-0.5 * cos((lambda1 - lambda2)))))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) - (t_0 * log(exp((0.5d0 + ((-0.5d0) * cos((lambda1 - lambda2)))))))))))
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 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) - (t_0 * Math.log(Math.exp((0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) - (t_0 * math.log(math.exp((0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * log(exp(Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - (t_0 * log(exp((0.5 + (-0.5 * cos((lambda1 - lambda2))))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[Log[N[Exp[N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\left(1 - t_1\right) - t_0 \cdot \log \left(e^{0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
div-sub60.2%
sin-diff61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr61.1%
div-sub60.2%
sin-diff61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr77.3%
add-log-exp77.3%
sqr-sin-a77.4%
cancel-sign-sub-inv77.4%
metadata-eval77.4%
cos-277.4%
cos-sum77.4%
add-log-exp26.8%
add-log-exp26.8%
sum-log26.4%
exp-sqrt26.4%
exp-sqrt26.4%
add-sqr-sqrt26.4%
add-log-exp77.4%
Applied egg-rr77.4%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sqrt (+ t_0 (* t_2 (* t_1 t_1))))))
(if (or (<= lambda2 -8.5e-5) (not (<= lambda2 0.00038)))
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
1.0
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (- 1.0 t_0) (* t_2 (+ 0.5 (* -0.5 (cos lambda1))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sqrt((t_0 + (t_2 * (t_1 * t_1))));
double tmp;
if ((lambda2 <= -8.5e-5) || !(lambda2 <= 0.00038)) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - t_0) - (t_2 * (0.5 + (-0.5 * cos(lambda1))))))));
}
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 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
t_3 = sqrt((t_0 + (t_2 * (t_1 * t_1))))
if ((lambda2 <= (-8.5d-5)) .or. (.not. (lambda2 <= 0.00038d0))) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt(((1.0d0 - t_0) - (t_2 * (0.5d0 + ((-0.5d0) * cos(lambda1))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sqrt((t_0 + (t_2 * (t_1 * t_1))));
double tmp;
if ((lambda2 <= -8.5e-5) || !(lambda2 <= 0.00038)) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt(((1.0 - t_0) - (t_2 * (0.5 + (-0.5 * Math.cos(lambda1))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sqrt((t_0 + (t_2 * (t_1 * t_1)))) tmp = 0 if (lambda2 <= -8.5e-5) or not (lambda2 <= 0.00038): tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt(((1.0 - t_0) - (t_2 * (0.5 + (-0.5 * math.cos(lambda1)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sqrt(Float64(t_0 + Float64(t_2 * Float64(t_1 * t_1)))) tmp = 0.0 if ((lambda2 <= -8.5e-5) || !(lambda2 <= 0.00038)) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(Float64(1.0 - t_0) - Float64(t_2 * Float64(0.5 + Float64(-0.5 * cos(lambda1))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); t_3 = sqrt((t_0 + (t_2 * (t_1 * t_1)))); tmp = 0.0; if ((lambda2 <= -8.5e-5) || ~((lambda2 <= 0.00038))) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - t_0) - (t_2 * (0.5 + (-0.5 * cos(lambda1)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -8.5e-5], N[Not[LessEqual[lambda2, 0.00038]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(t$95$2 * N[(0.5 + N[(-0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sqrt{t_0 + t_2 \cdot \left(t_1 \cdot t_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -8.5 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 0.00038\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{\left(1 - t_0\right) - t_2 \cdot \left(0.5 + -0.5 \cdot \cos \lambda_1\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -8.500000000000001e-5 or 3.8000000000000002e-4 < lambda2 Initial program 43.2%
associate-*l*43.2%
Simplified43.2%
div-sub43.2%
sin-diff44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
Applied egg-rr44.2%
Taylor expanded in lambda1 around 0 44.4%
if -8.500000000000001e-5 < lambda2 < 3.8000000000000002e-4Initial program 76.9%
associate-*l*76.9%
Simplified76.9%
div-sub76.9%
sin-diff77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
Applied egg-rr77.7%
div-sub76.9%
sin-diff77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
Applied egg-rr98.7%
add-log-exp98.7%
sqr-sin-a98.7%
cancel-sign-sub-inv98.7%
metadata-eval98.7%
cos-298.7%
cos-sum98.7%
add-log-exp49.2%
add-log-exp49.2%
sum-log49.2%
exp-sqrt49.2%
exp-sqrt49.2%
add-sqr-sqrt49.2%
add-log-exp98.7%
Applied egg-rr98.7%
Taylor expanded in lambda2 around 0 98.7%
Final simplification71.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (- 1.0 t_0))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (sqrt (+ t_0 (* t_3 (* t_1 t_1))))))
(if (or (<= lambda2 -2.35e-5) (not (<= lambda2 2.55e-5)))
(*
R
(*
2.0
(atan2 t_4 (sqrt (- t_2 (* t_3 (+ 0.5 (* -0.5 (cos lambda2)))))))))
(*
R
(*
2.0
(atan2 t_4 (sqrt (- t_2 (* t_3 (+ 0.5 (* -0.5 (cos lambda1))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = 1.0 - t_0;
double t_3 = cos(phi1) * cos(phi2);
double t_4 = sqrt((t_0 + (t_3 * (t_1 * t_1))));
double tmp;
if ((lambda2 <= -2.35e-5) || !(lambda2 <= 2.55e-5)) {
tmp = R * (2.0 * atan2(t_4, sqrt((t_2 - (t_3 * (0.5 + (-0.5 * cos(lambda2))))))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((t_2 - (t_3 * (0.5 + (-0.5 * cos(lambda1))))))));
}
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 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = 1.0d0 - t_0
t_3 = cos(phi1) * cos(phi2)
t_4 = sqrt((t_0 + (t_3 * (t_1 * t_1))))
if ((lambda2 <= (-2.35d-5)) .or. (.not. (lambda2 <= 2.55d-5))) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_2 - (t_3 * (0.5d0 + ((-0.5d0) * cos(lambda2))))))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_2 - (t_3 * (0.5d0 + ((-0.5d0) * cos(lambda1))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = 1.0 - t_0;
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double t_4 = Math.sqrt((t_0 + (t_3 * (t_1 * t_1))));
double tmp;
if ((lambda2 <= -2.35e-5) || !(lambda2 <= 2.55e-5)) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_2 - (t_3 * (0.5 + (-0.5 * Math.cos(lambda2))))))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_2 - (t_3 * (0.5 + (-0.5 * Math.cos(lambda1))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = 1.0 - t_0 t_3 = math.cos(phi1) * math.cos(phi2) t_4 = math.sqrt((t_0 + (t_3 * (t_1 * t_1)))) tmp = 0 if (lambda2 <= -2.35e-5) or not (lambda2 <= 2.55e-5): tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_2 - (t_3 * (0.5 + (-0.5 * math.cos(lambda2)))))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_2 - (t_3 * (0.5 + (-0.5 * math.cos(lambda1)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(1.0 - t_0) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = sqrt(Float64(t_0 + Float64(t_3 * Float64(t_1 * t_1)))) tmp = 0.0 if ((lambda2 <= -2.35e-5) || !(lambda2 <= 2.55e-5)) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_2 - Float64(t_3 * Float64(0.5 + Float64(-0.5 * cos(lambda2))))))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_2 - Float64(t_3 * Float64(0.5 + Float64(-0.5 * cos(lambda1))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = 1.0 - t_0; t_3 = cos(phi1) * cos(phi2); t_4 = sqrt((t_0 + (t_3 * (t_1 * t_1)))); tmp = 0.0; if ((lambda2 <= -2.35e-5) || ~((lambda2 <= 2.55e-5))) tmp = R * (2.0 * atan2(t_4, sqrt((t_2 - (t_3 * (0.5 + (-0.5 * cos(lambda2)))))))); else tmp = R * (2.0 * atan2(t_4, sqrt((t_2 - (t_3 * (0.5 + (-0.5 * cos(lambda1)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$0 + N[(t$95$3 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -2.35e-5], N[Not[LessEqual[lambda2, 2.55e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$2 - N[(t$95$3 * N[(0.5 + N[(-0.5 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$2 - N[(t$95$3 * N[(0.5 + N[(-0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := 1 - t_0\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := \sqrt{t_0 + t_3 \cdot \left(t_1 \cdot t_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -2.35 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 2.55 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{t_2 - t_3 \cdot \left(0.5 + -0.5 \cdot \cos \lambda_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{t_2 - t_3 \cdot \left(0.5 + -0.5 \cdot \cos \lambda_1\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -2.34999999999999986e-5 or 2.54999999999999998e-5 < lambda2 Initial program 43.2%
associate-*l*43.2%
Simplified43.2%
div-sub43.2%
sin-diff44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
Applied egg-rr44.2%
div-sub43.2%
sin-diff44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
div-inv44.2%
metadata-eval44.2%
Applied egg-rr55.6%
add-log-exp55.6%
sqr-sin-a55.7%
cancel-sign-sub-inv55.7%
metadata-eval55.7%
cos-255.7%
cos-sum55.7%
add-log-exp3.9%
add-log-exp3.9%
sum-log3.1%
exp-sqrt3.1%
exp-sqrt3.1%
add-sqr-sqrt3.1%
add-log-exp55.7%
Applied egg-rr55.7%
Taylor expanded in lambda1 around 0 55.4%
cos-neg55.4%
Simplified55.4%
if -2.34999999999999986e-5 < lambda2 < 2.54999999999999998e-5Initial program 76.9%
associate-*l*76.9%
Simplified76.9%
div-sub76.9%
sin-diff77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
Applied egg-rr77.7%
div-sub76.9%
sin-diff77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
div-inv77.7%
metadata-eval77.7%
Applied egg-rr98.7%
add-log-exp98.7%
sqr-sin-a98.7%
cancel-sign-sub-inv98.7%
metadata-eval98.7%
cos-298.7%
cos-sum98.7%
add-log-exp49.2%
add-log-exp49.2%
sum-log49.2%
exp-sqrt49.2%
exp-sqrt49.2%
add-sqr-sqrt49.2%
add-log-exp98.7%
Applied egg-rr98.7%
Taylor expanded in lambda2 around 0 98.7%
Final simplification77.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(-
(- 1.0 t_1)
(* t_0 (/ (+ (cos (- 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 = pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - (t_0 * ((cos((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((phi1 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) - (t_0 * ((cos((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.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) - (t_0 * ((Math.cos((lambda1 - lambda2)) + -1.0) / -2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) - (t_0 * ((math.cos((lambda1 - lambda2)) + -1.0) / -2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / -2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - (t_0 * ((cos((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[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[(N[(N[Cos[N[(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 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\left(1 - t_1\right) - t_0 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{-2}}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
div-sub60.2%
sin-diff61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr61.1%
div-sub60.2%
sin-diff61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr77.3%
sin-mult31.8%
frac-2neg31.8%
Applied egg-rr77.4%
neg-sub031.8%
cos-031.8%
associate--r-31.8%
metadata-eval31.8%
Simplified77.4%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (* phi1 0.5)) (cos (* 0.5 phi2)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)
(* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_0 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2)))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 * 0.5d0)) * cos((0.5d0 * phi2))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) - (t_0 * (0.5d0 + ((-0.5d0) * cos((lambda1 - lambda2)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((0.5 * phi2))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0) + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 * 0.5)) * math.cos((0.5 * phi2))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(0.5 * phi2))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) - Float64(t_0 * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 * 0.5)) * cos((0.5 * phi2))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $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{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) - t_0 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
div-sub60.2%
sin-diff61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr61.1%
sub-neg61.1%
div-inv61.1%
metadata-eval61.1%
distribute-rgt-neg-in61.1%
sqr-sin-a61.1%
cancel-sign-sub-inv61.1%
metadata-eval61.1%
cos-261.1%
cos-sum61.1%
add-log-exp20.5%
add-log-exp20.5%
Applied egg-rr61.1%
Final simplification61.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) t_1))
(sqrt
(-
(- 1.0 t_1)
(*
t_2
(expm1 (log1p (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) - (t_2 * expm1(log1p((0.5 + (-0.5 * cos((lambda1 - lambda2)))))))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), Math.sqrt(((1.0 - t_1) - (t_2 * Math.expm1(Math.log1p((0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), math.sqrt(((1.0 - t_1) - (t_2 * math.expm1(math.log1p((0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + t_1)), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_2 * expm1(log1p(Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$2 * N[(Exp[N[Log[1 + N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(t_0 \cdot t_0\right) + t_1}}{\sqrt{\left(1 - t_1\right) - t_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
expm1-log1p-u60.2%
sqr-sin-a60.2%
cancel-sign-sub-inv60.2%
metadata-eval60.2%
cos-260.2%
cos-sum60.2%
add-log-exp20.3%
add-log-exp20.3%
sum-log20.2%
exp-sqrt20.2%
exp-sqrt20.2%
add-sqr-sqrt20.2%
add-log-exp60.2%
Applied egg-rr60.2%
Final simplification60.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) t_1))
(sqrt
(-
(- 1.0 t_1)
(* t_2 (log (exp (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) - (t_2 * log(exp((0.5 + (-0.5 * cos((lambda1 - lambda2)))))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
code = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0d0 - t_1) - (t_2 * log(exp((0.5d0 + ((-0.5d0) * cos((lambda1 - lambda2)))))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), Math.sqrt(((1.0 - t_1) - (t_2 * Math.log(Math.exp((0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), math.sqrt(((1.0 - t_1) - (t_2 * math.log(math.exp((0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + t_1)), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_2 * log(exp(Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) - (t_2 * log(exp((0.5 + (-0.5 * cos((lambda1 - lambda2))))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$2 * N[Log[N[Exp[N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(t_0 \cdot t_0\right) + t_1}}{\sqrt{\left(1 - t_1\right) - t_2 \cdot \log \left(e^{0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
add-log-exp77.3%
sqr-sin-a77.4%
cancel-sign-sub-inv77.4%
metadata-eval77.4%
cos-277.4%
cos-sum77.4%
add-log-exp26.8%
add-log-exp26.8%
sum-log26.4%
exp-sqrt26.4%
exp-sqrt26.4%
add-sqr-sqrt26.4%
add-log-exp77.4%
Applied egg-rr60.2%
Final simplification60.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(if (or (<= phi1 -2.65e-5) (not (<= phi1 2.35e-16)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (- 1.0 t_0) t_2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 t_0))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double tmp;
if ((phi1 <= -2.65e-5) || !(phi1 <= 2.35e-16)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - t_0) - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_0)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
if ((phi1 <= (-2.65d-5)) .or. (.not. (phi1 <= 2.35d-16))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 - t_0) - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + t_0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double tmp;
if ((phi1 <= -2.65e-5) || !(phi1 <= 2.35e-16)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - t_0) - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_0)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) tmp = 0 if (phi1 <= -2.65e-5) or not (phi1 <= 2.35e-16): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - t_0) - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + t_0)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) tmp = 0.0 if ((phi1 <= -2.65e-5) || !(phi1 <= 2.35e-16)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_0) - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_0)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); tmp = 0.0; if ((phi1 <= -2.65e-5) || ~((phi1 <= 2.35e-16))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - t_0) - t_2)))); else tmp = R * (2.0 * atan2(sqrt((t_2 + t_0)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -2.65e-5], N[Not[LessEqual[phi1, 2.35e-16]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_1 \cdot t_1\right)\\
\mathbf{if}\;\phi_1 \leq -2.65 \cdot 10^{-5} \lor \neg \left(\phi_1 \leq 2.35 \cdot 10^{-16}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - t_0\right) - t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -2.65e-5 or 2.35000000000000022e-16 < phi1 Initial program 46.5%
associate-*l*46.5%
Simplified46.5%
Taylor expanded in phi2 around 0 46.8%
Taylor expanded in phi2 around 0 47.4%
if -2.65e-5 < phi1 < 2.35000000000000022e-16Initial program 74.5%
associate-*l*74.5%
Simplified74.5%
Taylor expanded in phi1 around 0 74.5%
+-commutative74.5%
associate--r+74.5%
unpow274.5%
1-sub-sin74.5%
unpow274.5%
*-commutative74.5%
Simplified74.5%
Final simplification60.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2))))
(if (or (<= phi2 -2.6e+15) (not (<= phi2 2.3e-5)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 (+ t_0 (* t_1 (* t_2 t_1))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_1)) t_0))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -2.6e+15) || !(phi2 <= 2.3e-5)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - (t_0 + (t_1 * (t_2 * t_1)))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
if ((phi2 <= (-2.6d+15)) .or. (.not. (phi2 <= 2.3d-5))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - (t_0 + (t_1 * (t_2 * t_1)))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((phi2 <= -2.6e+15) || !(phi2 <= 2.3e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - (t_0 + (t_1 * (t_2 * t_1)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_1 * t_1)) + t_0)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (phi2 <= -2.6e+15) or not (phi2 <= 2.3e-5): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - (t_0 + (t_1 * (t_2 * t_1))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_1 * t_1)) + t_0)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -2.6e+15) || !(phi2 <= 2.3e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_1 * Float64(t_2 * t_1)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_1)) + t_0)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); tmp = 0.0; if ((phi2 <= -2.6e+15) || ~((phi2 <= 2.3e-5))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - (t_0 + (t_1 * (t_2 * t_1))))))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -2.6e+15], N[Not[LessEqual[phi2, 2.3e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -2.6 \cdot 10^{+15} \lor \neg \left(\phi_2 \leq 2.3 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left(t_0 + t_1 \cdot \left(t_2 \cdot t_1\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(t_1 \cdot t_1\right) + t_0}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -2.6e15 or 2.3e-5 < phi2 Initial program 45.8%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in phi1 around 0 47.1%
if -2.6e15 < phi2 < 2.3e-5Initial program 76.2%
associate-*l*76.2%
Simplified76.2%
Taylor expanded in phi2 around 0 75.9%
+-commutative75.9%
associate--r+75.8%
unpow275.8%
1-sub-sin75.9%
unpow275.9%
*-commutative75.9%
Simplified75.9%
Final simplification60.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (or (<= phi2 -3.9e-6) (not (<= phi2 3.1e-5)))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi2 <= -3.9e-6) || !(phi2 <= 3.1e-5)) {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if ((phi2 <= (-3.9d-6)) .or. (.not. (phi2 <= 3.1d-5))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi2 <= -3.9e-6) || !(phi2 <= 3.1e-5)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if (phi2 <= -3.9e-6) or not (phi2 <= 3.1e-5): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if ((phi2 <= -3.9e-6) || !(phi2 <= 3.1e-5)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if ((phi2 <= -3.9e-6) || ~((phi2 <= 3.1e-5))) tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))))); else tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -3.9e-6], N[Not[LessEqual[phi2, 3.1e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -3.9 \cdot 10^{-6} \lor \neg \left(\phi_2 \leq 3.1 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_2}}\right)\\
\end{array}
\end{array}
if phi2 < -3.8999999999999999e-6 or 3.10000000000000014e-5 < phi2 Initial program 45.9%
associate-*l*45.9%
Simplified45.9%
Taylor expanded in phi1 around 0 46.2%
+-commutative46.2%
associate--r+46.3%
unpow246.3%
1-sub-sin46.2%
unpow246.2%
*-commutative46.2%
Simplified46.2%
if -3.8999999999999999e-6 < phi2 < 3.10000000000000014e-5Initial program 77.2%
associate-*l*77.2%
Simplified77.1%
Taylor expanded in phi2 around 0 77.1%
+-commutative77.1%
associate--r+77.1%
unpow277.1%
1-sub-sin77.2%
unpow277.2%
*-commutative77.2%
Simplified77.2%
Final simplification60.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(if (or (<= phi2 -9.2e-6) (not (<= phi2 0.00098)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(log (exp (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double tmp;
if ((phi2 <= -9.2e-6) || !(phi2 <= 0.00098)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(log(exp((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
if ((phi2 <= (-9.2d-6)) .or. (.not. (phi2 <= 0.00098d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(log(exp((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double tmp;
if ((phi2 <= -9.2e-6) || !(phi2 <= 0.00098)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.log(Math.exp((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) tmp = 0 if (phi2 <= -9.2e-6) or not (phi2 <= 0.00098): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.log(math.exp((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) tmp = 0.0 if ((phi2 <= -9.2e-6) || !(phi2 <= 0.00098)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(log(exp(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = 0.0; if ((phi2 <= -9.2e-6) || ~((phi2 <= 0.00098))) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(log(exp((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -9.2e-6], N[Not[LessEqual[phi2, 0.00098]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Log[N[Exp[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
\mathbf{if}\;\phi_2 \leq -9.2 \cdot 10^{-6} \lor \neg \left(\phi_2 \leq 0.00098\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\log \left(e^{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -9.2e-6 or 9.7999999999999997e-4 < phi2 Initial program 46.1%
associate-*l*46.1%
Simplified46.1%
Taylor expanded in phi1 around 0 46.4%
+-commutative46.4%
associate--r+46.4%
unpow246.4%
1-sub-sin46.4%
unpow246.4%
*-commutative46.4%
Simplified46.4%
Taylor expanded in phi1 around 0 46.0%
if -9.2e-6 < phi2 < 9.7999999999999997e-4Initial program 76.7%
associate-*l*76.7%
Simplified76.6%
Taylor expanded in phi1 around 0 48.0%
+-commutative48.0%
associate--r+48.0%
unpow248.0%
1-sub-sin48.0%
unpow248.0%
*-commutative48.0%
Simplified48.0%
Taylor expanded in phi2 around 0 48.0%
sub-neg48.0%
mul-1-neg48.0%
distribute-lft-in48.0%
metadata-eval48.0%
associate-*r*48.0%
associate-*r*48.0%
metadata-eval48.0%
distribute-lft-in48.0%
+-commutative48.0%
mul-1-neg48.0%
sub-neg48.0%
Simplified48.0%
add-log-exp48.0%
Applied egg-rr48.0%
Final simplification46.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (pow (cos (* phi2 -0.5)) 2.0)))
(if (or (<= lambda2 -1.15e-5) (not (<= lambda2 5.5e-10)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) t_1))
(sqrt (- t_3 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_2 (* t_0 (sin (* 0.5 lambda1))))))
(sqrt
(-
t_3
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if ((lambda2 <= -1.15e-5) || !(lambda2 <= 5.5e-10)) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt((t_3 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_0 * sin((0.5 * lambda1)))))), sqrt((t_3 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = cos((phi2 * (-0.5d0))) ** 2.0d0
if ((lambda2 <= (-1.15d-5)) .or. (.not. (lambda2 <= 5.5d-10))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt((t_3 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_2 * (t_0 * sin((0.5d0 * lambda1)))))), sqrt((t_3 - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double tmp;
if ((lambda2 <= -1.15e-5) || !(lambda2 <= 5.5e-10)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), Math.sqrt((t_3 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_2 * (t_0 * Math.sin((0.5 * lambda1)))))), Math.sqrt((t_3 - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.pow(math.cos((phi2 * -0.5)), 2.0) tmp = 0 if (lambda2 <= -1.15e-5) or not (lambda2 <= 5.5e-10): tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), math.sqrt((t_3 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_2 * (t_0 * math.sin((0.5 * lambda1)))))), math.sqrt((t_3 - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if ((lambda2 <= -1.15e-5) || !(lambda2 <= 5.5e-10)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + t_1)), sqrt(Float64(t_3 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * Float64(t_0 * sin(Float64(0.5 * lambda1)))))), sqrt(Float64(t_3 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = cos((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if ((lambda2 <= -1.15e-5) || ~((lambda2 <= 5.5e-10))) tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt((t_3 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_0 * sin((0.5 * lambda1)))))), sqrt((t_3 - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.15e-5], N[Not[LessEqual[lambda2, 5.5e-10]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(t$95$0 * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\lambda_2 \leq -1.15 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 5.5 \cdot 10^{-10}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(t_0 \cdot t_0\right) + t_1}}{\sqrt{t_3 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_2 \cdot \left(t_0 \cdot \sin \left(0.5 \cdot \lambda_1\right)\right)}}{\sqrt{t_3 - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < -1.15e-5 or 5.4999999999999996e-10 < lambda2 Initial program 43.2%
associate-*l*43.2%
Simplified43.2%
Taylor expanded in phi1 around 0 36.8%
+-commutative36.8%
associate--r+36.8%
unpow236.8%
1-sub-sin36.8%
unpow236.8%
*-commutative36.8%
Simplified36.8%
Taylor expanded in lambda1 around 0 37.1%
if -1.15e-5 < lambda2 < 5.4999999999999996e-10Initial program 76.9%
associate-*l*76.9%
Simplified76.9%
Taylor expanded in phi1 around 0 57.4%
+-commutative57.4%
associate--r+57.4%
unpow257.4%
1-sub-sin57.4%
unpow257.4%
*-commutative57.4%
Simplified57.4%
Taylor expanded in lambda2 around 0 57.4%
Final simplification47.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (cos (* phi2 -0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_1 t_1))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= lambda2 -0.000175) (not (<= lambda2 0.00028)))
(*
R
(*
2.0
(atan2
t_2
(sqrt (- t_0 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt (- t_0 (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(cos((phi2 * -0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((((cos(phi1) * cos(phi2)) * (t_1 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((lambda2 <= -0.000175) || !(lambda2 <= 0.00028)) {
tmp = R * (2.0 * atan2(t_2, sqrt((t_0 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((t_0 - (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((phi2 * (-0.5d0))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt((((cos(phi1) * cos(phi2)) * (t_1 * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if ((lambda2 <= (-0.000175d0)) .or. (.not. (lambda2 <= 0.00028d0))) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((t_0 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((t_0 - (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((lambda2 <= -0.000175) || !(lambda2 <= 0.00028)) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((t_0 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((t_0 - (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.cos((phi2 * -0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if (lambda2 <= -0.000175) or not (lambda2 <= 0.00028): tmp = R * (2.0 * math.atan2(t_2, math.sqrt((t_0 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((t_0 - (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((lambda2 <= -0.000175) || !(lambda2 <= 0.00028)) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(t_0 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(t_0 - Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt((((cos(phi1) * cos(phi2)) * (t_1 * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if ((lambda2 <= -0.000175) || ~((lambda2 <= 0.00028))) tmp = R * (2.0 * atan2(t_2, sqrt((t_0 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_2, sqrt((t_0 - (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.000175], N[Not[LessEqual[lambda2, 0.00028]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_1 \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\lambda_2 \leq -0.000175 \lor \neg \left(\lambda_2 \leq 0.00028\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{t_0 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{t_0 - \cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < -1.74999999999999998e-4 or 2.7999999999999998e-4 < lambda2 Initial program 43.2%
associate-*l*43.2%
Simplified43.2%
Taylor expanded in phi1 around 0 36.8%
+-commutative36.8%
associate--r+36.8%
unpow236.8%
1-sub-sin36.8%
unpow236.8%
*-commutative36.8%
Simplified36.8%
Taylor expanded in lambda1 around 0 37.1%
if -1.74999999999999998e-4 < lambda2 < 2.7999999999999998e-4Initial program 76.9%
associate-*l*76.9%
Simplified76.9%
Taylor expanded in phi1 around 0 57.4%
+-commutative57.4%
associate--r+57.4%
unpow257.4%
1-sub-sin57.4%
unpow257.4%
*-commutative57.4%
Simplified57.4%
Taylor expanded in lambda2 around 0 57.4%
Final simplification47.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) t_1))
(sqrt
(-
(- 1.0 t_1)
(* t_2 (/ (+ (cos (- lambda1 lambda2)) -1.0) -2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) - (t_2 * ((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 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
code = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0d0 - t_1) - (t_2 * ((cos((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.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), Math.sqrt(((1.0 - t_1) - (t_2 * ((Math.cos((lambda1 - lambda2)) + -1.0) / -2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), math.sqrt(((1.0 - t_1) - (t_2 * ((math.cos((lambda1 - lambda2)) + -1.0) / -2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + t_1)), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_2 * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / -2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) - (t_2 * ((cos((lambda1 - lambda2)) + -1.0) / -2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$2 * N[(N[(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{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(t_0 \cdot t_0\right) + t_1}}{\sqrt{\left(1 - t_1\right) - t_2 \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{-2}}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
sin-mult31.8%
frac-2neg31.8%
Applied egg-rr60.2%
neg-sub031.8%
cos-031.8%
associate--r-31.8%
metadata-eval31.8%
Simplified60.2%
Final simplification60.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
Taylor expanded in phi1 around 0 47.1%
+-commutative47.1%
associate--r+47.2%
unpow247.2%
1-sub-sin47.2%
unpow247.2%
*-commutative47.2%
Simplified47.2%
Final simplification47.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(log (exp (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(log(exp((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(log(exp((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.log(Math.exp((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.log(math.exp((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(log(exp(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(log(exp((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Log[N[Exp[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\log \left(e^{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}\right)}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
Taylor expanded in phi1 around 0 47.1%
+-commutative47.1%
associate--r+47.2%
unpow247.2%
1-sub-sin47.2%
unpow247.2%
*-commutative47.2%
Simplified47.2%
Taylor expanded in phi2 around 0 33.4%
sub-neg33.4%
mul-1-neg33.4%
distribute-lft-in33.4%
metadata-eval33.4%
associate-*r*33.4%
associate-*r*33.4%
metadata-eval33.4%
distribute-lft-in33.4%
+-commutative33.4%
mul-1-neg33.4%
sub-neg33.4%
Simplified33.4%
add-log-exp33.4%
Applied egg-rr33.4%
Final simplification33.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
Taylor expanded in phi1 around 0 47.1%
+-commutative47.1%
associate--r+47.2%
unpow247.2%
1-sub-sin47.2%
unpow247.2%
*-commutative47.2%
Simplified47.2%
Taylor expanded in phi2 around 0 33.4%
sub-neg33.4%
mul-1-neg33.4%
distribute-lft-in33.4%
metadata-eval33.4%
associate-*r*33.4%
associate-*r*33.4%
metadata-eval33.4%
distribute-lft-in33.4%
+-commutative33.4%
mul-1-neg33.4%
sub-neg33.4%
Simplified33.4%
Final simplification33.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (/ (+ (cos (- lambda1 lambda2)) -1.0) -2.0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) + -1.0) / -2.0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) + (-1.0d0)) / (-2.0d0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((lambda1 - lambda2)) + -1.0) / -2.0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * ((math.cos((lambda1 - lambda2)) + -1.0) / -2.0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / -2.0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) + -1.0) / -2.0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{-2} + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
Taylor expanded in phi1 around 0 47.1%
+-commutative47.1%
associate--r+47.2%
unpow247.2%
1-sub-sin47.2%
unpow247.2%
*-commutative47.2%
Simplified47.2%
Taylor expanded in phi2 around 0 33.4%
sub-neg33.4%
mul-1-neg33.4%
distribute-lft-in33.4%
metadata-eval33.4%
associate-*r*33.4%
associate-*r*33.4%
metadata-eval33.4%
distribute-lft-in33.4%
+-commutative33.4%
mul-1-neg33.4%
sub-neg33.4%
Simplified33.4%
sin-mult31.8%
frac-2neg31.8%
Applied egg-rr31.8%
neg-sub031.8%
cos-031.8%
associate--r-31.8%
metadata-eval31.8%
Simplified31.8%
Final simplification31.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (/ (+ (cos (- lambda1 lambda2)) -1.0) -2.0))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) + -1.0) / -2.0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) + (-1.0d0)) / (-2.0d0))) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((lambda1 - lambda2)) + -1.0) / -2.0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * ((math.cos((lambda1 - lambda2)) + -1.0) / -2.0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(lambda1 - lambda2)) + -1.0) / -2.0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) + -1.0) / -2.0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / -2.0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \frac{\cos \left(\lambda_1 - \lambda_2\right) + -1}{-2} + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
Initial program 60.2%
associate-*l*60.2%
Simplified60.2%
Taylor expanded in phi1 around 0 47.1%
+-commutative47.1%
associate--r+47.2%
unpow247.2%
1-sub-sin47.2%
unpow247.2%
*-commutative47.2%
Simplified47.2%
Taylor expanded in phi2 around 0 33.4%
sub-neg33.4%
mul-1-neg33.4%
distribute-lft-in33.4%
metadata-eval33.4%
associate-*r*33.4%
associate-*r*33.4%
metadata-eval33.4%
distribute-lft-in33.4%
+-commutative33.4%
mul-1-neg33.4%
sub-neg33.4%
Simplified33.4%
sin-mult31.8%
frac-2neg31.8%
Applied egg-rr31.8%
neg-sub031.8%
cos-031.8%
associate--r-31.8%
metadata-eval31.8%
Simplified31.8%
unpow231.8%
sin-mult28.8%
div-inv28.8%
metadata-eval28.8%
div-inv28.8%
metadata-eval28.8%
div-inv28.8%
metadata-eval28.8%
div-inv28.8%
metadata-eval28.8%
Applied egg-rr28.8%
div-sub28.8%
+-inverses28.8%
cos-028.8%
metadata-eval28.8%
distribute-lft-out28.8%
metadata-eval28.8%
*-rgt-identity28.8%
Simplified28.8%
Final simplification28.8%
herbie shell --seed 2024019
(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))))))))))