
(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 30 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 (fma (cos phi1) (* (cos phi2) (* t_0 t_0)) t_1))
(sqrt
(-
1.0
(fma
(cos phi1)
(*
(cos phi2)
(-
0.5
(/
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2)))
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 = 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(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), t_1)), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 - (((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0))), t_1)))));
}
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(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), t_1)), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))) / 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[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[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $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 := {\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{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), t_1\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - \frac{\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2}{2}\right), t_1\right)}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
div-sub62.5%
sin-diff63.4%
Applied egg-rr63.4%
div-sub62.5%
sin-diff63.4%
Applied egg-rr79.0%
sin-mult79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
+-inverses79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
Simplified79.1%
cos-diff79.7%
Applied egg-rr79.7%
Final simplification79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (/ phi1 2.0)))
(t_2 (cos (/ phi1 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (* t_0 t_0))
(pow (- (* t_1 (cos (/ phi2 2.0))) (* t_2 (sin (/ phi2 2.0)))) 2.0)))
(sqrt
(-
1.0
(fma
(* (cos phi2) (+ 0.5 (* (cos (- lambda1 lambda2)) -0.5)))
(cos phi1)
(pow
(fma (cos (* phi2 0.5)) t_1 (* (sin (* phi2 0.5)) (- t_2)))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sin((phi1 / 2.0));
double t_2 = cos((phi1 / 2.0));
return R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow(((t_1 * cos((phi2 / 2.0))) - (t_2 * sin((phi2 / 2.0)))), 2.0))), sqrt((1.0 - fma((cos(phi2) * (0.5 + (cos((lambda1 - lambda2)) * -0.5))), cos(phi1), pow(fma(cos((phi2 * 0.5)), t_1, (sin((phi2 * 0.5)) * -t_2)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(phi1 / 2.0)) t_2 = cos(Float64(phi1 / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(Float64(t_1 * cos(Float64(phi2 / 2.0))) - Float64(t_2 * sin(Float64(phi2 / 2.0)))) ^ 2.0))), sqrt(Float64(1.0 - fma(Float64(cos(phi2) * Float64(0.5 + Float64(cos(Float64(lambda1 - lambda2)) * -0.5))), cos(phi1), (fma(cos(Float64(phi2 * 0.5)), t_1, Float64(sin(Float64(phi2 * 0.5)) * Float64(-t_2))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(t$95$1 * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$1 + N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * (-t$95$2)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sin \left(\frac{\phi_1}{2}\right)\\
t_2 := \cos \left(\frac{\phi_1}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\left(t_1 \cdot \cos \left(\frac{\phi_2}{2}\right) - t_2 \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2 \cdot \left(0.5 + \cos \left(\lambda_1 - \lambda_2\right) \cdot -0.5\right), \cos \phi_1, {\left(\mathsf{fma}\left(\cos \left(\phi_2 \cdot 0.5\right), t_1, \sin \left(\phi_2 \cdot 0.5\right) \cdot \left(-t_2\right)\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
div-sub62.5%
sin-diff63.4%
Applied egg-rr63.4%
div-sub62.5%
sin-diff63.4%
Applied egg-rr79.0%
sin-mult79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
+-inverses79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
Simplified79.1%
sub-neg79.1%
div-inv79.1%
metadata-eval79.1%
Applied egg-rr79.1%
Simplified79.1%
Final simplification79.1%
(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_2 (sqrt (fma (cos phi1) (* (cos phi2) (* t_0 t_0)) t_1))))
(if (<= lambda1 -1.05)
(*
R
(*
2.0
(atan2
t_2
(sqrt
(+
1.0
(-
(* (cos phi1) (* (cos phi2) (- (* 0.5 (cos lambda1)) 0.5)))
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (/ (cos lambda2) 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 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), t_1));
double tmp;
if (lambda1 <= -1.05) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 + ((cos(phi1) * (cos(phi2) * ((0.5 * cos(lambda1)) - 0.5))) - pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 - (cos(lambda2) / 2.0))), t_1)))));
}
return tmp;
}
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 t_2 = sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), t_1)) tmp = 0.0 if (lambda1 <= -1.05) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(0.5 * cos(lambda1)) - 0.5))) - (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(cos(lambda2) / 2.0))), t_1)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.05], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] - 0.5), $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[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(N[Cos[lambda2], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), t_1\right)}\\
\mathbf{if}\;\lambda_1 \leq -1.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \lambda_1 - 0.5\right)\right) - {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - \frac{\cos \lambda_2}{2}\right), t_1\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.05000000000000004Initial program 47.6%
Simplified47.5%
div-sub47.5%
sin-diff48.6%
Applied egg-rr48.6%
div-sub47.5%
sin-diff48.6%
Applied egg-rr64.9%
sin-mult65.0%
Applied egg-rr65.0%
div-sub65.0%
+-inverses65.0%
+-inverses65.0%
+-inverses65.0%
cos-065.0%
metadata-eval65.0%
Simplified65.0%
Taylor expanded in lambda2 around 0 65.1%
if -1.05000000000000004 < lambda1 Initial program 67.3%
Simplified67.3%
div-sub67.3%
sin-diff68.1%
Applied egg-rr68.1%
div-sub67.3%
sin-diff68.1%
Applied egg-rr83.5%
sin-mult83.6%
Applied egg-rr83.6%
div-sub83.6%
+-inverses83.6%
+-inverses83.6%
+-inverses83.6%
cos-083.6%
metadata-eval83.6%
Simplified83.6%
Taylor expanded in lambda1 around 0 71.7%
cos-neg71.7%
Simplified71.7%
Final simplification70.1%
(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 (fma (cos phi1) (* (cos phi2) (* t_0 t_0)) t_1))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (/ (cos (- lambda1 lambda2)) 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 = 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(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), t_1)), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))), t_1)))));
}
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(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), t_1)), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 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[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[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $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 := {\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{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), t_1\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right), t_1\right)}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
div-sub62.5%
sin-diff63.4%
Applied egg-rr63.4%
div-sub62.5%
sin-diff63.4%
Applied egg-rr79.0%
sin-mult79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
+-inverses79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
Simplified79.1%
Final simplification79.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(fma
(cos phi1)
(* (cos phi2) (* t_0 t_0))
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))))
(t_2
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))
(if (<= lambda1 -1.05)
(*
R
(*
2.0
(atan2
t_1
(sqrt
(+
1.0
(-
(* (cos phi1) (* (cos phi2) (- (* 0.5 (cos lambda1)) 0.5)))
t_2))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(+
1.0
(-
(* (cos phi1) (* (cos phi2) (- (* 0.5 (cos (- lambda2))) 0.5)))
t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)));
double t_2 = pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0);
double tmp;
if (lambda1 <= -1.05) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 + ((cos(phi1) * (cos(phi2) * ((0.5 * cos(lambda1)) - 0.5))) - t_2)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 + ((cos(phi1) * (cos(phi2) * ((0.5 * cos(-lambda2)) - 0.5))) - t_2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0))) t_2 = Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 tmp = 0.0 if (lambda1 <= -1.05) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(0.5 * cos(lambda1)) - 0.5))) - t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(0.5 * cos(Float64(-lambda2))) - 0.5))) - t_2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda1, -1.05], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right)}\\
t_2 := {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -1.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \lambda_1 - 0.5\right)\right) - t_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \left(-\lambda_2\right) - 0.5\right)\right) - t_2\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.05000000000000004Initial program 47.6%
Simplified47.5%
div-sub47.5%
sin-diff48.6%
Applied egg-rr48.6%
div-sub47.5%
sin-diff48.6%
Applied egg-rr64.9%
sin-mult65.0%
Applied egg-rr65.0%
div-sub65.0%
+-inverses65.0%
+-inverses65.0%
+-inverses65.0%
cos-065.0%
metadata-eval65.0%
Simplified65.0%
Taylor expanded in lambda2 around 0 65.1%
if -1.05000000000000004 < lambda1 Initial program 67.3%
Simplified67.3%
div-sub67.3%
sin-diff68.1%
Applied egg-rr68.1%
div-sub67.3%
sin-diff68.1%
Applied egg-rr83.5%
sin-mult83.6%
Applied egg-rr83.6%
div-sub83.6%
+-inverses83.6%
+-inverses83.6%
+-inverses83.6%
cos-083.6%
metadata-eval83.6%
Simplified83.6%
Taylor expanded in lambda1 around 0 71.7%
Final simplification70.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (cos phi2) (* (cos phi1) t_0)))))
(if (<= lambda2 0.0048)
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (* t_0 t_0))
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(sqrt
(+
1.0
(-
(* (cos phi1) (* (cos phi2) (- (* 0.5 (cos lambda1)) 0.5)))
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(-
0.5
(/ (+ (* (cos phi1) (cos phi2)) (* (sin phi1) (sin phi2))) 2.0))
t_1))
(sqrt (- 1.0 (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0));
double tmp;
if (lambda2 <= 0.0048) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0))), sqrt((1.0 + ((cos(phi1) * (cos(phi2) * ((0.5 * cos(lambda1)) - 0.5))) - pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((0.5 - (((cos(phi1) * cos(phi2)) + (sin(phi1) * sin(phi2))) / 2.0)) + t_1)), sqrt((1.0 - (t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) tmp = 0.0 if (lambda2 <= 0.0048) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(0.5 * cos(lambda1)) - 0.5))) - (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(Float64(Float64(cos(phi1) * cos(phi2)) + Float64(sin(phi1) * sin(phi2))) / 2.0)) + t_1)), sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); end return 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[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 0.0048], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] - 0.5), $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[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\\
\mathbf{if}\;\lambda_2 \leq 0.0048:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right)}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \lambda_1 - 0.5\right)\right) - {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \phi_1 \cdot \cos \phi_2 + \sin \phi_1 \cdot \sin \phi_2}{2}\right) + t_1}}{\sqrt{1 - \left(t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 0.00479999999999999958Initial program 65.6%
Simplified65.6%
div-sub65.6%
sin-diff66.4%
Applied egg-rr66.4%
div-sub65.6%
sin-diff66.4%
Applied egg-rr83.0%
sin-mult83.1%
Applied egg-rr83.1%
div-sub83.1%
+-inverses83.1%
+-inverses83.1%
+-inverses83.1%
cos-083.1%
metadata-eval83.1%
Simplified83.1%
Taylor expanded in lambda2 around 0 69.3%
if 0.00479999999999999958 < lambda2 Initial program 52.7%
Simplified52.7%
unpow227.5%
sin-mult27.5%
div-inv27.5%
metadata-eval27.5%
div-inv27.5%
metadata-eval27.5%
div-inv27.5%
metadata-eval27.5%
div-inv27.5%
metadata-eval27.5%
Applied egg-rr52.7%
div-sub27.5%
+-inverses27.5%
cos-027.5%
metadata-eval27.5%
distribute-lft-out27.5%
metadata-eval27.5%
*-rgt-identity27.5%
Simplified52.7%
cos-diff53.9%
Applied egg-rr53.9%
Final simplification65.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi2) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(sqrt
(- 1.0 (fma (cos phi1) t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi2) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt(fma(cos(phi1), t_1, pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0))), sqrt((1.0 - fma(cos(phi1), t_1, pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi2) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), 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))), sqrt(Float64(1.0 - fma(cos(phi1), t_1, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * 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]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_2 \cdot \left(t_0 \cdot t_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, 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}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, t_1, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
div-sub62.5%
sin-diff63.4%
Applied egg-rr63.4%
Final simplification63.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (cos phi2) (* (cos phi1) t_0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0));
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) 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(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_1))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $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[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]], $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(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\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(\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\right)}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
div-sub62.5%
sin-diff63.4%
Applied egg-rr63.2%
Final simplification63.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (cos phi2) (* (cos phi1) t_0)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt (- 1.0 (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt((1.0 - (t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0))
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_1)), sqrt((1.0d0 - (t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1)), Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_1)), math.sqrt((1.0 - (t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0)); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt((1.0 - (t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $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[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\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(t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
div-sub62.5%
sin-diff63.4%
Applied egg-rr63.4%
Final simplification63.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (* (cos phi2) t_0))))
(*
(atan2
(sqrt (fma t_0 t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (fma t_0 t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))))
(* R 2.0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * (cos(phi2) * t_0);
return atan2(sqrt(fma(t_0, t_1, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_0, t_1, (0.5 - (cos((phi1 - phi2)) / 2.0)))))) * (R * 2.0);
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * Float64(cos(phi2) * t_0)) return Float64(atan(sqrt(fma(t_0, t_1, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_0, t_1, Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))))) * Float64(R * 2.0)) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[N[(t$95$0 * t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right)\\
\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, t_1, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_0, t_1, 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
unpow233.0%
sin-mult30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
Applied egg-rr62.6%
div-sub30.1%
+-inverses30.1%
cos-030.1%
metadata-eval30.1%
distribute-lft-out30.1%
metadata-eval30.1%
*-rgt-identity30.1%
Simplified62.6%
Final simplification62.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi1) (* (cos phi2) (* t_0 t_0)) t_1))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (/ (cos (- lambda1 lambda2)) 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 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), t_1)), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))), t_1)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), t_1)), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t_0 \cdot t_0\right), t_1\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right), t_1\right)}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
sin-mult79.1%
Applied egg-rr62.5%
div-sub79.1%
+-inverses79.1%
+-inverses79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
Simplified62.5%
Final simplification62.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (cos phi2) (* (cos phi1) t_0)))))
(*
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 * (cos(phi2) * (cos(phi1) * t_0));
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 * (cos(phi2) * (cos(phi1) * t_0))
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 * (Math.cos(phi2) * (Math.cos(phi1) * t_0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 + (((Math.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 * (math.cos(phi2) * (math.cos(phi1) * t_0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 + (((math.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(cos(phi2) * Float64(cos(phi1) * t_0))) 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 * (cos(phi2) * (cos(phi1) * t_0)); 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[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $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(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\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 62.5%
Simplified62.5%
unpow233.0%
sin-mult30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
Applied egg-rr62.5%
div-sub30.1%
+-inverses30.1%
cos-030.1%
metadata-eval30.1%
distribute-lft-out30.1%
metadata-eval30.1%
*-rgt-identity30.1%
Simplified62.5%
Final simplification62.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (or (<= phi1 -7e-8) (not (<= phi1 0.029)))
(*
R
(*
2.0
(atan2 t_1 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_2))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi1 <= -7e-8) || !(phi1 <= 0.029)) {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if ((phi1 <= (-7d-8)) .or. (.not. (phi1 <= 0.029d0))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_2)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi1 <= -7e-8) || !(phi1 <= 0.029)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if (phi1 <= -7e-8) or not (phi1 <= 0.029): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_2))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if ((phi1 <= -7e-8) || !(phi1 <= 0.029)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if ((phi1 <= -7e-8) || ~((phi1 <= 0.029))) tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_2))))); else tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -7e-8], N[Not[LessEqual[phi1, 0.029]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 0.029\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_2}}\right)\\
\end{array}
\end{array}
if phi1 < -7.00000000000000048e-8 or 0.0290000000000000015 < phi1 Initial program 50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 50.8%
+-commutative50.8%
associate--r+50.8%
unpow250.8%
1-sub-sin50.9%
unpow250.9%
*-commutative50.9%
Simplified50.9%
if -7.00000000000000048e-8 < phi1 < 0.0290000000000000015Initial program 75.3%
Simplified75.3%
Taylor expanded in phi1 around 0 75.4%
+-commutative75.4%
associate--r+75.4%
unpow275.4%
1-sub-sin75.5%
unpow275.5%
sub-neg75.5%
mul-1-neg75.5%
Simplified75.5%
Final simplification63.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (cos phi2) (* (cos phi1) t_0)))))
(if (or (<= phi2 -3.4e+19) (not (<= phi2 3.8e-38)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(cbrt
(pow (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)) 3.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0));
double tmp;
if ((phi2 <= -3.4e+19) || !(phi2 <= 3.8e-38)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(cbrt(pow((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), 3.0)))));
}
return tmp;
}
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 * (Math.cos(phi2) * (Math.cos(phi1) * t_0));
double tmp;
if ((phi2 <= -3.4e+19) || !(phi2 <= 3.8e-38)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.cbrt(Math.pow((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)), 3.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) tmp = 0.0 if ((phi2 <= -3.4e+19) || !(phi2 <= 3.8e-38)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(cbrt((Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) ^ 3.0)))))); end return 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[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -3.4e+19], N[Not[LessEqual[phi2, 3.8e-38]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Power[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $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(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\\
\mathbf{if}\;\phi_2 \leq -3.4 \cdot 10^{+19} \lor \neg \left(\phi_2 \leq 3.8 \cdot 10^{-38}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\sqrt[3]{{\left(1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)}^{3}}}}\right)\\
\end{array}
\end{array}
if phi2 < -3.4e19 or 3.8e-38 < phi2 Initial program 49.9%
Simplified49.9%
Taylor expanded in phi1 around 0 50.5%
+-commutative50.5%
associate--r+50.5%
unpow250.5%
1-sub-sin50.6%
unpow250.6%
sub-neg50.6%
mul-1-neg50.6%
Simplified50.6%
Taylor expanded in phi1 around 0 50.5%
if -3.4e19 < phi2 < 3.8e-38Initial program 76.5%
Simplified76.5%
Taylor expanded in phi1 around 0 44.6%
+-commutative44.6%
associate--r+44.6%
unpow244.6%
1-sub-sin44.6%
unpow244.6%
sub-neg44.6%
mul-1-neg44.6%
Simplified44.6%
Taylor expanded in phi2 around 0 44.6%
sub-neg44.6%
mul-1-neg44.6%
unpow244.6%
1-sub-sin44.6%
distribute-lft-in44.6%
associate-*r*44.6%
metadata-eval44.6%
metadata-eval44.6%
associate-*r*44.6%
neg-mul-144.6%
distribute-lft-in44.6%
+-commutative44.6%
sub-neg44.6%
*-commutative44.6%
distribute-lft-in44.6%
associate-*r*44.6%
metadata-eval44.6%
Simplified44.6%
add-cbrt-cube44.6%
*-commutative44.6%
*-commutative44.6%
*-commutative44.6%
Applied egg-rr44.6%
associate-*l*44.6%
cube-unmult44.6%
*-commutative44.6%
Simplified44.6%
Final simplification47.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 9.5e-18)
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* t_2 (* (cos phi2) (* (cos phi1) (sin (* lambda1 0.5)))))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (* (cos phi2) (* (cos phi1) t_2)) (sin (* lambda2 -0.5)))))
t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 9.5e-18) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5))))))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + ((cos(phi2) * (cos(phi1) * t_2)) * sin((lambda2 * -0.5))))), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda2 <= 9.5d-18) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5d0))))))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + ((cos(phi2) * (cos(phi1) * t_2)) * sin((lambda2 * (-0.5d0)))))), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 9.5e-18) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (Math.cos(phi2) * (Math.cos(phi1) * Math.sin((lambda1 * 0.5))))))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + ((Math.cos(phi2) * (Math.cos(phi1) * t_2)) * Math.sin((lambda2 * -0.5))))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 9.5e-18: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (math.cos(phi2) * (math.cos(phi1) * math.sin((lambda1 * 0.5))))))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + ((math.cos(phi2) * (math.cos(phi1) * t_2)) * math.sin((lambda2 * -0.5))))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= 9.5e-18) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(cos(phi2) * Float64(cos(phi1) * sin(Float64(lambda1 * 0.5))))))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(Float64(cos(phi2) * Float64(cos(phi1) * t_2)) * sin(Float64(lambda2 * -0.5))))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda2 <= 9.5e-18) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5))))))), t_1)); else tmp = R * (2.0 * atan2(sqrt((t_0 + ((cos(phi2) * (cos(phi1) * t_2)) * sin((lambda2 * -0.5))))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 9.5e-18], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 9.5 \cdot 10^{-18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)\right)}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_2\right)\right) \cdot \sin \left(\lambda_2 \cdot -0.5\right)}}{t_1}\right)\\
\end{array}
\end{array}
if lambda2 < 9.5000000000000003e-18Initial program 65.8%
Simplified65.8%
Taylor expanded in phi1 around 0 49.9%
+-commutative49.9%
associate--r+49.9%
unpow249.9%
1-sub-sin50.0%
unpow250.0%
sub-neg50.0%
mul-1-neg50.0%
Simplified50.0%
Taylor expanded in lambda2 around 0 41.2%
if 9.5000000000000003e-18 < lambda2 Initial program 53.1%
Simplified53.1%
Taylor expanded in phi1 around 0 41.3%
+-commutative41.3%
associate--r+41.3%
unpow241.3%
1-sub-sin41.4%
unpow241.4%
sub-neg41.4%
mul-1-neg41.4%
Simplified41.4%
Taylor expanded in lambda1 around 0 40.9%
Final simplification41.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (cos (* phi2 -0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda1 -1.05)
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* t_2 (* (cos phi2) (* (cos phi1) (sin (* lambda1 0.5)))))))
(sqrt
(-
t_1
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* (cos phi2) (* (cos phi1) t_2))) t_0))
(sqrt (- t_1 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(cos((phi2 * -0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda1 <= -1.05) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5))))))), sqrt((t_1 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (cos(phi2) * (cos(phi1) * t_2))) + t_0)), sqrt((t_1 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos((phi2 * (-0.5d0))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda1 <= (-1.05d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5d0))))))), sqrt((t_1 - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (cos(phi2) * (cos(phi1) * t_2))) + t_0)), sqrt((t_1 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda1 <= -1.05) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (Math.cos(phi2) * (Math.cos(phi1) * Math.sin((lambda1 * 0.5))))))), Math.sqrt((t_1 - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (Math.cos(phi2) * (Math.cos(phi1) * t_2))) + t_0)), Math.sqrt((t_1 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.cos((phi2 * -0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda1 <= -1.05: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (math.cos(phi2) * (math.cos(phi1) * math.sin((lambda1 * 0.5))))))), math.sqrt((t_1 - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (math.cos(phi2) * (math.cos(phi1) * t_2))) + t_0)), math.sqrt((t_1 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = cos(Float64(phi2 * -0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda1 <= -1.05) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(cos(phi2) * Float64(cos(phi1) * sin(Float64(lambda1 * 0.5))))))), sqrt(Float64(t_1 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(cos(phi2) * Float64(cos(phi1) * t_2))) + t_0)), sqrt(Float64(t_1 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos((phi2 * -0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda1 <= -1.05) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5))))))), sqrt((t_1 - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (cos(phi2) * (cos(phi1) * t_2))) + t_0)), sqrt((t_1 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.05], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 \leq -1.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)\right)}}{\sqrt{t_1 - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_2\right)\right) + t_0}}{\sqrt{t_1 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.05000000000000004Initial program 47.6%
Simplified47.6%
Taylor expanded in phi1 around 0 38.1%
+-commutative38.1%
associate--r+38.1%
unpow238.1%
1-sub-sin38.1%
unpow238.1%
sub-neg38.1%
mul-1-neg38.1%
Simplified38.1%
Taylor expanded in lambda2 around 0 37.8%
if -1.05000000000000004 < lambda1 Initial program 67.3%
Simplified67.3%
Taylor expanded in phi1 around 0 50.8%
+-commutative50.8%
associate--r+50.8%
unpow250.8%
1-sub-sin50.8%
unpow250.8%
sub-neg50.8%
mul-1-neg50.8%
Simplified50.8%
Taylor expanded in lambda1 around 0 44.4%
Final simplification42.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
(t_2 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= lambda1 -1.05)
(*
R
(*
2.0
(atan2
t_1
(sqrt (- t_2 (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- t_2 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_2 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda1 <= -1.05) {
tmp = R * (2.0 * atan2(t_1, sqrt((t_2 - (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((t_2 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
t_2 = cos((phi2 * (-0.5d0))) ** 2.0d0
if (lambda1 <= (-1.05d0)) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((t_2 - (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((t_2 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_2 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda1 <= -1.05) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((t_2 - (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((t_2 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) t_2 = math.pow(math.cos((phi2 * -0.5)), 2.0) tmp = 0 if lambda1 <= -1.05: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((t_2 - (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((t_2 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) t_2 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (lambda1 <= -1.05) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(t_2 - Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(t_2 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); t_2 = cos((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if (lambda1 <= -1.05) tmp = R * (2.0 * atan2(t_1, sqrt((t_2 - (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_1, sqrt((t_2 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda1, -1.05], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(t$95$2 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(t$95$2 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
t_2 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -1.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{t_2 - \cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{t_2 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.05000000000000004Initial program 47.6%
Simplified47.6%
Taylor expanded in phi1 around 0 38.1%
+-commutative38.1%
associate--r+38.1%
unpow238.1%
1-sub-sin38.1%
unpow238.1%
sub-neg38.1%
mul-1-neg38.1%
Simplified38.1%
Taylor expanded in lambda2 around 0 38.1%
if -1.05000000000000004 < lambda1 Initial program 67.3%
Simplified67.3%
Taylor expanded in phi1 around 0 50.8%
+-commutative50.8%
associate--r+50.8%
unpow250.8%
1-sub-sin50.8%
unpow250.8%
sub-neg50.8%
mul-1-neg50.8%
Simplified50.8%
Taylor expanded in lambda1 around 0 44.4%
Final simplification42.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
Taylor expanded in phi1 around 0 47.7%
+-commutative47.7%
associate--r+47.7%
unpow247.7%
1-sub-sin47.8%
unpow247.8%
sub-neg47.8%
mul-1-neg47.8%
Simplified47.8%
Final simplification47.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(- 1.0 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
Taylor expanded in phi1 around 0 47.2%
Taylor expanded in phi2 around 0 33.0%
Final simplification33.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 8e-106)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (cos phi2) (* (cos phi1) (sin (* lambda1 0.5)))))))
t_0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* (cos phi2) (* (cos phi1) t_1)))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 8e-106) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5))))))), t_0));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (cos(phi2) * (cos(phi1) * t_1))) + (0.5 - (cos((phi1 - phi2)) / 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 = sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda2 <= 8d-106) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5d0))))))), t_0))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (cos(phi2) * (cos(phi1) * t_1))) + (0.5d0 - (cos((phi1 - phi2)) / 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.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 8e-106) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (Math.cos(phi2) * (Math.cos(phi1) * Math.sin((lambda1 * 0.5))))))), t_0));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (Math.cos(phi2) * (Math.cos(phi1) * t_1))) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 8e-106: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (math.cos(phi2) * (math.cos(phi1) * math.sin((lambda1 * 0.5))))))), t_0)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (math.cos(phi2) * (math.cos(phi1) * t_1))) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= 8e-106) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(cos(phi2) * Float64(cos(phi1) * sin(Float64(lambda1 * 0.5))))))), t_0))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(cos(phi2) * Float64(cos(phi1) * t_1))) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda2 <= 8e-106) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5))))))), t_0)); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (cos(phi2) * (cos(phi1) * t_1))) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 8e-106], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - {\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}\;\lambda_2 \leq 8 \cdot 10^{-106}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)\right)}}{t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_1\right)\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t_0}\right)\\
\end{array}
\end{array}
if lambda2 < 7.99999999999999953e-106Initial program 66.6%
Simplified66.6%
Taylor expanded in phi1 around 0 50.4%
+-commutative50.4%
associate--r+50.4%
unpow250.4%
1-sub-sin50.4%
unpow250.4%
sub-neg50.4%
mul-1-neg50.4%
Simplified50.4%
Taylor expanded in phi2 around 0 34.8%
sub-neg34.8%
mul-1-neg34.8%
unpow234.8%
1-sub-sin34.8%
distribute-lft-in34.8%
associate-*r*34.8%
metadata-eval34.8%
metadata-eval34.8%
associate-*r*34.8%
neg-mul-134.8%
distribute-lft-in34.8%
+-commutative34.8%
sub-neg34.8%
*-commutative34.8%
distribute-lft-in34.8%
associate-*r*34.8%
metadata-eval34.8%
Simplified34.8%
Taylor expanded in lambda2 around 0 30.6%
if 7.99999999999999953e-106 < lambda2 Initial program 53.4%
Simplified53.4%
Taylor expanded in phi1 around 0 41.8%
+-commutative41.8%
associate--r+41.8%
unpow241.8%
1-sub-sin41.9%
unpow241.9%
sub-neg41.9%
mul-1-neg41.9%
Simplified41.9%
Taylor expanded in phi2 around 0 29.1%
sub-neg29.1%
mul-1-neg29.1%
unpow229.1%
1-sub-sin29.1%
distribute-lft-in29.1%
associate-*r*29.1%
metadata-eval29.1%
metadata-eval29.1%
associate-*r*29.1%
neg-mul-129.1%
distribute-lft-in29.1%
+-commutative29.1%
sub-neg29.1%
*-commutative29.1%
distribute-lft-in29.1%
associate-*r*29.1%
metadata-eval29.1%
Simplified29.1%
unpow229.1%
sin-mult29.1%
div-inv29.1%
metadata-eval29.1%
div-inv29.1%
metadata-eval29.1%
div-inv29.1%
metadata-eval29.1%
div-inv29.1%
metadata-eval29.1%
Applied egg-rr29.1%
div-sub29.1%
+-inverses29.1%
cos-029.1%
metadata-eval29.1%
distribute-lft-out29.1%
metadata-eval29.1%
*-rgt-identity29.1%
Simplified29.1%
Final simplification30.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
Taylor expanded in phi1 around 0 47.7%
+-commutative47.7%
associate--r+47.7%
unpow247.7%
1-sub-sin47.8%
unpow247.8%
sub-neg47.8%
mul-1-neg47.8%
Simplified47.8%
Taylor expanded in phi2 around 0 33.0%
sub-neg33.0%
mul-1-neg33.0%
unpow233.0%
1-sub-sin33.0%
distribute-lft-in33.0%
associate-*r*33.0%
metadata-eval33.0%
metadata-eval33.0%
associate-*r*33.0%
neg-mul-133.0%
distribute-lft-in33.0%
+-commutative33.0%
sub-neg33.0%
*-commutative33.0%
distribute-lft-in33.0%
associate-*r*33.0%
metadata-eval33.0%
Simplified33.0%
Final simplification33.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (cos phi2) (* (cos phi1) t_0)))))
(if (<= lambda2 9.5e-18)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (pow (cos (* lambda1 0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* lambda2 -0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0));
double tmp;
if (lambda2 <= 9.5e-18) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin((lambda2 * -0.5)), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0))
if (lambda2 <= 9.5d-18) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin((lambda2 * (-0.5d0))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0));
double tmp;
if (lambda2 <= 9.5e-18) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.pow(Math.cos((lambda1 * 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 - Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0)) tmp = 0 if lambda2 <= 9.5e-18: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.pow(math.cos((lambda1 * 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 - math.pow(math.sin((lambda2 * -0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) tmp = 0.0 if (lambda2 <= 9.5e-18) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((cos(Float64(lambda1 * 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 - (sin(Float64(lambda2 * -0.5)) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0)); tmp = 0.0; if (lambda2 <= 9.5e-18) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin((lambda2 * -0.5)) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 9.5e-18], 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[Power[N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\\
\mathbf{if}\;\lambda_2 \leq 9.5 \cdot 10^{-18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\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 - {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 9.5000000000000003e-18Initial program 65.8%
Simplified65.8%
Taylor expanded in phi1 around 0 49.9%
+-commutative49.9%
associate--r+49.9%
unpow249.9%
1-sub-sin50.0%
unpow250.0%
sub-neg50.0%
mul-1-neg50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 34.7%
sub-neg34.7%
mul-1-neg34.7%
unpow234.7%
1-sub-sin34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
metadata-eval34.7%
associate-*r*34.7%
neg-mul-134.7%
distribute-lft-in34.7%
+-commutative34.7%
sub-neg34.7%
*-commutative34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
Simplified34.7%
Taylor expanded in lambda2 around 0 32.1%
unpow232.1%
1-sub-sin32.1%
unpow232.1%
Simplified32.1%
if 9.5000000000000003e-18 < lambda2 Initial program 53.1%
Simplified53.1%
Taylor expanded in phi1 around 0 41.3%
+-commutative41.3%
associate--r+41.3%
unpow241.3%
1-sub-sin41.4%
unpow241.4%
sub-neg41.4%
mul-1-neg41.4%
Simplified41.4%
Taylor expanded in phi2 around 0 28.3%
sub-neg28.3%
mul-1-neg28.3%
unpow228.3%
1-sub-sin28.3%
distribute-lft-in28.3%
associate-*r*28.3%
metadata-eval28.3%
metadata-eval28.3%
associate-*r*28.3%
neg-mul-128.3%
distribute-lft-in28.3%
+-commutative28.3%
sub-neg28.3%
*-commutative28.3%
distribute-lft-in28.3%
associate-*r*28.3%
metadata-eval28.3%
Simplified28.3%
unpow228.3%
sin-mult28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
Applied egg-rr28.3%
div-sub28.3%
+-inverses28.3%
cos-028.3%
metadata-eval28.3%
distribute-lft-out28.3%
metadata-eval28.3%
*-rgt-identity28.3%
Simplified28.3%
Taylor expanded in lambda1 around 0 28.3%
*-commutative28.3%
Simplified28.3%
Final simplification31.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (<= lambda2 9.5e-18)
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* lambda1 0.5)) 2.0)))))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* lambda2 -0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (lambda2 <= 9.5e-18) {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((lambda2 * -0.5)), 2.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if (lambda2 <= 9.5d-18) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((lambda2 * (-0.5d0))) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (lambda2 <= 9.5e-18) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if lambda2 <= 9.5e-18: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if (lambda2 <= 9.5e-18) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if (lambda2 <= 9.5e-18) tmp = R * (2.0 * atan2(t_1, sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(t_1, sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 9.5e-18], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\lambda_2 \leq 9.5 \cdot 10^{-18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 9.5000000000000003e-18Initial program 65.8%
Simplified65.8%
Taylor expanded in phi1 around 0 49.9%
+-commutative49.9%
associate--r+49.9%
unpow249.9%
1-sub-sin50.0%
unpow250.0%
sub-neg50.0%
mul-1-neg50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 34.7%
sub-neg34.7%
mul-1-neg34.7%
unpow234.7%
1-sub-sin34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
metadata-eval34.7%
associate-*r*34.7%
neg-mul-134.7%
distribute-lft-in34.7%
+-commutative34.7%
sub-neg34.7%
*-commutative34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
Simplified34.7%
Taylor expanded in lambda2 around 0 32.1%
unpow232.1%
1-sub-sin32.1%
unpow232.1%
Simplified32.1%
if 9.5000000000000003e-18 < lambda2 Initial program 53.1%
Simplified53.1%
Taylor expanded in phi1 around 0 41.3%
+-commutative41.3%
associate--r+41.3%
unpow241.3%
1-sub-sin41.4%
unpow241.4%
sub-neg41.4%
mul-1-neg41.4%
Simplified41.4%
Taylor expanded in phi2 around 0 28.3%
sub-neg28.3%
mul-1-neg28.3%
unpow228.3%
1-sub-sin28.3%
distribute-lft-in28.3%
associate-*r*28.3%
metadata-eval28.3%
metadata-eval28.3%
associate-*r*28.3%
neg-mul-128.3%
distribute-lft-in28.3%
+-commutative28.3%
sub-neg28.3%
*-commutative28.3%
distribute-lft-in28.3%
associate-*r*28.3%
metadata-eval28.3%
Simplified28.3%
Taylor expanded in lambda1 around 0 28.3%
unpow228.3%
1-sub-sin28.3%
unpow228.3%
*-commutative28.3%
Simplified28.3%
Final simplification31.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (cos phi2) (* (cos phi1) t_0))))
(t_2 (sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))
(if (<= phi2 4500000000.0)
(* R (* 2.0 (atan2 (sqrt (+ t_1 (- 0.5 (/ (cos phi1) 2.0)))) t_2)))
(* R (* 2.0 (atan2 (sqrt (+ t_1 (- 0.5 (/ (cos phi2) 2.0)))) t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0));
double t_2 = sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double tmp;
if (phi2 <= 4500000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos(phi1) / 2.0)))), t_2));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos(phi2) / 2.0)))), t_2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0))
t_2 = sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))
if (phi2 <= 4500000000.0d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos(phi1) / 2.0d0)))), t_2))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos(phi2) / 2.0d0)))), t_2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0));
double t_2 = Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double tmp;
if (phi2 <= 4500000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos(phi1) / 2.0)))), t_2));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos(phi2) / 2.0)))), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0)) t_2 = math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) tmp = 0 if phi2 <= 4500000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos(phi1) / 2.0)))), t_2)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos(phi2) / 2.0)))), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) t_2 = sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) tmp = 0.0 if (phi2 <= 4500000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(phi1) / 2.0)))), t_2))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(phi2) / 2.0)))), t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (cos(phi2) * (cos(phi1) * t_0)); t_2 = sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))); tmp = 0.0; if (phi2 <= 4500000000.0) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos(phi1) / 2.0)))), t_2)); else tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos(phi2) / 2.0)))), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 4500000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[phi1], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[phi2], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $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(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\\
t_2 := \sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}\\
\mathbf{if}\;\phi_2 \leq 4500000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \left(0.5 - \frac{\cos \phi_1}{2}\right)}}{t_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \left(0.5 - \frac{\cos \phi_2}{2}\right)}}{t_2}\right)\\
\end{array}
\end{array}
if phi2 < 4.5e9Initial program 66.1%
Simplified66.1%
Taylor expanded in phi1 around 0 45.9%
+-commutative45.9%
associate--r+45.9%
unpow245.9%
1-sub-sin46.0%
unpow246.0%
sub-neg46.0%
mul-1-neg46.0%
Simplified46.0%
Taylor expanded in phi2 around 0 37.5%
sub-neg37.5%
mul-1-neg37.5%
unpow237.5%
1-sub-sin37.5%
distribute-lft-in37.5%
associate-*r*37.5%
metadata-eval37.5%
metadata-eval37.5%
associate-*r*37.5%
neg-mul-137.5%
distribute-lft-in37.5%
+-commutative37.5%
sub-neg37.5%
*-commutative37.5%
distribute-lft-in37.5%
associate-*r*37.5%
metadata-eval37.5%
Simplified37.5%
unpow237.5%
sin-mult33.6%
div-inv33.6%
metadata-eval33.6%
div-inv33.6%
metadata-eval33.6%
div-inv33.6%
metadata-eval33.6%
div-inv33.6%
metadata-eval33.6%
Applied egg-rr33.6%
div-sub33.6%
+-inverses33.6%
cos-033.6%
metadata-eval33.6%
distribute-lft-out33.6%
metadata-eval33.6%
*-rgt-identity33.6%
Simplified33.6%
Taylor expanded in phi2 around 0 31.8%
if 4.5e9 < phi2 Initial program 52.2%
Simplified52.2%
Taylor expanded in phi1 around 0 52.7%
+-commutative52.7%
associate--r+52.8%
unpow252.8%
1-sub-sin52.9%
unpow252.9%
sub-neg52.9%
mul-1-neg52.9%
Simplified52.9%
Taylor expanded in phi2 around 0 20.1%
sub-neg20.1%
mul-1-neg20.1%
unpow220.1%
1-sub-sin20.1%
distribute-lft-in20.1%
associate-*r*20.1%
metadata-eval20.1%
metadata-eval20.1%
associate-*r*20.1%
neg-mul-120.1%
distribute-lft-in20.1%
+-commutative20.1%
sub-neg20.1%
*-commutative20.1%
distribute-lft-in20.1%
associate-*r*20.1%
metadata-eval20.1%
Simplified20.1%
unpow220.1%
sin-mult20.1%
div-inv20.1%
metadata-eval20.1%
div-inv20.1%
metadata-eval20.1%
div-inv20.1%
metadata-eval20.1%
div-inv20.1%
metadata-eval20.1%
Applied egg-rr20.1%
div-sub20.1%
+-inverses20.1%
cos-020.1%
metadata-eval20.1%
distribute-lft-out20.1%
metadata-eval20.1%
*-rgt-identity20.1%
Simplified20.1%
Taylor expanded in phi1 around 0 20.3%
cos-neg20.3%
Simplified20.3%
Final simplification28.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 0.5 (/ (cos (- phi1 phi2)) 2.0)))
(t_1 (sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 2.7e-18)
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* t_2 (* (cos phi2) (* (cos phi1) (sin (* lambda1 0.5)))))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* t_2 (* (cos phi2) (* (cos phi1) (sin (* lambda2 -0.5)))))))
t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (cos((phi1 - phi2)) / 2.0);
double t_1 = sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 2.7e-18) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5))))))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda2 * -0.5))))))), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = 0.5d0 - (cos((phi1 - phi2)) / 2.0d0)
t_1 = sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda2 <= 2.7d-18) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5d0))))))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda2 * (-0.5d0)))))))), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 0.5 - (Math.cos((phi1 - phi2)) / 2.0);
double t_1 = Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 2.7e-18) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (Math.cos(phi2) * (Math.cos(phi1) * Math.sin((lambda1 * 0.5))))))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (Math.cos(phi2) * (Math.cos(phi1) * Math.sin((lambda2 * -0.5))))))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 0.5 - (math.cos((phi1 - phi2)) / 2.0) t_1 = math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 2.7e-18: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (math.cos(phi2) * (math.cos(phi1) * math.sin((lambda1 * 0.5))))))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (math.cos(phi2) * (math.cos(phi1) * math.sin((lambda2 * -0.5))))))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) t_1 = sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= 2.7e-18) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(cos(phi2) * Float64(cos(phi1) * sin(Float64(lambda1 * 0.5))))))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(cos(phi2) * Float64(cos(phi1) * sin(Float64(lambda2 * -0.5))))))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = 0.5 - (cos((phi1 - phi2)) / 2.0); t_1 = sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda2 <= 2.7e-18) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda1 * 0.5))))))), t_1)); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (cos(phi2) * (cos(phi1) * sin((lambda2 * -0.5))))))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 2.7e-18], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\\
t_1 := \sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 2.7 \cdot 10^{-18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)\right)}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}}{t_1}\right)\\
\end{array}
\end{array}
if lambda2 < 2.69999999999999989e-18Initial program 65.8%
Simplified65.8%
Taylor expanded in phi1 around 0 49.9%
+-commutative49.9%
associate--r+49.9%
unpow249.9%
1-sub-sin50.0%
unpow250.0%
sub-neg50.0%
mul-1-neg50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 34.7%
sub-neg34.7%
mul-1-neg34.7%
unpow234.7%
1-sub-sin34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
metadata-eval34.7%
associate-*r*34.7%
neg-mul-134.7%
distribute-lft-in34.7%
+-commutative34.7%
sub-neg34.7%
*-commutative34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
Simplified34.7%
unpow234.7%
sin-mult30.8%
div-inv30.8%
metadata-eval30.8%
div-inv30.8%
metadata-eval30.8%
div-inv30.8%
metadata-eval30.8%
div-inv30.8%
metadata-eval30.8%
Applied egg-rr30.8%
div-sub30.8%
+-inverses30.8%
cos-030.8%
metadata-eval30.8%
distribute-lft-out30.8%
metadata-eval30.8%
*-rgt-identity30.8%
Simplified30.8%
Taylor expanded in lambda2 around 0 26.8%
if 2.69999999999999989e-18 < lambda2 Initial program 53.1%
Simplified53.1%
Taylor expanded in phi1 around 0 41.3%
+-commutative41.3%
associate--r+41.3%
unpow241.3%
1-sub-sin41.4%
unpow241.4%
sub-neg41.4%
mul-1-neg41.4%
Simplified41.4%
Taylor expanded in phi2 around 0 28.3%
sub-neg28.3%
mul-1-neg28.3%
unpow228.3%
1-sub-sin28.3%
distribute-lft-in28.3%
associate-*r*28.3%
metadata-eval28.3%
metadata-eval28.3%
associate-*r*28.3%
neg-mul-128.3%
distribute-lft-in28.3%
+-commutative28.3%
sub-neg28.3%
*-commutative28.3%
distribute-lft-in28.3%
associate-*r*28.3%
metadata-eval28.3%
Simplified28.3%
unpow228.3%
sin-mult28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
Applied egg-rr28.3%
div-sub28.3%
+-inverses28.3%
cos-028.3%
metadata-eval28.3%
distribute-lft-out28.3%
metadata-eval28.3%
*-rgt-identity28.3%
Simplified28.3%
Taylor expanded in lambda1 around 0 27.8%
Final simplification27.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(if (<= lambda2 8000000000000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* (cos phi2) (* (cos phi1) t_0))) t_1))
(sqrt (- 1.0 (pow (sin (* lambda1 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_1 (* t_0 (* (cos phi2) (* (cos phi1) (sin (* lambda2 -0.5)))))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = 0.5 - (cos((phi1 - phi2)) / 2.0);
double tmp;
if (lambda2 <= 8000000000000.0) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + t_1)), sqrt((1.0 - pow(sin((lambda1 * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (cos(phi2) * (cos(phi1) * sin((lambda2 * -0.5))))))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = 0.5d0 - (cos((phi1 - phi2)) / 2.0d0)
if (lambda2 <= 8000000000000.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + t_1)), sqrt((1.0d0 - (sin((lambda1 * 0.5d0)) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (cos(phi2) * (cos(phi1) * sin((lambda2 * (-0.5d0)))))))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = 0.5 - (Math.cos((phi1 - phi2)) / 2.0);
double tmp;
if (lambda2 <= 8000000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + t_1)), Math.sqrt((1.0 - Math.pow(Math.sin((lambda1 * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (Math.cos(phi2) * (Math.cos(phi1) * Math.sin((lambda2 * -0.5))))))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = 0.5 - (math.cos((phi1 - phi2)) / 2.0) tmp = 0 if lambda2 <= 8000000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + t_1)), math.sqrt((1.0 - math.pow(math.sin((lambda1 * 0.5)), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (math.cos(phi2) * (math.cos(phi1) * math.sin((lambda2 * -0.5))))))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) tmp = 0.0 if (lambda2 <= 8000000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + t_1)), sqrt(Float64(1.0 - (sin(Float64(lambda1 * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * sin(Float64(lambda2 * -0.5))))))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = 0.5 - (cos((phi1 - phi2)) / 2.0); tmp = 0.0; if (lambda2 <= 8000000000000.0) tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + t_1)), sqrt((1.0 - (sin((lambda1 * 0.5)) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (cos(phi2) * (cos(phi1) * sin((lambda2 * -0.5))))))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 8000000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\\
\mathbf{if}\;\lambda_2 \leq 8000000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + t_1}}{\sqrt{1 - {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 8e12Initial program 65.4%
Simplified65.4%
Taylor expanded in phi1 around 0 49.6%
+-commutative49.6%
associate--r+49.6%
unpow249.6%
1-sub-sin49.6%
unpow249.6%
sub-neg49.6%
mul-1-neg49.6%
Simplified49.6%
Taylor expanded in phi2 around 0 34.7%
sub-neg34.7%
mul-1-neg34.7%
unpow234.7%
1-sub-sin34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
metadata-eval34.7%
associate-*r*34.7%
neg-mul-134.7%
distribute-lft-in34.7%
+-commutative34.7%
sub-neg34.7%
*-commutative34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
Simplified34.7%
unpow234.7%
sin-mult30.9%
div-inv30.9%
metadata-eval30.9%
div-inv30.9%
metadata-eval30.9%
div-inv30.9%
metadata-eval30.9%
div-inv30.9%
metadata-eval30.9%
Applied egg-rr30.9%
div-sub30.9%
+-inverses30.9%
cos-030.9%
metadata-eval30.9%
distribute-lft-out30.9%
metadata-eval30.9%
*-rgt-identity30.9%
Simplified30.9%
Taylor expanded in lambda2 around 0 28.4%
if 8e12 < lambda2 Initial program 53.2%
Simplified53.2%
Taylor expanded in phi1 around 0 41.7%
+-commutative41.7%
associate--r+41.7%
unpow241.7%
1-sub-sin41.8%
unpow241.8%
sub-neg41.8%
mul-1-neg41.8%
Simplified41.8%
Taylor expanded in phi2 around 0 27.6%
sub-neg27.6%
mul-1-neg27.6%
unpow227.6%
1-sub-sin27.6%
distribute-lft-in27.6%
associate-*r*27.6%
metadata-eval27.6%
metadata-eval27.6%
associate-*r*27.6%
neg-mul-127.6%
distribute-lft-in27.6%
+-commutative27.6%
sub-neg27.6%
*-commutative27.6%
distribute-lft-in27.6%
associate-*r*27.6%
metadata-eval27.6%
Simplified27.6%
unpow227.6%
sin-mult27.6%
div-inv27.6%
metadata-eval27.6%
div-inv27.6%
metadata-eval27.6%
div-inv27.6%
metadata-eval27.6%
div-inv27.6%
metadata-eval27.6%
Applied egg-rr27.6%
div-sub27.6%
+-inverses27.6%
cos-027.6%
metadata-eval27.6%
distribute-lft-out27.6%
metadata-eval27.6%
*-rgt-identity27.6%
Simplified27.6%
Taylor expanded in lambda1 around 0 27.1%
Final simplification28.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))))
(if (<= lambda2 7e-18)
(* R (* 2.0 (atan2 t_1 (sqrt (- 1.0 (pow (sin (* lambda1 0.5)) 2.0))))))
(*
R
(* 2.0 (atan2 t_1 (sqrt (- 1.0 (pow (sin (* lambda2 -0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5 - (cos((phi1 - phi2)) / 2.0))));
double tmp;
if (lambda2 <= 7e-18) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((lambda1 * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((lambda2 * -0.5)), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0))))
if (lambda2 <= 7d-18) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin((lambda1 * 0.5d0)) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin((lambda2 * (-0.5d0))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0))));
double tmp;
if (lambda2 <= 7e-18) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((lambda1 * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))) tmp = 0 if lambda2 <= 7e-18: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((lambda1 * 0.5)), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((lambda2 * -0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))) tmp = 0.0 if (lambda2 <= 7e-18) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(lambda1 * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(lambda2 * -0.5)) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5 - (cos((phi1 - phi2)) / 2.0)))); tmp = 0.0; if (lambda2 <= 7e-18) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((lambda1 * 0.5)) ^ 2.0))))); else tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((lambda2 * -0.5)) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 7e-18], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}\\
\mathbf{if}\;\lambda_2 \leq 7 \cdot 10^{-18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 6.9999999999999997e-18Initial program 65.8%
Simplified65.8%
Taylor expanded in phi1 around 0 49.9%
+-commutative49.9%
associate--r+49.9%
unpow249.9%
1-sub-sin50.0%
unpow250.0%
sub-neg50.0%
mul-1-neg50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 34.7%
sub-neg34.7%
mul-1-neg34.7%
unpow234.7%
1-sub-sin34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
metadata-eval34.7%
associate-*r*34.7%
neg-mul-134.7%
distribute-lft-in34.7%
+-commutative34.7%
sub-neg34.7%
*-commutative34.7%
distribute-lft-in34.7%
associate-*r*34.7%
metadata-eval34.7%
Simplified34.7%
unpow234.7%
sin-mult30.8%
div-inv30.8%
metadata-eval30.8%
div-inv30.8%
metadata-eval30.8%
div-inv30.8%
metadata-eval30.8%
div-inv30.8%
metadata-eval30.8%
Applied egg-rr30.8%
div-sub30.8%
+-inverses30.8%
cos-030.8%
metadata-eval30.8%
distribute-lft-out30.8%
metadata-eval30.8%
*-rgt-identity30.8%
Simplified30.8%
Taylor expanded in lambda2 around 0 28.2%
if 6.9999999999999997e-18 < lambda2 Initial program 53.1%
Simplified53.1%
Taylor expanded in phi1 around 0 41.3%
+-commutative41.3%
associate--r+41.3%
unpow241.3%
1-sub-sin41.4%
unpow241.4%
sub-neg41.4%
mul-1-neg41.4%
Simplified41.4%
Taylor expanded in phi2 around 0 28.3%
sub-neg28.3%
mul-1-neg28.3%
unpow228.3%
1-sub-sin28.3%
distribute-lft-in28.3%
associate-*r*28.3%
metadata-eval28.3%
metadata-eval28.3%
associate-*r*28.3%
neg-mul-128.3%
distribute-lft-in28.3%
+-commutative28.3%
sub-neg28.3%
*-commutative28.3%
distribute-lft-in28.3%
associate-*r*28.3%
metadata-eval28.3%
Simplified28.3%
unpow228.3%
sin-mult28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
div-inv28.3%
metadata-eval28.3%
Applied egg-rr28.3%
div-sub28.3%
+-inverses28.3%
cos-028.3%
metadata-eval28.3%
distribute-lft-out28.3%
metadata-eval28.3%
*-rgt-identity28.3%
Simplified28.3%
Taylor expanded in lambda1 around 0 28.3%
*-commutative28.3%
Simplified28.3%
Final simplification28.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
Taylor expanded in phi1 around 0 47.7%
+-commutative47.7%
associate--r+47.7%
unpow247.7%
1-sub-sin47.8%
unpow247.8%
sub-neg47.8%
mul-1-neg47.8%
Simplified47.8%
Taylor expanded in phi2 around 0 33.0%
sub-neg33.0%
mul-1-neg33.0%
unpow233.0%
1-sub-sin33.0%
distribute-lft-in33.0%
associate-*r*33.0%
metadata-eval33.0%
metadata-eval33.0%
associate-*r*33.0%
neg-mul-133.0%
distribute-lft-in33.0%
+-commutative33.0%
sub-neg33.0%
*-commutative33.0%
distribute-lft-in33.0%
associate-*r*33.0%
metadata-eval33.0%
Simplified33.0%
unpow233.0%
sin-mult30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
Applied egg-rr30.1%
div-sub30.1%
+-inverses30.1%
cos-030.1%
metadata-eval30.1%
distribute-lft-out30.1%
metadata-eval30.1%
*-rgt-identity30.1%
Simplified30.1%
Final simplification30.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (cos phi2) (* (cos phi1) t_0)))
(- 0.5 (/ (cos phi1) 2.0))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5 - (cos(phi1) / 2.0)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5d0 - (cos(phi1) / 2.0d0)))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (Math.cos(phi2) * (Math.cos(phi1) * t_0))) + (0.5 - (Math.cos(phi1) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * (math.cos(phi2) * (math.cos(phi1) * t_0))) + (0.5 - (math.cos(phi1) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(cos(phi2) * Float64(cos(phi1) * t_0))) + Float64(0.5 - Float64(cos(phi1) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * (cos(phi2) * (cos(phi1) * t_0))) + (0.5 - (cos(phi1) / 2.0)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[phi1], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right) + \left(0.5 - \frac{\cos \phi_1}{2}\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
Taylor expanded in phi1 around 0 47.7%
+-commutative47.7%
associate--r+47.7%
unpow247.7%
1-sub-sin47.8%
unpow247.8%
sub-neg47.8%
mul-1-neg47.8%
Simplified47.8%
Taylor expanded in phi2 around 0 33.0%
sub-neg33.0%
mul-1-neg33.0%
unpow233.0%
1-sub-sin33.0%
distribute-lft-in33.0%
associate-*r*33.0%
metadata-eval33.0%
metadata-eval33.0%
associate-*r*33.0%
neg-mul-133.0%
distribute-lft-in33.0%
+-commutative33.0%
sub-neg33.0%
*-commutative33.0%
distribute-lft-in33.0%
associate-*r*33.0%
metadata-eval33.0%
Simplified33.0%
unpow233.0%
sin-mult30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
div-inv30.1%
metadata-eval30.1%
Applied egg-rr30.1%
div-sub30.1%
+-inverses30.1%
cos-030.1%
metadata-eval30.1%
distribute-lft-out30.1%
metadata-eval30.1%
*-rgt-identity30.1%
Simplified30.1%
Taylor expanded in phi2 around 0 27.0%
Final simplification27.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
(* R 2.0)
(atan2
(sin (* phi2 -0.5))
(sqrt
(-
1.0
(fma
t_0
(* (cos phi1) (* (cos phi2) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return (R * 2.0) * atan2(sin((phi2 * -0.5)), sqrt((1.0 - fma(t_0, (cos(phi1) * (cos(phi2) * t_0)), pow(sin(((phi1 - phi2) / 2.0)), 2.0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(Float64(R * 2.0) * atan(sin(Float64(phi2 * -0.5)), sqrt(Float64(1.0 - fma(t_0, Float64(cos(phi1) * Float64(cos(phi2) * t_0)), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(\phi_2 \cdot -0.5\right)}{\sqrt{1 - \mathsf{fma}\left(t_0, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t_0\right), {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}
\end{array}
\end{array}
Initial program 62.5%
Simplified62.5%
Taylor expanded in phi1 around 0 41.8%
Taylor expanded in lambda2 around 0 28.8%
Taylor expanded in lambda1 around 0 9.4%
*-commutative9.4%
Simplified9.4%
Final simplification9.4%
herbie shell --seed 2023272
(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))))))))))