
(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 18 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
(fma
(* (sin lambda1) (cos lambda2))
(cos phi2)
(* (cos phi2) (* (cos lambda1) (sin (- lambda2)))))
(+
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(fma((sin(lambda1) * cos(lambda2)), cos(phi2), (cos(phi2) * (cos(lambda1) * sin(-lambda2)))), (cos(phi1) + (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(fma(Float64(sin(lambda1) * cos(lambda2)), cos(phi2), Float64(cos(phi2) * Float64(cos(lambda1) * sin(Float64(-lambda2))))), Float64(cos(phi1) + Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(N[Cos[phi2], $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[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1 \cdot \cos \lambda_2, \cos \phi_2, \cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \sin \left(-\lambda_2\right)\right)\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 98.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.5
Applied rewrites98.5%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_1 (+ lambda1 (atan2 t_0 (* (* phi1 phi1) -0.5))))
(t_2
(+
lambda1
(atan2
t_0
(+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))))
(if (<= t_2 -0.2)
t_1
(if (<= t_2 2e-26)
(+ lambda1 (atan2 (sin lambda1) (+ (cos phi1) (cos lambda1))))
t_1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * sin((lambda1 - lambda2));
double t_1 = lambda1 + atan2(t_0, ((phi1 * phi1) * -0.5));
double t_2 = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
double tmp;
if (t_2 <= -0.2) {
tmp = t_1;
} else if (t_2 <= 2e-26) {
tmp = lambda1 + atan2(sin(lambda1), (cos(phi1) + cos(lambda1)));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi2) * sin((lambda1 - lambda2))
t_1 = lambda1 + atan2(t_0, ((phi1 * phi1) * (-0.5d0)))
t_2 = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
if (t_2 <= (-0.2d0)) then
tmp = t_1
else if (t_2 <= 2d-26) then
tmp = lambda1 + atan2(sin(lambda1), (cos(phi1) + cos(lambda1)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double t_1 = lambda1 + Math.atan2(t_0, ((phi1 * phi1) * -0.5));
double t_2 = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (t_2 <= -0.2) {
tmp = t_1;
} else if (t_2 <= 2e-26) {
tmp = lambda1 + Math.atan2(Math.sin(lambda1), (Math.cos(phi1) + Math.cos(lambda1)));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.sin((lambda1 - lambda2)) t_1 = lambda1 + math.atan2(t_0, ((phi1 * phi1) * -0.5)) t_2 = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) tmp = 0 if t_2 <= -0.2: tmp = t_1 elif t_2 <= 2e-26: tmp = lambda1 + math.atan2(math.sin(lambda1), (math.cos(phi1) + math.cos(lambda1))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_1 = Float64(lambda1 + atan(t_0, Float64(Float64(phi1 * phi1) * -0.5))) t_2 = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) tmp = 0.0 if (t_2 <= -0.2) tmp = t_1; elseif (t_2 <= 2e-26) tmp = Float64(lambda1 + atan(sin(lambda1), Float64(cos(phi1) + cos(lambda1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * sin((lambda1 - lambda2)); t_1 = lambda1 + atan2(t_0, ((phi1 * phi1) * -0.5)); t_2 = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); tmp = 0.0; if (t_2 <= -0.2) tmp = t_1; elseif (t_2 <= 2e-26) tmp = lambda1 + atan2(sin(lambda1), (cos(phi1) + cos(lambda1))); else tmp = t_1; 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]}, Block[{t$95$1 = N[(lambda1 + N[ArcTan[t$95$0 / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -0.2], t$95$1, If[LessEqual[t$95$2, 2e-26], N[(lambda1 + N[ArcTan[N[Sin[lambda1], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \lambda_1 + \tan^{-1}_* \frac{t\_0}{\left(\phi_1 \cdot \phi_1\right) \cdot -0.5}\\
t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;t\_2 \leq -0.2:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-26}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \lambda_1}{\cos \phi_1 + \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.20000000000000001 or 2.0000000000000001e-26 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) Initial program 98.2%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.8
Applied rewrites83.8%
Taylor expanded in phi1 around inf
Applied rewrites70.5%
if -0.20000000000000001 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 2.0000000000000001e-26Initial program 99.0%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6453.2
Applied rewrites53.2%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6453.5
Applied rewrites53.5%
Taylor expanded in lambda2 around 0
Applied rewrites29.3%
Taylor expanded in lambda2 around 0
Applied rewrites29.3%
Final simplification60.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2)))), (cos(phi1) + (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[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[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 98.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.5
Applied rewrites98.5%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.6
Applied rewrites99.6%
Final simplification99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos lambda2))))
(fma
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))
(cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * fma(sin(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2)))), fma(cos(phi2), fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(lambda2)))), fma(cos(phi2), fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))), cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \mathsf{fma}\left(\sin \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right)}{\mathsf{fma}\left(\cos \phi_2, \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right), \cos \phi_1\right)}
\end{array}
Initial program 98.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.5
Applied rewrites98.5%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in phi1 around inf
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-cos.f6499.6
Applied rewrites99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(fma (sin (- lambda2)) (cos lambda1) (* (sin lambda1) (cos 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(-lambda2), cos(lambda1), (sin(lambda1) * cos(lambda2)))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * fma(sin(Float64(-lambda2)), cos(lambda1), Float64(sin(lambda1) * cos(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[(-lambda2)], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[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 \left(-\lambda_2\right), \cos \lambda_1, \sin \lambda_1 \cdot \cos \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.4%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
cos-negN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6498.5
Applied rewrites98.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (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) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * 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) * fma(sin(lambda2), sin(lambda1), Float64(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[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $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 \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)}
\end{array}
Initial program 98.4%
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
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6498.4
Applied rewrites98.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi1) 0.9956)
(+ lambda1 (atan2 t_0 (fma (cos phi2) (cos lambda1) (cos phi1))))
(+ lambda1 (atan2 t_0 (fma (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.9956) {
tmp = lambda1 + atan2(t_0, fma(cos(phi2), cos(lambda1), cos(phi1)));
} else {
tmp = lambda1 + atan2(t_0, fma(cos(phi2), 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.9956) tmp = Float64(lambda1 + atan(t_0, fma(cos(phi2), cos(lambda1), cos(phi1)))); else tmp = Float64(lambda1 + atan(t_0, fma(cos(phi2), cos(Float64(lambda1 - lambda2)), 1.0))); end return 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.9956], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - 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.9956:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \phi_2, \cos \lambda_1, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\cos \phi_2, \cos \left(\lambda_1 - \lambda_2\right), 1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.99560000000000004Initial program 98.9%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-cos.f6478.0
Applied rewrites78.0%
if 0.99560000000000004 < (cos.f64 phi1) Initial program 98.0%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6497.4
Applied rewrites97.4%
(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.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos phi2) (cos 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(lambda2), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(phi2), cos(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[lambda2], $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 \lambda_2, \cos \phi_1\right)}
\end{array}
Initial program 98.4%
Taylor expanded in lambda1 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-cos.f6497.4
Applied rewrites97.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi2 6.8e-9)
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0)))
(+
lambda1
(atan2
(* (cos phi2) t_1)
(fma (* phi1 phi1) -0.5 (+ (* (cos phi2) t_0) 1.0)))))))
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 (phi2 <= 6.8e-9) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_1), fma((phi1 * phi1), -0.5, ((cos(phi2) * t_0) + 1.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 6.8e-9) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), fma(Float64(phi1 * phi1), -0.5, Float64(Float64(cos(phi2) * t_0) + 1.0)))); 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[phi2, 6.8e-9], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + 1.0), $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}\;\phi_2 \leq 6.8 \cdot 10^{-9}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, \cos \phi_2 \cdot t\_0 + 1\right)}\\
\end{array}
\end{array}
if phi2 < 6.7999999999999997e-9Initial program 98.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6478.8
Applied rewrites78.8%
if 6.7999999999999997e-9 < phi2 Initial program 97.1%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.8
Applied rewrites78.8%
Applied rewrites78.8%
Final simplification78.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi2 6.8e-9)
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0)))
(+
lambda1
(atan2
(* (cos phi2) t_1)
(fma (cos phi2) t_0 (fma -0.5 (* phi1 phi1) 1.0)))))))
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 (phi2 <= 6.8e-9) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_1), fma(cos(phi2), t_0, fma(-0.5, (phi1 * phi1), 1.0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 6.8e-9) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), fma(cos(phi2), t_0, fma(-0.5, Float64(phi1 * phi1), 1.0)))); 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[phi2, 6.8e-9], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $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}\;\phi_2 \leq 6.8 \cdot 10^{-9}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\mathsf{fma}\left(\cos \phi_2, t\_0, \mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right)\right)}\\
\end{array}
\end{array}
if phi2 < 6.7999999999999997e-9Initial program 98.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6478.8
Applied rewrites78.8%
if 6.7999999999999997e-9 < phi2 Initial program 97.1%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.8
Applied rewrites78.8%
Final simplification78.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.06)
(+
lambda1
(atan2 (* (cos phi2) t_1) (+ t_0 (fma -0.5 (* phi1 phi1) 1.0))))
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0))))))
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.06) {
tmp = lambda1 + atan2((cos(phi2) * t_1), (t_0 + fma(-0.5, (phi1 * phi1), 1.0)));
} else {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
}
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.06) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(t_0 + fma(-0.5, Float64(phi1 * phi1), 1.0)))); else tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); 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.06], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(t$95$0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $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.06:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{t\_0 + \mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.059999999999999998Initial program 97.3%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.0
Applied rewrites78.0%
Taylor expanded in phi2 around 0
Applied rewrites55.3%
if 0.059999999999999998 < (cos.f64 phi2) Initial program 98.9%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6485.4
Applied rewrites85.4%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6485.4
Applied rewrites85.4%
Final simplification76.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 5.2e-15)
(+ lambda1 (atan2 t_1 (fma (cos phi2) t_0 1.0)))
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 5.2e-15) {
tmp = lambda1 + atan2(t_1, fma(cos(phi2), t_0, 1.0));
} else {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= 5.2e-15) tmp = Float64(lambda1 + atan(t_1, fma(cos(phi2), t_0, 1.0))); else tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); 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[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, 5.2e-15], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 5.2 \cdot 10^{-15}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\cos \phi_2, t\_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\end{array}
\end{array}
if phi1 < 5.20000000000000009e-15Initial program 98.8%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6486.8
Applied rewrites86.8%
if 5.20000000000000009e-15 < phi1 Initial program 97.2%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6470.2
Applied rewrites70.2%
Final simplification82.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.24)
(+ lambda1 (atan2 (* (cos phi2) t_0) (* (* phi1 phi1) -0.5)))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= -0.24) {
tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * -0.5));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi2) <= (-0.24d0)) then
tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * (-0.5d0)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= -0.24) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), ((phi1 * phi1) * -0.5));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= -0.24: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), ((phi1 * phi1) * -0.5)) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos((lambda1 - lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= -0.24) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(Float64(phi1 * phi1) * -0.5))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= -0.24) tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * -0.5)); else tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2)))); 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.24], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $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.24:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\left(\phi_1 \cdot \phi_1\right) \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.23999999999999999Initial program 97.3%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6477.1
Applied rewrites77.1%
Taylor expanded in phi1 around inf
Applied rewrites55.6%
if -0.23999999999999999 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6482.9
Applied rewrites82.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6483.0
Applied rewrites83.0%
Final simplification76.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + cos((lambda1 - lambda2))));
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + 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((lambda1 - lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + math.cos((lambda1 - lambda2))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + 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[Cos[N[(lambda1 - 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 \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.4%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6475.0
Applied rewrites75.0%
Final simplification75.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.235)
(+ lambda1 (atan2 (* (cos phi2) t_0) (* (* phi1 phi1) -0.5)))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= -0.235) {
tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * -0.5));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(lambda2)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi2) <= (-0.235d0)) then
tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * (-0.5d0)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(lambda2)))
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.235) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), ((phi1 * phi1) * -0.5));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos(lambda2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= -0.235: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), ((phi1 * phi1) * -0.5)) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos(lambda2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= -0.235) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(Float64(phi1 * phi1) * -0.5))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= -0.235) tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * -0.5)); else tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(lambda2))); 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.235], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[lambda2], $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.235:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\left(\phi_1 \cdot \phi_1\right) \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \lambda_2}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.23499999999999999Initial program 97.3%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6477.1
Applied rewrites77.1%
Taylor expanded in phi1 around inf
Applied rewrites55.6%
if -0.23499999999999999 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6482.9
Applied rewrites82.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6483.0
Applied rewrites83.0%
Taylor expanded in lambda1 around 0
Applied rewrites82.7%
Final simplification75.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.235)
(+ lambda1 (atan2 (* (cos phi2) t_0) (* (* phi1 phi1) -0.5)))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= -0.235) {
tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * -0.5));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(lambda1)));
}
return tmp;
}
real(8) function code(lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi2) <= (-0.235d0)) then
tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * (-0.5d0)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(lambda1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= -0.235) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), ((phi1 * phi1) * -0.5));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos(lambda1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= -0.235: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), ((phi1 * phi1) * -0.5)) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos(lambda1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= -0.235) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(Float64(phi1 * phi1) * -0.5))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= -0.235) tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * -0.5)); else tmp = lambda1 + atan2(t_0, (cos(phi1) + 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[N[Cos[phi2], $MachinePrecision], -0.235], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[lambda1], $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.235:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\left(\phi_1 \cdot \phi_1\right) \cdot -0.5}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \lambda_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.23499999999999999Initial program 97.3%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6477.1
Applied rewrites77.1%
Taylor expanded in phi1 around inf
Applied rewrites55.6%
if -0.23499999999999999 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6482.9
Applied rewrites82.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6483.0
Applied rewrites83.0%
Taylor expanded in lambda2 around 0
Applied rewrites71.8%
Final simplification67.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (* (* phi1 phi1) -0.5))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), ((phi1 * phi1) * -0.5));
}
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))), ((phi1 * phi1) * (-0.5d0)))
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))), ((phi1 * phi1) * -0.5));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), ((phi1 * phi1) * -0.5))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(Float64(phi1 * phi1) * -0.5))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), ((phi1 * phi1) * -0.5)); 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[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\left(\phi_1 \cdot \phi_1\right) \cdot -0.5}
\end{array}
Initial program 98.4%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6478.0
Applied rewrites78.0%
Taylor expanded in phi1 around inf
Applied rewrites55.3%
Final simplification55.3%
herbie shell --seed 2024223
(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)))))))