
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 25 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(cos phi2)
(fma (cos lambda1) (sin (- lambda2)) (* (cos lambda2) (sin lambda1))))
(fma
(cos phi1)
(sin phi2)
(*
(sin phi1)
(*
(- (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * fma(cos(lambda1), sin(-lambda2), (cos(lambda2) * sin(lambda1)))), fma(cos(phi1), sin(phi2), (sin(phi1) * (-cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * fma(cos(lambda1), sin(Float64(-lambda2)), Float64(cos(lambda2) * sin(lambda1)))), fma(cos(phi1), sin(phi2), Float64(sin(phi1) * Float64(Float64(-cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[((-N[Cos[phi2], $MachinePrecision]) * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \sin \left(-\lambda_2\right), \cos \lambda_2 \cdot \sin \lambda_1\right)}{\mathsf{fma}\left(\cos \phi_1, \sin \phi_2, \sin \phi_1 \cdot \left(\left(-\cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)}
\end{array}
Initial program 79.1%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.1
Applied rewrites92.1%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
lift--.f64N/A
sub-negN/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lift-sin.f64N/A
sin-negN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-atan2.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
sub-negN/A
Applied rewrites99.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (- t_0 (* t_1 (cos lambda2)))))
(if (<= lambda2 -1.5e-5)
(atan2
(*
(cos phi2)
(fma (sin (- lambda2)) (cos lambda1) (* (cos lambda2) (sin lambda1))))
t_2)
(if (<= lambda2 1e-26)
(atan2
(/ (cos phi2) (/ 1.0 (sin (- lambda1 lambda2))))
(- t_0 (* t_1 (cos lambda1))))
(atan2
(*
(cos phi2)
(fma (sin lambda1) (cos lambda2) (- (* (cos lambda1) (sin lambda2)))))
t_2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = t_0 - (t_1 * cos(lambda2));
double tmp;
if (lambda2 <= -1.5e-5) {
tmp = atan2((cos(phi2) * fma(sin(-lambda2), cos(lambda1), (cos(lambda2) * sin(lambda1)))), t_2);
} else if (lambda2 <= 1e-26) {
tmp = atan2((cos(phi2) / (1.0 / sin((lambda1 - lambda2)))), (t_0 - (t_1 * cos(lambda1))));
} else {
tmp = atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), -(cos(lambda1) * sin(lambda2)))), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(t_0 - Float64(t_1 * cos(lambda2))) tmp = 0.0 if (lambda2 <= -1.5e-5) tmp = atan(Float64(cos(phi2) * fma(sin(Float64(-lambda2)), cos(lambda1), Float64(cos(lambda2) * sin(lambda1)))), t_2); elseif (lambda2 <= 1e-26) tmp = atan(Float64(cos(phi2) / Float64(1.0 / sin(Float64(lambda1 - lambda2)))), Float64(t_0 - Float64(t_1 * cos(lambda1)))); else tmp = atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(-Float64(cos(lambda1) * sin(lambda2))))), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.5e-5], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[lambda2, 1e-26], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] / N[(1.0 / N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + (-N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := t\_0 - t\_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\lambda_2 \leq -1.5 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right)}{t\_2}\\
\mathbf{elif}\;\lambda_2 \leq 10^{-26}:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{\cos \phi_2}{\frac{1}{\sin \left(\lambda_1 - \lambda_2\right)}}}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, -\cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_2}\\
\end{array}
\end{array}
if lambda2 < -1.50000000000000004e-5Initial program 46.2%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6446.1
Applied rewrites46.1%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
lift-cos.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f6475.4
Applied rewrites75.4%
if -1.50000000000000004e-5 < lambda2 < 1e-26Initial program 99.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-cos.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
sin-diffN/A
lift--.f64N/A
lift-sin.f6499.8
lower-*.f64N/A
*-commutativeN/A
remove-double-divN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
if 1e-26 < lambda2 Initial program 67.6%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6467.7
Applied rewrites67.7%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6491.3
Applied rewrites91.3%
Final simplification92.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2
(atan2
(*
(cos phi2)
(fma
(sin lambda1)
(cos lambda2)
(- (* (cos lambda1) (sin lambda2)))))
(- t_0 (* t_1 (cos lambda2))))))
(if (<= lambda2 -1.5e-5)
t_2
(if (<= lambda2 1e-26)
(atan2
(/ (cos phi2) (/ 1.0 (sin (- lambda1 lambda2))))
(- t_0 (* t_1 (cos lambda1))))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), -(cos(lambda1) * sin(lambda2)))), (t_0 - (t_1 * cos(lambda2))));
double tmp;
if (lambda2 <= -1.5e-5) {
tmp = t_2;
} else if (lambda2 <= 1e-26) {
tmp = atan2((cos(phi2) / (1.0 / sin((lambda1 - lambda2)))), (t_0 - (t_1 * cos(lambda1))));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(-Float64(cos(lambda1) * sin(lambda2))))), Float64(t_0 - Float64(t_1 * cos(lambda2)))) tmp = 0.0 if (lambda2 <= -1.5e-5) tmp = t_2; elseif (lambda2 <= 1e-26) tmp = atan(Float64(cos(phi2) / Float64(1.0 / sin(Float64(lambda1 - lambda2)))), Float64(t_0 - Float64(t_1 * cos(lambda1)))); else tmp = t_2; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + (-N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -1.5e-5], t$95$2, If[LessEqual[lambda2, 1e-26], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] / N[(1.0 / N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, -\cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{if}\;\lambda_2 \leq -1.5 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_2 \leq 10^{-26}:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{\cos \phi_2}{\frac{1}{\sin \left(\lambda_1 - \lambda_2\right)}}}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda2 < -1.50000000000000004e-5 or 1e-26 < lambda2 Initial program 58.4%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6458.4
Applied rewrites58.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-neg.f6484.5
Applied rewrites84.5%
if -1.50000000000000004e-5 < lambda2 < 1e-26Initial program 99.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-cos.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
sin-diffN/A
lift--.f64N/A
lift-sin.f6499.8
lower-*.f64N/A
*-commutativeN/A
remove-double-divN/A
lift-/.f64N/A
un-div-invN/A
lower-/.f6499.8
Applied rewrites99.8%
Final simplification92.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2
(atan2
(*
(cos phi2)
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
(- t_0 (* t_1 (cos lambda1))))))
(if (<= lambda1 -10.0)
t_2
(if (<= lambda1 0.023)
(atan2
(*
(cos phi2)
(-
(*
lambda1
(fma
(fma lambda1 (* lambda1 -0.16666666666666666) 1.0)
(cos lambda2)
(* (* lambda1 (sin lambda2)) 0.5)))
(sin lambda2)))
(- t_0 (* t_1 (cos (- lambda1 lambda2)))))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (t_0 - (t_1 * cos(lambda1))));
double tmp;
if (lambda1 <= -10.0) {
tmp = t_2;
} else if (lambda1 <= 0.023) {
tmp = atan2((cos(phi2) * ((lambda1 * fma(fma(lambda1, (lambda1 * -0.16666666666666666), 1.0), cos(lambda2), ((lambda1 * sin(lambda2)) * 0.5))) - sin(lambda2))), (t_0 - (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(t_0 - Float64(t_1 * cos(lambda1)))) tmp = 0.0 if (lambda1 <= -10.0) tmp = t_2; elseif (lambda1 <= 0.023) tmp = atan(Float64(cos(phi2) * Float64(Float64(lambda1 * fma(fma(lambda1, Float64(lambda1 * -0.16666666666666666), 1.0), cos(lambda2), Float64(Float64(lambda1 * sin(lambda2)) * 0.5))) - sin(lambda2))), Float64(t_0 - Float64(t_1 * cos(Float64(lambda1 - lambda2))))); else tmp = t_2; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -10.0], t$95$2, If[LessEqual[lambda1, 0.023], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(lambda1 * N[(N[(lambda1 * N[(lambda1 * -0.16666666666666666), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[(lambda1 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\mathbf{if}\;\lambda_1 \leq -10:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 0.023:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\lambda_1 \cdot \mathsf{fma}\left(\mathsf{fma}\left(\lambda_1, \lambda_1 \cdot -0.16666666666666666, 1\right), \cos \lambda_2, \left(\lambda_1 \cdot \sin \lambda_2\right) \cdot 0.5\right) - \sin \lambda_2\right)}{t\_0 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if lambda1 < -10 or 0.023 < lambda1 Initial program 62.4%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6486.6
Applied rewrites86.6%
Taylor expanded in lambda2 around 0
lower-cos.f6486.5
Applied rewrites86.5%
if -10 < lambda1 < 0.023Initial program 98.3%
Taylor expanded in lambda1 around 0
+-commutativeN/A
sin-negN/A
unsub-negN/A
lower--.f64N/A
Applied rewrites98.5%
Final simplification92.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))) (- (* (cos phi1) (sin phi2)) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.1%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.1
Applied rewrites92.1%
Final simplification92.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2
(atan2
(* (cos phi2) (- (sin lambda1) t_0))
(- (* (cos phi1) (sin phi2)) (* t_1 (cos (- lambda1 lambda2)))))))
(if (<= phi1 -1.46e-5)
t_2
(if (<= phi1 9.5e-32)
(atan2
(* (cos phi2) (- (* (cos lambda2) (sin lambda1)) t_0))
(- (sin phi2) (* t_1 (cos lambda1))))
t_2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = atan2((cos(phi2) * (sin(lambda1) - t_0)), ((cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.46e-5) {
tmp = t_2;
} else if (phi1 <= 9.5e-32) {
tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - t_0)), (sin(phi2) - (t_1 * cos(lambda1))));
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = cos(phi2) * sin(phi1)
t_2 = atan2((cos(phi2) * (sin(lambda1) - t_0)), ((cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)))))
if (phi1 <= (-1.46d-5)) then
tmp = t_2
else if (phi1 <= 9.5d-32) then
tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - t_0)), (sin(phi2) - (t_1 * cos(lambda1))))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.atan2((Math.cos(phi2) * (Math.sin(lambda1) - t_0)), ((Math.cos(phi1) * Math.sin(phi2)) - (t_1 * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -1.46e-5) {
tmp = t_2;
} else if (phi1 <= 9.5e-32) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - t_0)), (Math.sin(phi2) - (t_1 * Math.cos(lambda1))));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.atan2((math.cos(phi2) * (math.sin(lambda1) - t_0)), ((math.cos(phi1) * math.sin(phi2)) - (t_1 * math.cos((lambda1 - lambda2))))) tmp = 0 if phi1 <= -1.46e-5: tmp = t_2 elif phi1 <= 9.5e-32: tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - t_0)), (math.sin(phi2) - (t_1 * math.cos(lambda1)))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = atan(Float64(cos(phi2) * Float64(sin(lambda1) - t_0)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi1 <= -1.46e-5) tmp = t_2; elseif (phi1 <= 9.5e-32) tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - t_0)), Float64(sin(phi2) - Float64(t_1 * cos(lambda1)))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = cos(phi2) * sin(phi1); t_2 = atan2((cos(phi2) * (sin(lambda1) - t_0)), ((cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi1 <= -1.46e-5) tmp = t_2; elseif (phi1 <= 9.5e-32) tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - t_0)), (sin(phi2) - (t_1 * cos(lambda1)))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.46e-5], t$95$2, If[LessEqual[phi1, 9.5e-32], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 - t\_0\right)}{\cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -1.46 \cdot 10^{-5}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 9.5 \cdot 10^{-32}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - t\_0\right)}{\sin \phi_2 - t\_1 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if phi1 < -1.46000000000000008e-5 or 9.4999999999999999e-32 < phi1 Initial program 83.1%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6485.3
Applied rewrites85.3%
Taylor expanded in lambda2 around 0
lower-sin.f6484.1
Applied rewrites84.1%
if -1.46000000000000008e-5 < phi1 < 9.4999999999999999e-32Initial program 74.9%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.3
Applied rewrites99.3%
Taylor expanded in lambda2 around 0
lower-cos.f6499.4
Applied rewrites99.4%
Taylor expanded in phi1 around 0
lower-sin.f6499.4
Applied rewrites99.4%
Final simplification91.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (cos phi2) (sin phi1)))
(t_3 (sin (- lambda1 lambda2))))
(if (<= phi1 -1.46e-5)
(atan2 (* (cos phi2) t_3) (+ t_0 (/ t_1 (/ -1.0 t_2))))
(if (<= phi1 2.75e-43)
(atan2
(*
(cos phi2)
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2))))
(- (sin phi2) (* t_2 (cos lambda1))))
(atan2 (/ (cos phi2) (/ 1.0 t_3)) (- t_0 (* t_2 t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = cos(phi2) * sin(phi1);
double t_3 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.46e-5) {
tmp = atan2((cos(phi2) * t_3), (t_0 + (t_1 / (-1.0 / t_2))));
} else if (phi1 <= 2.75e-43) {
tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (sin(phi2) - (t_2 * cos(lambda1))));
} else {
tmp = atan2((cos(phi2) / (1.0 / t_3)), (t_0 - (t_2 * t_1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = cos(phi2) * sin(phi1)
t_3 = sin((lambda1 - lambda2))
if (phi1 <= (-1.46d-5)) then
tmp = atan2((cos(phi2) * t_3), (t_0 + (t_1 / ((-1.0d0) / t_2))))
else if (phi1 <= 2.75d-43) then
tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (sin(phi2) - (t_2 * cos(lambda1))))
else
tmp = atan2((cos(phi2) / (1.0d0 / t_3)), (t_0 - (t_2 * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.cos(phi2) * Math.sin(phi1);
double t_3 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.46e-5) {
tmp = Math.atan2((Math.cos(phi2) * t_3), (t_0 + (t_1 / (-1.0 / t_2))));
} else if (phi1 <= 2.75e-43) {
tmp = Math.atan2((Math.cos(phi2) * ((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.sin(phi2) - (t_2 * Math.cos(lambda1))));
} else {
tmp = Math.atan2((Math.cos(phi2) / (1.0 / t_3)), (t_0 - (t_2 * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.cos(phi2) * math.sin(phi1) t_3 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= -1.46e-5: tmp = math.atan2((math.cos(phi2) * t_3), (t_0 + (t_1 / (-1.0 / t_2)))) elif phi1 <= 2.75e-43: tmp = math.atan2((math.cos(phi2) * ((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.sin(phi2) - (t_2 * math.cos(lambda1)))) else: tmp = math.atan2((math.cos(phi2) / (1.0 / t_3)), (t_0 - (t_2 * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(cos(phi2) * sin(phi1)) t_3 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -1.46e-5) tmp = atan(Float64(cos(phi2) * t_3), Float64(t_0 + Float64(t_1 / Float64(-1.0 / t_2)))); elseif (phi1 <= 2.75e-43) tmp = atan(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(sin(phi2) - Float64(t_2 * cos(lambda1)))); else tmp = atan(Float64(cos(phi2) / Float64(1.0 / t_3)), Float64(t_0 - Float64(t_2 * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = cos(phi2) * sin(phi1); t_3 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -1.46e-5) tmp = atan2((cos(phi2) * t_3), (t_0 + (t_1 / (-1.0 / t_2)))); elseif (phi1 <= 2.75e-43) tmp = atan2((cos(phi2) * ((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2)))), (sin(phi2) - (t_2 * cos(lambda1)))); else tmp = atan2((cos(phi2) / (1.0 / t_3)), (t_0 - (t_2 * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.46e-5], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision] / N[(t$95$0 + N[(t$95$1 / N[(-1.0 / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.75e-43], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] / N[(1.0 / t$95$3), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \cos \phi_2 \cdot \sin \phi_1\\
t_3 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.46 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_3}{t\_0 + \frac{t\_1}{\frac{-1}{t\_2}}}\\
\mathbf{elif}\;\phi_1 \leq 2.75 \cdot 10^{-43}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\sin \phi_2 - t\_2 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{\cos \phi_2}{\frac{1}{t\_3}}}{t\_0 - t\_2 \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -1.46000000000000008e-5Initial program 79.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
clear-numN/A
sin-cos-multN/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lower-/.f6479.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.8
Applied rewrites79.8%
if -1.46000000000000008e-5 < phi1 < 2.75000000000000006e-43Initial program 74.1%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.3
Applied rewrites99.3%
Taylor expanded in lambda2 around 0
lower-cos.f6499.4
Applied rewrites99.4%
Taylor expanded in phi1 around 0
lower-sin.f6499.4
Applied rewrites99.4%
if 2.75000000000000006e-43 < phi1 Initial program 86.5%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.2
Applied rewrites88.2%
lift-*.f64N/A
Applied rewrites86.6%
Final simplification91.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(/ (cos phi2) (/ 1.0 (sin (- lambda1 lambda2))))
(-
(* (cos phi1) (sin phi2))
(* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))))
(if (<= phi2 -4.4e-15)
t_0
(if (<= phi2 0.00086)
(atan2
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((cos(phi2) / (1.0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi2 <= -4.4e-15) {
tmp = t_0;
} else if (phi2 <= 0.00086) {
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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) :: tmp
t_0 = atan2((cos(phi2) / (1.0d0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
if (phi2 <= (-4.4d-15)) then
tmp = t_0
else if (phi2 <= 0.00086d0) then
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.cos(phi2) / (1.0 / Math.sin((lambda1 - lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi2 <= -4.4e-15) {
tmp = t_0;
} else if (phi2 <= 0.00086) {
tmp = Math.atan2(((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.cos(phi2) / (1.0 / math.sin((lambda1 - lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) tmp = 0 if phi2 <= -4.4e-15: tmp = t_0 elif phi2 <= 0.00086: tmp = math.atan2(((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(cos(phi2) / Float64(1.0 / sin(Float64(lambda1 - lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi2 <= -4.4e-15) tmp = t_0; elseif (phi2 <= 0.00086) tmp = atan(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((cos(phi2) / (1.0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi2 <= -4.4e-15) tmp = t_0; elseif (phi2 <= 0.00086) tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] / N[(1.0 / N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.4e-15], t$95$0, If[LessEqual[phi2, 0.00086], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\frac{\cos \phi_2}{\frac{1}{\sin \left(\lambda_1 - \lambda_2\right)}}}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 0.00086:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -4.39999999999999971e-15 or 8.59999999999999979e-4 < phi2 Initial program 75.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6491.1
Applied rewrites91.1%
lift-*.f64N/A
Applied rewrites75.9%
if -4.39999999999999971e-15 < phi2 < 8.59999999999999979e-4Initial program 82.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6482.7
Applied rewrites82.7%
Taylor expanded in phi1 around 0
lower-sin.f6482.6
Applied rewrites82.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6482.6
Applied rewrites82.6%
Applied rewrites93.0%
Final simplification83.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (cos phi2) (sin phi1))))
(if (<= lambda2 -1.2e+84)
(atan2
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(if (<= lambda2 -2.5e-148)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(if (<= lambda2 4.2e-51)
(atan2 (* (cos phi2) (sin lambda1)) (- t_0 (* t_1 (cos lambda1))))
(atan2
(* (cos phi2) (sin (- lambda2)))
(- t_0 (* t_1 (cos lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double tmp;
if (lambda2 <= -1.2e+84) {
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else if (lambda2 <= -2.5e-148) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else if (lambda2 <= 4.2e-51) {
tmp = atan2((cos(phi2) * sin(lambda1)), (t_0 - (t_1 * cos(lambda1))));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_1 * cos(lambda2))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
if (lambda2 <= (-1.2d+84)) then
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else if (lambda2 <= (-2.5d-148)) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else if (lambda2 <= 4.2d-51) then
tmp = atan2((cos(phi2) * sin(lambda1)), (t_0 - (t_1 * cos(lambda1))))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_1 * cos(lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if (lambda2 <= -1.2e+84) {
tmp = Math.atan2(((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else if (lambda2 <= -2.5e-148) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else if (lambda2 <= 4.2e-51) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), (t_0 - (t_1 * Math.cos(lambda1))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (t_0 - (t_1 * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) tmp = 0 if lambda2 <= -1.2e+84: tmp = math.atan2(((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) elif lambda2 <= -2.5e-148: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) elif lambda2 <= 4.2e-51: tmp = math.atan2((math.cos(phi2) * math.sin(lambda1)), (t_0 - (t_1 * math.cos(lambda1)))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (t_0 - (t_1 * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if (lambda2 <= -1.2e+84) tmp = atan(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); elseif (lambda2 <= -2.5e-148) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); elseif (lambda2 <= 4.2e-51) tmp = atan(Float64(cos(phi2) * sin(lambda1)), Float64(t_0 - Float64(t_1 * cos(lambda1)))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(t_0 - Float64(t_1 * cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); tmp = 0.0; if (lambda2 <= -1.2e+84) tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); elseif (lambda2 <= -2.5e-148) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); elseif (lambda2 <= 4.2e-51) tmp = atan2((cos(phi2) * sin(lambda1)), (t_0 - (t_1 * cos(lambda1)))); else tmp = atan2((cos(phi2) * sin(-lambda2)), (t_0 - (t_1 * cos(lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.2e+84], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, -2.5e-148], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 4.2e-51], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_2 \leq -1.2 \cdot 10^{+84}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{elif}\;\lambda_2 \leq -2.5 \cdot 10^{-148}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;\lambda_2 \leq 4.2 \cdot 10^{-51}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda2 < -1.2e84Initial program 42.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6435.5
Applied rewrites35.5%
Taylor expanded in phi1 around 0
lower-sin.f6435.4
Applied rewrites35.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6435.5
Applied rewrites35.5%
Applied rewrites51.1%
if -1.2e84 < lambda2 < -2.4999999999999999e-148Initial program 86.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6470.2
Applied rewrites70.2%
if -2.4999999999999999e-148 < lambda2 < 4.20000000000000003e-51Initial program 99.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-cos.f6499.8
Applied rewrites99.8%
Taylor expanded in lambda2 around 0
lower-sin.f6494.7
Applied rewrites94.7%
if 4.20000000000000003e-51 < lambda2 Initial program 69.7%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6468.7
Applied rewrites68.7%
Taylor expanded in lambda1 around 0
neg-mul-1N/A
lower-neg.f6466.2
Applied rewrites66.2%
Final simplification74.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
(* (cos phi1) (sin phi2))
(* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))))
(if (<= phi2 -4.4e-15)
t_0
(if (<= phi2 0.00086)
(atan2
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi2 <= -4.4e-15) {
tmp = t_0;
} else if (phi2 <= 0.00086) {
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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) :: tmp
t_0 = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
if (phi2 <= (-4.4d-15)) then
tmp = t_0
else if (phi2 <= 0.00086d0) then
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi2 <= -4.4e-15) {
tmp = t_0;
} else if (phi2 <= 0.00086) {
tmp = Math.atan2(((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) tmp = 0 if phi2 <= -4.4e-15: tmp = t_0 elif phi2 <= 0.00086: tmp = math.atan2(((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi2 <= -4.4e-15) tmp = t_0; elseif (phi2 <= 0.00086) tmp = atan(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi2 <= -4.4e-15) tmp = t_0; elseif (phi2 <= 0.00086) tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.4e-15], t$95$0, If[LessEqual[phi2, 0.00086], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 0.00086:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -4.39999999999999971e-15 or 8.59999999999999979e-4 < phi2 Initial program 75.8%
if -4.39999999999999971e-15 < phi2 < 8.59999999999999979e-4Initial program 82.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6482.7
Applied rewrites82.7%
Taylor expanded in phi1 around 0
lower-sin.f6482.6
Applied rewrites82.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6482.6
Applied rewrites82.6%
Applied rewrites93.0%
Final simplification83.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (cos phi2) (sin phi1)))
(t_2 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi2 -0.000105)
(atan2 t_2 (- t_0 (* t_1 (cos lambda2))))
(if (<= phi2 0.001)
(atan2
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2 t_2 (- t_0 (* t_1 (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(phi2) * sin(phi1);
double t_2 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.000105) {
tmp = atan2(t_2, (t_0 - (t_1 * cos(lambda2))));
} else if (phi2 <= 0.001) {
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2(t_2, (t_0 - (t_1 * cos(lambda1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos(phi2) * sin(phi1)
t_2 = cos(phi2) * sin((lambda1 - lambda2))
if (phi2 <= (-0.000105d0)) then
tmp = atan2(t_2, (t_0 - (t_1 * cos(lambda2))))
else if (phi2 <= 0.001d0) then
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2(t_2, (t_0 - (t_1 * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos(phi2) * Math.sin(phi1);
double t_2 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -0.000105) {
tmp = Math.atan2(t_2, (t_0 - (t_1 * Math.cos(lambda2))));
} else if (phi2 <= 0.001) {
tmp = Math.atan2(((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2(t_2, (t_0 - (t_1 * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos(phi2) * math.sin(phi1) t_2 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -0.000105: tmp = math.atan2(t_2, (t_0 - (t_1 * math.cos(lambda2)))) elif phi2 <= 0.001: tmp = math.atan2(((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2(t_2, (t_0 - (t_1 * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * sin(phi1)) t_2 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2 <= -0.000105) tmp = atan(t_2, Float64(t_0 - Float64(t_1 * cos(lambda2)))); elseif (phi2 <= 0.001) tmp = atan(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(t_2, Float64(t_0 - Float64(t_1 * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos(phi2) * sin(phi1); t_2 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -0.000105) tmp = atan2(t_2, (t_0 - (t_1 * cos(lambda2)))); elseif (phi2 <= 0.001) tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2(t_2, (t_0 - (t_1 * cos(lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.000105], N[ArcTan[t$95$2 / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 0.001], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \sin \phi_1\\
t_2 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.000105:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{elif}\;\phi_2 \leq 0.001:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if phi2 < -1.05e-4Initial program 78.9%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6470.1
Applied rewrites70.1%
if -1.05e-4 < phi2 < 1e-3Initial program 83.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6483.1
Applied rewrites83.1%
Taylor expanded in phi1 around 0
lower-sin.f6482.8
Applied rewrites82.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6482.8
Applied rewrites82.8%
Applied rewrites92.9%
if 1e-3 < phi2 Initial program 72.2%
Taylor expanded in lambda2 around 0
lower-cos.f6466.7
Applied rewrites66.7%
Final simplification80.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(-
(* (cos phi1) (sin phi2))
(* (* (cos phi2) (sin phi1)) (cos lambda1))))))
(if (<= phi2 -4.4e-15)
t_0
(if (<= phi2 0.001)
(atan2
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos(lambda1))));
double tmp;
if (phi2 <= -4.4e-15) {
tmp = t_0;
} else if (phi2 <= 0.001) {
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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) :: tmp
t_0 = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos(lambda1))))
if (phi2 <= (-4.4d-15)) then
tmp = t_0
else if (phi2 <= 0.001d0) then
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos(lambda1))));
double tmp;
if (phi2 <= -4.4e-15) {
tmp = t_0;
} else if (phi2 <= 0.001) {
tmp = Math.atan2(((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos(phi2) * math.sin(phi1)) * math.cos(lambda1)))) tmp = 0 if phi2 <= -4.4e-15: tmp = t_0 elif phi2 <= 0.001: tmp = math.atan2(((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(lambda1)))) tmp = 0.0 if (phi2 <= -4.4e-15) tmp = t_0; elseif (phi2 <= 0.001) tmp = atan(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - ((cos(phi2) * sin(phi1)) * cos(lambda1)))); tmp = 0.0; if (phi2 <= -4.4e-15) tmp = t_0; elseif (phi2 <= 0.001) tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.4e-15], t$95$0, If[LessEqual[phi2, 0.001], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \lambda_1}\\
\mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 0.001:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < -4.39999999999999971e-15 or 1e-3 < phi2 Initial program 75.8%
Taylor expanded in lambda2 around 0
lower-cos.f6468.1
Applied rewrites68.1%
if -4.39999999999999971e-15 < phi2 < 1e-3Initial program 82.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6482.7
Applied rewrites82.7%
Taylor expanded in phi1 around 0
lower-sin.f6482.6
Applied rewrites82.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6482.6
Applied rewrites82.6%
Applied rewrites93.0%
Final simplification79.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))))
(if (<= phi2 -4.4e-15)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
(if (<= phi2 0.0029)
(atan2
(- (* (cos lambda2) (sin lambda1)) (* (cos lambda1) (sin lambda2)))
(- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(atan2
(* (cos phi2) (sin lambda1))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double tmp;
if (phi2 <= -4.4e-15) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else if (phi2 <= 0.0029) {
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = atan2((cos(phi2) * sin(lambda1)), (t_0 - ((cos(phi2) * sin(phi1)) * cos(lambda1))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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) :: tmp
t_0 = cos(phi1) * sin(phi2)
if (phi2 <= (-4.4d-15)) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else if (phi2 <= 0.0029d0) then
tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
else
tmp = atan2((cos(phi2) * sin(lambda1)), (t_0 - ((cos(phi2) * sin(phi1)) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= -4.4e-15) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else if (phi2 <= 0.0029) {
tmp = Math.atan2(((Math.cos(lambda2) * Math.sin(lambda1)) - (Math.cos(lambda1) * Math.sin(lambda2))), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) tmp = 0 if phi2 <= -4.4e-15: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) elif phi2 <= 0.0029: tmp = math.atan2(((math.cos(lambda2) * math.sin(lambda1)) - (math.cos(lambda1) * math.sin(lambda2))), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))))) else: tmp = math.atan2((math.cos(phi2) * math.sin(lambda1)), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -4.4e-15) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); elseif (phi2 <= 0.0029) tmp = atan(Float64(Float64(cos(lambda2) * sin(lambda1)) - Float64(cos(lambda1) * sin(lambda2))), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = atan(Float64(cos(phi2) * sin(lambda1)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= -4.4e-15) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); elseif (phi2 <= 0.0029) tmp = atan2(((cos(lambda2) * sin(lambda1)) - (cos(lambda1) * sin(lambda2))), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); else tmp = atan2((cos(phi2) * sin(lambda1)), (t_0 - ((cos(phi2) * sin(phi1)) * cos(lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -4.4e-15], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 0.0029], N[ArcTan[N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{-15}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;\phi_2 \leq 0.0029:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \lambda_2 \cdot \sin \lambda_1 - \cos \lambda_1 \cdot \sin \lambda_2}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if phi2 < -4.39999999999999971e-15Initial program 79.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6453.2
Applied rewrites53.2%
if -4.39999999999999971e-15 < phi2 < 0.0029Initial program 82.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6482.7
Applied rewrites82.7%
Taylor expanded in phi1 around 0
lower-sin.f6482.6
Applied rewrites82.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6482.6
Applied rewrites82.6%
Applied rewrites93.0%
if 0.0029 < phi2 Initial program 72.2%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6487.6
Applied rewrites87.6%
Taylor expanded in lambda2 around 0
lower-cos.f6482.1
Applied rewrites82.1%
Taylor expanded in lambda2 around 0
lower-sin.f6450.8
Applied rewrites50.8%
Final simplification71.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(atan2
(* (cos phi2) (sin lambda1))
(- t_0 (* (* (cos phi2) (sin phi1)) (cos lambda1))))))
(if (<= lambda1 -1.95e+37)
t_1
(if (<= lambda1 8.8e-59)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- t_0 (* (sin phi1) (cos (- lambda1 lambda2)))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = atan2((cos(phi2) * sin(lambda1)), (t_0 - ((cos(phi2) * sin(phi1)) * cos(lambda1))));
double tmp;
if (lambda1 <= -1.95e+37) {
tmp = t_1;
} else if (lambda1 <= 8.8e-59) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = atan2((cos(phi2) * sin(lambda1)), (t_0 - ((cos(phi2) * sin(phi1)) * cos(lambda1))))
if (lambda1 <= (-1.95d+37)) then
tmp = t_1
else if (lambda1 <= 8.8d-59) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2)))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), (t_0 - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos(lambda1))));
double tmp;
if (lambda1 <= -1.95e+37) {
tmp = t_1;
} else if (lambda1 <= 8.8e-59) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (t_0 - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.atan2((math.cos(phi2) * math.sin(lambda1)), (t_0 - ((math.cos(phi2) * math.sin(phi1)) * math.cos(lambda1)))) tmp = 0 if lambda1 <= -1.95e+37: tmp = t_1 elif lambda1 <= 8.8e-59: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (t_0 - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = atan(Float64(cos(phi2) * sin(lambda1)), Float64(t_0 - Float64(Float64(cos(phi2) * sin(phi1)) * cos(lambda1)))) tmp = 0.0 if (lambda1 <= -1.95e+37) tmp = t_1; elseif (lambda1 <= 8.8e-59) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(t_0 - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = atan2((cos(phi2) * sin(lambda1)), (t_0 - ((cos(phi2) * sin(phi1)) * cos(lambda1)))); tmp = 0.0; if (lambda1 <= -1.95e+37) tmp = t_1; elseif (lambda1 <= 8.8e-59) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (t_0 - (sin(phi1) * cos((lambda1 - lambda2))))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.95e+37], t$95$1, If[LessEqual[lambda1, 8.8e-59], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_0 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \lambda_1}\\
\mathbf{if}\;\lambda_1 \leq -1.95 \cdot 10^{+37}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 8.8 \cdot 10^{-59}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda1 < -1.9499999999999999e37 or 8.7999999999999995e-59 < lambda1 Initial program 63.9%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6486.9
Applied rewrites86.9%
Taylor expanded in lambda2 around 0
lower-cos.f6485.1
Applied rewrites85.1%
Taylor expanded in lambda2 around 0
lower-sin.f6462.8
Applied rewrites62.8%
if -1.9499999999999999e37 < lambda1 < 8.7999999999999995e-59Initial program 97.4%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6480.2
Applied rewrites80.2%
Final simplification70.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos (- lambda2 lambda1)))))
(if (<= lambda2 -1.26e-130)
(atan2
(/ 1.0 (/ 1.0 (sin (- lambda1 lambda2))))
(- (* (cos phi1) (sin phi2)) t_0))
(if (<= lambda2 4.8e-27)
(atan2
(* (cos phi2) (sin lambda1))
(- (sin phi2) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2)))))
(atan2 (* (cos phi2) (sin (- lambda2))) (- (sin phi2) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos((lambda2 - lambda1));
double tmp;
if (lambda2 <= -1.26e-130) {
tmp = atan2((1.0 / (1.0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - t_0));
} else if (lambda2 <= 4.8e-27) {
tmp = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), (sin(phi2) - t_0));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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) :: tmp
t_0 = sin(phi1) * cos((lambda2 - lambda1))
if (lambda2 <= (-1.26d-130)) then
tmp = atan2((1.0d0 / (1.0d0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - t_0))
else if (lambda2 <= 4.8d-27) then
tmp = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
else
tmp = atan2((cos(phi2) * sin(-lambda2)), (sin(phi2) - t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos((lambda2 - lambda1));
double tmp;
if (lambda2 <= -1.26e-130) {
tmp = Math.atan2((1.0 / (1.0 / Math.sin((lambda1 - lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - t_0));
} else if (lambda2 <= 4.8e-27) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), (Math.sin(phi2) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), (Math.sin(phi2) - t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos((lambda2 - lambda1)) tmp = 0 if lambda2 <= -1.26e-130: tmp = math.atan2((1.0 / (1.0 / math.sin((lambda1 - lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - t_0)) elif lambda2 <= 4.8e-27: tmp = math.atan2((math.cos(phi2) * math.sin(lambda1)), (math.sin(phi2) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), (math.sin(phi2) - t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))) tmp = 0.0 if (lambda2 <= -1.26e-130) tmp = atan(Float64(1.0 / Float64(1.0 / sin(Float64(lambda1 - lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)); elseif (lambda2 <= 4.8e-27) tmp = atan(Float64(cos(phi2) * sin(lambda1)), Float64(sin(phi2) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), Float64(sin(phi2) - t_0)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos((lambda2 - lambda1)); tmp = 0.0; if (lambda2 <= -1.26e-130) tmp = atan2((1.0 / (1.0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - t_0)); elseif (lambda2 <= 4.8e-27) tmp = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); else tmp = atan2((cos(phi2) * sin(-lambda2)), (sin(phi2) - t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.26e-130], N[ArcTan[N[(1.0 / N[(1.0 / N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 4.8e-27], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\lambda_2 \leq -1.26 \cdot 10^{-130}:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{1}{\frac{1}{\sin \left(\lambda_1 - \lambda_2\right)}}}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\mathbf{elif}\;\lambda_2 \leq 4.8 \cdot 10^{-27}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{\sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{\sin \phi_2 - t\_0}\\
\end{array}
\end{array}
if lambda2 < -1.2599999999999999e-130Initial program 63.4%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6447.1
Applied rewrites47.1%
Applied rewrites47.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.2
Applied rewrites47.2%
if -1.2599999999999999e-130 < lambda2 < 4.80000000000000004e-27Initial program 99.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.1
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-sin.f6446.7
Applied rewrites46.7%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6474.1
Applied rewrites74.1%
if 4.80000000000000004e-27 < lambda2 Initial program 67.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.0
Applied rewrites48.0%
Taylor expanded in phi1 around 0
lower-sin.f6447.7
Applied rewrites47.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.5
Applied rewrites47.5%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-neg.f6454.2
Applied rewrites54.2%
Final simplification59.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin phi1))))
(if (<= lambda1 0.03)
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(- (sin phi2) (* t_0 (cos lambda2))))
(atan2
(* (cos phi2) (sin lambda1))
(- (sin phi2) (* t_0 (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin(phi1);
double tmp;
if (lambda1 <= 0.03) {
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (t_0 * cos(lambda2))));
} else {
tmp = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2)))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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) :: tmp
t_0 = cos(phi2) * sin(phi1)
if (lambda1 <= 0.03d0) then
tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (t_0 * cos(lambda2))))
else
tmp = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin(phi1);
double tmp;
if (lambda1 <= 0.03) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - (t_0 * Math.cos(lambda2))));
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), (Math.sin(phi2) - (t_0 * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin(phi1) tmp = 0 if lambda1 <= 0.03: tmp = math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - (t_0 * math.cos(lambda2)))) else: tmp = math.atan2((math.cos(phi2) * math.sin(lambda1)), (math.sin(phi2) - (t_0 * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(phi1)) tmp = 0.0 if (lambda1 <= 0.03) tmp = atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(t_0 * cos(lambda2)))); else tmp = atan(Float64(cos(phi2) * sin(lambda1)), Float64(sin(phi2) - Float64(t_0 * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin(phi1); tmp = 0.0; if (lambda1 <= 0.03) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - (t_0 * cos(lambda2)))); else tmp = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - (t_0 * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, 0.03], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \phi_1\\
\mathbf{if}\;\lambda_1 \leq 0.03:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - t\_0 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{\sin \phi_2 - t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if lambda1 < 0.029999999999999999Initial program 86.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6481.8
Applied rewrites81.8%
Taylor expanded in phi1 around 0
lower-sin.f6466.8
Applied rewrites66.8%
if 0.029999999999999999 < lambda1 Initial program 61.2%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6441.4
Applied rewrites41.4%
Taylor expanded in phi1 around 0
lower-sin.f6441.1
Applied rewrites41.1%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6455.5
Applied rewrites55.5%
Final simplification63.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (* (cos phi1) (sin phi2)) (* (sin phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6465.5
Applied rewrites65.5%
Final simplification65.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (- (sin phi2) (* (* (cos phi2) (sin phi1)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.sin(phi2) - ((Math.cos(phi2) * Math.sin(phi1)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.sin(phi2) - ((math.cos(phi2) * math.sin(phi1)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(sin(phi2) - Float64(Float64(cos(phi2) * sin(phi1)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((cos(phi2) * sin((lambda1 - lambda2))), (sin(phi2) - ((cos(phi2) * sin(phi1)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \left(\cos \phi_2 \cdot \sin \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 79.1%
Taylor expanded in phi1 around 0
lower-sin.f6463.9
Applied rewrites63.9%
Final simplification63.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos (- lambda2 lambda1))))
(t_1 (- (sin phi2) t_0)))
(if (<= lambda2 -1.26e-130)
(atan2
(/ 1.0 (/ 1.0 (sin (- lambda1 lambda2))))
(- (* (cos phi1) (sin phi2)) t_0))
(if (<= lambda2 4.8e-27)
(atan2 (* (cos phi2) (sin lambda1)) t_1)
(atan2 (* (cos phi2) (sin (- lambda2))) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos((lambda2 - lambda1));
double t_1 = sin(phi2) - t_0;
double tmp;
if (lambda2 <= -1.26e-130) {
tmp = atan2((1.0 / (1.0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - t_0));
} else if (lambda2 <= 4.8e-27) {
tmp = atan2((cos(phi2) * sin(lambda1)), t_1);
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), t_1);
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(phi1) * cos((lambda2 - lambda1))
t_1 = sin(phi2) - t_0
if (lambda2 <= (-1.26d-130)) then
tmp = atan2((1.0d0 / (1.0d0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - t_0))
else if (lambda2 <= 4.8d-27) then
tmp = atan2((cos(phi2) * sin(lambda1)), t_1)
else
tmp = atan2((cos(phi2) * sin(-lambda2)), t_1)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos((lambda2 - lambda1));
double t_1 = Math.sin(phi2) - t_0;
double tmp;
if (lambda2 <= -1.26e-130) {
tmp = Math.atan2((1.0 / (1.0 / Math.sin((lambda1 - lambda2)))), ((Math.cos(phi1) * Math.sin(phi2)) - t_0));
} else if (lambda2 <= 4.8e-27) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), t_1);
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos((lambda2 - lambda1)) t_1 = math.sin(phi2) - t_0 tmp = 0 if lambda2 <= -1.26e-130: tmp = math.atan2((1.0 / (1.0 / math.sin((lambda1 - lambda2)))), ((math.cos(phi1) * math.sin(phi2)) - t_0)) elif lambda2 <= 4.8e-27: tmp = math.atan2((math.cos(phi2) * math.sin(lambda1)), t_1) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))) t_1 = Float64(sin(phi2) - t_0) tmp = 0.0 if (lambda2 <= -1.26e-130) tmp = atan(Float64(1.0 / Float64(1.0 / sin(Float64(lambda1 - lambda2)))), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)); elseif (lambda2 <= 4.8e-27) tmp = atan(Float64(cos(phi2) * sin(lambda1)), t_1); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), t_1); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos((lambda2 - lambda1)); t_1 = sin(phi2) - t_0; tmp = 0.0; if (lambda2 <= -1.26e-130) tmp = atan2((1.0 / (1.0 / sin((lambda1 - lambda2)))), ((cos(phi1) * sin(phi2)) - t_0)); elseif (lambda2 <= 4.8e-27) tmp = atan2((cos(phi2) * sin(lambda1)), t_1); else tmp = atan2((cos(phi2) * sin(-lambda2)), t_1); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[lambda2, -1.26e-130], N[ArcTan[N[(1.0 / N[(1.0 / N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 4.8e-27], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_2 - t\_0\\
\mathbf{if}\;\lambda_2 \leq -1.26 \cdot 10^{-130}:\\
\;\;\;\;\tan^{-1}_* \frac{\frac{1}{\frac{1}{\sin \left(\lambda_1 - \lambda_2\right)}}}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\mathbf{elif}\;\lambda_2 \leq 4.8 \cdot 10^{-27}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_1}\\
\end{array}
\end{array}
if lambda2 < -1.2599999999999999e-130Initial program 63.4%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6447.1
Applied rewrites47.1%
Applied rewrites47.2%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.2
Applied rewrites47.2%
if -1.2599999999999999e-130 < lambda2 < 4.80000000000000004e-27Initial program 99.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.1
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-sin.f6446.7
Applied rewrites46.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.6
Applied rewrites47.6%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6473.5
Applied rewrites73.5%
if 4.80000000000000004e-27 < lambda2 Initial program 67.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.0
Applied rewrites48.0%
Taylor expanded in phi1 around 0
lower-sin.f6447.7
Applied rewrites47.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.5
Applied rewrites47.5%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-neg.f6454.2
Applied rewrites54.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos (- lambda2 lambda1))))
(t_1 (- (sin phi2) t_0)))
(if (<= lambda2 -1.26e-130)
(atan2 (sin (- lambda1 lambda2)) (- (* (cos phi1) (sin phi2)) t_0))
(if (<= lambda2 4.8e-27)
(atan2 (* (cos phi2) (sin lambda1)) t_1)
(atan2 (* (cos phi2) (sin (- lambda2))) t_1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos((lambda2 - lambda1));
double t_1 = sin(phi2) - t_0;
double tmp;
if (lambda2 <= -1.26e-130) {
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - t_0));
} else if (lambda2 <= 4.8e-27) {
tmp = atan2((cos(phi2) * sin(lambda1)), t_1);
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), t_1);
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(phi1) * cos((lambda2 - lambda1))
t_1 = sin(phi2) - t_0
if (lambda2 <= (-1.26d-130)) then
tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - t_0))
else if (lambda2 <= 4.8d-27) then
tmp = atan2((cos(phi2) * sin(lambda1)), t_1)
else
tmp = atan2((cos(phi2) * sin(-lambda2)), t_1)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.cos((lambda2 - lambda1));
double t_1 = Math.sin(phi2) - t_0;
double tmp;
if (lambda2 <= -1.26e-130) {
tmp = Math.atan2(Math.sin((lambda1 - lambda2)), ((Math.cos(phi1) * Math.sin(phi2)) - t_0));
} else if (lambda2 <= 4.8e-27) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), t_1);
} else {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), t_1);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.cos((lambda2 - lambda1)) t_1 = math.sin(phi2) - t_0 tmp = 0 if lambda2 <= -1.26e-130: tmp = math.atan2(math.sin((lambda1 - lambda2)), ((math.cos(phi1) * math.sin(phi2)) - t_0)) elif lambda2 <= 4.8e-27: tmp = math.atan2((math.cos(phi2) * math.sin(lambda1)), t_1) else: tmp = math.atan2((math.cos(phi2) * math.sin(-lambda2)), t_1) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))) t_1 = Float64(sin(phi2) - t_0) tmp = 0.0 if (lambda2 <= -1.26e-130) tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)); elseif (lambda2 <= 4.8e-27) tmp = atan(Float64(cos(phi2) * sin(lambda1)), t_1); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), t_1); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * cos((lambda2 - lambda1)); t_1 = sin(phi2) - t_0; tmp = 0.0; if (lambda2 <= -1.26e-130) tmp = atan2(sin((lambda1 - lambda2)), ((cos(phi1) * sin(phi2)) - t_0)); elseif (lambda2 <= 4.8e-27) tmp = atan2((cos(phi2) * sin(lambda1)), t_1); else tmp = atan2((cos(phi2) * sin(-lambda2)), t_1); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[lambda2, -1.26e-130], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 4.8e-27], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / t$95$1], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_2 - t\_0\\
\mathbf{if}\;\lambda_2 \leq -1.26 \cdot 10^{-130}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\mathbf{elif}\;\lambda_2 \leq 4.8 \cdot 10^{-27}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_1}\\
\end{array}
\end{array}
if lambda2 < -1.2599999999999999e-130Initial program 63.4%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6447.1
Applied rewrites47.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-sin.f6447.2
Applied rewrites47.2%
if -1.2599999999999999e-130 < lambda2 < 4.80000000000000004e-27Initial program 99.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.1
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-sin.f6446.7
Applied rewrites46.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.6
Applied rewrites47.6%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6473.5
Applied rewrites73.5%
if 4.80000000000000004e-27 < lambda2 Initial program 67.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.0
Applied rewrites48.0%
Taylor expanded in phi1 around 0
lower-sin.f6447.7
Applied rewrites47.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.5
Applied rewrites47.5%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-neg.f6454.2
Applied rewrites54.2%
Final simplification59.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))
(if (<= lambda2 -2.1e-147)
(atan2 (* (sin (- lambda1 lambda2)) (fma -0.5 (* phi2 phi2) 1.0)) t_0)
(if (<= lambda2 4.8e-27)
(atan2 (* (cos phi2) (sin lambda1)) t_0)
(atan2 (* (cos phi2) (sin (- lambda2))) t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)));
double tmp;
if (lambda2 <= -2.1e-147) {
tmp = atan2((sin((lambda1 - lambda2)) * fma(-0.5, (phi2 * phi2), 1.0)), t_0);
} else if (lambda2 <= 4.8e-27) {
tmp = atan2((cos(phi2) * sin(lambda1)), t_0);
} else {
tmp = atan2((cos(phi2) * sin(-lambda2)), t_0);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1)))) tmp = 0.0 if (lambda2 <= -2.1e-147) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * fma(-0.5, Float64(phi2 * phi2), 1.0)), t_0); elseif (lambda2 <= 4.8e-27) tmp = atan(Float64(cos(phi2) * sin(lambda1)), t_0); else tmp = atan(Float64(cos(phi2) * sin(Float64(-lambda2))), t_0); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -2.1e-147], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(-0.5 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], If[LessEqual[lambda2, 4.8e-27], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\lambda_2 \leq -2.1 \cdot 10^{-147}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(-0.5, \phi_2 \cdot \phi_2, 1\right)}{t\_0}\\
\mathbf{elif}\;\lambda_2 \leq 4.8 \cdot 10^{-27}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_0}\\
\end{array}
\end{array}
if lambda2 < -2.1e-147Initial program 65.5%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6446.8
Applied rewrites46.8%
Taylor expanded in phi1 around 0
lower-sin.f6445.4
Applied rewrites45.4%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6445.5
Applied rewrites45.5%
Taylor expanded in phi2 around 0
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
lower-sin.f64N/A
+-commutativeN/A
distribute-neg-inN/A
mul-1-negN/A
remove-double-negN/A
sub-negN/A
lower--.f6446.5
Applied rewrites46.5%
if -2.1e-147 < lambda2 < 4.80000000000000004e-27Initial program 99.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.4
Applied rewrites48.4%
Taylor expanded in phi1 around 0
lower-sin.f6447.0
Applied rewrites47.0%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.9
Applied rewrites47.9%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6475.0
Applied rewrites75.0%
if 4.80000000000000004e-27 < lambda2 Initial program 67.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6448.0
Applied rewrites48.0%
Taylor expanded in phi1 around 0
lower-sin.f6447.7
Applied rewrites47.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.5
Applied rewrites47.5%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-neg.f6454.2
Applied rewrites54.2%
Final simplification59.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos (- lambda2 lambda1))))
(t_1 (atan2 (* (cos phi2) (sin lambda1)) (- (sin phi2) t_0))))
(if (<= phi2 -1.3)
t_1
(if (<= phi2 0.245)
(atan2
(sin (- lambda1 lambda2))
(-
(* phi2 (* (cos phi1) (fma -0.16666666666666666 (* phi2 phi2) 1.0)))
t_0))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos((lambda2 - lambda1));
double t_1 = atan2((cos(phi2) * sin(lambda1)), (sin(phi2) - t_0));
double tmp;
if (phi2 <= -1.3) {
tmp = t_1;
} else if (phi2 <= 0.245) {
tmp = atan2(sin((lambda1 - lambda2)), ((phi2 * (cos(phi1) * fma(-0.16666666666666666, (phi2 * phi2), 1.0))) - t_0));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))) t_1 = atan(Float64(cos(phi2) * sin(lambda1)), Float64(sin(phi2) - t_0)) tmp = 0.0 if (phi2 <= -1.3) tmp = t_1; elseif (phi2 <= 0.245) tmp = atan(sin(Float64(lambda1 - lambda2)), Float64(Float64(phi2 * Float64(cos(phi1) * fma(-0.16666666666666666, Float64(phi2 * phi2), 1.0))) - t_0)); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.3], t$95$1, If[LessEqual[phi2, 0.245], N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[(phi2 * N[(N[Cos[phi1], $MachinePrecision] * N[(-0.16666666666666666 * N[(phi2 * phi2), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{\sin \phi_2 - t\_0}\\
\mathbf{if}\;\phi_2 \leq -1.3:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.245:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\phi_2 \cdot \left(\cos \phi_1 \cdot \mathsf{fma}\left(-0.16666666666666666, \phi_2 \cdot \phi_2, 1\right)\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if phi2 < -1.30000000000000004 or 0.245 < phi2 Initial program 75.3%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6414.6
Applied rewrites14.6%
Taylor expanded in phi1 around 0
lower-sin.f6412.7
Applied rewrites12.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6413.4
Applied rewrites13.4%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6434.4
Applied rewrites34.4%
if -1.30000000000000004 < phi2 < 0.245Initial program 83.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6483.1
Applied rewrites83.1%
Taylor expanded in phi1 around 0
lower-sin.f6482.8
Applied rewrites82.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6482.8
Applied rewrites82.8%
Taylor expanded in phi2 around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt1-inN/A
lower-*.f64N/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower-cos.f6483.1
Applied rewrites83.1%
Final simplification58.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1)))))
(t_1 (atan2 (sin (- lambda2)) t_0)))
(if (<= lambda2 -1.52e-34)
t_1
(if (<= lambda2 9.8e-12) (atan2 (sin lambda1) t_0) t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)));
double t_1 = atan2(sin(-lambda2), t_0);
double tmp;
if (lambda2 <= -1.52e-34) {
tmp = t_1;
} else if (lambda2 <= 9.8e-12) {
tmp = atan2(sin(lambda1), t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
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(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))
t_1 = atan2(sin(-lambda2), t_0)
if (lambda2 <= (-1.52d-34)) then
tmp = t_1
else if (lambda2 <= 9.8d-12) then
tmp = atan2(sin(lambda1), t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)));
double t_1 = Math.atan2(Math.sin(-lambda2), t_0);
double tmp;
if (lambda2 <= -1.52e-34) {
tmp = t_1;
} else if (lambda2 <= 9.8e-12) {
tmp = Math.atan2(Math.sin(lambda1), t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1))) t_1 = math.atan2(math.sin(-lambda2), t_0) tmp = 0 if lambda2 <= -1.52e-34: tmp = t_1 elif lambda2 <= 9.8e-12: tmp = math.atan2(math.sin(lambda1), t_0) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1)))) t_1 = atan(sin(Float64(-lambda2)), t_0) tmp = 0.0 if (lambda2 <= -1.52e-34) tmp = t_1; elseif (lambda2 <= 9.8e-12) tmp = atan(sin(lambda1), t_0); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))); t_1 = atan2(sin(-lambda2), t_0); tmp = 0.0; if (lambda2 <= -1.52e-34) tmp = t_1; elseif (lambda2 <= 9.8e-12) tmp = atan2(sin(lambda1), t_0); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[Sin[(-lambda2)], $MachinePrecision] / t$95$0], $MachinePrecision]}, If[LessEqual[lambda2, -1.52e-34], t$95$1, If[LessEqual[lambda2, 9.8e-12], N[ArcTan[N[Sin[lambda1], $MachinePrecision] / t$95$0], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right)}{t\_0}\\
\mathbf{if}\;\lambda_2 \leq -1.52 \cdot 10^{-34}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 9.8 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -1.52e-34 or 9.79999999999999944e-12 < lambda2 Initial program 59.4%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6443.9
Applied rewrites43.9%
Taylor expanded in phi1 around 0
lower-sin.f6443.6
Applied rewrites43.6%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6443.6
Applied rewrites43.6%
Taylor expanded in lambda1 around 0
Applied rewrites41.6%
if -1.52e-34 < lambda2 < 9.79999999999999944e-12Initial program 99.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6451.8
Applied rewrites51.8%
Taylor expanded in phi1 around 0
lower-sin.f6449.9
Applied rewrites49.9%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6450.6
Applied rewrites50.6%
Taylor expanded in lambda2 around 0
Applied rewrites48.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin (- lambda1 lambda2)) (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin((lambda1 - lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin((lambda1 - lambda2)), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin((lambda1 - lambda2)), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(Float64(lambda1 - lambda2)), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin((lambda1 - lambda2)), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 79.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6447.8
Applied rewrites47.8%
Taylor expanded in phi1 around 0
lower-sin.f6446.7
Applied rewrites46.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.0
Applied rewrites47.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (sin lambda1) (- (sin phi2) (* (sin phi1) (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2(sin(lambda1), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2(sin(lambda1), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2(Math.sin(lambda1), (Math.sin(phi2) - (Math.sin(phi1) * Math.cos((lambda2 - lambda1)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2(math.sin(lambda1), (math.sin(phi2) - (math.sin(phi1) * math.cos((lambda2 - lambda1)))))
function code(lambda1, lambda2, phi1, phi2) return atan(sin(lambda1), Float64(sin(phi2) - Float64(sin(phi1) * cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2(sin(lambda1), (sin(phi2) - (sin(phi1) * cos((lambda2 - lambda1))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \lambda_1}{\sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 79.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6447.8
Applied rewrites47.8%
Taylor expanded in phi1 around 0
lower-sin.f6446.7
Applied rewrites46.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
sub-negN/A
remove-double-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
cos-negN/A
lower-cos.f64N/A
mul-1-negN/A
unsub-negN/A
lower--.f6447.0
Applied rewrites47.0%
Taylor expanded in lambda2 around 0
Applied rewrites31.8%
herbie shell --seed 2024237
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Bearing on a great circle"
:precision binary64
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))