
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 41 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.1
Applied rewrites90.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.1
Applied rewrites90.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -700000000000.0)
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (- (cos phi2)) (* t_2 (sin phi1)))))
(if (<= phi2 1e-41)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
t_0
(*
(* (sin phi1) (fma (* phi2 phi2) -0.5 1.0))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -700000000000.0) {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), (-cos(phi2) * (t_2 * sin(phi1)))));
} else if (phi2 <= 1e-41) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - ((sin(phi1) * fma((phi2 * phi2), -0.5, 1.0)) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -700000000000.0) tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(t_2 * sin(phi1))))); elseif (phi2 <= 1e-41) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * fma(Float64(phi2 * phi2), -0.5, 1.0)) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -700000000000.0], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(t$95$2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1e-41], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -700000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(t\_2 \cdot \sin \phi_1\right)\right)}\\
\mathbf{elif}\;\phi_2 \leq 10^{-41}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\right) \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\end{array}
\end{array}
if phi2 < -7e11Initial program 82.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.1
Applied rewrites92.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-diff-revN/A
associate-*r*N/A
*-commutativeN/A
Applied rewrites92.2%
if -7e11 < phi2 < 1.00000000000000001e-41Initial program 82.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.4
Applied rewrites90.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6499.9
Applied rewrites99.9%
if 1.00000000000000001e-41 < phi2 Initial program 76.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6488.2
Applied rewrites88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2)))
(t_2 (* (sin phi1) (cos phi2))))
(if (<= phi2 -8.5e-5)
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (- (cos phi2)) (* t_0 (sin phi1)))))
(if (<= phi2 1e-41)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) phi2)
(*
t_2
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* t_2 t_0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = sin(phi1) * cos(phi2);
double tmp;
if (phi2 <= -8.5e-5) {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), (-cos(phi2) * (t_0 * sin(phi1)))));
} else if (phi2 <= 1e-41) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * phi2) - (t_2 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_2 * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)) t_2 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if (phi2 <= -8.5e-5) tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(t_0 * sin(phi1))))); elseif (phi2 <= 1e-41) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * phi2) - Float64(t_2 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_2 * 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[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -8.5e-5], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1e-41], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * phi2), $MachinePrecision] - N[(t$95$2 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -8.5 \cdot 10^{-5}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(t\_0 \cdot \sin \phi_1\right)\right)}\\
\mathbf{elif}\;\phi_2 \leq 10^{-41}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \phi_2 - t\_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - t\_2 \cdot t\_0}\\
\end{array}
\end{array}
if phi2 < -8.500000000000001e-5Initial program 82.1%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.7
Applied rewrites92.7%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-diff-revN/A
associate-*r*N/A
*-commutativeN/A
Applied rewrites92.8%
if -8.500000000000001e-5 < phi2 < 1.00000000000000001e-41Initial program 82.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.1
Applied rewrites90.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
Applied rewrites99.8%
if 1.00000000000000001e-41 < phi2 Initial program 76.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6488.2
Applied rewrites88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -700000000000.0)
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (- (cos phi2)) (* t_2 (sin phi1)))))
(if (<= phi2 1e-41)
(atan2
t_1
(-
t_0
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -700000000000.0) {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), (-cos(phi2) * (t_2 * sin(phi1)))));
} else if (phi2 <= 1e-41) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -700000000000.0) tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(t_2 * sin(phi1))))); elseif (phi2 <= 1e-41) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -700000000000.0], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(t$95$2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1e-41], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -700000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(t\_2 \cdot \sin \phi_1\right)\right)}\\
\mathbf{elif}\;\phi_2 \leq 10^{-41}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}\\
\end{array}
\end{array}
if phi2 < -7e11Initial program 82.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.1
Applied rewrites92.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-diff-revN/A
associate-*r*N/A
*-commutativeN/A
Applied rewrites92.2%
if -7e11 < phi2 < 1.00000000000000001e-41Initial program 82.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.4
Applied rewrites90.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi2 around 0
lift-sin.f6499.6
Applied rewrites99.6%
if 1.00000000000000001e-41 < phi2 Initial program 76.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6488.2
Applied rewrites88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2)))
(t_1
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi2 -700000000000.0)
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (- (cos phi2)) (* t_2 (sin phi1)))))
(if (<= phi2 1e-41)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(-
(sin phi2)
(*
t_0
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* t_0 t_2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
double t_1 = fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -700000000000.0) {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), (-cos(phi2) * (t_2 * sin(phi1)))));
} else if (phi2 <= 1e-41) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (t_0 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_0 * t_2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) t_1 = Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -700000000000.0) tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(t_2 * sin(phi1))))); elseif (phi2 <= 1e-41) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(t_0 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * t_2))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -700000000000.0], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(t$95$2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1e-41], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
t_1 := \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -700000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(t\_2 \cdot \sin \phi_1\right)\right)}\\
\mathbf{elif}\;\phi_2 \leq 10^{-41}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_0 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot t\_2}\\
\end{array}
\end{array}
if phi2 < -7e11Initial program 82.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6492.1
Applied rewrites92.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.5
Applied rewrites99.5%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-diff-revN/A
associate-*r*N/A
*-commutativeN/A
Applied rewrites92.2%
if -7e11 < phi2 < 1.00000000000000001e-41Initial program 82.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.4
Applied rewrites90.4%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi1 around 0
lift-sin.f6499.4
Applied rewrites99.4%
if 1.00000000000000001e-41 < phi2 Initial program 76.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6488.2
Applied rewrites88.2%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6488.2
Applied rewrites88.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -1.3e+27) (not (<= lambda2 0.045)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* t_1 (cos lambda2))))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(- t_0 (* t_1 (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda2 <= -1.3e+27) || !(lambda2 <= 0.045)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -1.3e+27) || !(lambda2 <= 0.045)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.3e+27], N[Not[LessEqual[lambda2, 0.045]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -1.3 \cdot 10^{+27} \lor \neg \left(\lambda_2 \leq 0.045\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda2 < -1.30000000000000004e27 or 0.044999999999999998 < lambda2 Initial program 59.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.2
Applied rewrites80.2%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f6480.6
Applied rewrites80.6%
if -1.30000000000000004e27 < lambda2 < 0.044999999999999998Initial program 96.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6497.7
Applied rewrites97.7%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda2 around 0
cos-diff-revN/A
lift-cos.f6497.7
Applied rewrites97.7%
Final simplification90.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2)))
(t_2 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -1.3e+27) (not (<= lambda2 0.045)))
(atan2 t_1 (- t_0 (* t_2 (cos lambda2))))
(atan2 t_1 (- t_0 (* t_2 (cos lambda1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda2 <= -1.3e+27) || !(lambda2 <= 0.045)) {
tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda2))));
} else {
tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)
t_2 = sin(phi1) * cos(phi2)
if ((lambda2 <= (-1.3d+27)) .or. (.not. (lambda2 <= 0.045d0))) then
tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda2))))
else
tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = ((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2);
double t_2 = Math.sin(phi1) * Math.cos(phi2);
double tmp;
if ((lambda2 <= -1.3e+27) || !(lambda2 <= 0.045)) {
tmp = Math.atan2(t_1, (t_0 - (t_2 * Math.cos(lambda2))));
} else {
tmp = Math.atan2(t_1, (t_0 - (t_2 * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = ((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2) t_2 = math.sin(phi1) * math.cos(phi2) tmp = 0 if (lambda2 <= -1.3e+27) or not (lambda2 <= 0.045): tmp = math.atan2(t_1, (t_0 - (t_2 * math.cos(lambda2)))) else: tmp = math.atan2(t_1, (t_0 - (t_2 * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)) t_2 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -1.3e+27) || !(lambda2 <= 0.045)) tmp = atan(t_1, Float64(t_0 - Float64(t_2 * cos(lambda2)))); else tmp = atan(t_1, Float64(t_0 - Float64(t_2 * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2); t_2 = sin(phi1) * cos(phi2); tmp = 0.0; if ((lambda2 <= -1.3e+27) || ~((lambda2 <= 0.045))) tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda2)))); else tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -1.3e+27], N[Not[LessEqual[lambda2, 0.045]], $MachinePrecision]], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$2 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -1.3 \cdot 10^{+27} \lor \neg \left(\lambda_2 \leq 0.045\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - t\_2 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - t\_2 \cdot \cos \lambda_1}\\
\end{array}
\end{array}
if lambda2 < -1.30000000000000004e27 or 0.044999999999999998 < lambda2 Initial program 59.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.2
Applied rewrites80.2%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f6480.6
Applied rewrites80.6%
if -1.30000000000000004e27 < lambda2 < 0.044999999999999998Initial program 96.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6497.7
Applied rewrites97.7%
Taylor expanded in lambda1 around inf
Applied rewrites97.7%
Final simplification90.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (* (sin phi1) (cos phi2))))
(if (or (<= lambda2 -0.56) (not (<= lambda2 0.045)))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- t_0 (* t_1 (cos lambda2))))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
t_0
(* t_1 (* (+ (/ (cos lambda1) lambda2) (sin lambda1)) lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(phi1) * cos(phi2);
double tmp;
if ((lambda2 <= -0.56) || !(lambda2 <= 0.045)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * (((cos(lambda1) / lambda2) + sin(lambda1)) * lambda2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin(phi1) * cos(phi2)
if ((lambda2 <= (-0.56d0)) .or. (.not. (lambda2 <= 0.045d0))) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2))))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * (((cos(lambda1) / lambda2) + sin(lambda1)) * lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin(phi1) * Math.cos(phi2);
double tmp;
if ((lambda2 <= -0.56) || !(lambda2 <= 0.045)) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (t_0 - (t_1 * Math.cos(lambda2))));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (t_1 * (((Math.cos(lambda1) / lambda2) + Math.sin(lambda1)) * lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(phi1) * math.cos(phi2) tmp = 0 if (lambda2 <= -0.56) or not (lambda2 <= 0.045): tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (t_0 - (t_1 * math.cos(lambda2)))) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (t_1 * (((math.cos(lambda1) / lambda2) + math.sin(lambda1)) * lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -0.56) || !(lambda2 <= 0.045)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(t_1 * cos(lambda2)))); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(t_1 * Float64(Float64(Float64(cos(lambda1) / lambda2) + sin(lambda1)) * lambda2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(phi1) * cos(phi2); tmp = 0.0; if ((lambda2 <= -0.56) || ~((lambda2 <= 0.045))) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (t_1 * cos(lambda2)))); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (t_1 * (((cos(lambda1) / lambda2) + sin(lambda1)) * lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.56], N[Not[LessEqual[lambda2, 0.045]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[(N[(N[(N[Cos[lambda1], $MachinePrecision] / lambda2), $MachinePrecision] + N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.56 \lor \neg \left(\lambda_2 \leq 0.045\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \cos \lambda_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \left(\left(\frac{\cos \lambda_1}{\lambda_2} + \sin \lambda_1\right) \cdot \lambda_2\right)}\\
\end{array}
\end{array}
if lambda2 < -0.56000000000000005 or 0.044999999999999998 < lambda2 Initial program 58.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.4
Applied rewrites79.4%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f6479.8
Applied rewrites79.8%
if -0.56000000000000005 < lambda2 < 0.044999999999999998Initial program 98.6%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f6498.7
Applied rewrites98.7%
Taylor expanded in lambda2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-/.f64N/A
lift-cos.f64N/A
lift-sin.f6498.7
Applied rewrites98.7%
Final simplification90.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2)))
(t_2 (* (sin phi1) (cos phi2)))
(t_3 (- t_0 (* t_2 (cos lambda2)))))
(if (<= lambda2 -1.3e+27)
(atan2 t_1 t_3)
(if (<= lambda2 0.045)
(atan2 t_1 (- t_0 (* t_2 (cos lambda1))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
t_3)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2);
double t_2 = sin(phi1) * cos(phi2);
double t_3 = t_0 - (t_2 * cos(lambda2));
double tmp;
if (lambda2 <= -1.3e+27) {
tmp = atan2(t_1, t_3);
} else if (lambda2 <= 0.045) {
tmp = atan2(t_1, (t_0 - (t_2 * cos(lambda1))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), t_3);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)) t_2 = Float64(sin(phi1) * cos(phi2)) t_3 = Float64(t_0 - Float64(t_2 * cos(lambda2))) tmp = 0.0 if (lambda2 <= -1.3e+27) tmp = atan(t_1, t_3); elseif (lambda2 <= 0.045) tmp = atan(t_1, Float64(t_0 - Float64(t_2 * cos(lambda1)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), t_3); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 - N[(t$95$2 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -1.3e+27], N[ArcTan[t$95$1 / t$95$3], $MachinePrecision], If[LessEqual[lambda2, 0.045], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$3], $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
t_3 := t\_0 - t\_2 \cdot \cos \lambda_2\\
\mathbf{if}\;\lambda_2 \leq -1.3 \cdot 10^{+27}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_3}\\
\mathbf{elif}\;\lambda_2 \leq 0.045:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - t\_2 \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_3}\\
\end{array}
\end{array}
if lambda2 < -1.30000000000000004e27Initial program 55.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.9
Applied rewrites79.9%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
cos-diff-revN/A
lift-cos.f6479.9
Applied rewrites79.9%
if -1.30000000000000004e27 < lambda2 < 0.044999999999999998Initial program 96.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6497.7
Applied rewrites97.7%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in lambda2 around 0
cos-diff-revN/A
lift-cos.f6497.7
Applied rewrites97.7%
if 0.044999999999999998 < lambda2 Initial program 63.8%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6480.5
Applied rewrites80.5%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
cos-neg-revN/A
lift-cos.f6481.3
Applied rewrites81.3%
Final simplification90.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2))) (cos phi2)) (fma (sin phi2) (cos phi1) (* (- (cos phi2)) (* (cos (- lambda1 lambda2)) (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(phi2) * (cos((lambda1 - lambda2)) * sin(phi1)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)\right)}
\end{array}
Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.1
Applied rewrites90.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-diff-revN/A
associate-*r*N/A
*-commutativeN/A
Applied rewrites90.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (fma (sin phi2) (cos phi1) (* (- (cos phi2)) (* (cos (- lambda1 lambda2)) (sin phi1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), (-cos(phi2) * (cos((lambda1 - lambda2)) * sin(phi1)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-cos(phi2)) * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Cos[phi2], $MachinePrecision]) * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\cos \phi_2\right) \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)\right)}
\end{array}
Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.1
Applied rewrites90.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
cos-diff-revN/A
sin-+PI/2-revN/A
Applied rewrites90.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 80.7%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.1
Applied rewrites90.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -4.3e-10) (not (<= phi1 8.6e-10)))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) (sin lambda2)) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) t_1)))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(- t_0 (* (sin phi1) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -4.3e-10) || !(phi1 <= 8.6e-10)) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - sin(lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (sin(phi1) * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -4.3e-10) || !(phi1 <= 8.6e-10)) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - sin(lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(sin(phi1) * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -4.3e-10], N[Not[LessEqual[phi1, 8.6e-10]], $MachinePrecision]], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -4.3 \cdot 10^{-10} \lor \neg \left(\phi_1 \leq 8.6 \cdot 10^{-10}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \sin \phi_1 \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -4.30000000000000014e-10 or 8.60000000000000029e-10 < phi1 Initial program 78.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6481.2
Applied rewrites81.2%
Taylor expanded in lambda1 around 0
lift-sin.f6479.6
Applied rewrites79.6%
if -4.30000000000000014e-10 < phi1 < 8.60000000000000029e-10Initial program 83.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
lift-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Final simplification89.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin lambda1) (cos lambda2))))
(if (or (<= phi1 -4.3e-10) (not (<= phi1 8.6e-10)))
(atan2
(* (- t_1 (sin lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))
(atan2
(* (- t_1 (* (cos lambda1) (sin lambda2))) (cos phi2))
(- (sin phi2) (* (sin phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(lambda1) * cos(lambda2);
double tmp;
if ((phi1 <= -4.3e-10) || !(phi1 <= 8.6e-10)) {
tmp = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
} else {
tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin(lambda1) * cos(lambda2)
if ((phi1 <= (-4.3d-10)) .or. (.not. (phi1 <= 8.6d-10))) then
tmp = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)))
else
tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(lambda1) * Math.cos(lambda2);
double tmp;
if ((phi1 <= -4.3e-10) || !(phi1 <= 8.6e-10)) {
tmp = Math.atan2(((t_1 - Math.sin(lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
} else {
tmp = Math.atan2(((t_1 - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(lambda1) * math.cos(lambda2) tmp = 0 if (phi1 <= -4.3e-10) or not (phi1 <= 8.6e-10): tmp = math.atan2(((t_1 - math.sin(lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) else: tmp = math.atan2(((t_1 - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(lambda1) * cos(lambda2)) tmp = 0.0 if ((phi1 <= -4.3e-10) || !(phi1 <= 8.6e-10)) tmp = atan(Float64(Float64(t_1 - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); else tmp = atan(Float64(Float64(t_1 - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(lambda1) * cos(lambda2); tmp = 0.0; if ((phi1 <= -4.3e-10) || ~((phi1 <= 8.6e-10))) tmp = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0))); else tmp = atan2(((t_1 - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -4.3e-10], N[Not[LessEqual[phi1, 8.6e-10]], $MachinePrecision]], N[ArcTan[N[(N[(t$95$1 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(t$95$1 - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[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 \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -4.3 \cdot 10^{-10} \lor \neg \left(\phi_1 \leq 8.6 \cdot 10^{-10}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_1 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -4.30000000000000014e-10 or 8.60000000000000029e-10 < phi1 Initial program 78.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6481.2
Applied rewrites81.2%
Taylor expanded in lambda1 around 0
lift-sin.f6479.6
Applied rewrites79.6%
if -4.30000000000000014e-10 < phi1 < 8.60000000000000029e-10Initial program 83.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6499.8
Applied rewrites99.8%
Final simplification89.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (sin lambda2))) (t_1 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -7.5e-10) (not (<= phi1 1e-54)))
(atan2
(* (- (sin lambda1) t_0) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_1)))
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_0) (cos phi2))
(- (sin phi2) (* (sin phi1) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * sin(lambda2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -7.5e-10) || !(phi1 <= 1e-54)) {
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1)));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(lambda1) * sin(lambda2)
t_1 = cos((lambda1 - lambda2))
if ((phi1 <= (-7.5d-10)) .or. (.not. (phi1 <= 1d-54))) then
tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1)))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (sin(phi2) - (sin(phi1) * 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(lambda1) * Math.sin(lambda2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -7.5e-10) || !(phi1 <= 1e-54)) {
tmp = Math.atan2(((Math.sin(lambda1) - t_0) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * t_1)));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_0) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(lambda1) * math.sin(lambda2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -7.5e-10) or not (phi1 <= 1e-54): tmp = math.atan2(((math.sin(lambda1) - t_0) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * t_1))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_0) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * sin(lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -7.5e-10) || !(phi1 <= 1e-54)) tmp = atan(Float64(Float64(sin(lambda1) - t_0) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(lambda1) * sin(lambda2); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -7.5e-10) || ~((phi1 <= 1e-54))) tmp = atan2(((sin(lambda1) - t_0) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - t_0) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -7.5e-10], N[Not[LessEqual[phi1, 1e-54]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \sin \lambda_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -7.5 \cdot 10^{-10} \lor \neg \left(\phi_1 \leq 10^{-54}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - t\_0\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_0\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t\_1}\\
\end{array}
\end{array}
if phi1 < -7.49999999999999995e-10 or 1e-54 < phi1 Initial program 79.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6482.1
Applied rewrites82.1%
Taylor expanded in lambda2 around 0
lift-sin.f6479.9
Applied rewrites79.9%
if -7.49999999999999995e-10 < phi1 < 1e-54Initial program 82.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6499.8
Applied rewrites99.8%
Final simplification88.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -8.5e-10) (not (<= phi1 9e-10)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* t_0 (sin phi1)) (cos phi2))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (cos lambda1) (sin lambda2)))
(cos phi2))
(- (sin phi2) (* (sin phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -8.5e-10) || !(phi1 <= 9e-10)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if ((phi1 <= (-8.5d-10)) .or. (.not. (phi1 <= 9d-10))) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -8.5e-10) || !(phi1 <= 9e-10)) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((t_0 * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.cos(lambda1) * Math.sin(lambda2))) * Math.cos(phi2)), (Math.sin(phi2) - (Math.sin(phi1) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if (phi1 <= -8.5e-10) or not (phi1 <= 9e-10): tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((t_0 * math.sin(phi1)) * math.cos(phi2)))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.cos(lambda1) * math.sin(lambda2))) * math.cos(phi2)), (math.sin(phi2) - (math.sin(phi1) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -8.5e-10) || !(phi1 <= 9e-10)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(sin(phi1) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if ((phi1 <= -8.5e-10) || ~((phi1 <= 9e-10))) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((t_0 * sin(phi1)) * cos(phi2)))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - (sin(phi1) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -8.5e-10], N[Not[LessEqual[phi1, 9e-10]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -8.5 \cdot 10^{-10} \lor \neg \left(\phi_1 \leq 9 \cdot 10^{-10}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -8.4999999999999996e-10 or 8.9999999999999999e-10 < phi1 Initial program 78.6%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6478.6
Applied rewrites78.6%
if -8.4999999999999996e-10 < phi1 < 8.9999999999999999e-10Initial program 83.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi2 around 0
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
lift-sin.f6499.8
Applied rewrites99.8%
Final simplification88.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -9.5e-20) (not (<= phi1 1.7e-13)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (cos (- lambda1 lambda2)) (sin phi1)) (cos phi2))))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -9.5e-20) || !(phi1 <= 1.7e-13)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda1 - lambda2)) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -9.5e-20) || !(phi1 <= 1.7e-13)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)) * cos(phi2)))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -9.5e-20], N[Not[LessEqual[phi1, 1.7e-13]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-20} \lor \neg \left(\phi_1 \leq 1.7 \cdot 10^{-13}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -9.5e-20 or 1.70000000000000008e-13 < phi1 Initial program 78.8%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6478.8
Applied rewrites78.8%
if -9.5e-20 < phi1 < 1.70000000000000008e-13Initial program 82.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi1 around 0
cos-diff-revN/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lift-sin.f6498.0
Applied rewrites98.0%
Final simplification87.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -0.058) (not (<= lambda2 0.052)))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (cos lambda1) (sin phi1)) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -0.058) || !(lambda2 <= 0.052)) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos(lambda1) * sin(phi1)) * cos(phi2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -0.058) || !(lambda2 <= 0.052)) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(lambda1) * sin(phi1)) * cos(phi2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -0.058], N[Not[LessEqual[lambda2, 0.052]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -0.058 \lor \neg \left(\lambda_2 \leq 0.052\right):\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_1 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
\end{array}
if lambda2 < -0.0580000000000000029 or 0.0519999999999999976 < lambda2 Initial program 58.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.1
Applied rewrites79.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
cos-diff-revN/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lift-sin.f6462.1
Applied rewrites62.1%
if -0.0580000000000000029 < lambda2 < 0.0519999999999999976Initial program 99.1%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6499.1
Applied rewrites99.1%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.1
Applied rewrites99.1%
Final simplification82.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- (cos lambda1))))
(if (or (<= lambda2 -0.058) (not (<= lambda2 0.052)))
(atan2
(* (fma (sin lambda1) (cos lambda2) (* t_0 (sin lambda2))) (cos phi2))
(sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma (sin phi2) (cos phi1) (* t_0 (* (sin phi1) (cos phi2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = -cos(lambda1);
double tmp;
if ((lambda2 <= -0.058) || !(lambda2 <= 0.052)) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (t_0 * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (t_0 * (sin(phi1) * cos(phi2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(-cos(lambda1)) tmp = 0.0 if ((lambda2 <= -0.058) || !(lambda2 <= 0.052)) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(t_0 * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(t_0 * Float64(sin(phi1) * cos(phi2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = (-N[Cos[lambda1], $MachinePrecision])}, If[Or[LessEqual[lambda2, -0.058], N[Not[LessEqual[lambda2, 0.052]], $MachinePrecision]], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(t$95$0 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -\cos \lambda_1\\
\mathbf{if}\;\lambda_2 \leq -0.058 \lor \neg \left(\lambda_2 \leq 0.052\right):\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, t\_0 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, t\_0 \cdot \left(\sin \phi_1 \cdot \cos \phi_2\right)\right)}\\
\end{array}
\end{array}
if lambda2 < -0.0580000000000000029 or 0.0519999999999999976 < lambda2 Initial program 58.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.1
Applied rewrites79.1%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
cos-diff-revN/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lift-sin.f6462.1
Applied rewrites62.1%
if -0.0580000000000000029 < lambda2 < 0.0519999999999999976Initial program 99.1%
Taylor expanded in lambda2 around 0
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f6499.1
Applied rewrites99.1%
Final simplification82.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (or (<= lambda1 -1.35) (not (<= lambda1 4e+16)))
(atan2 (* (sin lambda1) (cos phi2)) (- (* (cos phi1) (sin phi2)) t_0))
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (sin phi2) t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -1.35) || !(lambda1 <= 4e+16)) {
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_0));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_0));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))
if ((lambda1 <= (-1.35d0)) .or. (.not. (lambda1 <= 4d+16))) then
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_0))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double tmp;
if ((lambda1 <= -1.35) || !(lambda1 <= 4e+16)) {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - t_0));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (Math.sin(phi2) - t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) tmp = 0 if (lambda1 <= -1.35) or not (lambda1 <= 4e+16): tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - t_0)) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi2) - t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if ((lambda1 <= -1.35) || !(lambda1 <= 4e+16)) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - t_0)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)); tmp = 0.0; if ((lambda1 <= -1.35) || ~((lambda1 <= 4e+16))) tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_0)); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.35], N[Not[LessEqual[lambda1, 4e+16]], $MachinePrecision]], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\lambda_1 \leq -1.35 \lor \neg \left(\lambda_1 \leq 4 \cdot 10^{+16}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_0}\\
\end{array}
\end{array}
if lambda1 < -1.3500000000000001 or 4e16 < lambda1 Initial program 63.7%
Taylor expanded in lambda1 around inf
Applied rewrites63.7%
if -1.3500000000000001 < lambda1 < 4e16Initial program 98.5%
Taylor expanded in phi1 around 0
lift-sin.f6486.1
Applied rewrites86.1%
Final simplification74.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (* (cos phi1) (sin phi2))))
(if (<= lambda2 -0.058)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(sin phi2))
(if (<= lambda2 0.045)
(atan2 t_0 (- t_1 (* (* (cos lambda1) (sin phi1)) (cos phi2))))
(atan2 t_0 (- t_1 (* (* (sin phi1) (cos phi2)) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = cos(phi1) * sin(phi2);
double tmp;
if (lambda2 <= -0.058) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else if (lambda2 <= 0.045) {
tmp = atan2(t_0, (t_1 - ((cos(lambda1) * sin(phi1)) * cos(phi2))));
} else {
tmp = atan2(t_0, (t_1 - ((sin(phi1) * cos(phi2)) * cos(lambda2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = Float64(cos(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= -0.058) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), sin(phi2)); elseif (lambda2 <= 0.045) tmp = atan(t_0, Float64(t_1 - Float64(Float64(cos(lambda1) * sin(phi1)) * cos(phi2)))); else tmp = atan(t_0, Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.058], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 0.045], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.058:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{elif}\;\lambda_2 \leq 0.045:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_1 - \left(\cos \lambda_1 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if lambda2 < -0.0580000000000000029Initial program 53.1%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6477.7
Applied rewrites77.7%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
cos-diff-revN/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lift-sin.f6467.3
Applied rewrites67.3%
if -0.0580000000000000029 < lambda2 < 0.044999999999999998Initial program 99.1%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f64N/A
lift-cos.f6499.1
Applied rewrites99.1%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.1
Applied rewrites99.1%
if 0.044999999999999998 < lambda2 Initial program 63.8%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6463.8
Applied rewrites63.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -9.5e-20) (not (<= phi1 1.7e-13)))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- (sin phi2) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -9.5e-20) || !(phi1 <= 1.7e-13)) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -9.5e-20) || !(phi1 <= 1.7e-13)) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -9.5e-20], N[Not[LessEqual[phi1, 1.7e-13]], $MachinePrecision]], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-20} \lor \neg \left(\phi_1 \leq 1.7 \cdot 10^{-13}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi1 < -9.5e-20 or 1.70000000000000008e-13 < phi1 Initial program 78.8%
Taylor expanded in phi1 around 0
lift-sin.f6453.3
Applied rewrites53.3%
if -9.5e-20 < phi1 < 1.70000000000000008e-13Initial program 82.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi1 around 0
cos-diff-revN/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lift-sin.f6498.0
Applied rewrites98.0%
Final simplification74.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -9.5e-20)
(atan2 t_1 (- (sin phi2) (* (* (sin phi1) (cos phi2)) t_0)))
(if (<= phi1 3.2e-10)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin 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)) * cos(phi2);
double tmp;
if (phi1 <= -9.5e-20) {
tmp = atan2(t_1, (sin(phi2) - ((sin(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 3.2e-10) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -9.5e-20) tmp = atan(t_1, Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 3.2e-10) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -9.5e-20], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 3.2e-10], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[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) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-20}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 3.2 \cdot 10^{-10}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -9.5e-20Initial program 83.7%
Taylor expanded in phi1 around 0
lift-sin.f6452.1
Applied rewrites52.1%
if -9.5e-20 < phi1 < 3.19999999999999981e-10Initial program 82.9%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.9
Applied rewrites99.9%
Taylor expanded in phi1 around 0
cos-diff-revN/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lift-sin.f6498.0
Applied rewrites98.0%
if 3.19999999999999981e-10 < phi1 Initial program 73.3%
Taylor expanded in phi2 around 0
lift-sin.f6454.7
Applied rewrites54.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi1 -0.024)
(atan2 (* t_1 (cos phi2)) (* t_0 (- (sin phi1))))
(if (<= phi1 1.7e-8)
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(sin phi2))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin 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 (phi1 <= -0.024) {
tmp = atan2((t_1 * cos(phi2)), (t_0 * -sin(phi1)));
} else if (phi1 <= 1.7e-8) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(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 (phi1 <= -0.024) tmp = atan(Float64(t_1 * cos(phi2)), Float64(t_0 * Float64(-sin(phi1)))); elseif (phi1 <= 1.7e-8) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), sin(phi2)); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(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[phi1, -0.024], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.7e-8], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[((-N[Cos[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[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}\;\phi_1 \leq -0.024:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.7 \cdot 10^{-8}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, \left(-\cos \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -0.024Initial program 83.0%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6449.5
Applied rewrites49.5%
if -0.024 < phi1 < 1.7e-8Initial program 83.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
lift--.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-sin.f64N/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-cos.f64N/A
lift-sin.f6499.8
Applied rewrites99.8%
Taylor expanded in phi1 around 0
cos-diff-revN/A
*-commutativeN/A
associate-*l*N/A
associate-*l*N/A
*-commutativeN/A
lift-sin.f6496.6
Applied rewrites96.6%
if 1.7e-8 < phi1 Initial program 73.3%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6476.5
Applied rewrites76.5%
Taylor expanded in phi2 around 0
lift-sin.f6457.8
Applied rewrites57.8%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6451.6
Applied rewrites51.6%
Final simplification72.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* t_1 (cos phi2))))
(if (<= phi1 -0.025)
(atan2 t_2 (* t_0 (- (sin phi1))))
(if (<= phi1 2.1e+21)
(atan2
t_2
(-
(*
(fma
(-
(*
(fma (* phi1 phi1) -0.001388888888888889 0.041666666666666664)
(* phi1 phi1))
0.5)
(* phi1 phi1)
1.0)
(sin phi2))
(*
(* (* (fma (* phi1 phi1) -0.16666666666666666 1.0) phi1) (cos phi2))
t_0)))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin 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 t_2 = t_1 * cos(phi2);
double tmp;
if (phi1 <= -0.025) {
tmp = atan2(t_2, (t_0 * -sin(phi1)));
} else if (phi1 <= 2.1e+21) {
tmp = atan2(t_2, ((fma(((fma((phi1 * phi1), -0.001388888888888889, 0.041666666666666664) * (phi1 * phi1)) - 0.5), (phi1 * phi1), 1.0) * sin(phi2)) - (((fma((phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * cos(phi2)) * t_0)));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(t_1 * cos(phi2)) tmp = 0.0 if (phi1 <= -0.025) tmp = atan(t_2, Float64(t_0 * Float64(-sin(phi1)))); elseif (phi1 <= 2.1e+21) tmp = atan(t_2, Float64(Float64(fma(Float64(Float64(fma(Float64(phi1 * phi1), -0.001388888888888889, 0.041666666666666664) * Float64(phi1 * phi1)) - 0.5), Float64(phi1 * phi1), 1.0) * sin(phi2)) - Float64(Float64(Float64(fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * cos(phi2)) * t_0))); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(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]}, Block[{t$95$2 = N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.025], N[ArcTan[t$95$2 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.1e+21], N[ArcTan[t$95$2 / N[(N[(N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi1 * phi1), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[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)\\
t_2 := t\_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.025:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{+21}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(\phi_1 \cdot \phi_1\right) - 0.5, \phi_1 \cdot \phi_1, 1\right) \cdot \sin \phi_2 - \left(\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right) \cdot \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -0.025000000000000001Initial program 83.0%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6449.5
Applied rewrites49.5%
if -0.025000000000000001 < phi1 < 2.1e21Initial program 84.3%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.1
Applied rewrites82.1%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6482.1
Applied rewrites82.1%
if 2.1e21 < phi1 Initial program 69.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6473.2
Applied rewrites73.2%
Taylor expanded in phi2 around 0
lift-sin.f6457.0
Applied rewrites57.0%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6451.4
Applied rewrites51.4%
Final simplification66.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* t_1 (cos phi2))))
(if (<= phi1 -0.025)
(atan2 t_2 (* t_0 (- (sin phi1))))
(if (<= phi1 2.1e+21)
(atan2
t_2
(-
(* (fma (* phi1 phi1) -0.5 1.0) (sin phi2))
(*
(* (* (fma (* phi1 phi1) -0.16666666666666666 1.0) phi1) (cos phi2))
t_0)))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin 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 t_2 = t_1 * cos(phi2);
double tmp;
if (phi1 <= -0.025) {
tmp = atan2(t_2, (t_0 * -sin(phi1)));
} else if (phi1 <= 2.1e+21) {
tmp = atan2(t_2, ((fma((phi1 * phi1), -0.5, 1.0) * sin(phi2)) - (((fma((phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * cos(phi2)) * t_0)));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(t_1 * cos(phi2)) tmp = 0.0 if (phi1 <= -0.025) tmp = atan(t_2, Float64(t_0 * Float64(-sin(phi1)))); elseif (phi1 <= 2.1e+21) tmp = atan(t_2, Float64(Float64(fma(Float64(phi1 * phi1), -0.5, 1.0) * sin(phi2)) - Float64(Float64(Float64(fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * cos(phi2)) * t_0))); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(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]}, Block[{t$95$2 = N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.025], N[ArcTan[t$95$2 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.1e+21], N[ArcTan[t$95$2 / N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[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)\\
t_2 := t\_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.025:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{+21}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.5, 1\right) \cdot \sin \phi_2 - \left(\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right) \cdot \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -0.025000000000000001Initial program 83.0%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6449.5
Applied rewrites49.5%
if -0.025000000000000001 < phi1 < 2.1e21Initial program 84.3%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.1
Applied rewrites82.1%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6482.0
Applied rewrites82.0%
if 2.1e21 < phi1 Initial program 69.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6473.2
Applied rewrites73.2%
Taylor expanded in phi2 around 0
lift-sin.f6457.0
Applied rewrites57.0%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6451.4
Applied rewrites51.4%
Final simplification66.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* t_1 (cos phi2))))
(if (<= phi1 -0.025)
(atan2 t_2 (* t_0 (- (sin phi1))))
(if (<= phi1 2.1e+21)
(atan2
t_2
(-
(sin phi2)
(*
(* (* (fma (* phi1 phi1) -0.16666666666666666 1.0) phi1) (cos phi2))
t_0)))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin 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 t_2 = t_1 * cos(phi2);
double tmp;
if (phi1 <= -0.025) {
tmp = atan2(t_2, (t_0 * -sin(phi1)));
} else if (phi1 <= 2.1e+21) {
tmp = atan2(t_2, (sin(phi2) - (((fma((phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * cos(phi2)) * t_0)));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(t_1 * cos(phi2)) tmp = 0.0 if (phi1 <= -0.025) tmp = atan(t_2, Float64(t_0 * Float64(-sin(phi1)))); elseif (phi1 <= 2.1e+21) tmp = atan(t_2, Float64(sin(phi2) - Float64(Float64(Float64(fma(Float64(phi1 * phi1), -0.16666666666666666, 1.0) * phi1) * cos(phi2)) * t_0))); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(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]}, Block[{t$95$2 = N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.025], N[ArcTan[t$95$2 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 2.1e+21], N[ArcTan[t$95$2 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[(N[(N[(phi1 * phi1), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[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)\\
t_2 := t\_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.025:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{+21}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\sin \phi_2 - \left(\left(\mathsf{fma}\left(\phi_1 \cdot \phi_1, -0.16666666666666666, 1\right) \cdot \phi_1\right) \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -0.025000000000000001Initial program 83.0%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6449.5
Applied rewrites49.5%
if -0.025000000000000001 < phi1 < 2.1e21Initial program 84.3%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6482.1
Applied rewrites82.1%
Taylor expanded in phi1 around 0
lift-sin.f6481.5
Applied rewrites81.5%
if 2.1e21 < phi1 Initial program 69.5%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6473.2
Applied rewrites73.2%
Taylor expanded in phi2 around 0
lift-sin.f6457.0
Applied rewrites57.0%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6451.4
Applied rewrites51.4%
Final simplification66.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (* t_1 (cos phi2))))
(if (<= phi1 -0.024)
(atan2 t_2 (* t_0 (- (sin phi1))))
(if (<= phi1 0.00029)
(atan2 t_2 (- (sin phi2) (* (* phi1 (cos phi2)) t_0)))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* (sin 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 t_2 = t_1 * cos(phi2);
double tmp;
if (phi1 <= -0.024) {
tmp = atan2(t_2, (t_0 * -sin(phi1)));
} else if (phi1 <= 0.00029) {
tmp = atan2(t_2, (sin(phi2) - ((phi1 * cos(phi2)) * t_0)));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2))
t_2 = t_1 * cos(phi2)
if (phi1 <= (-0.024d0)) then
tmp = atan2(t_2, (t_0 * -sin(phi1)))
else if (phi1 <= 0.00029d0) then
tmp = atan2(t_2, (sin(phi2) - ((phi1 * cos(phi2)) * t_0)))
else
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2));
double t_2 = t_1 * Math.cos(phi2);
double tmp;
if (phi1 <= -0.024) {
tmp = Math.atan2(t_2, (t_0 * -Math.sin(phi1)));
} else if (phi1 <= 0.00029) {
tmp = Math.atan2(t_2, (Math.sin(phi2) - ((phi1 * Math.cos(phi2)) * t_0)));
} else {
tmp = Math.atan2(t_1, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) t_2 = t_1 * math.cos(phi2) tmp = 0 if phi1 <= -0.024: tmp = math.atan2(t_2, (t_0 * -math.sin(phi1))) elif phi1 <= 0.00029: tmp = math.atan2(t_2, (math.sin(phi2) - ((phi1 * math.cos(phi2)) * t_0))) else: tmp = math.atan2(t_1, ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = Float64(t_1 * cos(phi2)) tmp = 0.0 if (phi1 <= -0.024) tmp = atan(t_2, Float64(t_0 * Float64(-sin(phi1)))); elseif (phi1 <= 0.00029) tmp = atan(t_2, Float64(sin(phi2) - Float64(Float64(phi1 * cos(phi2)) * t_0))); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(phi1) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); t_2 = t_1 * cos(phi2); tmp = 0.0; if (phi1 <= -0.024) tmp = atan2(t_2, (t_0 * -sin(phi1))); elseif (phi1 <= 0.00029) tmp = atan2(t_2, (sin(phi2) - ((phi1 * cos(phi2)) * t_0))); else tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (sin(phi1) * t_0))); end tmp_2 = 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]}, Block[{t$95$2 = N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.024], N[ArcTan[t$95$2 / N[(t$95$0 * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.00029], N[ArcTan[t$95$2 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(phi1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[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)\\
t_2 := t\_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.024:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 \cdot \left(-\sin \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 0.00029:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\sin \phi_2 - \left(\phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot t\_0}\\
\end{array}
\end{array}
if phi1 < -0.024Initial program 83.0%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6449.5
Applied rewrites49.5%
if -0.024 < phi1 < 2.9e-4Initial program 83.7%
Taylor expanded in phi1 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6483.5
Applied rewrites83.5%
Taylor expanded in phi1 around 0
lift-sin.f6482.9
Applied rewrites82.9%
Taylor expanded in phi1 around 0
Applied rewrites82.9%
if 2.9e-4 < phi1 Initial program 72.0%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6475.3
Applied rewrites75.3%
Taylor expanded in phi2 around 0
lift-sin.f6456.4
Applied rewrites56.4%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6450.8
Applied rewrites50.8%
Final simplification66.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (or (<= phi2 -0.000165) (not (<= phi2 2e-21)))
(atan2 (* t_0 (cos phi2)) (sin phi2))
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (sin phi1) (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if ((phi2 <= -0.000165) || !(phi2 <= 2e-21)) {
tmp = atan2((t_0 * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (sin(phi1) * cos((lambda1 - lambda2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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 ((phi2 <= (-0.000165d0)) .or. (.not. (phi2 <= 2d-21))) then
tmp = atan2((t_0 * cos(phi2)), sin(phi2))
else
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (sin(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 ((phi2 <= -0.000165) || !(phi2 <= 2e-21)) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.sin(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if (phi2 <= -0.000165) or not (phi2 <= 2e-21): tmp = math.atan2((t_0 * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.sin(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi2 <= -0.000165) || !(phi2 <= 2e-21)) tmp = atan(Float64(t_0 * cos(phi2)), sin(phi2)); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(sin(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 ((phi2 <= -0.000165) || ~((phi2 <= 2e-21))) tmp = atan2((t_0 * cos(phi2)), sin(phi2)); else tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (sin(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[Or[LessEqual[phi2, -0.000165], N[Not[LessEqual[phi2, 2e-21]], $MachinePrecision]], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.000165 \lor \neg \left(\phi_2 \leq 2 \cdot 10^{-21}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \sin \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < -1.65e-4 or 1.99999999999999982e-21 < phi2 Initial program 78.1%
Taylor expanded in phi1 around 0
lift-sin.f6448.5
Applied rewrites48.5%
if -1.65e-4 < phi2 < 1.99999999999999982e-21Initial program 83.2%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
cos-negN/A
mul-1-negN/A
lower--.f64N/A
mul-1-negN/A
lower-*.f64N/A
lower-sin.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6490.3
Applied rewrites90.3%
Taylor expanded in phi2 around 0
lift-sin.f6490.3
Applied rewrites90.3%
Taylor expanded in phi2 around 0
sin-diff-revN/A
*-commutativeN/A
sin-diff-revN/A
lift-sin.f64N/A
lift--.f6483.2
Applied rewrites83.2%
Final simplification66.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (or (<= phi2 -2.6e-15) (not (<= phi2 2e-21)))
(atan2 t_0 (sin phi2))
(atan2 t_0 (* (cos (- lambda1 lambda2)) (- (sin phi1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if ((phi2 <= -2.6e-15) || !(phi2 <= 2e-21)) {
tmp = atan2(t_0, sin(phi2));
} else {
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
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)) * cos(phi2)
if ((phi2 <= (-2.6d-15)) .or. (.not. (phi2 <= 2d-21))) then
tmp = atan2(t_0, sin(phi2))
else
tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(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)) * Math.cos(phi2);
double tmp;
if ((phi2 <= -2.6e-15) || !(phi2 <= 2e-21)) {
tmp = Math.atan2(t_0, Math.sin(phi2));
} else {
tmp = Math.atan2(t_0, (Math.cos((lambda1 - lambda2)) * -Math.sin(phi1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if (phi2 <= -2.6e-15) or not (phi2 <= 2e-21): tmp = math.atan2(t_0, math.sin(phi2)) else: tmp = math.atan2(t_0, (math.cos((lambda1 - lambda2)) * -math.sin(phi1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if ((phi2 <= -2.6e-15) || !(phi2 <= 2e-21)) tmp = atan(t_0, sin(phi2)); else tmp = atan(t_0, Float64(cos(Float64(lambda1 - lambda2)) * Float64(-sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if ((phi2 <= -2.6e-15) || ~((phi2 <= 2e-21))) tmp = atan2(t_0, sin(phi2)); else tmp = atan2(t_0, (cos((lambda1 - lambda2)) * -sin(phi1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -2.6e-15], N[Not[LessEqual[phi2, 2e-21]], $MachinePrecision]], N[ArcTan[t$95$0 / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * (-N[Sin[phi1], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -2.6 \cdot 10^{-15} \lor \neg \left(\phi_2 \leq 2 \cdot 10^{-21}\right):\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \left(\lambda_1 - \lambda_2\right) \cdot \left(-\sin \phi_1\right)}\\
\end{array}
\end{array}
if phi2 < -2.60000000000000004e-15 or 1.99999999999999982e-21 < phi2 Initial program 77.8%
Taylor expanded in phi1 around 0
lift-sin.f6448.3
Applied rewrites48.3%
if -2.60000000000000004e-15 < phi2 < 1.99999999999999982e-21Initial program 83.5%
Taylor expanded in phi2 around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-sin.f6482.1
Applied rewrites82.1%
Final simplification65.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= lambda2 -9e-41) (not (<= lambda2 1.8e-63))) (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2)) (atan2 (* (sin lambda1) (cos phi2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -9e-41) || !(lambda2 <= 1.8e-63)) {
tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda2 <= (-9d-41)) .or. (.not. (lambda2 <= 1.8d-63))) then
tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2))
else
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -9e-41) || !(lambda2 <= 1.8e-63)) {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda2 <= -9e-41) or not (lambda2 <= 1.8e-63): tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -9e-41) || !(lambda2 <= 1.8e-63)) tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda2 <= -9e-41) || ~((lambda2 <= 1.8e-63))) tmp = atan2((sin(-lambda2) * cos(phi2)), sin(phi2)); else tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -9e-41], N[Not[LessEqual[lambda2, 1.8e-63]], $MachinePrecision]], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -9 \cdot 10^{-41} \lor \neg \left(\lambda_2 \leq 1.8 \cdot 10^{-63}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if lambda2 < -9e-41 or 1.80000000000000004e-63 < lambda2 Initial program 66.6%
Taylor expanded in phi1 around 0
lift-sin.f6443.9
Applied rewrites43.9%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6441.2
Applied rewrites41.2%
if -9e-41 < lambda2 < 1.80000000000000004e-63Initial program 99.7%
Taylor expanded in phi1 around 0
lift-sin.f6456.2
Applied rewrites56.2%
Taylor expanded in lambda1 around inf
Applied rewrites50.9%
Final simplification45.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 0.115) (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2) (atan2 (* (sin lambda1) (cos phi2)) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.115) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
} else {
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 0.115d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
else
tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.115) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.115: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) else: tmp = math.atan2((math.sin(lambda1) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.115) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(sin(lambda1) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.115) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan2((sin(lambda1) * cos(phi2)), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.115], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.115:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 0.115000000000000005Initial program 83.1%
Taylor expanded in phi1 around 0
lift-sin.f6450.2
Applied rewrites50.2%
Taylor expanded in phi2 around 0
Applied rewrites44.5%
if 0.115000000000000005 < phi2 Initial program 74.2%
Taylor expanded in phi1 around 0
lift-sin.f6446.3
Applied rewrites46.3%
Taylor expanded in lambda1 around inf
Applied rewrites27.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}
\end{array}
Initial program 80.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.2
Applied rewrites49.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -700000000000.0)
(atan2 t_0 phi2)
(atan2 t_0 (* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= -700000000000.0) {
tmp = atan2(t_0, phi2);
} else {
tmp = atan2(t_0, (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= -700000000000.0) tmp = atan(t_0, phi2); else tmp = atan(t_0, Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -700000000000.0], N[ArcTan[t$95$0 / phi2], $MachinePrecision], N[ArcTan[t$95$0 / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -700000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -7e11Initial program 82.6%
Taylor expanded in phi1 around 0
lift-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in phi2 around 0
Applied rewrites29.8%
if -7e11 < phi2 Initial program 80.2%
Taylor expanded in phi1 around 0
lift-sin.f6449.7
Applied rewrites49.7%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6439.2
Applied rewrites39.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 1050000000.0) (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) phi2) (atan2 (* (sin lambda1) 1.0) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1050000000.0) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2);
} else {
tmp = atan2((sin(lambda1) * 1.0), sin(phi2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 1050000000.0d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2)
else
tmp = atan2((sin(lambda1) * 1.0d0), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1050000000.0) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2((Math.sin(lambda1) * 1.0), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1050000000.0: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), phi2) else: tmp = math.atan2((math.sin(lambda1) * 1.0), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1050000000.0) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(sin(lambda1) * 1.0), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 1050000000.0) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), phi2); else tmp = atan2((sin(lambda1) * 1.0), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1050000000.0], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1050000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot 1}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < 1.05e9Initial program 83.2%
Taylor expanded in phi1 around 0
lift-sin.f6450.7
Applied rewrites50.7%
Taylor expanded in phi2 around 0
Applied rewrites44.1%
if 1.05e9 < phi2 Initial program 73.5%
Taylor expanded in phi1 around 0
lift-sin.f6444.7
Applied rewrites44.7%
Taylor expanded in phi2 around 0
Applied rewrites12.6%
Taylor expanded in lambda1 around inf
Applied rewrites12.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -3.2e+63) (atan2 (* (- (sin lambda2)) (cos phi2)) phi2) (atan2 (* (sin (- lambda1 lambda2)) 1.0) (sin phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -3.2e+63) {
tmp = atan2((-sin(lambda2) * cos(phi2)), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), sin(phi2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= (-3.2d+63)) then
tmp = atan2((-sin(lambda2) * cos(phi2)), phi2)
else
tmp = atan2((sin((lambda1 - lambda2)) * 1.0d0), sin(phi2))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -3.2e+63) {
tmp = Math.atan2((-Math.sin(lambda2) * Math.cos(phi2)), phi2);
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -3.2e+63: tmp = math.atan2((-math.sin(lambda2) * math.cos(phi2)), phi2) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * 1.0), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -3.2e+63) tmp = atan(Float64(Float64(-sin(lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -3.2e+63) tmp = atan2((-sin(lambda2) * cos(phi2)), phi2); else tmp = atan2((sin((lambda1 - lambda2)) * 1.0), sin(phi2)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -3.2e+63], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{+63}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\sin \phi_2}\\
\end{array}
\end{array}
if phi2 < -3.20000000000000011e63Initial program 81.5%
Taylor expanded in phi1 around 0
lift-sin.f6444.6
Applied rewrites44.6%
Taylor expanded in phi2 around 0
Applied rewrites13.9%
Taylor expanded in phi2 around 0
Applied rewrites13.5%
Taylor expanded in lambda1 around 0
sin-diff-revN/A
sin-negN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f6423.8
Applied rewrites23.8%
if -3.20000000000000011e63 < phi2 Initial program 80.6%
Taylor expanded in phi1 around 0
lift-sin.f6450.1
Applied rewrites50.1%
Taylor expanded in phi2 around 0
Applied rewrites36.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -700000000000.0)
(atan2 (* (- (sin lambda2)) (cos phi2)) phi2)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -700000000000.0) {
tmp = atan2((-sin(lambda2) * cos(phi2)), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -700000000000.0) tmp = atan(Float64(Float64(-sin(lambda2)) * cos(phi2)), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -700000000000.0], N[ArcTan[N[((-N[Sin[lambda2], $MachinePrecision]) * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -700000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(-\sin \lambda_2\right) \cdot \cos \phi_2}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -7e11Initial program 82.6%
Taylor expanded in phi1 around 0
lift-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in phi2 around 0
Applied rewrites15.0%
Taylor expanded in phi2 around 0
Applied rewrites14.5%
Taylor expanded in lambda1 around 0
sin-diff-revN/A
sin-negN/A
mul-1-negN/A
*-commutativeN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f6422.8
Applied rewrites22.8%
if -7e11 < phi2 Initial program 80.2%
Taylor expanded in phi1 around 0
lift-sin.f6449.7
Applied rewrites49.7%
Taylor expanded in phi2 around 0
Applied rewrites37.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6436.9
Applied rewrites36.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -700000000000.0)
(atan2 (* (sin (- lambda2)) 1.0) phi2)
(atan2
(* (sin (- lambda1 lambda2)) 1.0)
(* (fma (* phi2 phi2) -0.16666666666666666 1.0) phi2))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -700000000000.0) {
tmp = atan2((sin(-lambda2) * 1.0), phi2);
} else {
tmp = atan2((sin((lambda1 - lambda2)) * 1.0), (fma((phi2 * phi2), -0.16666666666666666, 1.0) * phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -700000000000.0) tmp = atan(Float64(sin(Float64(-lambda2)) * 1.0), phi2); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), Float64(fma(Float64(phi2 * phi2), -0.16666666666666666, 1.0) * phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -700000000000.0], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.16666666666666666 + 1.0), $MachinePrecision] * phi2), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -700000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot 1}{\phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.16666666666666666, 1\right) \cdot \phi_2}\\
\end{array}
\end{array}
if phi2 < -7e11Initial program 82.6%
Taylor expanded in phi1 around 0
lift-sin.f6447.2
Applied rewrites47.2%
Taylor expanded in phi2 around 0
Applied rewrites15.0%
Taylor expanded in phi2 around 0
Applied rewrites14.5%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6420.0
Applied rewrites20.0%
if -7e11 < phi2 Initial program 80.2%
Taylor expanded in phi1 around 0
lift-sin.f6449.7
Applied rewrites49.7%
Taylor expanded in phi2 around 0
Applied rewrites37.5%
Taylor expanded in phi2 around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6436.9
Applied rewrites36.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) 1.0) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * 1.0), phi2);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * 1.0d0), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * 1.0), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * 1.0), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * 1.0), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * 1.0), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot 1}{\phi_2}
\end{array}
Initial program 80.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.2
Applied rewrites49.2%
Taylor expanded in phi2 around 0
Applied rewrites33.1%
Taylor expanded in phi2 around 0
Applied rewrites30.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda2)) 1.0) phi2))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin(-lambda2) * 1.0), phi2);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin(-lambda2) * 1.0d0), phi2)
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin(-lambda2) * 1.0), phi2);
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin(-lambda2) * 1.0), phi2)
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(-lambda2)) * 1.0), phi2) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin(-lambda2) * 1.0), phi2); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * 1.0), $MachinePrecision] / phi2], $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot 1}{\phi_2}
\end{array}
Initial program 80.7%
Taylor expanded in phi1 around 0
lift-sin.f6449.2
Applied rewrites49.2%
Taylor expanded in phi2 around 0
Applied rewrites33.1%
Taylor expanded in phi2 around 0
Applied rewrites30.7%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6422.2
Applied rewrites22.2%
herbie shell --seed 2025072
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Bearing on a great circle"
:precision binary64
(atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))