
(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 21 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)
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + 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[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 98.7%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6498.9
Applied rewrites98.9%
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
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(fma
(/
(atan2
(*
(fma (- (cos lambda1)) (sin lambda2) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(fma
(fma (cos lambda2) (cos lambda1) (* (sin lambda2) lambda1))
(cos phi2)
(cos phi1)))
lambda1)
lambda1
lambda1))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return fma((atan2((fma(-cos(lambda1), sin(lambda2), (cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(fma(cos(lambda2), cos(lambda1), (sin(lambda2) * lambda1)), cos(phi2), cos(phi1))) / lambda1), lambda1, lambda1);
}
function code(lambda1, lambda2, phi1, phi2) return fma(Float64(atan(Float64(fma(Float64(-cos(lambda1)), sin(lambda2), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), fma(fma(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * lambda1)), cos(phi2), cos(phi1))) / lambda1), lambda1, lambda1) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(N[(N[ArcTan[N[(N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * lambda1), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / lambda1), $MachinePrecision] * lambda1 + lambda1), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{\tan^{-1}_* \frac{\mathsf{fma}\left(-\cos \lambda_1, \sin \lambda_2, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \lambda_1\right), \cos \phi_2, \cos \phi_1\right)}}{\lambda_1}, \lambda_1, \lambda_1\right)
\end{array}
Initial program 98.7%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6498.9
Applied rewrites98.9%
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
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda1 around inf
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f64N/A
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
Applied rewrites99.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2))))
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + 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[(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 \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.7%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6498.9
Applied rewrites98.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * 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) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * 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[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $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 \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
\end{array}
Initial program 98.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6498.8
Applied rewrites98.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.9999999999995779)
(+
lambda1
(atan2
(* (cos phi2) t_1)
(fma (* -0.5 phi1) phi1 (fma t_0 (cos phi2) 1.0))))
(+ lambda1 (atan2 (* 1.0 t_1) (+ t_0 (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.9999999999995779) {
tmp = lambda1 + atan2((cos(phi2) * t_1), fma((-0.5 * phi1), phi1, fma(t_0, cos(phi2), 1.0)));
} else {
tmp = lambda1 + atan2((1.0 * t_1), (t_0 + cos(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.9999999999995779) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), fma(Float64(-0.5 * phi1), phi1, fma(t_0, cos(phi2), 1.0)))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_1), Float64(t_0 + cos(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.9999999999995779], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(-0.5 * phi1), $MachinePrecision] * phi1 + N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$1), $MachinePrecision] / N[(t$95$0 + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.9999999999995779:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\mathsf{fma}\left(-0.5 \cdot \phi_1, \phi_1, \mathsf{fma}\left(t\_0, \cos \phi_2, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_1}{t\_0 + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.99999999999957789Initial program 98.7%
Taylor expanded in phi1 around 0
+-commutativeN/A
associate-+l+N/A
unpow2N/A
associate-*r*N/A
+-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6483.4
Applied rewrites83.4%
if 0.99999999999957789 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6498.8
Applied rewrites98.8%
Taylor expanded in phi2 around 0
Applied rewrites98.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -1e-7) (not (<= lambda2 1e-14)))
(+
lambda1
(atan2
(* (cos phi2) (- (sin lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma (cos lambda1) (cos phi2) (cos phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -1e-7) || !(lambda2 <= 1e-14)) {
tmp = lambda1 + atan2((cos(phi2) * -sin(lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
} else {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -1e-7) || !(lambda2 <= 1e-14)) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(-sin(lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -1e-7], N[Not[LessEqual[lambda2, 1e-14]], $MachinePrecision]], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -1 \cdot 10^{-7} \lor \neg \left(\lambda_2 \leq 10^{-14}\right):\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2, \cos \phi_1\right)}\\
\end{array}
\end{array}
if lambda2 < -9.9999999999999995e-8 or 9.99999999999999999e-15 < lambda2 Initial program 97.9%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6497.9
Applied rewrites97.9%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lower-sin.f6497.9
Applied rewrites97.9%
if -9.9999999999999995e-8 < lambda2 < 9.99999999999999999e-15Initial program 99.6%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
Final simplification98.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -1e-26) (not (<= lambda2 1e-14)))
(+
lambda1
(atan2
(* (cos phi2) (- (sin lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+ (cos phi2) (cos phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -1e-26) || !(lambda2 <= 1e-14)) {
tmp = lambda1 + atan2((cos(phi2) * -sin(lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
} else {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi2) + cos(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -1e-26) || !(lambda2 <= 1e-14)) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(-sin(lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi2) + cos(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -1e-26], N[Not[LessEqual[lambda2, 1e-14]], $MachinePrecision]], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -1 \cdot 10^{-26} \lor \neg \left(\lambda_2 \leq 10^{-14}\right):\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_2 + \cos \phi_1}\\
\end{array}
\end{array}
if lambda2 < -1e-26 or 9.99999999999999999e-15 < lambda2 Initial program 98.0%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6498.0
Applied rewrites98.0%
Taylor expanded in lambda1 around 0
sin-negN/A
lower-neg.f64N/A
lower-sin.f6498.0
Applied rewrites98.0%
if -1e-26 < lambda2 < 9.99999999999999999e-15Initial program 99.6%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6498.1
Applied rewrites98.1%
Taylor expanded in lambda2 around 0
Applied rewrites98.1%
Final simplification98.1%
(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 98.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.865)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos phi2) (cos phi1))))
(+
lambda1
(atan2 (* 1.0 t_0) (+ (cos (- lambda1 lambda2)) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.865) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + cos(phi1)));
} else {
tmp = lambda1 + atan2((1.0 * t_0), (cos((lambda1 - 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 = sin((lambda1 - lambda2))
if (cos(phi2) <= 0.865d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + cos(phi1)))
else
tmp = lambda1 + atan2((1.0d0 * t_0), (cos((lambda1 - 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.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.865) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (Math.cos(phi2) + Math.cos(phi1)));
} else {
tmp = lambda1 + Math.atan2((1.0 * t_0), (Math.cos((lambda1 - lambda2)) + Math.cos(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.865: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (math.cos(phi2) + math.cos(phi1))) else: tmp = lambda1 + math.atan2((1.0 * t_0), (math.cos((lambda1 - lambda2)) + math.cos(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.865) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi2) + cos(phi1)))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_0), Float64(cos(Float64(lambda1 - lambda2)) + cos(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.865) tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi2) + cos(phi1))); else tmp = lambda1 + atan2((1.0 * t_0), (cos((lambda1 - lambda2)) + cos(phi1))); 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.865], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$0), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $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.865:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_2 + \cos \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_0}{\cos \left(\lambda_1 - \lambda_2\right) + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.86499999999999999Initial program 98.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6497.8
Applied rewrites97.8%
Taylor expanded in lambda2 around 0
Applied rewrites81.2%
if 0.86499999999999999 < (cos.f64 phi2) Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in phi2 around 0
Applied rewrites95.9%
(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 98.7%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6498.1
Applied rewrites98.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos lambda2) (cos phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), 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[lambda2], $MachinePrecision] * N[Cos[phi2], $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 \lambda_2, \cos \phi_2, \cos \phi_1\right)}
\end{array}
Initial program 98.7%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6498.1
Applied rewrites98.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.832)
(+
lambda1
(atan2
(* (cos phi2) t_0)
(fma
(-
(*
(*
(fma (* phi1 phi1) -0.001388888888888889 0.041666666666666664)
phi1)
phi1)
0.5)
(* phi1 phi1)
(+ 1.0 (cos phi2)))))
(+
lambda1
(atan2 (* 1.0 t_0) (+ (cos (- lambda1 lambda2)) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.832) {
tmp = lambda1 + atan2((cos(phi2) * t_0), fma((((fma((phi1 * phi1), -0.001388888888888889, 0.041666666666666664) * phi1) * phi1) - 0.5), (phi1 * phi1), (1.0 + cos(phi2))));
} else {
tmp = lambda1 + atan2((1.0 * t_0), (cos((lambda1 - lambda2)) + cos(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.832) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), fma(Float64(Float64(Float64(fma(Float64(phi1 * phi1), -0.001388888888888889, 0.041666666666666664) * phi1) * phi1) - 0.5), Float64(phi1 * phi1), Float64(1.0 + cos(phi2))))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_0), Float64(cos(Float64(lambda1 - lambda2)) + cos(phi1)))); end return 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.832], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * phi1), $MachinePrecision] * phi1), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision] + N[(1.0 + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$0), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $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.832:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.001388888888888889, 0.041666666666666664\right) \cdot \phi_1\right) \cdot \phi_1 - 0.5, \phi_1 \cdot \phi_1, 1 + \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_0}{\cos \left(\lambda_1 - \lambda_2\right) + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.831999999999999962Initial program 98.9%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6498.1
Applied rewrites98.1%
Taylor expanded in lambda2 around 0
Applied rewrites80.9%
Taylor expanded in phi1 around 0
Applied rewrites77.4%
if 0.831999999999999962 < (cos.f64 phi2) Initial program 98.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6495.0
Applied rewrites95.0%
Taylor expanded in phi2 around 0
Applied rewrites95.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.832)
(+
lambda1
(atan2 (* (cos phi2) t_0) (fma (* phi1 phi1) -0.5 (+ 1.0 (cos phi2)))))
(+
lambda1
(atan2 (* 1.0 t_0) (+ (cos (- lambda1 lambda2)) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.832) {
tmp = lambda1 + atan2((cos(phi2) * t_0), fma((phi1 * phi1), -0.5, (1.0 + cos(phi2))));
} else {
tmp = lambda1 + atan2((1.0 * t_0), (cos((lambda1 - lambda2)) + cos(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.832) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), fma(Float64(phi1 * phi1), -0.5, Float64(1.0 + cos(phi2))))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_0), Float64(cos(Float64(lambda1 - lambda2)) + cos(phi1)))); end return 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.832], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + N[(1.0 + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$0), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $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.832:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1 + \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_0}{\cos \left(\lambda_1 - \lambda_2\right) + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.831999999999999962Initial program 98.9%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6498.1
Applied rewrites98.1%
Taylor expanded in lambda2 around 0
Applied rewrites80.9%
Taylor expanded in phi1 around 0
Applied rewrites77.0%
if 0.831999999999999962 < (cos.f64 phi2) Initial program 98.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6495.0
Applied rewrites95.0%
Taylor expanded in phi2 around 0
Applied rewrites95.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.865)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ 1.0 (cos phi2))))
(+
lambda1
(atan2 (* 1.0 t_0) (+ (cos (- lambda1 lambda2)) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.865) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2)));
} else {
tmp = lambda1 + atan2((1.0 * t_0), (cos((lambda1 - 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 = sin((lambda1 - lambda2))
if (cos(phi2) <= 0.865d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + cos(phi2)))
else
tmp = lambda1 + atan2((1.0d0 * t_0), (cos((lambda1 - 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.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.865) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2((1.0 * t_0), (Math.cos((lambda1 - lambda2)) + Math.cos(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.865: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + math.cos(phi2))) else: tmp = lambda1 + math.atan2((1.0 * t_0), (math.cos((lambda1 - lambda2)) + math.cos(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.865) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + cos(phi2)))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_0), Float64(cos(Float64(lambda1 - lambda2)) + cos(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.865) tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2))); else tmp = lambda1 + atan2((1.0 * t_0), (cos((lambda1 - lambda2)) + cos(phi1))); 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.865], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$0), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $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.865:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_0}{\cos \left(\lambda_1 - \lambda_2\right) + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.86499999999999999Initial program 98.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6497.8
Applied rewrites97.8%
Taylor expanded in lambda2 around 0
Applied rewrites81.2%
Taylor expanded in phi1 around 0
Applied rewrites70.4%
if 0.86499999999999999 < (cos.f64 phi2) Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in phi2 around 0
Applied rewrites95.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.865)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ 1.0 (cos phi2))))
(+ lambda1 (atan2 (* 1.0 t_0) (+ (cos lambda2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.865) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2)));
} else {
tmp = lambda1 + atan2((1.0 * 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 = sin((lambda1 - lambda2))
if (cos(phi2) <= 0.865d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + cos(phi2)))
else
tmp = lambda1 + atan2((1.0d0 * 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.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.865) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2((1.0 * t_0), (Math.cos(lambda2) + Math.cos(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.865: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + math.cos(phi2))) else: tmp = lambda1 + math.atan2((1.0 * t_0), (math.cos(lambda2) + math.cos(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.865) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + cos(phi2)))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_0), Float64(cos(lambda2) + cos(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.865) tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2))); else tmp = lambda1 + atan2((1.0 * t_0), (cos(lambda2) + cos(phi1))); 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.865], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$0), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $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.865:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_0}{\cos \lambda_2 + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.86499999999999999Initial program 98.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6497.8
Applied rewrites97.8%
Taylor expanded in lambda2 around 0
Applied rewrites81.2%
Taylor expanded in phi1 around 0
Applied rewrites70.4%
if 0.86499999999999999 < (cos.f64 phi2) Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6495.9
Applied rewrites95.9%
Taylor expanded in phi2 around 0
Applied rewrites95.9%
Taylor expanded in lambda1 around 0
Applied rewrites95.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= (cos phi1) 0.4)
(+
lambda1
(atan2 (* 1.0 (sin lambda1)) (+ (cos (- lambda1 lambda2)) (cos phi1))))
(+
lambda1
(atan2 (* 1.0 (sin (- lambda1 lambda2))) (+ 1.0 (cos lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (cos(phi1) <= 0.4) {
tmp = lambda1 + atan2((1.0 * sin(lambda1)), (cos((lambda1 - lambda2)) + cos(phi1)));
} else {
tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + 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) :: tmp
if (cos(phi1) <= 0.4d0) then
tmp = lambda1 + atan2((1.0d0 * sin(lambda1)), (cos((lambda1 - lambda2)) + cos(phi1)))
else
tmp = lambda1 + atan2((1.0d0 * sin((lambda1 - lambda2))), (1.0d0 + cos(lambda2)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (Math.cos(phi1) <= 0.4) {
tmp = lambda1 + Math.atan2((1.0 * Math.sin(lambda1)), (Math.cos((lambda1 - lambda2)) + Math.cos(phi1)));
} else {
tmp = lambda1 + Math.atan2((1.0 * Math.sin((lambda1 - lambda2))), (1.0 + Math.cos(lambda2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if math.cos(phi1) <= 0.4: tmp = lambda1 + math.atan2((1.0 * math.sin(lambda1)), (math.cos((lambda1 - lambda2)) + math.cos(phi1))) else: tmp = lambda1 + math.atan2((1.0 * math.sin((lambda1 - lambda2))), (1.0 + math.cos(lambda2))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (cos(phi1) <= 0.4) tmp = Float64(lambda1 + atan(Float64(1.0 * sin(lambda1)), Float64(cos(Float64(lambda1 - lambda2)) + cos(phi1)))); else tmp = Float64(lambda1 + atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(1.0 + cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (cos(phi1) <= 0.4) tmp = lambda1 + atan2((1.0 * sin(lambda1)), (cos((lambda1 - lambda2)) + cos(phi1))); else tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + cos(lambda2))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.4], N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \phi_1 \leq 0.4:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \lambda_1}{\cos \left(\lambda_1 - \lambda_2\right) + \cos \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \lambda_2}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.40000000000000002Initial program 98.1%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6478.7
Applied rewrites78.7%
Taylor expanded in phi2 around 0
Applied rewrites76.9%
Taylor expanded in lambda2 around 0
lower-sin.f6465.0
Applied rewrites65.0%
if 0.40000000000000002 < (cos.f64 phi1) Initial program 99.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6481.1
Applied rewrites81.1%
Taylor expanded in phi2 around 0
Applied rewrites79.7%
Taylor expanded in phi1 around 0
Applied rewrites75.6%
Taylor expanded in lambda1 around 0
Applied rewrites75.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* 1.0 (sin (- lambda1 lambda2)))))
(if (<= phi1 1.9)
(+
lambda1
(atan2
t_0
(+
(cos (- lambda2 lambda1))
(fma
(- (* 0.041666666666666664 (* phi1 phi1)) 0.5)
(* phi1 phi1)
1.0))))
(+ lambda1 (atan2 t_0 (+ (cos lambda1) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 1.9) {
tmp = lambda1 + atan2(t_0, (cos((lambda2 - lambda1)) + fma(((0.041666666666666664 * (phi1 * phi1)) - 0.5), (phi1 * phi1), 1.0)));
} else {
tmp = lambda1 + atan2(t_0, (cos(lambda1) + cos(phi1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(1.0 * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= 1.9) tmp = Float64(lambda1 + atan(t_0, Float64(cos(Float64(lambda2 - lambda1)) + fma(Float64(Float64(0.041666666666666664 * Float64(phi1 * phi1)) - 0.5), Float64(phi1 * phi1), 1.0)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(lambda1) + cos(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, 1.9], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[(N[(0.041666666666666664 * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[lambda1], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 1.9:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \left(\lambda_2 - \lambda_1\right) + \mathsf{fma}\left(0.041666666666666664 \cdot \left(\phi_1 \cdot \phi_1\right) - 0.5, \phi_1 \cdot \phi_1, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \lambda_1 + \cos \phi_1}\\
\end{array}
\end{array}
if phi1 < 1.8999999999999999Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6481.4
Applied rewrites81.4%
Taylor expanded in phi2 around 0
Applied rewrites80.1%
Taylor expanded in phi1 around 0
Applied rewrites73.7%
if 1.8999999999999999 < phi1 Initial program 98.8%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6477.6
Applied rewrites77.6%
Taylor expanded in phi2 around 0
Applied rewrites75.4%
Taylor expanded in lambda2 around 0
Applied rewrites70.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* 1.0 (sin (- lambda1 lambda2))) (+ (cos lambda2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (cos(lambda2) + cos(phi1)));
}
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((1.0d0 * sin((lambda1 - lambda2))), (cos(lambda2) + cos(phi1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((1.0 * Math.sin((lambda1 - lambda2))), (Math.cos(lambda2) + Math.cos(phi1)));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((1.0 * math.sin((lambda1 - lambda2))), (math.cos(lambda2) + math.cos(phi1)))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(cos(lambda2) + cos(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (cos(lambda2) + cos(phi1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \lambda_2 + \cos \phi_1}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6480.3
Applied rewrites80.3%
Taylor expanded in phi2 around 0
Applied rewrites78.7%
Taylor expanded in lambda1 around 0
Applied rewrites78.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* 1.0 (sin (- lambda1 lambda2))) (+ 1.0 (cos lambda2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + 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((1.0d0 * sin((lambda1 - lambda2))), (1.0d0 + cos(lambda2)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((1.0 * Math.sin((lambda1 - lambda2))), (1.0 + Math.cos(lambda2)));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((1.0 * math.sin((lambda1 - lambda2))), (1.0 + math.cos(lambda2)))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(1.0 + cos(lambda2)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + cos(lambda2))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \lambda_2}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6480.3
Applied rewrites80.3%
Taylor expanded in phi2 around 0
Applied rewrites78.7%
Taylor expanded in phi1 around 0
Applied rewrites70.5%
Taylor expanded in lambda1 around 0
Applied rewrites70.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* 1.0 (sin (- lambda1 lambda2))) (+ 1.0 (cos lambda1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + 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((1.0d0 * sin((lambda1 - lambda2))), (1.0d0 + cos(lambda1)))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((1.0 * Math.sin((lambda1 - lambda2))), (1.0 + Math.cos(lambda1)));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((1.0 * math.sin((lambda1 - lambda2))), (1.0 + math.cos(lambda1)))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(1.0 + cos(lambda1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + cos(lambda1))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \lambda_1}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6480.3
Applied rewrites80.3%
Taylor expanded in phi2 around 0
Applied rewrites78.7%
Taylor expanded in phi1 around 0
Applied rewrites70.5%
Taylor expanded in lambda2 around 0
Applied rewrites64.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* 1.0 (sin lambda1)) (+ 1.0 (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((1.0 * sin(lambda1)), (1.0 + 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 = lambda1 + atan2((1.0d0 * sin(lambda1)), (1.0d0 + cos((lambda2 - lambda1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((1.0 * Math.sin(lambda1)), (1.0 + Math.cos((lambda2 - lambda1))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((1.0 * math.sin(lambda1)), (1.0 + math.cos((lambda2 - lambda1))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(1.0 * sin(lambda1)), Float64(1.0 + cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((1.0 * sin(lambda1)), (1.0 + cos((lambda2 - lambda1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \lambda_1}{1 + \cos \left(\lambda_2 - \lambda_1\right)}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-cos.f64N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
lower-cos.f6480.3
Applied rewrites80.3%
Taylor expanded in phi2 around 0
Applied rewrites78.7%
Taylor expanded in phi1 around 0
Applied rewrites70.5%
Taylor expanded in lambda2 around 0
lower-sin.f6457.7
Applied rewrites57.7%
herbie shell --seed 2024338
(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)))))))