
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(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 = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 99.1%
cos-diff99.1%
+-commutative99.1%
*-commutative99.1%
Applied egg-rr99.1%
sin-diff99.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(+ (* (cos lambda2) (cos lambda1)) (* lambda1 (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (lambda1 * sin(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 = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (lambda1 * sin(lambda2))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2)))), (Math.cos(phi1) + (Math.cos(phi2) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (lambda1 * Math.sin(lambda2))))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2)))), (math.cos(phi1) + (math.cos(phi2) * ((math.cos(lambda2) * math.cos(lambda1)) + (lambda1 * math.sin(lambda2))))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(lambda1 * sin(lambda2))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (lambda1 * sin(lambda2)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(lambda1 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 99.1%
cos-diff99.1%
+-commutative99.1%
*-commutative99.1%
Applied egg-rr99.1%
sin-diff99.7%
Applied egg-rr99.7%
Taylor expanded in lambda1 around 0 99.3%
Final simplification99.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+
(cos phi1)
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 99.1%
cos-diff99.1%
+-commutative99.1%
*-commutative99.1%
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi1) -0.4)
(+ lambda1 (atan2 t_0 (+ (cos phi2) (cos phi1))))
(if (<= (cos phi1) 0.99998)
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda2 lambda1)))))
(+
lambda1
(atan2 t_0 (+ (* (cos phi2) (cos (- lambda1 lambda2))) 1.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= -0.4) {
tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
} else if (cos(phi1) <= 0.99998) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda2 - lambda1))));
} else {
tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos((lambda1 - lambda2))) + 1.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 = cos(phi2) * sin((lambda1 - lambda2))
if (cos(phi1) <= (-0.4d0)) then
tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)))
else if (cos(phi1) <= 0.99998d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda2 - lambda1))))
else
tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos((lambda1 - lambda2))) + 1.0d0))
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((lambda1 - lambda2));
double tmp;
if (Math.cos(phi1) <= -0.4) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + Math.cos(phi1)));
} else if (Math.cos(phi1) <= 0.99998) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos((lambda2 - lambda1))));
} else {
tmp = lambda1 + Math.atan2(t_0, ((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + 1.0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi1) <= -0.4: tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + math.cos(phi1))) elif math.cos(phi1) <= 0.99998: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos((lambda2 - lambda1)))) else: tmp = lambda1 + math.atan2(t_0, ((math.cos(phi2) * math.cos((lambda1 - lambda2))) + 1.0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi1) <= -0.4) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + cos(phi1)))); elseif (cos(phi1) <= 0.99998) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda2 - lambda1))))); else tmp = Float64(lambda1 + atan(t_0, Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + 1.0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi1) <= -0.4) tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1))); elseif (cos(phi1) <= 0.99998) tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda2 - lambda1)))); else tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos((lambda1 - lambda2))) + 1.0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], -0.4], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.99998], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq -0.4:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_2 + \cos \phi_1}\\
\mathbf{elif}\;\cos \phi_1 \leq 0.99998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_1 + \cos \left(\lambda_2 - \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + 1}\\
\end{array}
\end{array}
if (cos.f64 phi1) < -0.40000000000000002Initial program 99.8%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in lambda2 around 0 86.5%
*-commutative86.5%
Simplified86.5%
Taylor expanded in lambda1 around 0 86.5%
+-commutative86.5%
Simplified86.5%
if -0.40000000000000002 < (cos.f64 phi1) < 0.99997999999999998Initial program 99.0%
Taylor expanded in phi2 around 0 81.8%
+-commutative81.8%
sub-neg81.8%
remove-double-neg81.8%
mul-1-neg81.8%
distribute-neg-in81.8%
+-commutative81.8%
cos-neg81.8%
mul-1-neg81.8%
unsub-neg81.8%
Simplified81.8%
if 0.99997999999999998 < (cos.f64 phi1) Initial program 98.8%
Taylor expanded in phi1 around 0 98.2%
Final simplification90.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi1) -0.4)
(+ lambda1 (atan2 t_0 (+ (cos phi2) (cos phi1))))
(if (<= (cos phi1) 0.99998)
(+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1))))
(+ lambda1 (atan2 t_0 (+ (* (cos phi2) (cos lambda2)) 1.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= -0.4) {
tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
} else if (cos(phi1) <= 0.99998) {
tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
} else {
tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.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 = cos(phi2) * sin((lambda1 - lambda2))
if (cos(phi1) <= (-0.4d0)) then
tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)))
else if (cos(phi1) <= 0.99998d0) then
tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
else
tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.0d0))
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((lambda1 - lambda2));
double tmp;
if (Math.cos(phi1) <= -0.4) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + Math.cos(phi1)));
} else if (Math.cos(phi1) <= 0.99998) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
} else {
tmp = lambda1 + Math.atan2(t_0, ((Math.cos(phi2) * Math.cos(lambda2)) + 1.0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi1) <= -0.4: tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + math.cos(phi1))) elif math.cos(phi1) <= 0.99998: tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1))) else: tmp = lambda1 + math.atan2(t_0, ((math.cos(phi2) * math.cos(lambda2)) + 1.0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi1) <= -0.4) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + cos(phi1)))); elseif (cos(phi1) <= 0.99998) tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1)))); else tmp = Float64(lambda1 + atan(t_0, Float64(Float64(cos(phi2) * cos(lambda2)) + 1.0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi1) <= -0.4) tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1))); elseif (cos(phi1) <= 0.99998) tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1))); else tmp = lambda1 + atan2(t_0, ((cos(phi2) * cos(lambda2)) + 1.0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], -0.4], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.99998], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq -0.4:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_2 + \cos \phi_1}\\
\mathbf{elif}\;\cos \phi_1 \leq 0.99998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \lambda_2 + \cos \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_2 \cdot \cos \lambda_2 + 1}\\
\end{array}
\end{array}
if (cos.f64 phi1) < -0.40000000000000002Initial program 99.8%
cos-diff99.8%
+-commutative99.8%
*-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in lambda2 around 0 86.5%
*-commutative86.5%
Simplified86.5%
Taylor expanded in lambda1 around 0 86.5%
+-commutative86.5%
Simplified86.5%
if -0.40000000000000002 < (cos.f64 phi1) < 0.99997999999999998Initial program 99.0%
Taylor expanded in phi2 around 0 81.8%
+-commutative81.8%
sub-neg81.8%
remove-double-neg81.8%
mul-1-neg81.8%
distribute-neg-in81.8%
+-commutative81.8%
cos-neg81.8%
mul-1-neg81.8%
unsub-neg81.8%
Simplified81.8%
Taylor expanded in lambda1 around 0 81.4%
if 0.99997999999999998 < (cos.f64 phi1) Initial program 98.8%
expm1-log1p-u98.5%
+-commutative98.5%
*-commutative98.5%
fma-def98.5%
Applied egg-rr98.5%
Taylor expanded in phi1 around 0 98.1%
Taylor expanded in lambda1 around 0 96.7%
cos-neg96.7%
*-commutative96.7%
Simplified96.7%
Final simplification89.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos phi2) (cos (- lambda1 lambda2)) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(phi2), cos((lambda1 - lambda2)), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi2), cos(Float64(lambda1 - lambda2)), cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_2, \cos \left(\lambda_1 - \lambda_2\right), \cos \phi_1\right)}
\end{array}
Initial program 99.1%
cos-neg99.1%
cos-neg99.1%
cos-neg99.1%
+-commutative99.1%
cos-neg99.1%
fma-def99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi2) 1.0)
(+ lambda1 (atan2 t_0 (+ (cos phi2) (cos phi1))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda2 lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 1.0) {
tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda2 - 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(phi2) * sin((lambda1 - lambda2))
if (cos(phi2) <= 1.0d0) then
tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda2 - lambda1))))
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((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 1.0) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + Math.cos(phi1)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos((lambda2 - lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 1.0: tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + math.cos(phi1))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos((lambda2 - lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi2) <= 1.0) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + cos(phi1)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda2 - lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 1.0) tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda2 - lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 1.0], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 1:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_2 + \cos \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_1 + \cos \left(\lambda_2 - \lambda_1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 1Initial program 99.1%
cos-diff99.1%
+-commutative99.1%
*-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in lambda2 around 0 79.4%
*-commutative79.4%
Simplified79.4%
Taylor expanded in lambda1 around 0 78.5%
+-commutative78.5%
Simplified78.5%
if 1 < (cos.f64 phi2) Initial program 99.1%
Taylor expanded in phi2 around 0 78.5%
+-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Final simplification78.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 99.1%
Final simplification99.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi2) 0.999)
(+ lambda1 (atan2 t_0 (+ (cos phi2) 1.0)))
(+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.999) {
tmp = lambda1 + atan2(t_0, (cos(phi2) + 1.0));
} else {
tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
}
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((lambda1 - lambda2))
if (cos(phi2) <= 0.999d0) then
tmp = lambda1 + atan2(t_0, (cos(phi2) + 1.0d0))
else
tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
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((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.999) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + 1.0));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.999: tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + 1.0)) else: tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi2) <= 0.999) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + 1.0))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.999) tmp = lambda1 + atan2(t_0, (cos(phi2) + 1.0)); else tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.999], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.999:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_2 + 1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \lambda_2 + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.998999999999999999Initial program 99.0%
cos-diff99.0%
+-commutative99.0%
*-commutative99.0%
Applied egg-rr99.0%
Taylor expanded in lambda2 around 0 76.6%
*-commutative76.6%
Simplified76.6%
Taylor expanded in phi1 around 0 65.3%
*-commutative65.3%
Simplified65.3%
Taylor expanded in lambda1 around 0 64.1%
if 0.998999999999999999 < (cos.f64 phi2) Initial program 99.1%
Taylor expanded in phi2 around 0 98.2%
+-commutative98.2%
sub-neg98.2%
remove-double-neg98.2%
mul-1-neg98.2%
distribute-neg-in98.2%
+-commutative98.2%
cos-neg98.2%
mul-1-neg98.2%
unsub-neg98.2%
Simplified98.2%
Taylor expanded in lambda1 around 0 97.7%
Final simplification82.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi2) 1.0)
(+ lambda1 (atan2 t_0 (+ (cos phi2) (cos phi1))))
(+ lambda1 (atan2 t_0 (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 1.0) {
tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)));
} else {
tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)));
}
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((lambda1 - lambda2))
if (cos(phi2) <= 1.0d0) then
tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1)))
else
tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1)))
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((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 1.0) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + Math.cos(phi1)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(lambda2) + Math.cos(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 1.0: tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + math.cos(phi1))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(lambda2) + math.cos(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi2) <= 1.0) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + cos(phi1)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda2) + cos(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 1.0) tmp = lambda1 + atan2(t_0, (cos(phi2) + cos(phi1))); else tmp = lambda1 + atan2(t_0, (cos(lambda2) + cos(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 1.0], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 1:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_2 + \cos \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \lambda_2 + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 1Initial program 99.1%
cos-diff99.1%
+-commutative99.1%
*-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in lambda2 around 0 79.4%
*-commutative79.4%
Simplified79.4%
Taylor expanded in lambda1 around 0 78.5%
+-commutative78.5%
Simplified78.5%
if 1 < (cos.f64 phi2) Initial program 99.1%
Taylor expanded in phi2 around 0 78.5%
+-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in lambda1 around 0 78.2%
Final simplification78.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda2))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(lambda2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}
\end{array}
Initial program 99.1%
Taylor expanded in lambda1 around 0 98.2%
cos-neg98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.999)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos phi2) 1.0)))
(+ lambda1 (atan2 t_0 (+ (cos (- lambda2 lambda1)) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.999) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + 1.0));
} else {
tmp = lambda1 + atan2(t_0, (cos((lambda2 - lambda1)) + 1.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((lambda1 - lambda2))
if (cos(phi2) <= 0.999d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + 1.0d0))
else
tmp = lambda1 + atan2(t_0, (cos((lambda2 - lambda1)) + 1.0d0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.999) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi2) + 1.0));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos((lambda2 - lambda1)) + 1.0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.999: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi2) + 1.0)) else: tmp = lambda1 + math.atan2(t_0, (math.cos((lambda2 - lambda1)) + 1.0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.999) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi2) + 1.0))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(Float64(lambda2 - lambda1)) + 1.0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.999) tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + 1.0)); else tmp = lambda1 + atan2(t_0, (cos((lambda2 - lambda1)) + 1.0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.999], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.999:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t_0}{\cos \phi_2 + 1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \left(\lambda_2 - \lambda_1\right) + 1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.998999999999999999Initial program 99.0%
cos-diff99.0%
+-commutative99.0%
*-commutative99.0%
Applied egg-rr99.0%
Taylor expanded in lambda2 around 0 76.6%
*-commutative76.6%
Simplified76.6%
Taylor expanded in phi1 around 0 65.3%
*-commutative65.3%
Simplified65.3%
Taylor expanded in lambda1 around 0 64.1%
if 0.998999999999999999 < (cos.f64 phi2) Initial program 99.1%
Taylor expanded in phi2 around 0 98.2%
+-commutative98.2%
sub-neg98.2%
remove-double-neg98.2%
mul-1-neg98.2%
distribute-neg-in98.2%
+-commutative98.2%
cos-neg98.2%
mul-1-neg98.2%
unsub-neg98.2%
Simplified98.2%
Taylor expanded in phi1 around 0 79.5%
Taylor expanded in phi2 around 0 79.5%
Final simplification72.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi1 4e+20)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos (- lambda2 lambda1)) 1.0)))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 4e+20) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos((lambda2 - lambda1)) + 1.0));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * 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 = sin((lambda1 - lambda2))
if (phi1 <= 4d+20) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos((lambda2 - lambda1)) + 1.0d0))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 4e+20) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos((lambda2 - lambda1)) + 1.0));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= 4e+20: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos((lambda2 - lambda1)) + 1.0)) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= 4e+20) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(Float64(lambda2 - lambda1)) + 1.0))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(lambda1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= 4e+20) tmp = lambda1 + atan2((cos(phi2) * t_0), (cos((lambda2 - lambda1)) + 1.0)); else tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos(lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 4e+20], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 4 \cdot 10^{+20}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t_0}{\cos \left(\lambda_2 - \lambda_1\right) + 1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if phi1 < 4e20Initial program 98.9%
Taylor expanded in phi2 around 0 77.6%
+-commutative77.6%
sub-neg77.6%
remove-double-neg77.6%
mul-1-neg77.6%
distribute-neg-in77.6%
+-commutative77.6%
cos-neg77.6%
mul-1-neg77.6%
unsub-neg77.6%
Simplified77.6%
Taylor expanded in phi1 around 0 69.4%
if 4e20 < phi1 Initial program 99.7%
cos-diff99.7%
+-commutative99.7%
*-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in lambda2 around 0 80.4%
*-commutative80.4%
Simplified80.4%
Taylor expanded in phi2 around 0 72.8%
Final simplification70.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos (- lambda2 lambda1)) 1.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (cos((lambda2 - lambda1)) + 1.0));
}
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 = lambda1 + atan2(sin((lambda1 - lambda2)), (cos((lambda2 - lambda1)) + 1.0d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos((lambda2 - lambda1)) + 1.0));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos((lambda2 - lambda1)) + 1.0))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(Float64(lambda2 - lambda1)) + 1.0))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos((lambda2 - lambda1)) + 1.0)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \left(\lambda_2 - \lambda_1\right) + 1}
\end{array}
Initial program 99.1%
Taylor expanded in phi2 around 0 78.5%
+-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi1 around 0 67.8%
Taylor expanded in phi2 around 0 66.6%
Final simplification66.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin lambda1) (+ (cos (- lambda2 lambda1)) 1.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin(lambda1), (cos((lambda2 - lambda1)) + 1.0));
}
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 = lambda1 + atan2(sin(lambda1), (cos((lambda2 - lambda1)) + 1.0d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin(lambda1), (Math.cos((lambda2 - lambda1)) + 1.0));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin(lambda1), (math.cos((lambda2 - lambda1)) + 1.0))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(lambda1), Float64(cos(Float64(lambda2 - lambda1)) + 1.0))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin(lambda1), (cos((lambda2 - lambda1)) + 1.0)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \lambda_1}{\cos \left(\lambda_2 - \lambda_1\right) + 1}
\end{array}
Initial program 99.1%
Taylor expanded in phi2 around 0 78.5%
+-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi1 around 0 67.8%
Taylor expanded in phi2 around 0 66.6%
Taylor expanded in lambda2 around 0 55.0%
Final simplification55.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos lambda1) 1.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda1) + 1.0));
}
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 = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda1) + 1.0d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(lambda1) + 1.0));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(lambda1) + 1.0))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(lambda1) + 1.0))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda1) + 1.0)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[lambda1], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_1 + 1}
\end{array}
Initial program 99.1%
Taylor expanded in phi2 around 0 78.5%
+-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi1 around 0 67.8%
Taylor expanded in phi2 around 0 66.6%
Taylor expanded in lambda2 around 0 61.7%
cos-neg61.7%
+-commutative61.7%
Simplified61.7%
Final simplification61.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos lambda2) 1.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + 1.0));
}
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 = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + 1.0d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(lambda2) + 1.0));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(lambda2) + 1.0))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(lambda2) + 1.0))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(lambda2) + 1.0)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + 1}
\end{array}
Initial program 99.1%
Taylor expanded in phi2 around 0 78.5%
+-commutative78.5%
sub-neg78.5%
remove-double-neg78.5%
mul-1-neg78.5%
distribute-neg-in78.5%
+-commutative78.5%
cos-neg78.5%
mul-1-neg78.5%
unsub-neg78.5%
Simplified78.5%
Taylor expanded in phi1 around 0 67.8%
Taylor expanded in phi2 around 0 66.6%
Taylor expanded in lambda1 around 0 66.5%
+-commutative66.5%
Simplified66.5%
Final simplification66.5%
herbie shell --seed 2023313
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Midpoint on a great circle"
:precision binary64
(+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))