
(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]
\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)}
Herbie found 36 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]
\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)}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (cos lambda2))))
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(/
(fma
(* (* (- (sin lambda1)) (sin lambda2)) (sin lambda2))
(sin lambda1)
(pow t_0 2.0))
(- t_0 (* (sin lambda2) (sin lambda1)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * cos(lambda2);
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * (fma(((-sin(lambda1) * sin(lambda2)) * sin(lambda2)), sin(lambda1), pow(t_0, 2.0)) / (t_0 - (sin(lambda2) * sin(lambda1)))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * cos(lambda2)) 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)) * Float64(fma(Float64(Float64(Float64(-sin(lambda1)) * sin(lambda2)) * sin(lambda2)), sin(lambda1), (t_0 ^ 2.0)) / Float64(t_0 - Float64(sin(lambda2) * sin(lambda1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[((-N[Sin[lambda1], $MachinePrecision]) * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \cos \lambda_2\\
\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 \frac{\mathsf{fma}\left(\left(\left(-\sin \lambda_1\right) \cdot \sin \lambda_2\right) \cdot \sin \lambda_2, \sin \lambda_1, {t\_0}^{2}\right)}{t\_0 - \sin \lambda_2 \cdot \sin \lambda_1}}
\end{array}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites99.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (cos lambda2))))
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(/
(fma
(- 0.5 (* 0.5 (cos (* 2.0 lambda2))))
(- (- 0.5 (* 0.5 (cos (* 2.0 lambda1)))))
(pow t_0 2.0))
(- t_0 (* (sin lambda2) (sin lambda1)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * cos(lambda2);
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * (fma((0.5 - (0.5 * cos((2.0 * lambda2)))), -(0.5 - (0.5 * cos((2.0 * lambda1)))), pow(t_0, 2.0)) / (t_0 - (sin(lambda2) * sin(lambda1)))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * cos(lambda2)) 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)) * Float64(fma(Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * lambda2)))), Float64(-Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * lambda1))))), (t_0 ^ 2.0)) / Float64(t_0 - Float64(sin(lambda2) * sin(lambda1))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \cos \lambda_2\\
\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 \frac{\mathsf{fma}\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \lambda_2\right), -\left(0.5 - 0.5 \cdot \cos \left(2 \cdot \lambda_1\right)\right), {t\_0}^{2}\right)}{t\_0 - \sin \lambda_2 \cdot \sin \lambda_1}}
\end{array}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites99.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
swap-sqrN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos lambda1) (cos lambda2)))
(t_1 (* (sin lambda2) (sin lambda1))))
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(/ (- (pow t_0 2.0) (pow t_1 2.0)) (- t_0 t_1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(lambda1) * cos(lambda2);
double t_1 = sin(lambda2) * sin(lambda1);
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * ((pow(t_0, 2.0) - pow(t_1, 2.0)) / (t_0 - t_1)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(lambda1) * cos(lambda2)) t_1 = Float64(sin(lambda2) * sin(lambda1)) 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)) * Float64(Float64((t_0 ^ 2.0) - (t_1 ^ 2.0)) / Float64(t_0 - t_1))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \cos \lambda_1 \cdot \cos \lambda_2\\
t_1 := \sin \lambda_2 \cdot \sin \lambda_1\\
\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 \frac{{t\_0}^{2} - {t\_1}^{2}}{t\_0 - t\_1}}
\end{array}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites99.7%
lift-*.f64N/A
pow2N/A
lower-pow.f6499.7%
lift-*.f64N/A
pow2N/A
lower-pow.f6499.7%
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (cos phi2))))
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(fma
(* t_0 (sin lambda2))
(sin lambda1)
(* (* t_0 (cos lambda1)) (cos lambda2)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * cos(phi2);
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - fma((t_0 * sin(lambda2)), sin(lambda1), ((t_0 * cos(lambda1)) * cos(lambda2)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * cos(phi2)) return atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - fma(Float64(t_0 * sin(lambda2)), sin(lambda1), Float64(Float64(t_0 * cos(lambda1)) * cos(lambda2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \cos \phi_2\\
\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 - \mathsf{fma}\left(t\_0 \cdot \sin \lambda_2, \sin \lambda_1, \left(t\_0 \cdot \cos \lambda_1\right) \cdot \cos \lambda_2\right)}
\end{array}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites99.7%
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-*.f64N/A
Applied rewrites99.7%
(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
(sin lambda2)
(sin lambda1)
(* (cos lambda1) (cos 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(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(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(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(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[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\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(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites99.7%
lower-unsound--.f64N/A
lower-unsound-*.f64N/A
lower-unsound-*.f64N/A
lower-unsound-/.f64N/A
lower-unsound--.f64N/A
flip-+N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6499.7%
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (+ lambda2 lambda1))))
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(* (/ 1.0 t_0) (* (cos (- lambda2 lambda1)) t_0)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 + lambda1));
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * ((1.0 / t_0) * (cos((lambda2 - lambda1)) * t_0)))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 + lambda1)) 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)) * Float64(Float64(1.0 / t_0) * Float64(cos(Float64(lambda2 - lambda1)) * t_0))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 + lambda1), $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \cos \left(\lambda_2 + \lambda_1\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}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{1}{t\_0} \cdot \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot t\_0\right)\right)}
\end{array}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites99.7%
lift-/.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (+ lambda2 lambda1))))
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(* (cos (- lambda2 lambda1)) (* t_0 (/ 1.0 t_0))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 + lambda1));
return atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * (cos((lambda2 - lambda1)) * (t_0 * (1.0 / t_0))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 + lambda1)) 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)) * Float64(cos(Float64(lambda2 - lambda1)) * Float64(t_0 * Float64(1.0 / t_0)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 + lambda1), $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[(t$95$0 * N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \cos \left(\lambda_2 + \lambda_1\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}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \left(t\_0 \cdot \frac{1}{t\_0}\right)\right)}
\end{array}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
flip-+N/A
lower-unsound-/.f64N/A
Applied rewrites99.7%
lift-/.f64N/A
mult-flipN/A
Applied rewrites88.7%
(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)) (cos (- lambda1 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)) * cos((lambda1 - 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)) * cos(Float64(lambda1 - 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\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 \cos \left(\lambda_1 - \lambda_2\right)}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda2)))
(t_2
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1)))))))
(if (<= lambda1 -0.36)
t_2
(if (<= lambda1 4.6e-10)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
t_0
(*
(* (sin phi1) (cos phi2))
(+
t_1
(*
lambda1
(- (* -0.5 (* lambda1 t_1)) (sin (- lambda2))))))))
t_2))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos(-lambda2);
double t_2 = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
double tmp;
if (lambda1 <= -0.36) {
tmp = t_2;
} else if (lambda1 <= 4.6e-10) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * (t_1 + (lambda1 * ((-0.5 * (lambda1 * t_1)) - sin(-lambda2)))))));
} else {
tmp = t_2;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(-lambda2)) t_2 = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))) tmp = 0.0 if (lambda1 <= -0.36) tmp = t_2; elseif (lambda1 <= 4.6e-10) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * Float64(t_1 + Float64(lambda1 * Float64(Float64(-0.5 * Float64(lambda1 * t_1)) - sin(Float64(-lambda2)))))))); else tmp = 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[Cos[(-lambda2)], $MachinePrecision]}, Block[{t$95$2 = 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[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.36], t$95$2, If[LessEqual[lambda1, 4.6e-10], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 + N[(lambda1 * N[(N[(-0.5 * N[(lambda1 * t$95$1), $MachinePrecision]), $MachinePrecision] - N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(-\lambda_2\right)\\
t_2 := \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 - \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\lambda_1 \leq -0.36:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 4.6 \cdot 10^{-10}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 + \lambda_1 \cdot \left(-0.5 \cdot \left(\lambda_1 \cdot t\_1\right) - \sin \left(-\lambda_2\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if lambda1 < -0.35999999999999999 or 4.6000000000000001e-10 < lambda1 Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6478.9%
Applied rewrites78.9%
if -0.35999999999999999 < lambda1 < 4.6000000000000001e-10Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f64N/A
lower-neg.f6456.8%
Applied rewrites56.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1))) (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)) - (sin(lambda2) * cos(lambda1))) * 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)) - (sin(lambda2) * cos(lambda1))) * 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.sin(lambda2) * Math.cos(lambda1))) * 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.sin(lambda2) * math.cos(lambda1))) * 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(sin(lambda2) * cos(lambda1))) * 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)) - (sin(lambda2) * cos(lambda1))) * 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[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $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]
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\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)}
Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6488.7%
Applied rewrites88.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (<= phi1 -1.5e+40)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(*
(-
1.0
(/
(* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2))
t_0))
t_0))
(if (<= phi1 0.0013)
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(- (sin phi2) t_1))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* -1.0 (sin lambda2)))
(cos phi2))
(- (* (cos phi1) (sin phi2)) t_1))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double t_1 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -1.5e+40) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((1.0 - (((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)) / t_0)) * t_0));
} else if (phi1 <= 0.0013) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - t_1));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-1.0 * sin(lambda2))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_1));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) t_1 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -1.5e+40) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(1.0 - Float64(Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)) / t_0)) * t_0)); elseif (phi1 <= 0.0013) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - t_1)); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(-1.0 * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - t_1)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.5e+40], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - N[(N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0013], 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] - t$95$1), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(-1.0 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
t_1 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.5 \cdot 10^{+40}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 - \frac{\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}{t\_0}\right) \cdot t\_0}\\
\mathbf{elif}\;\phi_1 \leq 0.0013:\\
\;\;\;\;\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 - t\_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, -1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_1}\\
\end{array}
if phi1 < -1.5000000000000001e40Initial program 78.8%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites78.8%
if -1.5000000000000001e40 < phi1 < 0.0012999999999999999Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
Taylor expanded in phi1 around 0
lower-sin.f6474.9%
Applied rewrites74.9%
if 0.0012999999999999999 < phi1 Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
Taylor expanded in lambda1 around 0
Applied rewrites80.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (<= phi1 -1.5e+40)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (sin phi2) (cos phi1))
(* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2))))
(if (<= phi1 0.0013)
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(- (sin phi2) t_0))
(atan2
(*
(fma (sin lambda1) (cos lambda2) (* -1.0 (sin lambda2)))
(cos phi2))
(- (* (cos phi1) (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 (phi1 <= -1.5e+40) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 0.0013) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - t_0));
} else {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-1.0 * sin(lambda2))) * cos(phi2)), ((cos(phi1) * 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 (phi1 <= -1.5e+40) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 0.0013) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - t_0)); else tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(-1.0 * sin(lambda2))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)); end return 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[LessEqual[phi1, -1.5e+40], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0013], 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] - t$95$0), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(-1.0 * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t_0 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -1.5 \cdot 10^{+40}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 0.0013:\\
\;\;\;\;\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 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_1, \cos \lambda_2, -1 \cdot \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\end{array}
if phi1 < -1.5000000000000001e40Initial program 78.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6478.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8%
Applied rewrites78.8%
if -1.5000000000000001e40 < phi1 < 0.0012999999999999999Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
Taylor expanded in phi1 around 0
lower-sin.f6474.9%
Applied rewrites74.9%
if 0.0012999999999999999 < phi1 Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
Taylor expanded in lambda1 around 0
Applied rewrites80.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -1.5e+40)
(atan2
t_1
(- (* (sin phi2) (cos phi1)) (* (* t_0 (sin phi1)) (cos phi2))))
(if (<= phi1 0.0013)
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(sin phi2)
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
t_1
(fma
(sin phi2)
(cos phi1)
(* (- (sin phi1)) (* t_0 (cos phi2)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -1.5e+40) {
tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 0.0013) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), (-sin(phi1) * (t_0 * cos(phi2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -1.5e+40) tmp = atan(t_1, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 0.0013) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(-sin(phi1)) * Float64(t_0 * cos(phi2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.5e+40], N[ArcTan[t$95$1 / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0013], 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[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Sin[phi1], $MachinePrecision]) * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.5 \cdot 10^{+40}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 \cdot \cos \phi_1 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 0.0013:\\
\;\;\;\;\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 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1\right) \cdot \left(t\_0 \cdot \cos \phi_2\right)\right)}\\
\end{array}
if phi1 < -1.5000000000000001e40Initial program 78.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6478.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8%
Applied rewrites78.8%
if -1.5000000000000001e40 < phi1 < 0.0012999999999999999Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
Taylor expanded in phi1 around 0
lower-sin.f6474.9%
Applied rewrites74.9%
if 0.0012999999999999999 < phi1 Initial program 78.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6478.8%
Applied rewrites78.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -7e+26)
(atan2
t_1
(- (* (sin phi2) (cos phi1)) (* (* t_0 (sin phi1)) (cos phi2))))
(if (<= phi1 0.0013)
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(+
(sin phi2)
(* -1.0 (* phi1 (* (cos phi2) (cos (- lambda1 lambda2)))))))
(atan2
t_1
(fma
(sin phi2)
(cos phi1)
(* (- (sin phi1)) (* t_0 (cos phi2)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -7e+26) {
tmp = atan2(t_1, ((sin(phi2) * cos(phi1)) - ((t_0 * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 0.0013) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), (sin(phi2) + (-1.0 * (phi1 * (cos(phi2) * cos((lambda1 - lambda2)))))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), (-sin(phi1) * (t_0 * cos(phi2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -7e+26) tmp = atan(t_1, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(t_0 * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 0.0013) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(sin(phi2) + Float64(-1.0 * Float64(phi1 * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(-sin(phi1)) * Float64(t_0 * cos(phi2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -7e+26], N[ArcTan[t$95$1 / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 0.0013], 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[(-1.0 * N[(phi1 * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Sin[phi1], $MachinePrecision]) * N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -7 \cdot 10^{+26}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 \cdot \cos \phi_1 - \left(t\_0 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 0.0013:\\
\;\;\;\;\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 + -1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1\right) \cdot \left(t\_0 \cdot \cos \phi_2\right)\right)}\\
\end{array}
if phi1 < -6.9999999999999998e26Initial program 78.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6478.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8%
Applied rewrites78.8%
if -6.9999999999999998e26 < phi1 < 0.0012999999999999999Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6456.9%
Applied rewrites56.9%
if 0.0012999999999999999 < phi1 Initial program 78.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6478.8%
Applied rewrites78.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (- lambda2 lambda1)) (cos phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -1.25)
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* t_0 (sin phi1))))
(if (<= phi2 1.4e-6)
(atan2
(*
(fma
(sin lambda1)
(cos lambda2)
(* (- (cos lambda1)) (sin lambda2)))
(cos phi2))
(-
(* phi2 (cos phi1))
(* (cos (- lambda1 lambda2)) (sin phi1))))
(atan2
t_1
(fma (sin phi2) (cos phi1) (* (- (sin phi1)) t_0)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1)) * cos(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= -1.25) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_0 * sin(phi1))));
} else if (phi2 <= 1.4e-6) {
tmp = atan2((fma(sin(lambda1), cos(lambda2), (-cos(lambda1) * sin(lambda2))) * cos(phi2)), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = atan2(t_1, fma(sin(phi2), cos(phi1), (-sin(phi1) * t_0)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(lambda2 - lambda1)) * cos(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= -1.25) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * sin(phi1)))); elseif (phi2 <= 1.4e-6) tmp = atan(Float64(fma(sin(lambda1), cos(lambda2), Float64(Float64(-cos(lambda1)) * sin(lambda2))) * cos(phi2)), Float64(Float64(phi2 * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = atan(t_1, fma(sin(phi2), cos(phi1), Float64(Float64(-sin(phi1)) * t_0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.25], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.4e-6], 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[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Sin[phi1], $MachinePrecision]) * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right) \cdot \cos \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.25:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot \sin \phi_1}\\
\mathbf{elif}\;\phi_2 \leq 1.4 \cdot 10^{-6}:\\
\;\;\;\;\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}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1\right) \cdot t\_0\right)}\\
\end{array}
if phi2 < -1.25Initial program 78.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8%
Applied rewrites78.8%
if -1.25 < phi2 < 1.3999999999999999e-6Initial program 78.8%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
fp-cancel-sub-sign-invN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-cos.f64N/A
lower-sin.f6488.7%
Applied rewrites88.7%
Taylor expanded in phi2 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6452.7%
Applied rewrites52.7%
if 1.3999999999999999e-6 < phi2 Initial program 78.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6478.8%
Applied rewrites78.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin lambda1) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= lambda1 -3.9e+55)
t_0
(if (<= lambda1 800000000.0)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma
(sin phi2)
(cos phi1)
(- (* (* (sin phi1) (cos lambda2)) (cos phi2)))))
t_0))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (lambda1 <= -3.9e+55) {
tmp = t_0;
} else if (lambda1 <= 800000000.0) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), -((sin(phi1) * cos(lambda2)) * cos(phi2))));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (lambda1 <= -3.9e+55) tmp = t_0; elseif (lambda1 <= 800000000.0) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(-Float64(Float64(sin(phi1) * cos(lambda2)) * cos(phi2))))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[lambda1], $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]}, If[LessEqual[lambda1, -3.9e+55], t$95$0, If[LessEqual[lambda1, 800000000.0], 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[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \lambda_1 \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)}\\
\mathbf{if}\;\lambda_1 \leq -3.9 \cdot 10^{+55}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 800000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, -\left(\sin \phi_1 \cdot \cos \lambda_2\right) \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if lambda1 < -3.9000000000000003e55 or 8e8 < lambda1 Initial program 78.8%
Taylor expanded in lambda2 around 0
lower-sin.f6448.2%
Applied rewrites48.2%
if -3.9000000000000003e55 < lambda1 < 8e8Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6469.0%
Applied rewrites69.0%
lift--.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-neg.f6469.0%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.0%
Applied rewrites69.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(atan2
(* (sin lambda1) (cos phi2))
(-
t_0
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= lambda1 -3.9e+55)
t_1
(if (<= lambda1 800000000.0)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos phi2) (cos lambda2)) (sin phi1))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (lambda1 <= -3.9e+55) {
tmp = t_1;
} else if (lambda1 <= 800000000.0) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(phi2) * cos(lambda2)) * sin(phi1))));
} else {
tmp = 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(phi1) * sin(phi2)
t_1 = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
if (lambda1 <= (-3.9d+55)) then
tmp = t_1
else if (lambda1 <= 800000000.0d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(phi2) * cos(lambda2)) * sin(phi1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.atan2((Math.sin(lambda1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (lambda1 <= -3.9e+55) {
tmp = t_1;
} else if (lambda1 <= 800000000.0) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(phi2) * Math.cos(lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.atan2((math.sin(lambda1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) tmp = 0 if lambda1 <= -3.9e+55: tmp = t_1 elif lambda1 <= 800000000.0: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(phi2) * math.cos(lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = atan(Float64(sin(lambda1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (lambda1 <= -3.9e+55) tmp = t_1; elseif (lambda1 <= 800000000.0) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(phi2) * cos(lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = atan2((sin(lambda1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); tmp = 0.0; if (lambda1 <= -3.9e+55) tmp = t_1; elseif (lambda1 <= 800000000.0) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(phi2) * cos(lambda2)) * sin(phi1)))); else tmp = t_1; 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[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -3.9e+55], t$95$1, If[LessEqual[lambda1, 800000000.0], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\lambda_1 \leq -3.9 \cdot 10^{+55}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 800000000:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \phi_2 \cdot \cos \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if lambda1 < -3.9000000000000003e55 or 8e8 < lambda1 Initial program 78.8%
Taylor expanded in lambda2 around 0
lower-sin.f6448.2%
Applied rewrites48.2%
if -3.9000000000000003e55 < lambda1 < 8e8Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6469.0%
Applied rewrites69.0%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
cos-neg-revN/A
lift-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6469.0%
Applied rewrites69.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= lambda2 -660000000.0)
(atan2 t_1 (- t_0 (* (* (cos phi2) (cos lambda2)) (sin phi1))))
(if (<= lambda2 3.6e+64)
(atan2 t_1 (- t_0 (* (* (sin phi1) (cos phi2)) (cos lambda1))))
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (cos phi2) (* (cos (- lambda2)) (sin phi1)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (lambda2 <= -660000000.0) {
tmp = atan2(t_1, (t_0 - ((cos(phi2) * cos(lambda2)) * sin(phi1))));
} else if (lambda2 <= 3.6e+64) {
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-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) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (lambda2 <= (-660000000.0d0)) then
tmp = atan2(t_1, (t_0 - ((cos(phi2) * cos(lambda2)) * sin(phi1))))
else if (lambda2 <= 3.6d+64) then
tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1))))
else
tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-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.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (lambda2 <= -660000000.0) {
tmp = Math.atan2(t_1, (t_0 - ((Math.cos(phi2) * Math.cos(lambda2)) * Math.sin(phi1))));
} else if (lambda2 <= 3.6e+64) {
tmp = Math.atan2(t_1, (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} else {
tmp = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(-lambda2) * Math.sin(phi1)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if lambda2 <= -660000000.0: tmp = math.atan2(t_1, (t_0 - ((math.cos(phi2) * math.cos(lambda2)) * math.sin(phi1)))) elif lambda2 <= 3.6e+64: tmp = math.atan2(t_1, (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda1)))) else: tmp = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(-lambda2) * math.sin(phi1))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (lambda2 <= -660000000.0) tmp = atan(t_1, Float64(t_0 - Float64(Float64(cos(phi2) * cos(lambda2)) * sin(phi1)))); elseif (lambda2 <= 3.6e+64) tmp = atan(t_1, Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(cos(Float64(-lambda2)) * sin(phi1))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (lambda2 <= -660000000.0) tmp = atan2(t_1, (t_0 - ((cos(phi2) * cos(lambda2)) * sin(phi1)))); elseif (lambda2 <= 3.6e+64) tmp = atan2(t_1, (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-lambda2) * sin(phi1))))); 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -660000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda2, 3.6e+64], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[(-lambda2)], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -660000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\cos \phi_2 \cdot \cos \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{elif}\;\lambda_2 \leq 3.6 \cdot 10^{+64}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \phi_2 \cdot \left(\cos \left(-\lambda_2\right) \cdot \sin \phi_1\right)}\\
\end{array}
if lambda2 < -6.6e8Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6469.0%
Applied rewrites69.0%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
cos-neg-revN/A
lift-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6469.0%
Applied rewrites69.0%
if -6.6e8 < lambda2 < 3.6000000000000001e64Initial program 78.8%
Taylor expanded in lambda2 around 0
lower-cos.f6469.1%
Applied rewrites69.1%
if 3.6000000000000001e64 < lambda2 Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6469.0%
Applied rewrites69.0%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-neg.f6447.2%
Applied rewrites47.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (fma (sin phi2) (cos phi1) (* (- (sin phi1)) (* (cos (- lambda2 lambda1)) (cos phi2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-sin(phi1) * (cos((lambda2 - lambda1)) * cos(phi2)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-sin(phi1)) * Float64(cos(Float64(lambda2 - lambda1)) * cos(phi2))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := 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[((-N[Sin[phi1], $MachinePrecision]) * N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1\right) \cdot \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \cos \phi_2\right)\right)}
Initial program 78.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6478.8%
Applied rewrites78.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (sin phi2) (cos phi1)) (* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(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) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(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) * Math.cos(phi1)) - ((Math.cos((lambda2 - lambda1)) * Math.sin(phi1)) * Math.cos(phi2))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - ((math.cos((lambda2 - lambda1)) * math.sin(phi1)) * math.cos(phi2))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}
Initial program 78.8%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6478.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8%
Applied rewrites78.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (cos (- lambda2 lambda1)) (cos phi2)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda2 - lambda1)) * cos(phi2)) * sin(phi1))));
}
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)) - ((cos((lambda2 - lambda1)) * cos(phi2)) * sin(phi1))))
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.cos((lambda2 - lambda1)) * Math.cos(phi2)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.cos((lambda2 - lambda1)) * math.cos(phi2)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * cos(phi2)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda2 - lambda1)) * cos(phi2)) * sin(phi1)))); 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[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\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_2 - \lambda_1\right) \cdot \cos \phi_2\right) \cdot \sin \phi_1}
Initial program 78.8%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6478.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.8%
Applied rewrites78.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 5800000000.0)
(atan2 t_1 (- t_0 (* (cos (- lambda1 lambda2)) (sin phi1))))
(atan2 t_1 (- t_0 (* (* (cos phi2) (cos lambda2)) (sin phi1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= 5800000000.0) {
tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = atan2(t_1, (t_0 - ((cos(phi2) * cos(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) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi2 <= 5800000000.0d0) then
tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = atan2(t_1, (t_0 - ((cos(phi2) * cos(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.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi2 <= 5800000000.0) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_1, (t_0 - ((Math.cos(phi2) * Math.cos(lambda2)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi2 <= 5800000000.0: tmp = math.atan2(t_1, (t_0 - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = math.atan2(t_1, (t_0 - ((math.cos(phi2) * math.cos(lambda2)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= 5800000000.0) tmp = atan(t_1, Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = atan(t_1, Float64(t_0 - Float64(Float64(cos(phi2) * cos(lambda2)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi2 <= 5800000000.0) tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = atan2(t_1, (t_0 - ((cos(phi2) * cos(lambda2)) * sin(phi1)))); 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 5800000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq 5800000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \left(\cos \phi_2 \cdot \cos \lambda_2\right) \cdot \sin \phi_1}\\
\end{array}
if phi2 < 5.8e9Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6465.5%
Applied rewrites65.5%
if 5.8e9 < phi2 Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6469.0%
Applied rewrites69.0%
lift-*.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
lift-neg.f64N/A
cos-neg-revN/A
lift-cos.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6469.0%
Applied rewrites69.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1
(atan2
(* t_0 (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1)))))
(t_2 (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(if (<= phi2 -15.5)
t_1
(if (<= phi2 1.12e-12)
(atan2
(* t_0 t_2)
(-
(sin phi2)
(* (* (sin phi1) t_2) (cos (- lambda1 lambda2)))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))));
double t_2 = 1.0 + (-0.5 * pow(phi2, 2.0));
double tmp;
if (phi2 <= -15.5) {
tmp = t_1;
} else if (phi2 <= 1.12e-12) {
tmp = atan2((t_0 * t_2), (sin(phi2) - ((sin(phi1) * t_2) * cos((lambda1 - lambda2)))));
} else {
tmp = 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) :: t_2
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))))
t_2 = 1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))
if (phi2 <= (-15.5d0)) then
tmp = t_1
else if (phi2 <= 1.12d-12) then
tmp = atan2((t_0 * t_2), (sin(phi2) - ((sin(phi1) * t_2) * cos((lambda1 - lambda2)))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.atan2((t_0 * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * Math.sin(phi1))));
double t_2 = 1.0 + (-0.5 * Math.pow(phi2, 2.0));
double tmp;
if (phi2 <= -15.5) {
tmp = t_1;
} else if (phi2 <= 1.12e-12) {
tmp = Math.atan2((t_0 * t_2), (Math.sin(phi2) - ((Math.sin(phi1) * t_2) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * math.sin(phi1)))) t_2 = 1.0 + (-0.5 * math.pow(phi2, 2.0)) tmp = 0 if phi2 <= -15.5: tmp = t_1 elif phi2 <= 1.12e-12: tmp = math.atan2((t_0 * t_2), (math.sin(phi2) - ((math.sin(phi1) * t_2) * math.cos((lambda1 - lambda2))))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))) t_2 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) tmp = 0.0 if (phi2 <= -15.5) tmp = t_1; elseif (phi2 <= 1.12e-12) tmp = atan(Float64(t_0 * t_2), Float64(sin(phi2) - Float64(Float64(sin(phi1) * t_2) * cos(Float64(lambda1 - lambda2))))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1)))); t_2 = 1.0 + (-0.5 * (phi2 ^ 2.0)); tmp = 0.0; if (phi2 <= -15.5) tmp = t_1; elseif (phi2 <= 1.12e-12) tmp = atan2((t_0 * t_2), (sin(phi2) - ((sin(phi1) * t_2) * cos((lambda1 - lambda2))))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -15.5], t$95$1, If[LessEqual[phi2, 1.12e-12], N[ArcTan[N[(t$95$0 * t$95$2), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
t_2 := 1 + -0.5 \cdot {\phi_2}^{2}\\
\mathbf{if}\;\phi_2 \leq -15.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 1.12 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot t\_2}{\sin \phi_2 - \left(\sin \phi_1 \cdot t\_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -15.5 or 1.1200000000000001e-12 < phi2 Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6469.0%
Applied rewrites69.0%
Taylor expanded in lambda2 around 0
lower-sin.f6459.3%
Applied rewrites59.3%
if -15.5 < phi2 < 1.1200000000000001e-12Initial program 78.8%
Taylor expanded in phi1 around 0
lower-sin.f6465.2%
Applied rewrites65.2%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6445.7%
Applied rewrites45.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6446.2%
Applied rewrites46.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 5800000000.0)
(atan2 t_1 (- t_0 (* (cos (- lambda1 lambda2)) (sin phi1))))
(atan2 t_1 (- t_0 (* (cos phi2) (sin phi1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= 5800000000.0) {
tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = atan2(t_1, (t_0 - (cos(phi2) * 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) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi2 <= 5800000000.0d0) then
tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1))))
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 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi2 <= 5800000000.0) {
tmp = Math.atan2(t_1, (t_0 - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_1, (t_0 - (Math.cos(phi2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi2 <= 5800000000.0: tmp = math.atan2(t_1, (t_0 - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = math.atan2(t_1, (t_0 - (math.cos(phi2) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= 5800000000.0) tmp = atan(t_1, Float64(t_0 - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = atan(t_1, Float64(t_0 - Float64(cos(phi2) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi2 <= 5800000000.0) tmp = atan2(t_1, (t_0 - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = atan2(t_1, (t_0 - (cos(phi2) * sin(phi1)))); 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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 5800000000.0], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq 5800000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \cos \phi_2 \cdot \sin \phi_1}\\
\end{array}
if phi2 < 5.8e9Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6465.5%
Applied rewrites65.5%
if 5.8e9 < phi2 Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6469.0%
Applied rewrites69.0%
Taylor expanded in lambda2 around 0
lower-sin.f6459.3%
Applied rewrites59.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 2000000000.0)
(atan2
t_0
(-
(sin phi2)
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
t_0
(- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= 2000000000.0) {
tmp = atan2(t_0, (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * 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 <= 2000000000.0d0) then
tmp = atan2(t_0, (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * 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 <= 2000000000.0) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi2 <= 2000000000.0: tmp = math.atan2(t_0, (math.sin(phi2) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * 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 <= 2000000000.0) tmp = atan(t_0, Float64(sin(phi2) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * 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 <= 2000000000.0) tmp = atan2(t_0, (sin(phi2) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * 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[LessEqual[phi2, 2000000000.0], N[ArcTan[t$95$0 / 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[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq 2000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\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{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
\end{array}
if phi2 < 2e9Initial program 78.8%
Taylor expanded in phi1 around 0
lower-sin.f6465.2%
Applied rewrites65.2%
if 2e9 < phi2 Initial program 78.8%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6469.0%
Applied rewrites69.0%
Taylor expanded in lambda2 around 0
lower-sin.f6459.3%
Applied rewrites59.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (atan2 t_0 (* (sin phi1) (- (cos (- lambda2 lambda1)))))))
(if (<= phi1 -95000.0)
t_1
(if (<= phi1 6.0)
(atan2
t_0
(-
(sin phi2)
(* (* phi1 (cos phi2)) (cos (- lambda1 lambda2)))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = atan2(t_0, (sin(phi1) * -cos((lambda2 - lambda1))));
double tmp;
if (phi1 <= -95000.0) {
tmp = t_1;
} else if (phi1 <= 6.0) {
tmp = atan2(t_0, (sin(phi2) - ((phi1 * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = 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 = sin((lambda1 - lambda2)) * cos(phi2)
t_1 = atan2(t_0, (sin(phi1) * -cos((lambda2 - lambda1))))
if (phi1 <= (-95000.0d0)) then
tmp = t_1
else if (phi1 <= 6.0d0) then
tmp = atan2(t_0, (sin(phi2) - ((phi1 * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double t_1 = Math.atan2(t_0, (Math.sin(phi1) * -Math.cos((lambda2 - lambda1))));
double tmp;
if (phi1 <= -95000.0) {
tmp = t_1;
} else if (phi1 <= 6.0) {
tmp = Math.atan2(t_0, (Math.sin(phi2) - ((phi1 * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) t_1 = math.atan2(t_0, (math.sin(phi1) * -math.cos((lambda2 - lambda1)))) tmp = 0 if phi1 <= -95000.0: tmp = t_1 elif phi1 <= 6.0: tmp = math.atan2(t_0, (math.sin(phi2) - ((phi1 * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = atan(t_0, Float64(sin(phi1) * Float64(-cos(Float64(lambda2 - lambda1))))) tmp = 0.0 if (phi1 <= -95000.0) tmp = t_1; elseif (phi1 <= 6.0) tmp = atan(t_0, Float64(sin(phi2) - Float64(Float64(phi1 * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); t_1 = atan2(t_0, (sin(phi1) * -cos((lambda2 - lambda1)))); tmp = 0.0; if (phi1 <= -95000.0) tmp = t_1; elseif (phi1 <= 6.0) tmp = atan2(t_0, (sin(phi2) - ((phi1 * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = t_1; 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]}, Block[{t$95$1 = N[ArcTan[t$95$0 / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -95000.0], t$95$1, If[LessEqual[phi1, 6.0], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(N[(phi1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{t\_0}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_2 - \lambda_1\right)\right)}\\
\mathbf{if}\;\phi_1 \leq -95000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 6:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - \left(\phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi1 < -95000 or 6 < phi1 Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6448.1%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6448.1%
Applied rewrites48.1%
if -95000 < phi1 < 6Initial program 78.8%
Taylor expanded in phi1 around 0
lower-sin.f6465.2%
Applied rewrites65.2%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f6447.8%
Applied rewrites47.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 2.05e+55)
(atan2
t_0
(- (* phi2 (cos phi1)) (* (cos (- lambda1 lambda2)) (sin phi1))))
(atan2
t_0
(*
-1.0
(* (sin (+ (- lambda2 lambda1) (* 0.5 PI))) (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.05e+55) {
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = atan2(t_0, (-1.0 * (sin(((lambda2 - lambda1) + (0.5 * ((double) M_PI)))) * sin(phi1))));
}
return tmp;
}
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.05e+55) {
tmp = Math.atan2(t_0, ((phi2 * Math.cos(phi1)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_0, (-1.0 * (Math.sin(((lambda2 - lambda1) + (0.5 * Math.PI))) * 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.05e+55: tmp = math.atan2(t_0, ((phi2 * math.cos(phi1)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = math.atan2(t_0, (-1.0 * (math.sin(((lambda2 - lambda1) + (0.5 * math.pi))) * 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.05e+55) tmp = atan(t_0, Float64(Float64(phi2 * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = atan(t_0, Float64(-1.0 * Float64(sin(Float64(Float64(lambda2 - lambda1) + Float64(0.5 * pi))) * 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.05e+55) tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = atan2(t_0, (-1.0 * (sin(((lambda2 - lambda1) + (0.5 * pi))) * 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[LessEqual[phi2, 2.05e+55], N[ArcTan[t$95$0 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(-1.0 * N[(N[Sin[N[(N[(lambda2 - lambda1), $MachinePrecision] + N[(0.5 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq 2.05 \cdot 10^{+55}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{-1 \cdot \left(\sin \left(\left(\lambda_2 - \lambda_1\right) + 0.5 \cdot \pi\right) \cdot \sin \phi_1\right)}\\
\end{array}
if phi2 < 2.0499999999999999e55Initial program 78.8%
Taylor expanded in phi2 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.4%
Applied rewrites48.4%
if 2.0499999999999999e55 < phi2 Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
lift-cos.f64N/A
lift--.f64N/A
flip3--N/A
lower-unsound-/.f64N/A
lower-unsound--.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-fma.f64N/A
lower-unsound-*.f64N/A
lower-unsound-fma.f64N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lower-sin.f64N/A
lower-+.f64N/A
Applied rewrites38.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1
(atan2
(* t_0 (cos phi2))
(* -1.0 (* (cos lambda1) (sin phi1))))))
(if (<= phi2 -3.2e+36)
t_1
(if (<= phi2 280000000.0)
(atan2
(* t_0 (+ 1.0 (* -0.5 (pow phi2 2.0))))
(* -1.0 (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), (-1.0 * (cos(lambda1) * sin(phi1))));
double tmp;
if (phi2 <= -3.2e+36) {
tmp = t_1;
} else if (phi2 <= 280000000.0) {
tmp = atan2((t_0 * (1.0 + (-0.5 * pow(phi2, 2.0)))), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = 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 = sin((lambda1 - lambda2))
t_1 = atan2((t_0 * cos(phi2)), ((-1.0d0) * (cos(lambda1) * sin(phi1))))
if (phi2 <= (-3.2d+36)) then
tmp = t_1
else if (phi2 <= 280000000.0d0) then
tmp = atan2((t_0 * (1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0)))), ((-1.0d0) * (cos((lambda1 - lambda2)) * sin(phi1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.atan2((t_0 * Math.cos(phi2)), (-1.0 * (Math.cos(lambda1) * Math.sin(phi1))));
double tmp;
if (phi2 <= -3.2e+36) {
tmp = t_1;
} else if (phi2 <= 280000000.0) {
tmp = Math.atan2((t_0 * (1.0 + (-0.5 * Math.pow(phi2, 2.0)))), (-1.0 * (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.atan2((t_0 * math.cos(phi2)), (-1.0 * (math.cos(lambda1) * math.sin(phi1)))) tmp = 0 if phi2 <= -3.2e+36: tmp = t_1 elif phi2 <= 280000000.0: tmp = math.atan2((t_0 * (1.0 + (-0.5 * math.pow(phi2, 2.0)))), (-1.0 * (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = atan(Float64(t_0 * cos(phi2)), Float64(-1.0 * Float64(cos(lambda1) * sin(phi1)))) tmp = 0.0 if (phi2 <= -3.2e+36) tmp = t_1; elseif (phi2 <= 280000000.0) tmp = atan(Float64(t_0 * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))), Float64(-1.0 * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = atan2((t_0 * cos(phi2)), (-1.0 * (cos(lambda1) * sin(phi1)))); tmp = 0.0; if (phi2 <= -3.2e+36) tmp = t_1; elseif (phi2 <= 280000000.0) tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 ^ 2.0)))), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -3.2e+36], t$95$1, If[LessEqual[phi2, 280000000.0], N[ArcTan[N[(t$95$0 * N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{-1 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\phi_2 \leq -3.2 \cdot 10^{+36}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 280000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -3.1999999999999999e36 or 2.8e8 < phi2 Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6443.2%
Applied rewrites43.2%
if -3.1999999999999999e36 < phi2 < 2.8e8Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6443.8%
Applied rewrites43.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (* (sin phi1) (- (cos (- lambda2 lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi1) * -cos((lambda2 - lambda1))));
}
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(phi1) * -cos((lambda2 - lambda1))))
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(phi1) * -Math.cos((lambda2 - lambda1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (math.sin(phi1) * -math.cos((lambda2 - lambda1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(sin(phi1) * Float64(-cos(Float64(lambda2 - lambda1))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (sin(phi1) * -cos((lambda2 - lambda1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_2 - \lambda_1\right)\right)}
Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6448.1%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6448.1%
Applied rewrites48.1%
(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 (<= phi2 -1.55e+36)
(atan2 t_2 (* -1.0 (* phi1 (cos lambda1))))
(if (<= phi2 4.8e+121)
(atan2
(* t_1 (+ 1.0 (* -0.5 (pow phi2 2.0))))
(* -1.0 (* t_0 (sin phi1))))
(atan2
t_2
(*
-1.0
(*
t_0
(*
phi1
(+ 1.0 (* -0.16666666666666666 (pow phi1 2.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 (phi2 <= -1.55e+36) {
tmp = atan2(t_2, (-1.0 * (phi1 * cos(lambda1))));
} else if (phi2 <= 4.8e+121) {
tmp = atan2((t_1 * (1.0 + (-0.5 * pow(phi2, 2.0)))), (-1.0 * (t_0 * sin(phi1))));
} else {
tmp = atan2(t_2, (-1.0 * (t_0 * (phi1 * (1.0 + (-0.16666666666666666 * pow(phi1, 2.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 (phi2 <= (-1.55d+36)) then
tmp = atan2(t_2, ((-1.0d0) * (phi1 * cos(lambda1))))
else if (phi2 <= 4.8d+121) then
tmp = atan2((t_1 * (1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0)))), ((-1.0d0) * (t_0 * sin(phi1))))
else
tmp = atan2(t_2, ((-1.0d0) * (t_0 * (phi1 * (1.0d0 + ((-0.16666666666666666d0) * (phi1 ** 2.0d0)))))))
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 (phi2 <= -1.55e+36) {
tmp = Math.atan2(t_2, (-1.0 * (phi1 * Math.cos(lambda1))));
} else if (phi2 <= 4.8e+121) {
tmp = Math.atan2((t_1 * (1.0 + (-0.5 * Math.pow(phi2, 2.0)))), (-1.0 * (t_0 * Math.sin(phi1))));
} else {
tmp = Math.atan2(t_2, (-1.0 * (t_0 * (phi1 * (1.0 + (-0.16666666666666666 * Math.pow(phi1, 2.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 phi2 <= -1.55e+36: tmp = math.atan2(t_2, (-1.0 * (phi1 * math.cos(lambda1)))) elif phi2 <= 4.8e+121: tmp = math.atan2((t_1 * (1.0 + (-0.5 * math.pow(phi2, 2.0)))), (-1.0 * (t_0 * math.sin(phi1)))) else: tmp = math.atan2(t_2, (-1.0 * (t_0 * (phi1 * (1.0 + (-0.16666666666666666 * math.pow(phi1, 2.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 (phi2 <= -1.55e+36) tmp = atan(t_2, Float64(-1.0 * Float64(phi1 * cos(lambda1)))); elseif (phi2 <= 4.8e+121) tmp = atan(Float64(t_1 * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))), Float64(-1.0 * Float64(t_0 * sin(phi1)))); else tmp = atan(t_2, Float64(-1.0 * Float64(t_0 * Float64(phi1 * Float64(1.0 + Float64(-0.16666666666666666 * (phi1 ^ 2.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 (phi2 <= -1.55e+36) tmp = atan2(t_2, (-1.0 * (phi1 * cos(lambda1)))); elseif (phi2 <= 4.8e+121) tmp = atan2((t_1 * (1.0 + (-0.5 * (phi2 ^ 2.0)))), (-1.0 * (t_0 * sin(phi1)))); else tmp = atan2(t_2, (-1.0 * (t_0 * (phi1 * (1.0 + (-0.16666666666666666 * (phi1 ^ 2.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[phi2, -1.55e+36], N[ArcTan[t$95$2 / N[(-1.0 * N[(phi1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 4.8e+121], N[ArcTan[N[(t$95$1 * N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(-1.0 * N[(t$95$0 * N[(phi1 * N[(1.0 + N[(-0.16666666666666666 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\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_2 \leq -1.55 \cdot 10^{+36}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{-1 \cdot \left(\phi_1 \cdot \cos \lambda_1\right)}\\
\mathbf{elif}\;\phi_2 \leq 4.8 \cdot 10^{+121}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)}{-1 \cdot \left(t\_0 \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{-1 \cdot \left(t\_0 \cdot \left(\phi_1 \cdot \left(1 + -0.16666666666666666 \cdot {\phi_1}^{2}\right)\right)\right)}\\
\end{array}
if phi2 < -1.55e36Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f6431.3%
Applied rewrites31.3%
if -1.55e36 < phi2 < 4.8000000000000004e121Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6443.8%
Applied rewrites43.8%
if 4.8000000000000004e121 < phi2 Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6431.5%
Applied rewrites31.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 -1.55e+36)
(atan2 (* t_0 (cos phi2)) (* -1.0 (* phi1 (cos lambda1))))
(atan2
(* t_0 (+ 1.0 (* -0.5 (pow phi2 2.0))))
(* -1.0 (* (cos (- lambda1 lambda2)) (sin phi1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.55e+36) {
tmp = atan2((t_0 * cos(phi2)), (-1.0 * (phi1 * cos(lambda1))));
} else {
tmp = atan2((t_0 * (1.0 + (-0.5 * pow(phi2, 2.0)))), (-1.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))
if (phi2 <= (-1.55d+36)) then
tmp = atan2((t_0 * cos(phi2)), ((-1.0d0) * (phi1 * cos(lambda1))))
else
tmp = atan2((t_0 * (1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0)))), ((-1.0d0) * (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));
double tmp;
if (phi2 <= -1.55e+36) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), (-1.0 * (phi1 * Math.cos(lambda1))));
} else {
tmp = Math.atan2((t_0 * (1.0 + (-0.5 * Math.pow(phi2, 2.0)))), (-1.0 * (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -1.55e+36: tmp = math.atan2((t_0 * math.cos(phi2)), (-1.0 * (phi1 * math.cos(lambda1)))) else: tmp = math.atan2((t_0 * (1.0 + (-0.5 * math.pow(phi2, 2.0)))), (-1.0 * (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.55e+36) tmp = atan(Float64(t_0 * cos(phi2)), Float64(-1.0 * Float64(phi1 * cos(lambda1)))); else tmp = atan(Float64(t_0 * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))), Float64(-1.0 * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -1.55e+36) tmp = atan2((t_0 * cos(phi2)), (-1.0 * (phi1 * cos(lambda1)))); else tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 ^ 2.0)))), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.55e+36], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(phi1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.55 \cdot 10^{+36}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{-1 \cdot \left(\phi_1 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
\end{array}
if phi2 < -1.55e36Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f6431.3%
Applied rewrites31.3%
if -1.55e36 < phi2 Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6443.8%
Applied rewrites43.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(* (sin (- lambda1 lambda2)) (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(t_1 (atan2 t_0 (* -1.0 (* (cos lambda1) (sin phi1))))))
(if (<= lambda1 -3.5e+91)
t_1
(if (<= lambda1 1e-22)
(atan2 t_0 (* -1.0 (* (cos (- lambda2)) (sin phi1))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * (1.0 + (-0.5 * pow(phi2, 2.0)));
double t_1 = atan2(t_0, (-1.0 * (cos(lambda1) * sin(phi1))));
double tmp;
if (lambda1 <= -3.5e+91) {
tmp = t_1;
} else if (lambda1 <= 1e-22) {
tmp = atan2(t_0, (-1.0 * (cos(-lambda2) * sin(phi1))));
} else {
tmp = 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 = sin((lambda1 - lambda2)) * (1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0)))
t_1 = atan2(t_0, ((-1.0d0) * (cos(lambda1) * sin(phi1))))
if (lambda1 <= (-3.5d+91)) then
tmp = t_1
else if (lambda1 <= 1d-22) then
tmp = atan2(t_0, ((-1.0d0) * (cos(-lambda2) * sin(phi1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * (1.0 + (-0.5 * Math.pow(phi2, 2.0)));
double t_1 = Math.atan2(t_0, (-1.0 * (Math.cos(lambda1) * Math.sin(phi1))));
double tmp;
if (lambda1 <= -3.5e+91) {
tmp = t_1;
} else if (lambda1 <= 1e-22) {
tmp = Math.atan2(t_0, (-1.0 * (Math.cos(-lambda2) * Math.sin(phi1))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * (1.0 + (-0.5 * math.pow(phi2, 2.0))) t_1 = math.atan2(t_0, (-1.0 * (math.cos(lambda1) * math.sin(phi1)))) tmp = 0 if lambda1 <= -3.5e+91: tmp = t_1 elif lambda1 <= 1e-22: tmp = math.atan2(t_0, (-1.0 * (math.cos(-lambda2) * math.sin(phi1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))) t_1 = atan(t_0, Float64(-1.0 * Float64(cos(lambda1) * sin(phi1)))) tmp = 0.0 if (lambda1 <= -3.5e+91) tmp = t_1; elseif (lambda1 <= 1e-22) tmp = atan(t_0, Float64(-1.0 * Float64(cos(Float64(-lambda2)) * sin(phi1)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 ^ 2.0))); t_1 = atan2(t_0, (-1.0 * (cos(lambda1) * sin(phi1)))); tmp = 0.0; if (lambda1 <= -3.5e+91) tmp = t_1; elseif (lambda1 <= 1e-22) tmp = atan2(t_0, (-1.0 * (cos(-lambda2) * sin(phi1)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[t$95$0 / N[(-1.0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -3.5e+91], t$95$1, If[LessEqual[lambda1, 1e-22], N[ArcTan[t$95$0 / N[(-1.0 * N[(N[Cos[(-lambda2)], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)\\
t_1 := \tan^{-1}_* \frac{t\_0}{-1 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\lambda_1 \leq -3.5 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 10^{-22}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{-1 \cdot \left(\cos \left(-\lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if lambda1 < -3.5e91 or 1e-22 < lambda1 Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.5%
Applied rewrites28.5%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6438.8%
Applied rewrites38.8%
if -3.5e91 < lambda1 < 1e-22Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.5%
Applied rewrites28.5%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6439.0%
Applied rewrites39.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 -1.55e+36)
(atan2 (* t_0 (cos phi2)) (* -1.0 (* phi1 (cos lambda1))))
(atan2
(* t_0 (+ 1.0 (* -0.5 (pow phi2 2.0))))
(* -1.0 (* (cos lambda1) (sin phi1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.55e+36) {
tmp = atan2((t_0 * cos(phi2)), (-1.0 * (phi1 * cos(lambda1))));
} else {
tmp = atan2((t_0 * (1.0 + (-0.5 * pow(phi2, 2.0)))), (-1.0 * (cos(lambda1) * 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))
if (phi2 <= (-1.55d+36)) then
tmp = atan2((t_0 * cos(phi2)), ((-1.0d0) * (phi1 * cos(lambda1))))
else
tmp = atan2((t_0 * (1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0)))), ((-1.0d0) * (cos(lambda1) * 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));
double tmp;
if (phi2 <= -1.55e+36) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), (-1.0 * (phi1 * Math.cos(lambda1))));
} else {
tmp = Math.atan2((t_0 * (1.0 + (-0.5 * Math.pow(phi2, 2.0)))), (-1.0 * (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -1.55e+36: tmp = math.atan2((t_0 * math.cos(phi2)), (-1.0 * (phi1 * math.cos(lambda1)))) else: tmp = math.atan2((t_0 * (1.0 + (-0.5 * math.pow(phi2, 2.0)))), (-1.0 * (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.55e+36) tmp = atan(Float64(t_0 * cos(phi2)), Float64(-1.0 * Float64(phi1 * cos(lambda1)))); else tmp = atan(Float64(t_0 * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))), Float64(-1.0 * Float64(cos(lambda1) * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -1.55e+36) tmp = atan2((t_0 * cos(phi2)), (-1.0 * (phi1 * cos(lambda1)))); else tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 ^ 2.0)))), (-1.0 * (cos(lambda1) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.55e+36], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(phi1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.55 \cdot 10^{+36}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{-1 \cdot \left(\phi_1 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)}{-1 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\end{array}
if phi2 < -1.55e36Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f6431.3%
Applied rewrites31.3%
if -1.55e36 < phi2 Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.5%
Applied rewrites28.5%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6438.8%
Applied rewrites38.8%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (* -1.0 (* phi1 (cos lambda1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), (-1.0 * (phi1 * cos(lambda1))));
}
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)), ((-1.0d0) * (phi1 * cos(lambda1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (-1.0 * (phi1 * Math.cos(lambda1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (-1.0 * (phi1 * math.cos(lambda1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(-1.0 * Float64(phi1 * cos(lambda1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (-1.0 * (phi1 * cos(lambda1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(phi1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-1 \cdot \left(\phi_1 \cdot \cos \lambda_1\right)}
Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f6431.3%
Applied rewrites31.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (+ 1.0 (* -0.5 (pow phi2 2.0)))) (* -1.0 (* phi1 (cos lambda1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * (1.0 + (-0.5 * pow(phi2, 2.0)))), (-1.0 * (phi1 * cos(lambda1))));
}
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 + ((-0.5d0) * (phi2 ** 2.0d0)))), ((-1.0d0) * (phi1 * cos(lambda1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * (1.0 + (-0.5 * Math.pow(phi2, 2.0)))), (-1.0 * (phi1 * Math.cos(lambda1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * (1.0 + (-0.5 * math.pow(phi2, 2.0)))), (-1.0 * (phi1 * math.cos(lambda1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))), Float64(-1.0 * Float64(phi1 * cos(lambda1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * (1.0 + (-0.5 * (phi2 ^ 2.0)))), (-1.0 * (phi1 * cos(lambda1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(phi1 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)}{-1 \cdot \left(\phi_1 \cdot \cos \lambda_1\right)}
Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.5%
Applied rewrites28.5%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f6428.4%
Applied rewrites28.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (fma (* -0.5 phi2) phi2 1.0) (sin (- lambda1 lambda2))) (- (* (cos (- lambda2 lambda1)) phi1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma((-0.5 * phi2), phi2, 1.0) * sin((lambda1 - lambda2))), -(cos((lambda2 - lambda1)) * phi1));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(Float64(-0.5 * phi2), phi2, 1.0) * sin(Float64(lambda1 - lambda2))), Float64(-Float64(cos(Float64(lambda2 - lambda1)) * phi1))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(-0.5 * phi2), $MachinePrecision] * phi2 + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / (-N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * phi1), $MachinePrecision])], $MachinePrecision]
\tan^{-1}_* \frac{\mathsf{fma}\left(-0.5 \cdot \phi_2, \phi_2, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{-\cos \left(\lambda_2 - \lambda_1\right) \cdot \phi_1}
Initial program 78.8%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.1%
Applied rewrites48.1%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.4%
Applied rewrites31.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.5%
Applied rewrites28.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6428.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6428.5%
lower-*.f64N/A
Applied rewrites28.5%
herbie shell --seed 2025213
(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))))))