
(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 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* (* (cos phi1) (log (exp (cos phi2)))) t_0))))
(sqrt (- 1.0 (+ t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * ((cos(phi1) * log(exp(cos(phi2)))) * t_0)))), sqrt((1.0 - (t_1 + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * ((cos(phi1) * log(exp(cos(phi2)))) * t_0)))), sqrt((1.0d0 - (t_1 + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * ((Math.cos(phi1) * Math.log(Math.exp(Math.cos(phi2)))) * t_0)))), Math.sqrt((1.0 - (t_1 + (t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * ((math.cos(phi1) * math.log(math.exp(math.cos(phi2)))) * t_0)))), math.sqrt((1.0 - (t_1 + (t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(Float64(cos(phi1) * log(exp(cos(phi2)))) * t_0)))), sqrt(Float64(1.0 - Float64(t_1 + Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * ((cos(phi1) * log(exp(cos(phi2)))) * t_0)))), sqrt((1.0 - (t_1 + (t_0 * (t_0 * (cos(phi1) * cos(phi2))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Log[N[Exp[N[Cos[phi2], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \log \left(e^{\cos \phi_2}\right)\right) \cdot t\_0\right)}}{\sqrt{1 - \left(t\_1 + t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 58.5%
div-sub58.5%
sin-diff59.9%
Applied egg-rr59.9%
div-sub58.5%
sin-diff59.9%
Applied egg-rr76.5%
add-log-exp76.5%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1)))
(if (<= (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) 0.002)
(*
R
(*
2.0
(atan2
(sqrt t_2)
(sqrt
(+
1.0
(-
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))
(pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1;
double tmp;
if ((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0)) <= 0.002) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_1
if ((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) <= 0.002d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)) - (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1;
double tmp;
if ((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) <= 0.002) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 + ((Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_1 tmp = 0 if (t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) <= 0.002: tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 + ((math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1) tmp = 0.0 if (Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) <= 0.002) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 + Float64(Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)) - (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_1; tmp = 0.0; if ((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) <= 0.002) tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]}, If[LessEqual[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 0.002], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(phi2 * -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[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1\\
\mathbf{if}\;t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} \leq 0.002:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 + \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right) - {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 2e-3Initial program 52.0%
div-sub52.0%
sin-diff59.3%
Applied egg-rr59.3%
Taylor expanded in phi1 around 0 60.0%
unpow260.0%
sin-mult60.0%
Applied egg-rr60.0%
div-sub60.0%
+-inverses60.0%
+-inverses60.0%
+-inverses60.0%
cos-060.0%
metadata-eval60.0%
distribute-rgt-out60.0%
metadata-eval60.0%
*-rgt-identity60.0%
Simplified60.0%
if 2e-3 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 59.6%
div-sub59.6%
sin-diff60.1%
Applied egg-rr60.1%
div-sub59.6%
sin-diff60.1%
Applied egg-rr75.4%
sin-diff60.1%
div-sub60.1%
unpow260.1%
sin-mult60.1%
Applied egg-rr60.5%
div-sub60.1%
+-inverses60.1%
+-inverses60.1%
+-inverses60.1%
+-inverses48.3%
+-inverses60.1%
cos-060.1%
metadata-eval60.1%
distribute-lft-out60.1%
metadata-eval60.1%
*-rgt-identity60.1%
Simplified60.5%
Final simplification60.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* t_1 (* (cos phi1) (cos phi2))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_2
(pow
(- (expm1 (log1p (* (cos (* phi2 0.5)) (sin (* phi1 0.5))))) t_0)
2.0)))
(sqrt
(-
1.0
(+
(pow (- (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0))) t_0) 2.0)
t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 / 2.0)) * sin((phi2 / 2.0));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * (t_1 * (cos(phi1) * cos(phi2)));
return R * (2.0 * atan2(sqrt((t_2 + pow((expm1(log1p((cos((phi2 * 0.5)) * sin((phi1 * 0.5))))) - t_0), 2.0))), sqrt((1.0 - (pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - t_0), 2.0) + t_2)))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * (t_1 * (Math.cos(phi1) * Math.cos(phi2)));
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((Math.expm1(Math.log1p((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))))) - t_0), 2.0))), Math.sqrt((1.0 - (Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - t_0), 2.0) + t_2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_1 * (t_1 * (math.cos(phi1) * math.cos(phi2))) return R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((math.expm1(math.log1p((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))))) - t_0), 2.0))), math.sqrt((1.0 - (math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - t_0), 2.0) + t_2)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * Float64(t_1 * Float64(cos(phi1) * cos(phi2)))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(expm1(log1p(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))))) - t_0) ^ 2.0))), sqrt(Float64(1.0 - Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - t_0) ^ 2.0) + t_2)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(N[(Exp[N[Log[1 + N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] - t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot \left(t\_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\right)\right) - t\_0\right)}^{2}}}{\sqrt{1 - \left({\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - t\_0\right)}^{2} + t\_2\right)}}\right)
\end{array}
\end{array}
Initial program 58.5%
div-sub58.5%
sin-diff59.9%
Applied egg-rr59.9%
div-sub58.5%
sin-diff59.9%
Applied egg-rr76.5%
expm1-log1p-u76.5%
div-inv76.5%
metadata-eval76.5%
div-inv76.5%
metadata-eval76.5%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_0 (* (cos phi1) (cos phi2)))))))
(* 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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))));
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 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))))
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 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2))));
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 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2))))) 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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))); 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[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 58.5%
div-sub58.5%
sin-diff59.9%
Applied egg-rr59.9%
div-sub58.5%
sin-diff59.9%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(*
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0))))
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))) + pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = (cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))) + (((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
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) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) + Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) + math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) return R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) + (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))) + (((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0); tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right) + {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 58.5%
div-sub58.5%
sin-diff59.9%
Applied egg-rr59.9%
div-sub58.5%
sin-diff59.9%
Applied egg-rr76.5%
add-log-exp76.5%
Applied egg-rr76.5%
Taylor expanded in phi1 around 0 76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2 (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (- (sin (* phi1 0.5)) t_2) 2.0)))
(sqrt
(-
1.0
(+
(pow (- (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0))) t_2) 2.0)
t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = cos((phi1 / 2.0)) * sin((phi2 / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + pow((sin((phi1 * 0.5)) - t_2), 2.0))), sqrt((1.0 - (pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - t_2), 2.0) + t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + ((sin((phi1 * 0.5d0)) - t_2) ** 2.0d0))), sqrt((1.0d0 - ((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - t_2) ** 2.0d0) + t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow((Math.sin((phi1 * 0.5)) - t_2), 2.0))), Math.sqrt((1.0 - (Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - t_2), 2.0) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow((math.sin((phi1 * 0.5)) - t_2), 2.0))), math.sqrt((1.0 - (math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - t_2), 2.0) + t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (Float64(sin(Float64(phi1 * 0.5)) - t_2) ^ 2.0))), sqrt(Float64(1.0 - Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - t_2) ^ 2.0) + t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = cos((phi1 / 2.0)) * sin((phi2 / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + ((sin((phi1 * 0.5)) - t_2) ^ 2.0))), sqrt((1.0 - ((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - t_2) ^ 2.0) + t_1))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] - t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\left(\sin \left(\phi_1 \cdot 0.5\right) - t\_2\right)}^{2}}}{\sqrt{1 - \left({\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - t\_2\right)}^{2} + t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 58.5%
div-sub58.5%
sin-diff59.9%
Applied egg-rr59.9%
div-sub58.5%
sin-diff59.9%
Applied egg-rr76.5%
Taylor expanded in phi2 around 0 60.6%
Final simplification60.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt (+ 1.0 (- (- (/ (cos (- phi1 phi2)) 2.0) 0.5) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_1)), sqrt((1.0d0 + (((cos((phi1 - phi2)) / 2.0d0) - 0.5d0) - t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1)), Math.sqrt((1.0 + (((Math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_1)), math.sqrt((1.0 + (((math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5) - t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - 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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1}}{\sqrt{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 58.5%
div-sub58.5%
sin-diff59.9%
Applied egg-rr59.9%
div-sub58.5%
sin-diff59.9%
Applied egg-rr76.5%
sin-diff59.9%
div-sub59.9%
unpow259.9%
sin-mult60.0%
Applied egg-rr60.0%
div-sub60.0%
+-inverses60.0%
+-inverses60.0%
+-inverses60.0%
+-inverses49.9%
+-inverses60.0%
cos-060.0%
metadata-eval60.0%
distribute-lft-out60.0%
metadata-eval60.0%
*-rgt-identity60.0%
Simplified60.0%
Final simplification60.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (+ 1.0 (- (- (/ (cos (- phi1 phi2)) 2.0) 0.5) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 + (((cos((phi1 - phi2)) / 2.0d0) - 0.5d0) - t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 + (((Math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 + (((math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5) - t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - 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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 58.5%
unpow258.5%
sin-mult58.6%
div-inv58.6%
metadata-eval58.6%
div-inv58.6%
metadata-eval58.6%
div-inv58.6%
metadata-eval58.6%
div-inv58.6%
metadata-eval58.6%
Applied egg-rr58.6%
div-sub58.6%
+-inverses58.6%
cos-058.6%
metadata-eval58.6%
distribute-lft-out58.6%
metadata-eval58.6%
*-rgt-identity58.6%
Simplified58.6%
Final simplification58.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -4.4e+21) (not (<= phi2 8.5e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(+
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* t_1 (* (cos phi1) (cos phi2))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -4.4e+21) || !(phi2 <= 8.5e-5)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_1 * (cos(phi1) * cos(phi2)))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-4.4d+21)) .or. (.not. (phi2 <= 8.5d-5))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_1 * (cos(phi1) * cos(phi2)))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -4.4e+21) || !(phi2 <= 8.5e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_1 * (Math.cos(phi1) * Math.cos(phi2)))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -4.4e+21) or not (phi2 <= 8.5e-5): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) + (math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_1 * (math.cos(phi1) * math.cos(phi2)))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -4.4e+21) || !(phi2 <= 8.5e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_1 * Float64(cos(phi1) * cos(phi2)))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -4.4e+21) || ~((phi2 <= 8.5e-5))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_1 * (cos(phi1) * cos(phi2)))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.4e+21], N[Not[LessEqual[phi2, 8.5e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{+21} \lor \neg \left(\phi_2 \leq 8.5 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_0}}\right)\\
\end{array}
\end{array}
if phi2 < -4.4e21 or 8.500000000000001e-5 < phi2 Initial program 41.7%
Taylor expanded in phi1 around 0 42.4%
+-commutative42.4%
associate--r+42.4%
unpow242.4%
1-sub-sin42.5%
unpow242.5%
Simplified42.5%
Taylor expanded in phi1 around 0 44.1%
unpow244.8%
sin-mult44.8%
Applied egg-rr44.1%
div-sub44.8%
+-inverses44.8%
+-inverses44.8%
+-inverses44.8%
cos-044.8%
metadata-eval44.8%
distribute-rgt-out44.8%
metadata-eval44.8%
*-rgt-identity44.8%
Simplified44.1%
if -4.4e21 < phi2 < 8.500000000000001e-5Initial program 78.6%
Taylor expanded in phi2 around 0 78.6%
+-commutative78.6%
associate--r+78.6%
unpow278.6%
1-sub-sin78.8%
unpow278.8%
*-commutative78.8%
Simplified78.8%
Final simplification59.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- lambda1 lambda2) 0.5))) (t_1 (pow t_0 2.0)))
(if (or (<= phi2 -1.65e-10) (not (<= phi2 2.1e-7)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(+
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))
(*
(* R 2.0)
(atan2
(hypot
(sin (* 0.5 (- phi1 phi2)))
(* t_0 (sqrt (* (cos phi1) (cos phi2)))))
(sqrt (- 1.0 (fma (cos phi1) t_1 (pow (sin (* phi1 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
double t_1 = pow(t_0, 2.0);
double tmp;
if ((phi2 <= -1.65e-10) || !(phi2 <= 2.1e-7)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = (R * 2.0) * atan2(hypot(sin((0.5 * (phi1 - phi2))), (t_0 * sqrt((cos(phi1) * cos(phi2))))), sqrt((1.0 - fma(cos(phi1), t_1, pow(sin((phi1 * 0.5)), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) t_1 = t_0 ^ 2.0 tmp = 0.0 if ((phi2 <= -1.65e-10) || !(phi2 <= 2.1e-7)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))); else tmp = Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(0.5 * Float64(phi1 - phi2))), Float64(t_0 * sqrt(Float64(cos(phi1) * cos(phi2))))), sqrt(Float64(1.0 - fma(cos(phi1), t_1, (sin(Float64(phi1 * 0.5)) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -1.65e-10], N[Not[LessEqual[phi2, 2.1e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + N[(t$95$0 * N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
t_1 := {t\_0}^{2}\\
\mathbf{if}\;\phi_2 \leq -1.65 \cdot 10^{-10} \lor \neg \left(\phi_2 \leq 2.1 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), t\_0 \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, t\_1, {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\\
\end{array}
\end{array}
if phi2 < -1.65e-10 or 2.1e-7 < phi2 Initial program 41.7%
Taylor expanded in phi1 around 0 42.1%
+-commutative42.1%
associate--r+42.1%
unpow242.1%
1-sub-sin42.2%
unpow242.2%
Simplified42.2%
Taylor expanded in phi1 around 0 43.7%
unpow244.4%
sin-mult44.5%
Applied egg-rr43.7%
div-sub44.5%
+-inverses44.5%
+-inverses44.5%
+-inverses44.5%
cos-044.5%
metadata-eval44.5%
distribute-rgt-out44.5%
metadata-eval44.5%
*-rgt-identity44.5%
Simplified43.7%
if -1.65e-10 < phi2 < 2.1e-7Initial program 79.1%
Simplified79.1%
Applied egg-rr43.5%
pow143.5%
Applied egg-rr56.4%
Simplified56.4%
Taylor expanded in phi2 around 0 56.4%
fma-define56.4%
unpow256.4%
sqr-neg56.4%
sin-neg56.4%
distribute-lft-neg-in56.4%
metadata-eval56.4%
sin-neg56.4%
distribute-lft-neg-in56.4%
metadata-eval56.4%
unpow256.4%
Simplified56.4%
Final simplification49.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- lambda1 lambda2) 0.5))) (t_1 (pow t_0 2.0)))
(if (or (<= phi2 -3.2e-10) (not (<= phi2 1.15e-7)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(+
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))
(*
(* R 2.0)
(atan2
(hypot
(sin (* 0.5 (- phi1 phi2)))
(* t_0 (sqrt (* (cos phi1) (cos phi2)))))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 -0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
double t_1 = pow(t_0, 2.0);
double tmp;
if ((phi2 <= -3.2e-10) || !(phi2 <= 1.15e-7)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = (R * 2.0) * atan2(hypot(sin((0.5 * (phi1 - phi2))), (t_0 * sqrt((cos(phi1) * cos(phi2))))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * -0.5)), 2.0)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) * 0.5));
double t_1 = Math.pow(t_0, 2.0);
double tmp;
if ((phi2 <= -3.2e-10) || !(phi2 <= 1.15e-7)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * 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.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = (R * 2.0) * Math.atan2(Math.hypot(Math.sin((0.5 * (phi1 - phi2))), (t_0 * Math.sqrt((Math.cos(phi1) * Math.cos(phi2))))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * -0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) * 0.5)) t_1 = math.pow(t_0, 2.0) tmp = 0 if (phi2 <= -3.2e-10) or not (phi2 <= 1.15e-7): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * 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.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) else: tmp = (R * 2.0) * math.atan2(math.hypot(math.sin((0.5 * (phi1 - phi2))), (t_0 * math.sqrt((math.cos(phi1) * math.cos(phi2))))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * -0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) t_1 = t_0 ^ 2.0 tmp = 0.0 if ((phi2 <= -3.2e-10) || !(phi2 <= 1.15e-7)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))); else tmp = Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(0.5 * Float64(phi1 - phi2))), Float64(t_0 * sqrt(Float64(cos(phi1) * cos(phi2))))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * -0.5)) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)); t_1 = t_0 ^ 2.0; tmp = 0.0; if ((phi2 <= -3.2e-10) || ~((phi2 <= 1.15e-7))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); else tmp = (R * 2.0) * atan2(hypot(sin((0.5 * (phi1 - phi2))), (t_0 * sqrt((cos(phi1) * cos(phi2))))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * -0.5)) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -3.2e-10], N[Not[LessEqual[phi2, 1.15e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + N[(t$95$0 * N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
t_1 := {t\_0}^{2}\\
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{-10} \lor \neg \left(\phi_2 \leq 1.15 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), t\_0 \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot -0.5\right)}^{2}\right)}}\\
\end{array}
\end{array}
if phi2 < -3.19999999999999981e-10 or 1.14999999999999997e-7 < phi2 Initial program 41.7%
Taylor expanded in phi1 around 0 42.1%
+-commutative42.1%
associate--r+42.1%
unpow242.1%
1-sub-sin42.2%
unpow242.2%
Simplified42.2%
Taylor expanded in phi1 around 0 43.7%
unpow244.4%
sin-mult44.5%
Applied egg-rr43.7%
div-sub44.5%
+-inverses44.5%
+-inverses44.5%
+-inverses44.5%
cos-044.5%
metadata-eval44.5%
distribute-rgt-out44.5%
metadata-eval44.5%
*-rgt-identity44.5%
Simplified43.7%
if -3.19999999999999981e-10 < phi2 < 1.14999999999999997e-7Initial program 79.1%
Simplified79.1%
Applied egg-rr43.5%
pow143.5%
Applied egg-rr56.4%
Simplified56.4%
Taylor expanded in phi2 around 0 56.4%
Final simplification49.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))))
(if (or (<= (- lambda1 lambda2) -1e+22)
(not (<= (- lambda1 lambda2) 1e-10)))
(* R (* 2.0 (atan2 t_1 (sqrt (- 1.0 t_0)))))
(* R (* 2.0 (atan2 t_1 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0)));
double tmp;
if (((lambda1 - lambda2) <= -1e+22) || !((lambda1 - lambda2) <= 1e-10)) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sqrt(((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0)))
if (((lambda1 - lambda2) <= (-1d+22)) .or. (.not. ((lambda1 - lambda2) <= 1d-10))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - t_0))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0)));
double tmp;
if (((lambda1 - lambda2) <= -1e+22) || !((lambda1 - lambda2) <= 1e-10)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))) tmp = 0 if ((lambda1 - lambda2) <= -1e+22) or not ((lambda1 - lambda2) <= 1e-10): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - t_0)))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -1e+22) || !(Float64(lambda1 - lambda2) <= 1e-10)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sqrt(((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0))); tmp = 0.0; if (((lambda1 - lambda2) <= -1e+22) || ~(((lambda1 - lambda2) <= 1e-10))) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - t_0)))); else tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+22], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 1e-10]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+22} \lor \neg \left(\lambda_1 - \lambda_2 \leq 10^{-10}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t\_0}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1e22 or 1.00000000000000004e-10 < (-.f64 lambda1 lambda2) Initial program 51.3%
Taylor expanded in phi1 around 0 39.3%
+-commutative39.3%
associate--r+39.3%
unpow239.3%
1-sub-sin39.3%
unpow239.3%
Simplified39.3%
Taylor expanded in phi1 around 0 39.8%
Taylor expanded in phi2 around 0 29.7%
if -1e22 < (-.f64 lambda1 lambda2) < 1.00000000000000004e-10Initial program 78.4%
Taylor expanded in phi1 around 0 59.0%
+-commutative59.0%
associate--r+59.0%
unpow259.0%
1-sub-sin59.2%
unpow259.2%
Simplified59.2%
Taylor expanded in phi1 around 0 48.0%
Taylor expanded in phi2 around 0 46.4%
Final simplification34.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(+
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt(((cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
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(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) + (math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[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[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
Initial program 58.5%
Taylor expanded in phi1 around 0 44.5%
+-commutative44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in phi1 around 0 42.0%
unpow245.8%
sin-mult45.8%
Applied egg-rr42.0%
div-sub45.8%
+-inverses45.8%
+-inverses43.1%
+-inverses45.8%
cos-045.8%
metadata-eval45.8%
distribute-rgt-out45.8%
metadata-eval45.8%
*-rgt-identity45.8%
Simplified42.0%
Final simplification42.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 58.5%
Taylor expanded in phi1 around 0 44.5%
+-commutative44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in phi1 around 0 42.0%
unpow245.8%
sin-mult45.8%
Applied egg-rr39.6%
div-sub45.8%
+-inverses45.8%
+-inverses43.1%
+-inverses45.8%
cos-045.8%
metadata-eval45.8%
distribute-rgt-out45.8%
metadata-eval45.8%
*-rgt-identity45.8%
Simplified39.6%
Final simplification39.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((t_0 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_0 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_0}}\right)
\end{array}
\end{array}
Initial program 58.5%
Taylor expanded in phi1 around 0 44.5%
+-commutative44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in phi1 around 0 42.0%
Taylor expanded in phi2 around 0 34.0%
Final simplification34.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - t_0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 58.5%
Taylor expanded in phi1 around 0 44.5%
+-commutative44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in phi1 around 0 42.0%
Taylor expanded in phi2 around 0 29.8%
Final simplification29.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* (- lambda1 lambda2) 0.5))
(sqrt
(+
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt((pow(cos((phi2 * -0.5)), 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin(((lambda1 - lambda2) * 0.5d0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin(((lambda1 - lambda2) * 0.5)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin(((lambda1 - lambda2) * 0.5)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) + (math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(Float64(lambda1 - lambda2) * 0.5)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
Initial program 58.5%
Taylor expanded in phi1 around 0 44.5%
+-commutative44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in phi1 around 0 42.0%
Taylor expanded in phi2 around 0 16.0%
unpow245.8%
sin-mult45.8%
Applied egg-rr16.0%
div-sub45.8%
+-inverses45.8%
+-inverses43.1%
+-inverses45.8%
cos-045.8%
metadata-eval45.8%
distribute-rgt-out45.8%
metadata-eval45.8%
*-rgt-identity45.8%
Simplified16.0%
Final simplification16.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- lambda1 lambda2) 0.5))))
(*
R
(*
2.0
(atan2
t_0
(sqrt (- (/ (+ (cos phi2) 1.0) 2.0) (* (cos phi2) (pow t_0 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
return R * (2.0 * atan2(t_0, sqrt((((cos(phi2) + 1.0) / 2.0) - (cos(phi2) * pow(t_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
t_0 = sin(((lambda1 - lambda2) * 0.5d0))
code = r * (2.0d0 * atan2(t_0, sqrt((((cos(phi2) + 1.0d0) / 2.0d0) - (cos(phi2) * (t_0 ** 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) * 0.5));
return R * (2.0 * Math.atan2(t_0, Math.sqrt((((Math.cos(phi2) + 1.0) / 2.0) - (Math.cos(phi2) * Math.pow(t_0, 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) * 0.5)) return R * (2.0 * math.atan2(t_0, math.sqrt((((math.cos(phi2) + 1.0) / 2.0) - (math.cos(phi2) * math.pow(t_0, 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(Float64(Float64(cos(phi2) + 1.0) / 2.0) - Float64(cos(phi2) * (t_0 ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)); tmp = R * (2.0 * atan2(t_0, sqrt((((cos(phi2) + 1.0) / 2.0) - (cos(phi2) * (t_0 ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(N[(N[(N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{\frac{\cos \phi_2 + 1}{2} - \cos \phi_2 \cdot {t\_0}^{2}}}\right)
\end{array}
\end{array}
Initial program 58.5%
Taylor expanded in phi1 around 0 44.5%
+-commutative44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in phi1 around 0 42.0%
Taylor expanded in phi2 around 0 16.0%
unpow216.0%
cos-mult16.0%
*-commutative16.0%
*-commutative16.0%
*-commutative16.0%
*-commutative16.0%
Applied egg-rr16.0%
distribute-lft-out16.0%
metadata-eval16.0%
*-commutative16.0%
mul-1-neg16.0%
cos-neg16.0%
+-inverses16.0%
cos-016.0%
Simplified16.0%
Final simplification16.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (sin (* (- lambda1 lambda2) 0.5)))) (* R (* 2.0 (atan2 t_0 (sqrt (- 1.0 (* (cos phi2) (pow t_0 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
return R * (2.0 * atan2(t_0, sqrt((1.0 - (cos(phi2) * pow(t_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
t_0 = sin(((lambda1 - lambda2) * 0.5d0))
code = r * (2.0d0 * atan2(t_0, sqrt((1.0d0 - (cos(phi2) * (t_0 ** 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) * 0.5));
return R * (2.0 * Math.atan2(t_0, Math.sqrt((1.0 - (Math.cos(phi2) * Math.pow(t_0, 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) * 0.5)) return R * (2.0 * math.atan2(t_0, math.sqrt((1.0 - (math.cos(phi2) * math.pow(t_0, 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(1.0 - Float64(cos(phi2) * (t_0 ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)); tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - (cos(phi2) * (t_0 ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{1 - \cos \phi_2 \cdot {t\_0}^{2}}}\right)
\end{array}
\end{array}
Initial program 58.5%
Taylor expanded in phi1 around 0 44.5%
+-commutative44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in phi1 around 0 42.0%
Taylor expanded in phi2 around 0 16.0%
Taylor expanded in phi2 around 0 15.8%
Final simplification15.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (sin (* (- lambda1 lambda2) 0.5)))) (* R (* 2.0 (atan2 t_0 (sqrt (- 1.0 (pow t_0 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
return R * (2.0 * atan2(t_0, sqrt((1.0 - pow(t_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
t_0 = sin(((lambda1 - lambda2) * 0.5d0))
code = r * (2.0d0 * atan2(t_0, sqrt((1.0d0 - (t_0 ** 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) * 0.5));
return R * (2.0 * Math.atan2(t_0, Math.sqrt((1.0 - Math.pow(t_0, 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) * 0.5)) return R * (2.0 * math.atan2(t_0, math.sqrt((1.0 - math.pow(t_0, 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(1.0 - (t_0 ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)); tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - (t_0 ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{1 - {t\_0}^{2}}}\right)
\end{array}
\end{array}
Initial program 58.5%
Taylor expanded in phi1 around 0 44.5%
+-commutative44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.6%
unpow244.6%
Simplified44.6%
Taylor expanded in phi1 around 0 42.0%
Taylor expanded in phi2 around 0 16.0%
Taylor expanded in phi2 around 0 15.8%
Final simplification15.8%
herbie shell --seed 2024158
(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))))))))))