
(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 20 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 (- lambda2)) (cos lambda1) (* (cos lambda2) (sin lambda1))))
(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), (cos(lambda2) * sin(lambda1)))), 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(cos(lambda2) * sin(lambda1)))), 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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $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, \cos \lambda_2 \cdot \sin \lambda_1\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.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
Applied rewrites98.3%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
lift-cos.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in phi2 around inf
+-commutativeN/A
cos-negN/A
associate-*r*N/A
cos-negN/A
*-commutativeN/A
distribute-rgt-outN/A
lower-fma.f64N/A
Applied rewrites99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (+ lambda1 (atan2 t_1 (* (* phi1 phi1) -0.5))))
(t_3 (+ lambda1 (atan2 t_1 (+ (cos phi1) (* (cos phi2) t_0))))))
(if (<= t_3 -0.01)
t_2
(if (<= t_3 2e-6)
(+
lambda1
(atan2
(fma
lambda2
(fma 0.16666666666666666 (* lambda2 lambda2) -1.0)
(fma
lambda1
(fma
lambda1
(fma
lambda1
(fma (* lambda2 lambda2) 0.08333333333333333 -0.16666666666666666)
(* lambda2 (fma (* lambda2 lambda2) -0.08333333333333333 0.5)))
(* -0.5 (* lambda2 lambda2)))
lambda1))
(+ (cos phi1) t_0)))
t_2))))
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 t_2 = lambda1 + atan2(t_1, ((phi1 * phi1) * -0.5));
double t_3 = lambda1 + atan2(t_1, (cos(phi1) + (cos(phi2) * t_0)));
double tmp;
if (t_3 <= -0.01) {
tmp = t_2;
} else if (t_3 <= 2e-6) {
tmp = lambda1 + atan2(fma(lambda2, fma(0.16666666666666666, (lambda2 * lambda2), -1.0), fma(lambda1, fma(lambda1, fma(lambda1, fma((lambda2 * lambda2), 0.08333333333333333, -0.16666666666666666), (lambda2 * fma((lambda2 * lambda2), -0.08333333333333333, 0.5))), (-0.5 * (lambda2 * lambda2))), lambda1)), (cos(phi1) + t_0));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(lambda1 + atan(t_1, Float64(Float64(phi1 * phi1) * -0.5))) t_3 = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))) tmp = 0.0 if (t_3 <= -0.01) tmp = t_2; elseif (t_3 <= 2e-6) tmp = Float64(lambda1 + atan(fma(lambda2, fma(0.16666666666666666, Float64(lambda2 * lambda2), -1.0), fma(lambda1, fma(lambda1, fma(lambda1, fma(Float64(lambda2 * lambda2), 0.08333333333333333, -0.16666666666666666), Float64(lambda2 * fma(Float64(lambda2 * lambda2), -0.08333333333333333, 0.5))), Float64(-0.5 * Float64(lambda2 * lambda2))), lambda1)), Float64(cos(phi1) + t_0))); else tmp = t_2; 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]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -0.01], t$95$2, If[LessEqual[t$95$3, 2e-6], N[(lambda1 + N[ArcTan[N[(lambda2 * N[(0.16666666666666666 * N[(lambda2 * lambda2), $MachinePrecision] + -1.0), $MachinePrecision] + N[(lambda1 * N[(lambda1 * N[(lambda1 * N[(N[(lambda2 * lambda2), $MachinePrecision] * 0.08333333333333333 + -0.16666666666666666), $MachinePrecision] + N[(lambda2 * N[(N[(lambda2 * lambda2), $MachinePrecision] * -0.08333333333333333 + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(lambda2 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + lambda1), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\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)\\
t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\left(\phi_1 \cdot \phi_1\right) \cdot -0.5}\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;t\_3 \leq -0.01:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\lambda_2, \mathsf{fma}\left(0.16666666666666666, \lambda_2 \cdot \lambda_2, -1\right), \mathsf{fma}\left(\lambda_1, \mathsf{fma}\left(\lambda_1, \mathsf{fma}\left(\lambda_1, \mathsf{fma}\left(\lambda_2 \cdot \lambda_2, 0.08333333333333333, -0.16666666666666666\right), \lambda_2 \cdot \mathsf{fma}\left(\lambda_2 \cdot \lambda_2, -0.08333333333333333, 0.5\right)\right), -0.5 \cdot \left(\lambda_2 \cdot \lambda_2\right)\right), \lambda_1\right)\right)}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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.0100000000000000002 or 1.99999999999999991e-6 < (+.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.0%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites98.0%
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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6482.0
Applied rewrites82.0%
Taylor expanded in phi1 around inf
Applied rewrites68.1%
if -0.0100000000000000002 < (+.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)))))) < 1.99999999999999991e-6Initial program 98.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6463.4
Applied rewrites63.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6463.9
Applied rewrites63.9%
Taylor expanded in lambda2 around 0
Applied rewrites63.9%
Taylor expanded in lambda1 around 0
Applied rewrites63.9%
Final simplification67.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (+ lambda1 (atan2 t_1 (* (* phi1 phi1) -0.5))))
(t_3 (+ lambda1 (atan2 t_1 (+ (cos phi1) (* (cos phi2) t_0))))))
(if (<= t_3 -0.01)
t_2
(if (<= t_3 0.1)
(+
lambda1
(atan2
(fma
lambda1
(fma -0.5 (* lambda2 lambda2) 1.0)
(* lambda2 (fma 0.16666666666666666 (* lambda2 lambda2) -1.0)))
(+ (cos phi1) t_0)))
t_2))))
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 t_2 = lambda1 + atan2(t_1, ((phi1 * phi1) * -0.5));
double t_3 = lambda1 + atan2(t_1, (cos(phi1) + (cos(phi2) * t_0)));
double tmp;
if (t_3 <= -0.01) {
tmp = t_2;
} else if (t_3 <= 0.1) {
tmp = lambda1 + atan2(fma(lambda1, fma(-0.5, (lambda2 * lambda2), 1.0), (lambda2 * fma(0.16666666666666666, (lambda2 * lambda2), -1.0))), (cos(phi1) + t_0));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(lambda1 + atan(t_1, Float64(Float64(phi1 * phi1) * -0.5))) t_3 = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))) tmp = 0.0 if (t_3 <= -0.01) tmp = t_2; elseif (t_3 <= 0.1) tmp = Float64(lambda1 + atan(fma(lambda1, fma(-0.5, Float64(lambda2 * lambda2), 1.0), Float64(lambda2 * fma(0.16666666666666666, Float64(lambda2 * lambda2), -1.0))), Float64(cos(phi1) + t_0))); else tmp = t_2; 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]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -0.01], t$95$2, If[LessEqual[t$95$3, 0.1], N[(lambda1 + N[ArcTan[N[(lambda1 * N[(-0.5 * N[(lambda2 * lambda2), $MachinePrecision] + 1.0), $MachinePrecision] + N[(lambda2 * N[(0.16666666666666666 * N[(lambda2 * lambda2), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\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)\\
t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\left(\phi_1 \cdot \phi_1\right) \cdot -0.5}\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;t\_3 \leq -0.01:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 0.1:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\lambda_1, \mathsf{fma}\left(-0.5, \lambda_2 \cdot \lambda_2, 1\right), \lambda_2 \cdot \mathsf{fma}\left(0.16666666666666666, \lambda_2 \cdot \lambda_2, -1\right)\right)}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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.0100000000000000002 or 0.10000000000000001 < (+.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.4%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites98.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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6482.2
Applied rewrites82.2%
Taylor expanded in phi1 around inf
Applied rewrites68.9%
if -0.0100000000000000002 < (+.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.10000000000000001Initial program 97.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6460.5
Applied rewrites60.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6460.9
Applied rewrites60.9%
Taylor expanded in lambda2 around 0
Applied rewrites61.2%
Taylor expanded in lambda1 around 0
Applied rewrites60.7%
Final simplification67.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2))))
(t_2 (+ lambda1 (atan2 t_1 (* (* phi1 phi1) -0.5))))
(t_3 (+ lambda1 (atan2 t_1 (+ (cos phi1) (* (cos phi2) t_0))))))
(if (<= t_3 -0.01)
t_2
(if (<= t_3 0.1)
(+
lambda1
(atan2
(* lambda2 (fma 0.16666666666666666 (* lambda2 lambda2) -1.0))
(+ (cos phi1) t_0)))
t_2))))
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 t_2 = lambda1 + atan2(t_1, ((phi1 * phi1) * -0.5));
double t_3 = lambda1 + atan2(t_1, (cos(phi1) + (cos(phi2) * t_0)));
double tmp;
if (t_3 <= -0.01) {
tmp = t_2;
} else if (t_3 <= 0.1) {
tmp = lambda1 + atan2((lambda2 * fma(0.16666666666666666, (lambda2 * lambda2), -1.0)), (cos(phi1) + t_0));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) t_2 = Float64(lambda1 + atan(t_1, Float64(Float64(phi1 * phi1) * -0.5))) t_3 = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + Float64(cos(phi2) * t_0)))) tmp = 0.0 if (t_3 <= -0.01) tmp = t_2; elseif (t_3 <= 0.1) tmp = Float64(lambda1 + atan(Float64(lambda2 * fma(0.16666666666666666, Float64(lambda2 * lambda2), -1.0)), Float64(cos(phi1) + t_0))); else tmp = t_2; 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]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[t$95$1 / N[(N[(phi1 * phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -0.01], t$95$2, If[LessEqual[t$95$3, 0.1], N[(lambda1 + N[ArcTan[N[(lambda2 * N[(0.16666666666666666 * N[(lambda2 * lambda2), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\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)\\
t_2 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\left(\phi_1 \cdot \phi_1\right) \cdot -0.5}\\
t_3 := \lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;t\_3 \leq -0.01:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_3 \leq 0.1:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\lambda_2 \cdot \mathsf{fma}\left(0.16666666666666666, \lambda_2 \cdot \lambda_2, -1\right)}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\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.0100000000000000002 or 0.10000000000000001 < (+.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.4%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites98.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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6482.2
Applied rewrites82.2%
Taylor expanded in phi1 around inf
Applied rewrites68.9%
if -0.0100000000000000002 < (+.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.10000000000000001Initial program 97.1%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6460.5
Applied rewrites60.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6460.9
Applied rewrites60.9%
Taylor expanded in lambda2 around 0
Applied rewrites61.2%
Taylor expanded in lambda1 around 0
Applied rewrites36.9%
Final simplification61.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(fma (sin (- lambda2)) (cos lambda1) (* (cos lambda2) (sin lambda1))))
(fma
(cos phi2)
(fma
(cos lambda1)
(cos lambda2)
(*
lambda1
(* (sin lambda2) (fma -0.16666666666666666 (* lambda1 lambda1) 1.0))))
(cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * fma(sin(-lambda2), cos(lambda1), (cos(lambda2) * sin(lambda1)))), fma(cos(phi2), fma(cos(lambda1), cos(lambda2), (lambda1 * (sin(lambda2) * fma(-0.16666666666666666, (lambda1 * lambda1), 1.0)))), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * fma(sin(Float64(-lambda2)), cos(lambda1), Float64(cos(lambda2) * sin(lambda1)))), fma(cos(phi2), fma(cos(lambda1), cos(lambda2), Float64(lambda1 * Float64(sin(lambda2) * fma(-0.16666666666666666, Float64(lambda1 * lambda1), 1.0)))), 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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(lambda1 * N[(N[Sin[lambda2], $MachinePrecision] * N[(-0.16666666666666666 * N[(lambda1 * lambda1), $MachinePrecision] + 1.0), $MachinePrecision]), $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, \cos \lambda_2 \cdot \sin \lambda_1\right)}{\mathsf{fma}\left(\cos \phi_2, \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \lambda_1 \cdot \left(\sin \lambda_2 \cdot \mathsf{fma}\left(-0.16666666666666666, \lambda_1 \cdot \lambda_1, 1\right)\right)\right), \cos \phi_1\right)}
\end{array}
Initial program 98.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
Applied rewrites98.3%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
lift-cos.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in phi2 around inf
+-commutativeN/A
cos-negN/A
associate-*r*N/A
cos-negN/A
*-commutativeN/A
distribute-rgt-outN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in lambda1 around 0
Applied rewrites98.9%
Final simplification98.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(*
(cos phi2)
(fma (sin (- lambda2)) (cos lambda1) (* (cos lambda2) (sin lambda1))))
(fma
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* 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), (cos(lambda2) * sin(lambda1)))), fma(cos(phi2), fma(cos(lambda1), cos(lambda2), (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(cos(lambda2) * sin(lambda1)))), fma(cos(phi2), fma(cos(lambda1), cos(lambda2), Float64(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[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(lambda1 * 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, \cos \lambda_2 \cdot \sin \lambda_1\right)}{\mathsf{fma}\left(\cos \phi_2, \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \lambda_1 \cdot \sin \lambda_2\right), \cos \phi_1\right)}
\end{array}
Initial program 98.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
Applied rewrites98.3%
lift-sin.f64N/A
lift--.f64N/A
sub-negN/A
+-commutativeN/A
sin-sumN/A
lift-cos.f64N/A
cos-negN/A
lift-cos.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
Taylor expanded in phi2 around inf
+-commutativeN/A
cos-negN/A
associate-*r*N/A
cos-negN/A
*-commutativeN/A
distribute-rgt-outN/A
lower-fma.f64N/A
Applied rewrites99.6%
Taylor expanded in lambda1 around 0
Applied rewrites98.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(* (cos phi2) (cos lambda2))
(cos lambda1)
(fma (cos phi2) (* (sin lambda1) (sin 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(lambda1), fma(cos(phi2), (sin(lambda1) * sin(lambda2)), cos(phi1))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(Float64(cos(phi2) * cos(lambda2)), cos(lambda1), fma(cos(phi2), Float64(sin(lambda1) * sin(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[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $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 \cdot \cos \lambda_2, \cos \lambda_1, \mathsf{fma}\left(\cos \phi_2, \sin \lambda_1 \cdot \sin \lambda_2, \cos \phi_1\right)\right)}
\end{array}
Initial program 98.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
distribute-lft-inN/A
associate-+l+N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
Applied rewrites98.3%
(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.2%
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.3
Applied rewrites98.3%
Final simplification98.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.9995)
(+
lambda1
(atan2
(* (cos phi2) t_1)
(fma
(cos phi2)
t_0
(fma
(* phi1 phi1)
(fma
(* phi1 phi1)
(fma (* phi1 phi1) -0.001388888888888889 0.041666666666666664)
-0.5)
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.9995) {
tmp = lambda1 + atan2((cos(phi2) * t_1), fma(cos(phi2), t_0, fma((phi1 * phi1), fma((phi1 * phi1), fma((phi1 * phi1), -0.001388888888888889, 0.041666666666666664), -0.5), 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.9995) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), fma(cos(phi2), t_0, fma(Float64(phi1 * phi1), fma(Float64(phi1 * phi1), fma(Float64(phi1 * phi1), -0.001388888888888889, 0.041666666666666664), -0.5), 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.9995], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[(N[(phi1 * phi1), $MachinePrecision] * N[(N[(phi1 * phi1), $MachinePrecision] * N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] + -0.5), $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.9995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\mathsf{fma}\left(\cos \phi_2, t\_0, \mathsf{fma}\left(\phi_1 \cdot \phi_1, \mathsf{fma}\left(\phi_1 \cdot \phi_1, \mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.001388888888888889, 0.041666666666666664\right), -0.5\right), 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.99950000000000006Initial program 97.5%
Taylor expanded in phi1 around 0
associate-+r+N/A
+-commutativeN/A
associate-+l+N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f64N/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites80.1%
if 0.99950000000000006 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6498.2
Applied rewrites98.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6498.2
Applied rewrites98.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.9995)
(+
lambda1
(atan2
(* (cos phi2) t_0)
(fma (cos phi2) (cos lambda2) (fma phi1 (* phi1 -0.5) 1.0))))
(+ 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.9995) {
tmp = lambda1 + atan2((cos(phi2) * t_0), fma(cos(phi2), cos(lambda2), fma(phi1, (phi1 * -0.5), 1.0)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.9995) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), fma(cos(phi2), cos(lambda2), fma(phi1, Float64(phi1 * -0.5), 1.0)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); 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.9995], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(phi1 * N[(phi1 * -0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $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.9995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(\cos \phi_2, \cos \lambda_2, \mathsf{fma}\left(\phi_1, \phi_1 \cdot -0.5, 1\right)\right)}\\
\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.99950000000000006Initial program 97.5%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites97.5%
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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6479.9
Applied rewrites79.9%
Taylor expanded in lambda1 around 0
Applied rewrites79.9%
if 0.99950000000000006 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6498.2
Applied rewrites98.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6498.2
Applied rewrites98.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= (cos phi1) 0.9996)
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0)))
(+ lambda1 (atan2 t_1 (fma (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 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.9996) {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2(t_1, fma(cos(phi2), t_0, 1.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 (cos(phi1) <= 0.9996) tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(t_1, fma(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[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.9996], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + 1.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}\;\cos \phi_1 \leq 0.9996:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\cos \phi_2, t\_0, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.99960000000000004Initial program 98.2%
Taylor expanded in phi2 around 0
+-commutativeN/A
lower-+.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-cos.f6477.3
Applied rewrites77.3%
if 0.99960000000000004 < (cos.f64 phi1) Initial program 98.1%
Taylor expanded in phi1 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6497.7
Applied rewrites97.7%
Final simplification87.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.3)
(+
lambda1
(atan2 (* (cos phi2) t_1) (+ 1.0 (fma -0.5 (* phi1 phi1) t_0))))
(+ lambda1 (atan2 t_1 (+ (cos phi1) (* (cos phi2) 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.3) {
tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0 + fma(-0.5, (phi1 * phi1), t_0)));
} else {
tmp = lambda1 + atan2(t_1, (cos(phi1) + (cos(phi2) * 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.3) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(1.0 + fma(-0.5, Float64(phi1 * phi1), t_0)))); else tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + Float64(cos(phi2) * 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.3], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$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}\;\cos \phi_2 \leq 0.3:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{1 + \mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.299999999999999989Initial program 97.0%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites97.0%
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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6479.7
Applied rewrites79.7%
Taylor expanded in phi2 around 0
Applied rewrites63.9%
if 0.299999999999999989 < (cos.f64 phi2) Initial program 98.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6489.1
Applied rewrites89.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.2%
(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.2%
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.2
Applied rewrites97.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.61)
(+
lambda1
(atan2 (* (cos phi2) t_1) (+ 1.0 (fma -0.5 (* phi1 phi1) t_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.61) {
tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0 + fma(-0.5, (phi1 * phi1), t_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.61) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(1.0 + fma(-0.5, Float64(phi1 * phi1), t_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.61], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(1.0 + N[(-0.5 * N[(phi1 * phi1), $MachinePrecision] + t$95$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.61:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{1 + \mathsf{fma}\left(-0.5, \phi_1 \cdot \phi_1, t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.609999999999999987Initial program 97.4%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites97.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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6479.8
Applied rewrites79.8%
Taylor expanded in phi2 around 0
Applied rewrites64.1%
if 0.609999999999999987 < (cos.f64 phi2) Initial program 98.6%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6490.4
Applied rewrites90.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6490.5
Applied rewrites90.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.06)
(+ 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.06) {
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.06d0)) 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.06) {
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.06: 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.06) 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.06) 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.06], 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.06:\\
\;\;\;\;\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.059999999999999998Initial program 96.6%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites96.5%
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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6479.8
Applied rewrites79.8%
Taylor expanded in phi1 around inf
Applied rewrites64.4%
if -0.059999999999999998 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6487.2
Applied rewrites87.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6486.9
Applied rewrites86.9%
Final simplification81.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.055)
(+ 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.055) {
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.055d0)) 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.055) {
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.055: 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.055) 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.055) 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.055], 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.055:\\
\;\;\;\;\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.0550000000000000003Initial program 96.6%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites96.5%
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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6479.8
Applied rewrites79.8%
Taylor expanded in phi1 around inf
Applied rewrites64.4%
if -0.0550000000000000003 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6487.2
Applied rewrites87.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6486.9
Applied rewrites86.9%
Taylor expanded in lambda1 around 0
Applied rewrites85.9%
Final simplification80.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.055)
(+ 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.055) {
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.055d0)) 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.055) {
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.055: 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.055) 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.055) 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.055], 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.055:\\
\;\;\;\;\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.0550000000000000003Initial program 96.6%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites96.5%
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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6479.8
Applied rewrites79.8%
Taylor expanded in phi1 around inf
Applied rewrites64.4%
if -0.0550000000000000003 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6487.2
Applied rewrites87.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6486.9
Applied rewrites86.9%
Taylor expanded in lambda2 around 0
Applied rewrites69.3%
Final simplification68.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) -0.055)
(+ lambda1 (atan2 (* (cos phi2) t_0) (* (* phi1 phi1) -0.5)))
(+ lambda1 (atan2 t_0 (+ (cos phi2) (cos phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= -0.055) {
tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * -0.5));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi2) + 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.055d0)) then
tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * (-0.5d0)))
else
tmp = lambda1 + atan2(t_0, (cos(phi2) + 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.055) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), ((phi1 * phi1) * -0.5));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi2) + Math.cos(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= -0.055: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), ((phi1 * phi1) * -0.5)) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi2) + math.cos(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= -0.055) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(Float64(phi1 * phi1) * -0.5))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi2) + 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.055) tmp = lambda1 + atan2((cos(phi2) * t_0), ((phi1 * phi1) * -0.5)); else tmp = lambda1 + atan2(t_0, (cos(phi2) + 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.055], 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[phi2], $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.055:\\
\;\;\;\;\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_2 + \cos \phi_1}\\
\end{array}
\end{array}
if (cos.f64 phi2) < -0.0550000000000000003Initial program 96.6%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites96.5%
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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6479.8
Applied rewrites79.8%
Taylor expanded in phi1 around inf
Applied rewrites64.4%
if -0.0550000000000000003 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in phi2 around 0
lower-sin.f64N/A
lower--.f6487.2
Applied rewrites87.2%
Taylor expanded in lambda1 around 0
+-commutativeN/A
mul-1-negN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
sin-negN/A
remove-double-negN/A
associate-*r*N/A
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
distribute-lft-outN/A
+-commutativeN/A
lower-fma.f64N/A
Applied rewrites86.2%
Taylor expanded in lambda2 around 0
Applied rewrites68.7%
Final simplification67.6%
(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.2%
lift-+.f64N/A
flip3-+N/A
clear-numN/A
lower-/.f64N/A
clear-numN/A
flip3-+N/A
Applied rewrites98.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
*-commutativeN/A
unpow2N/A
associate-*l*N/A
lower-fma.f64N/A
lower-*.f6476.1
Applied rewrites76.1%
Taylor expanded in phi1 around inf
Applied rewrites55.2%
Final simplification55.2%
herbie shell --seed 2024226
(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)))))))