
(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 33 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
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[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[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\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_2 \cdot \cos \lambda_1\right)}
Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
remove-double-negN/A
lift-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
lower-neg.f6499.7%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
(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))
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1)))))))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)) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
}
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)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))) 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[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $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 \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)}
Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
remove-double-negN/A
lift-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(cos phi2)
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[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[Cos[phi2], $MachinePrecision] * N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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 - \cos \phi_2 \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}
Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
remove-double-negN/A
lift-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6499.7%
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2)))
(t_1 (* (sin phi1) (cos phi2)))
(t_2 (- (* (cos phi1) (sin phi2)) (* t_1 (cos (- lambda1 lambda2))))))
(if (<= phi2 -1.75e-12)
(atan2 t_0 t_2)
(if (<= phi2 3e-28)
(atan2
t_0
(-
(sin phi2)
(*
t_1
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (cos lambda1))))))
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
t_2)))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2);
double t_1 = sin(phi1) * cos(phi2);
double t_2 = (cos(phi1) * sin(phi2)) - (t_1 * cos((lambda1 - lambda2)));
double tmp;
if (phi2 <= -1.75e-12) {
tmp = atan2(t_0, t_2);
} else if (phi2 <= 3e-28) {
tmp = atan2(t_0, (sin(phi2) - (t_1 * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * cos(lambda1))))));
} else {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)) t_1 = Float64(sin(phi1) * cos(phi2)) t_2 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_1 * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi2 <= -1.75e-12) tmp = atan(t_0, t_2); elseif (phi2 <= 3e-28) tmp = atan(t_0, Float64(sin(phi2) - Float64(t_1 * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))); else tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), t_2); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.75e-12], N[ArcTan[t$95$0 / t$95$2], $MachinePrecision], If[LessEqual[phi2, 3e-28], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] - N[(t$95$1 * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \cos \phi_2\\
t_2 := \cos \phi_1 \cdot \sin \phi_2 - t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.75 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{t\_2}\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-28}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 - t\_1 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{t\_2}\\
\end{array}
if phi2 < -1.75e-12Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
if -1.75e-12 < phi2 < 3e-28Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
remove-double-negN/A
lift-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.f6480.5%
Applied rewrites80.5%
if 3e-28 < phi2 Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
remove-double-negN/A
lift-sin.f64N/A
sin-negN/A
lift-neg.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lower-neg.f6489.3%
lift-*.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
Applied rewrites89.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))))
(if (<= phi2 -1.5e-64)
(atan2 t_1 t_0)
(if (<= phi2 2e-91)
(atan2
t_1
(*
-1.0
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2
(*
(fma (sin lambda2) (- (cos lambda1)) (* (cos lambda2) (sin lambda1)))
(cos phi2))
t_0)))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)));
double t_1 = ((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2);
double tmp;
if (phi2 <= -1.5e-64) {
tmp = atan2(t_1, t_0);
} else if (phi2 <= 2e-91) {
tmp = atan2(t_1, (-1.0 * (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2((fma(sin(lambda2), -cos(lambda1), (cos(lambda2) * sin(lambda1))) * cos(phi2)), t_0);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)) tmp = 0.0 if (phi2 <= -1.5e-64) tmp = atan(t_1, t_0); elseif (phi2 <= 2e-91) tmp = atan(t_1, Float64(-1.0 * Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(Float64(fma(sin(lambda2), Float64(-cos(lambda1)), Float64(cos(lambda2) * sin(lambda1))) * cos(phi2)), t_0); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = 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]}, If[LessEqual[phi2, -1.5e-64], N[ArcTan[t$95$1 / t$95$0], $MachinePrecision], If[LessEqual[phi2, 2e-91], N[ArcTan[t$95$1 / N[(-1.0 * N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[(N[Sin[lambda2], $MachinePrecision] * (-N[Cos[lambda1], $MachinePrecision]) + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.5 \cdot 10^{-64}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0}\\
\mathbf{elif}\;\phi_2 \leq 2 \cdot 10^{-91}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{-1 \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(\sin \lambda_2, -\cos \lambda_1, \cos \lambda_2 \cdot \sin \lambda_1\right) \cdot \cos \phi_2}{t\_0}\\
\end{array}
if phi2 < -1.5e-64Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
if -1.5e-64 < phi2 < 2e-91Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
remove-double-negN/A
lift-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6458.2%
Applied rewrites58.2%
if 2e-91 < phi2 Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
remove-double-negN/A
lift-sin.f64N/A
sin-negN/A
lift-neg.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lower-neg.f6489.3%
lift-*.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
Applied rewrites89.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2)))
(t_1
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= phi2 -1.5e-64)
t_1
(if (<= phi2 2e-91)
(atan2
t_0
(*
-1.0
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = ((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2);
double t_1 = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi2 <= -1.5e-64) {
tmp = t_1;
} else if (phi2 <= 2e-91) {
tmp = atan2(t_0, (-1.0 * (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)) t_1 = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi2 <= -1.5e-64) tmp = t_1; elseif (phi2 <= 2e-91) tmp = atan(t_0, Float64(-1.0 * Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[ArcTan[t$95$0 / 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[phi2, -1.5e-64], t$95$1, If[LessEqual[phi2, 2e-91], N[ArcTan[t$95$0 / N[(-1.0 * N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2\\
t_1 := \tan^{-1}_* \frac{t\_0}{\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}\;\phi_2 \leq -1.5 \cdot 10^{-64}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 2 \cdot 10^{-91}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{-1 \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -1.5e-64 or 2e-91 < phi2 Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
if -1.5e-64 < phi2 < 2e-91Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
remove-double-negN/A
lift-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6458.2%
Applied rewrites58.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1
(atan2
(* (- t_0 (sin lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= phi2 -1.5e-64)
t_1
(if (<= phi2 2.1e-82)
(atan2
(* (- t_0 (* (sin lambda2) (cos lambda1))) (cos phi2))
(*
-1.0
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = atan2(((t_0 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi2 <= -1.5e-64) {
tmp = t_1;
} else if (phi2 <= 2.1e-82) {
tmp = atan2(((t_0 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (-1.0 * (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = t_1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = atan(Float64(Float64(t_0 - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi2 <= -1.5e-64) tmp = t_1; elseif (phi2 <= 2.1e-82) tmp = atan(Float64(Float64(t_0 - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(-1.0 * Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[(t$95$0 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.5e-64], t$95$1, If[LessEqual[phi2, 2.1e-82], N[ArcTan[N[(N[(t$95$0 - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \tan^{-1}_* \frac{\left(t\_0 - \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)}\\
\mathbf{if}\;\phi_2 \leq -1.5 \cdot 10^{-64}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 2.1 \cdot 10^{-82}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{-1 \cdot \left(\sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -1.5e-64 or 2.1e-82 < phi2 Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
Taylor expanded in lambda1 around 0
lower-sin.f6481.5%
Applied rewrites81.5%
if -1.5e-64 < phi2 < 2.1e-82Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.f64N/A
remove-double-negN/A
lift-neg.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-neg.f64N/A
sin-negN/A
lift-sin.f64N/A
remove-double-negN/A
lift-cos.f64N/A
cos-neg-revN/A
lift-neg.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-fma.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6458.2%
Applied rewrites58.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1
(atan2
(* (- t_0 (* (sin lambda2) (cos lambda1))) (cos phi2))
(-
(* (sin phi2) (cos phi1))
(* (* (cos lambda2) (sin phi1)) (cos phi2))))))
(if (<= lambda2 -1960000.0)
t_1
(if (<= lambda2 3e+19)
(atan2
(*
(-
t_0
(*
(* lambda2 (+ 1.0 (* -0.16666666666666666 (pow lambda2 2.0))))
(cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = atan2(((t_0 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos(lambda2) * sin(phi1)) * cos(phi2))));
double tmp;
if (lambda2 <= -1960000.0) {
tmp = t_1;
} else if (lambda2 <= 3e+19) {
tmp = atan2(((t_0 - ((lambda2 * (1.0 + (-0.16666666666666666 * pow(lambda2, 2.0)))) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(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) * cos(lambda2)
t_1 = atan2(((t_0 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos(lambda2) * sin(phi1)) * cos(phi2))))
if (lambda2 <= (-1960000.0d0)) then
tmp = t_1
else if (lambda2 <= 3d+19) then
tmp = atan2(((t_0 - ((lambda2 * (1.0d0 + ((-0.16666666666666666d0) * (lambda2 ** 2.0d0)))) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(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) * Math.cos(lambda2);
double t_1 = Math.atan2(((t_0 - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), ((Math.sin(phi2) * Math.cos(phi1)) - ((Math.cos(lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
double tmp;
if (lambda2 <= -1960000.0) {
tmp = t_1;
} else if (lambda2 <= 3e+19) {
tmp = Math.atan2(((t_0 - ((lambda2 * (1.0 + (-0.16666666666666666 * Math.pow(lambda2, 2.0)))) * Math.cos(lambda1))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(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) * math.cos(lambda2) t_1 = math.atan2(((t_0 - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - ((math.cos(lambda2) * math.sin(phi1)) * math.cos(phi2)))) tmp = 0 if lambda2 <= -1960000.0: tmp = t_1 elif lambda2 <= 3e+19: tmp = math.atan2(((t_0 - ((lambda2 * (1.0 + (-0.16666666666666666 * math.pow(lambda2, 2.0)))) * math.cos(lambda1))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = atan(Float64(Float64(t_0 - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(lambda2) * sin(phi1)) * cos(phi2)))) tmp = 0.0 if (lambda2 <= -1960000.0) tmp = t_1; elseif (lambda2 <= 3e+19) tmp = atan(Float64(Float64(t_0 - Float64(Float64(lambda2 * Float64(1.0 + Float64(-0.16666666666666666 * (lambda2 ^ 2.0)))) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(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) * cos(lambda2); t_1 = atan2(((t_0 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos(lambda2) * sin(phi1)) * cos(phi2)))); tmp = 0.0; if (lambda2 <= -1960000.0) tmp = t_1; elseif (lambda2 <= 3e+19) tmp = atan2(((t_0 - ((lambda2 * (1.0 + (-0.16666666666666666 * (lambda2 ^ 2.0)))) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(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[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[(t$95$0 - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -1960000.0], t$95$1, If[LessEqual[lambda2, 3e+19], N[ArcTan[N[(N[(t$95$0 - N[(N[(lambda2 * N[(1.0 + N[(-0.16666666666666666 * N[Power[lambda2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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], t$95$1]]]]
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \tan^{-1}_* \frac{\left(t\_0 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \lambda_2 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -1960000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 3 \cdot 10^{+19}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_0 - \left(\lambda_2 \cdot \left(1 + -0.16666666666666666 \cdot {\lambda_2}^{2}\right)\right) \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)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if lambda2 < -1.96e6 or 3e19 < lambda2 Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6479.3%
Applied rewrites79.3%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.3%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6479.3%
lift-cos.f64N/A
lift-neg.f64N/A
cos-neg-revN/A
lift-cos.f6479.3%
Applied rewrites79.3%
if -1.96e6 < lambda2 < 3e19Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6459.8%
Applied rewrites59.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin lambda2) (cos lambda1)))
(t_2
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_1) (cos phi2))
(- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1)))))))
(if (<= lambda1 -0.76)
t_2
(if (<= lambda1 2.95e-6)
(atan2
(* (- (* lambda1 (cos lambda2)) t_1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
t_2))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(lambda2) * cos(lambda1);
double t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
double tmp;
if (lambda1 <= -0.76) {
tmp = t_2;
} else if (lambda1 <= 2.95e-6) {
tmp = atan2((((lambda1 * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin(lambda2) * cos(lambda1)
t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))))
if (lambda1 <= (-0.76d0)) then
tmp = t_2
else if (lambda1 <= 2.95d-6) then
tmp = atan2((((lambda1 * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = t_2
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(lambda2) * Math.cos(lambda1);
double t_2 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_1) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * (Math.cos(phi2) * Math.sin(phi1)))));
double tmp;
if (lambda1 <= -0.76) {
tmp = t_2;
} else if (lambda1 <= 2.95e-6) {
tmp = Math.atan2((((lambda1 * Math.cos(lambda2)) - t_1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(lambda2) * math.cos(lambda1) t_2 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_1) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) tmp = 0 if lambda1 <= -0.76: tmp = t_2 elif lambda1 <= 2.95e-6: tmp = math.atan2((((lambda1 * math.cos(lambda2)) - t_1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(lambda2) * cos(lambda1)) t_2 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))) tmp = 0.0 if (lambda1 <= -0.76) tmp = t_2; elseif (lambda1 <= 2.95e-6) tmp = atan(Float64(Float64(Float64(lambda1 * cos(lambda2)) - t_1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(lambda2) * cos(lambda1); t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1))))); tmp = 0.0; if (lambda1 <= -0.76) tmp = t_2; elseif (lambda1 <= 2.95e-6) tmp = atan2((((lambda1 * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = t_2; 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[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$1), $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.76], t$95$2, If[LessEqual[lambda1, 2.95e-6], N[ArcTan[N[(N[(N[(lambda1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$1), $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], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_2 \cdot \cos \lambda_1\\
t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_1\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.76:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 2.95 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\lambda_1 \cdot \cos \lambda_2 - t\_1\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if lambda1 < -0.76000000000000001 or 2.9500000000000001e-6 < lambda1 Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6479.5%
Applied rewrites79.5%
if -0.76000000000000001 < lambda1 < 2.9500000000000001e-6Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f6459.3%
Applied rewrites59.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))
(t_1 (* (sin lambda1) (cos lambda2)))
(t_2
(atan2
(* (- t_1 (sin lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) t_0))))
(if (<= phi1 -42.0)
t_2
(if (<= phi1 650.0)
(atan2
(* (- t_1 (* (sin lambda2) (cos lambda1))) (cos phi2))
(- (sin phi2) t_0))
t_2))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double t_1 = sin(lambda1) * cos(lambda2);
double t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_0));
double tmp;
if (phi1 <= -42.0) {
tmp = t_2;
} else if (phi1 <= 650.0) {
tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) - t_0));
} else {
tmp = t_2;
}
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(phi1) * cos(phi2)) * cos((lambda1 - lambda2))
t_1 = sin(lambda1) * cos(lambda2)
t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_0))
if (phi1 <= (-42.0d0)) then
tmp = t_2
else if (phi1 <= 650.0d0) then
tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) - t_0))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(lambda1) * Math.cos(lambda2);
double t_2 = Math.atan2(((t_1 - Math.sin(lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - t_0));
double tmp;
if (phi1 <= -42.0) {
tmp = t_2;
} else if (phi1 <= 650.0) {
tmp = Math.atan2(((t_1 - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), (Math.sin(phi2) - t_0));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = (math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) t_1 = math.sin(lambda1) * math.cos(lambda2) t_2 = math.atan2(((t_1 - math.sin(lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - t_0)) tmp = 0 if phi1 <= -42.0: tmp = t_2 elif phi1 <= 650.0: tmp = math.atan2(((t_1 - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), (math.sin(phi2) - t_0)) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) t_1 = Float64(sin(lambda1) * cos(lambda2)) t_2 = atan(Float64(Float64(t_1 - sin(lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - t_0)) tmp = 0.0 if (phi1 <= -42.0) tmp = t_2; elseif (phi1 <= 650.0) tmp = atan(Float64(Float64(t_1 - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(sin(phi2) - t_0)); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = (sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)); t_1 = sin(lambda1) * cos(lambda2); t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - t_0)); tmp = 0.0; if (phi1 <= -42.0) tmp = t_2; elseif (phi1 <= 650.0) tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) - t_0)); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(t$95$1 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -42.0], t$95$2, If[LessEqual[phi1, 650.0], N[ArcTan[N[(N[(t$95$1 - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_2 := \tan^{-1}_* \frac{\left(t\_1 - \sin \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - t\_0}\\
\mathbf{if}\;\phi_1 \leq -42:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 650:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_1 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2 - t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if phi1 < -42 or 650 < phi1 Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
Taylor expanded in lambda1 around 0
lower-sin.f6481.5%
Applied rewrites81.5%
if -42 < phi1 < 650Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
Taylor expanded in phi1 around 0
lower-sin.f6475.5%
Applied rewrites75.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (cos (- lambda2 lambda1)) (cos phi2)) (sin phi1))))))
(if (<= phi1 -0.25)
t_0
(if (<= phi1 54000000000000.0)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(+
(sin phi2)
(* -1.0 (* phi1 (* (cos phi2) (cos (- lambda1 lambda2)))))))
t_0))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda2 - lambda1)) * cos(phi2)) * sin(phi1))));
double tmp;
if (phi1 <= -0.25) {
tmp = t_0;
} else if (phi1 <= 54000000000000.0) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + (-1.0 * (phi1 * (cos(phi2) * cos((lambda1 - lambda2)))))));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda2 - lambda1)) * cos(phi2)) * sin(phi1))))
if (phi1 <= (-0.25d0)) then
tmp = t_0
else if (phi1 <= 54000000000000.0d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + ((-1.0d0) * (phi1 * (cos(phi2) * cos((lambda1 - lambda2)))))))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 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))));
double tmp;
if (phi1 <= -0.25) {
tmp = t_0;
} else if (phi1 <= 54000000000000.0) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), (Math.sin(phi2) + (-1.0 * (phi1 * (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))))));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = 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)))) tmp = 0 if phi1 <= -0.25: tmp = t_0 elif phi1 <= 54000000000000.0: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), (math.sin(phi2) + (-1.0 * (phi1 * (math.cos(phi2) * math.cos((lambda1 - lambda2))))))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * cos(phi2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -0.25) tmp = t_0; elseif (phi1 <= 54000000000000.0) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(sin(phi2) + Float64(-1.0 * Float64(phi1 * Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))))))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((cos((lambda2 - lambda1)) * cos(phi2)) * sin(phi1)))); tmp = 0.0; if (phi1 <= -0.25) tmp = t_0; elseif (phi1 <= 54000000000000.0) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + (-1.0 * (phi1 * (cos(phi2) * cos((lambda1 - lambda2))))))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, If[LessEqual[phi1, -0.25], t$95$0, If[LessEqual[phi1, 54000000000000.0], 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[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], t$95$0]]]
\begin{array}{l}
t_0 := \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}\\
\mathbf{if}\;\phi_1 \leq -0.25:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 54000000000000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\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}:\\
\;\;\;\;t\_0\\
\end{array}
if phi1 < -0.25 or 5.4e13 < phi1 Initial program 79.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6479.6%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6479.6%
Applied rewrites79.6%
if -0.25 < phi1 < 5.4e13Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
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--.f6457.1%
Applied rewrites57.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (- lambda2 lambda1)) (cos phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 -0.1)
(atan2 t_1 (fma (sin phi1) (- t_0) (* (sin phi2) (cos phi1))))
(if (<= phi2 3.1e-28)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(- (* phi2 (cos phi1)) (* (cos (- lambda1 lambda2)) (sin phi1))))
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* t_0 (sin phi1))))))))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 <= -0.1) {
tmp = atan2(t_1, fma(sin(phi1), -t_0, (sin(phi2) * cos(phi1))));
} else if (phi2 <= 3.1e-28) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_0 * sin(phi1))));
}
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 <= -0.1) tmp = atan(t_1, fma(sin(phi1), Float64(-t_0), Float64(sin(phi2) * cos(phi1)))); elseif (phi2 <= 3.1e-28) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(phi2 * cos(phi1)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * sin(phi1)))); 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, -0.1], N[ArcTan[t$95$1 / N[(N[Sin[phi1], $MachinePrecision] * (-t$95$0) + N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 3.1e-28], 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[(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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $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 -0.1:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\mathsf{fma}\left(\sin \phi_1, -t\_0, \sin \phi_2 \cdot \cos \phi_1\right)}\\
\mathbf{elif}\;\phi_2 \leq 3.1 \cdot 10^{-28}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\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}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot \sin \phi_1}\\
\end{array}
if phi2 < -0.10000000000000001Initial program 79.6%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*l*N/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites79.6%
if -0.10000000000000001 < phi2 < 3.0999999999999999e-28Initial program 79.6%
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.f6489.3%
Applied rewrites89.3%
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 3.0999999999999999e-28 < phi2 Initial program 79.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6479.6%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6479.6%
Applied rewrites79.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (cos phi2) (* (cos (- lambda2)) (sin phi1)))))))
(if (<= lambda2 -4.4e+24)
t_1
(if (<= lambda2 1.6)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos lambda1))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-lambda2) * sin(phi1)))));
double tmp;
if (lambda2 <= -4.4e+24) {
tmp = t_1;
} else if (lambda2 <= 1.6) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
} 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(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-lambda2) * sin(phi1)))))
if (lambda2 <= (-4.4d+24)) then
tmp = t_1
else if (lambda2 <= 1.6d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(-lambda2) * Math.sin(phi1)))));
double tmp;
if (lambda2 <= -4.4e+24) {
tmp = t_1;
} else if (lambda2 <= 1.6) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} 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(-lambda2) * math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(-lambda2) * math.sin(phi1))))) tmp = 0 if lambda2 <= -4.4e+24: tmp = t_1 elif lambda2 <= 1.6: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda1)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(cos(Float64(-lambda2)) * sin(phi1))))) tmp = 0.0 if (lambda2 <= -4.4e+24) tmp = t_1; elseif (lambda2 <= 1.6) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda1)))); 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(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-lambda2) * sin(phi1))))); tmp = 0.0; if (lambda2 <= -4.4e+24) tmp = t_1; elseif (lambda2 <= 1.6) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos(lambda1)))); 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[(-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]}, If[LessEqual[lambda2, -4.4e+24], t$95$1, If[LessEqual[lambda2, 1.6], 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[Cos[lambda1], $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 \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)}\\
\mathbf{if}\;\lambda_2 \leq -4.4 \cdot 10^{+24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 1.6:\\
\;\;\;\;\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 \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if lambda2 < -4.4e24 or 1.6000000000000001 < lambda2 Initial program 79.6%
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.6%
Applied rewrites69.6%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-neg.f6448.4%
Applied rewrites48.4%
if -4.4e24 < lambda2 < 1.6000000000000001Initial program 79.6%
Taylor expanded in lambda2 around 0
lower-cos.f6469.8%
Applied rewrites69.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 79.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6479.6%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6479.6%
Applied rewrites79.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (* (cos lambda2) (cos phi2)) (sin phi1))))))
(if (<= phi2 -2.5)
t_1
(if (<= phi2 3e-39)
(atan2
t_0
(-
(*
(cos phi1)
(* phi2 (+ 1.0 (* -0.16666666666666666 (pow phi2 2.0)))))
(* (* (sin 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, ((cos(phi1) * sin(phi2)) - ((cos(lambda2) * cos(phi2)) * sin(phi1))));
double tmp;
if (phi2 <= -2.5) {
tmp = t_1;
} else if (phi2 <= 3e-39) {
tmp = atan2(t_0, ((cos(phi1) * (phi2 * (1.0 + (-0.16666666666666666 * pow(phi2, 2.0))))) - ((sin(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, ((cos(phi1) * sin(phi2)) - ((cos(lambda2) * cos(phi2)) * sin(phi1))))
if (phi2 <= (-2.5d0)) then
tmp = t_1
else if (phi2 <= 3d-39) then
tmp = atan2(t_0, ((cos(phi1) * (phi2 * (1.0d0 + ((-0.16666666666666666d0) * (phi2 ** 2.0d0))))) - ((sin(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.cos(phi1) * Math.sin(phi2)) - ((Math.cos(lambda2) * Math.cos(phi2)) * Math.sin(phi1))));
double tmp;
if (phi2 <= -2.5) {
tmp = t_1;
} else if (phi2 <= 3e-39) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * (phi2 * (1.0 + (-0.16666666666666666 * Math.pow(phi2, 2.0))))) - ((Math.sin(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.cos(phi1) * math.sin(phi2)) - ((math.cos(lambda2) * math.cos(phi2)) * math.sin(phi1)))) tmp = 0 if phi2 <= -2.5: tmp = t_1 elif phi2 <= 3e-39: tmp = math.atan2(t_0, ((math.cos(phi1) * (phi2 * (1.0 + (-0.16666666666666666 * math.pow(phi2, 2.0))))) - ((math.sin(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(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(cos(lambda2) * cos(phi2)) * sin(phi1)))) tmp = 0.0 if (phi2 <= -2.5) tmp = t_1; elseif (phi2 <= 3e-39) tmp = atan(t_0, Float64(Float64(cos(phi1) * Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * (phi2 ^ 2.0))))) - Float64(Float64(sin(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, ((cos(phi1) * sin(phi2)) - ((cos(lambda2) * cos(phi2)) * sin(phi1)))); tmp = 0.0; if (phi2 <= -2.5) tmp = t_1; elseif (phi2 <= 3e-39) tmp = atan2(t_0, ((cos(phi1) * (phi2 * (1.0 + (-0.16666666666666666 * (phi2 ^ 2.0))))) - ((sin(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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2.5], t$95$1, If[LessEqual[phi2, 3e-39], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * 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}{\cos \phi_1 \cdot \sin \phi_2 - \left(\cos \lambda_2 \cdot \cos \phi_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_2 \leq -2.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-39}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \left(\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot {\phi_2}^{2}\right)\right) - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -2.5 or 3.0000000000000003e-39 < phi2 Initial program 79.6%
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.6%
Applied rewrites69.6%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6469.6%
lift-cos.f64N/A
lift-neg.f64N/A
cos-neg-revN/A
lift-cos.f6469.6%
Applied rewrites69.6%
if -2.5 < phi2 < 3.0000000000000003e-39Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6448.5%
Applied rewrites48.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (cos phi2) (* (cos (- lambda2)) (sin phi1)))))))
(if (<= lambda2 -4.4e+24)
t_1
(if (<= lambda2 1.6)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (cos (- lambda1 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(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-lambda2) * sin(phi1)))));
double tmp;
if (lambda2 <= -4.4e+24) {
tmp = t_1;
} else if (lambda2 <= 1.6) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_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 = cos(phi1) * sin(phi2)
t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-lambda2) * sin(phi1)))))
if (lambda2 <= (-4.4d+24)) then
tmp = t_1
else if (lambda2 <= 1.6d0) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - (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.cos(phi1) * Math.sin(phi2);
double t_1 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * (Math.cos(-lambda2) * Math.sin(phi1)))));
double tmp;
if (lambda2 <= -4.4e+24) {
tmp = t_1;
} else if (lambda2 <= 1.6) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - (Math.cos((lambda1 - 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(-lambda2) * math.cos(phi2)), (t_0 - (math.cos(phi2) * (math.cos(-lambda2) * math.sin(phi1))))) tmp = 0 if lambda2 <= -4.4e+24: tmp = t_1 elif lambda2 <= 1.6: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - (math.cos((lambda1 - 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(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * Float64(cos(Float64(-lambda2)) * sin(phi1))))) tmp = 0.0 if (lambda2 <= -4.4e+24) tmp = t_1; elseif (lambda2 <= 1.6) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_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 = cos(phi1) * sin(phi2); t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - (cos(phi2) * (cos(-lambda2) * sin(phi1))))); tmp = 0.0; if (lambda2 <= -4.4e+24) tmp = t_1; elseif (lambda2 <= 1.6) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[lambda2, -4.4e+24], t$95$1, If[LessEqual[lambda2, 1.6], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[N[(lambda1 - 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 \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)}\\
\mathbf{if}\;\lambda_2 \leq -4.4 \cdot 10^{+24}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 1.6:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if lambda2 < -4.4e24 or 1.6000000000000001 < lambda2 Initial program 79.6%
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.6%
Applied rewrites69.6%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-neg.f6448.4%
Applied rewrites48.4%
if -4.4e24 < lambda2 < 1.6000000000000001Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6466.1%
Applied rewrites66.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1
(atan2 t_0 (- (* (cos phi1) (sin phi2)) (* (cos phi2) (sin phi1))))))
(if (<= phi2 -2.5)
t_1
(if (<= phi2 1.0)
(atan2
t_0
(-
(*
(cos phi1)
(* phi2 (+ 1.0 (* -0.16666666666666666 (pow phi2 2.0)))))
(* (* (sin 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, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))));
double tmp;
if (phi2 <= -2.5) {
tmp = t_1;
} else if (phi2 <= 1.0) {
tmp = atan2(t_0, ((cos(phi1) * (phi2 * (1.0 + (-0.16666666666666666 * pow(phi2, 2.0))))) - ((sin(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, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))))
if (phi2 <= (-2.5d0)) then
tmp = t_1
else if (phi2 <= 1.0d0) then
tmp = atan2(t_0, ((cos(phi1) * (phi2 * (1.0d0 + ((-0.16666666666666666d0) * (phi2 ** 2.0d0))))) - ((sin(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.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * Math.sin(phi1))));
double tmp;
if (phi2 <= -2.5) {
tmp = t_1;
} else if (phi2 <= 1.0) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * (phi2 * (1.0 + (-0.16666666666666666 * Math.pow(phi2, 2.0))))) - ((Math.sin(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.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * math.sin(phi1)))) tmp = 0 if phi2 <= -2.5: tmp = t_1 elif phi2 <= 1.0: tmp = math.atan2(t_0, ((math.cos(phi1) * (phi2 * (1.0 + (-0.16666666666666666 * math.pow(phi2, 2.0))))) - ((math.sin(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(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))) tmp = 0.0 if (phi2 <= -2.5) tmp = t_1; elseif (phi2 <= 1.0) tmp = atan(t_0, Float64(Float64(cos(phi1) * Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * (phi2 ^ 2.0))))) - Float64(Float64(sin(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, ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1)))); tmp = 0.0; if (phi2 <= -2.5) tmp = t_1; elseif (phi2 <= 1.0) tmp = atan2(t_0, ((cos(phi1) * (phi2 * (1.0 + (-0.16666666666666666 * (phi2 ^ 2.0))))) - ((sin(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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2.5], t$95$1, If[LessEqual[phi2, 1.0], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * 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}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_2 \leq -2.5:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 1:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \left(\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot {\phi_2}^{2}\right)\right) - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -2.5 or 1 < phi2 Initial program 79.6%
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.6%
Applied rewrites69.6%
Taylor expanded in lambda2 around 0
lower-sin.f6459.8%
Applied rewrites59.8%
if -2.5 < phi2 < 1Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6448.5%
Applied rewrites48.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (sin (- lambda1 lambda2)))
(t_2 (atan2 (* t_1 (cos phi2)) (- t_0 (* (cos phi2) (sin phi1)))))
(t_3 (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(if (<= phi2 -7800.0)
t_2
(if (<= phi2 1.0)
(atan2
(* t_1 t_3)
(- t_0 (* (* (sin phi1) t_3) (cos (- lambda1 lambda2)))))
t_2))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin((lambda1 - lambda2));
double t_2 = atan2((t_1 * cos(phi2)), (t_0 - (cos(phi2) * sin(phi1))));
double t_3 = 1.0 + (-0.5 * pow(phi2, 2.0));
double tmp;
if (phi2 <= -7800.0) {
tmp = t_2;
} else if (phi2 <= 1.0) {
tmp = atan2((t_1 * t_3), (t_0 - ((sin(phi1) * t_3) * cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
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) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin((lambda1 - lambda2))
t_2 = atan2((t_1 * cos(phi2)), (t_0 - (cos(phi2) * sin(phi1))))
t_3 = 1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))
if (phi2 <= (-7800.0d0)) then
tmp = t_2
else if (phi2 <= 1.0d0) then
tmp = atan2((t_1 * t_3), (t_0 - ((sin(phi1) * t_3) * cos((lambda1 - lambda2)))))
else
tmp = t_2
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));
double t_2 = Math.atan2((t_1 * Math.cos(phi2)), (t_0 - (Math.cos(phi2) * Math.sin(phi1))));
double t_3 = 1.0 + (-0.5 * Math.pow(phi2, 2.0));
double tmp;
if (phi2 <= -7800.0) {
tmp = t_2;
} else if (phi2 <= 1.0) {
tmp = Math.atan2((t_1 * t_3), (t_0 - ((Math.sin(phi1) * t_3) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin((lambda1 - lambda2)) t_2 = math.atan2((t_1 * math.cos(phi2)), (t_0 - (math.cos(phi2) * math.sin(phi1)))) t_3 = 1.0 + (-0.5 * math.pow(phi2, 2.0)) tmp = 0 if phi2 <= -7800.0: tmp = t_2 elif phi2 <= 1.0: tmp = math.atan2((t_1 * t_3), (t_0 - ((math.sin(phi1) * t_3) * math.cos((lambda1 - lambda2))))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = sin(Float64(lambda1 - lambda2)) t_2 = atan(Float64(t_1 * cos(phi2)), Float64(t_0 - Float64(cos(phi2) * sin(phi1)))) t_3 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) tmp = 0.0 if (phi2 <= -7800.0) tmp = t_2; elseif (phi2 <= 1.0) tmp = atan(Float64(t_1 * t_3), Float64(t_0 - Float64(Float64(sin(phi1) * t_3) * cos(Float64(lambda1 - lambda2))))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin((lambda1 - lambda2)); t_2 = atan2((t_1 * cos(phi2)), (t_0 - (cos(phi2) * sin(phi1)))); t_3 = 1.0 + (-0.5 * (phi2 ^ 2.0)); tmp = 0.0; if (phi2 <= -7800.0) tmp = t_2; elseif (phi2 <= 1.0) tmp = atan2((t_1 * t_3), (t_0 - ((sin(phi1) * t_3) * cos((lambda1 - lambda2))))); else tmp = t_2; 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[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7800.0], t$95$2, If[LessEqual[phi2, 1.0], N[ArcTan[N[(t$95$1 * t$95$3), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * t$95$3), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_2 := \tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{t\_0 - \cos \phi_2 \cdot \sin \phi_1}\\
t_3 := 1 + -0.5 \cdot {\phi_2}^{2}\\
\mathbf{if}\;\phi_2 \leq -7800:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_2 \leq 1:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot t\_3}{t\_0 - \left(\sin \phi_1 \cdot t\_3\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if phi2 < -7800 or 1 < phi2 Initial program 79.6%
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.6%
Applied rewrites69.6%
Taylor expanded in lambda2 around 0
lower-sin.f6459.8%
Applied rewrites59.8%
if -7800 < phi2 < 1Initial program 79.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6446.6%
Applied rewrites46.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6446.9%
Applied rewrites46.9%
(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))))))
(if (<= phi2 -430000.0)
t_1
(if (<= phi2 0.85)
(atan2
(*
t_0
(+
1.0
(* (pow phi2 2.0) (- (* 0.041666666666666664 (pow phi2 2.0)) 0.5))))
(- (* phi2 (cos phi1)) (* (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)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))));
double tmp;
if (phi2 <= -430000.0) {
tmp = t_1;
} else if (phi2 <= 0.85) {
tmp = atan2((t_0 * (1.0 + (pow(phi2, 2.0) * ((0.041666666666666664 * pow(phi2, 2.0)) - 0.5)))), ((phi2 * cos(phi1)) - (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)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1))))
if (phi2 <= (-430000.0d0)) then
tmp = t_1
else if (phi2 <= 0.85d0) then
tmp = atan2((t_0 * (1.0d0 + ((phi2 ** 2.0d0) * ((0.041666666666666664d0 * (phi2 ** 2.0d0)) - 0.5d0)))), ((phi2 * cos(phi1)) - (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)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * Math.sin(phi1))));
double tmp;
if (phi2 <= -430000.0) {
tmp = t_1;
} else if (phi2 <= 0.85) {
tmp = Math.atan2((t_0 * (1.0 + (Math.pow(phi2, 2.0) * ((0.041666666666666664 * Math.pow(phi2, 2.0)) - 0.5)))), ((phi2 * Math.cos(phi1)) - (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)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * math.sin(phi1)))) tmp = 0 if phi2 <= -430000.0: tmp = t_1 elif phi2 <= 0.85: tmp = math.atan2((t_0 * (1.0 + (math.pow(phi2, 2.0) * ((0.041666666666666664 * math.pow(phi2, 2.0)) - 0.5)))), ((phi2 * math.cos(phi1)) - (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(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * sin(phi1)))) tmp = 0.0 if (phi2 <= -430000.0) tmp = t_1; elseif (phi2 <= 0.85) tmp = atan(Float64(t_0 * Float64(1.0 + Float64((phi2 ^ 2.0) * Float64(Float64(0.041666666666666664 * (phi2 ^ 2.0)) - 0.5)))), Float64(Float64(phi2 * cos(phi1)) - 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)), ((cos(phi1) * sin(phi2)) - (cos(phi2) * sin(phi1)))); tmp = 0.0; if (phi2 <= -430000.0) tmp = t_1; elseif (phi2 <= 0.85) tmp = atan2((t_0 * (1.0 + ((phi2 ^ 2.0) * ((0.041666666666666664 * (phi2 ^ 2.0)) - 0.5)))), ((phi2 * cos(phi1)) - (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[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -430000.0], t$95$1, If[LessEqual[phi2, 0.85], N[ArcTan[N[(t$95$0 * N[(1.0 + N[(N[Power[phi2, 2.0], $MachinePrecision] * N[(N[(0.041666666666666664 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $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], 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}\\
\mathbf{if}\;\phi_2 \leq -430000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 0.85:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \left(1 + {\phi_2}^{2} \cdot \left(0.041666666666666664 \cdot {\phi_2}^{2} - 0.5\right)\right)}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -4.3e5 or 0.84999999999999998 < phi2 Initial program 79.6%
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.6%
Applied rewrites69.6%
Taylor expanded in lambda2 around 0
lower-sin.f6459.8%
Applied rewrites59.8%
if -4.3e5 < phi2 < 0.84999999999999998Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6446.0%
Applied rewrites46.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 5.4e+61)
(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 <= 5.4e+61) {
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 <= 5.4d+61) 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 <= 5.4e+61) {
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 <= 5.4e+61: 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 <= 5.4e+61) 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 <= 5.4e+61) 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, 5.4e+61], 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 5.4 \cdot 10^{+61}:\\
\;\;\;\;\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.4000000000000004e61Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6466.1%
Applied rewrites66.1%
if 5.4000000000000004e61 < phi2 Initial program 79.6%
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.6%
Applied rewrites69.6%
Taylor expanded in lambda2 around 0
lower-sin.f6459.8%
Applied rewrites59.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (* t_0 (cos phi2)))
(t_2 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.23)
(atan2 t_1 (* (sin phi1) (- (cos (- lambda2 lambda1)))))
(if (<= phi1 7e-14)
(atan2 t_1 (+ (sin phi2) (* -1.0 (* phi1 (* (cos phi2) t_2)))))
(atan2
(* t_0 (+ 1.0 (* -0.5 (pow phi2 2.0))))
(- (* phi2 (cos phi1)) (* t_2 (sin phi1))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = t_0 * cos(phi2);
double t_2 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.23) {
tmp = atan2(t_1, (sin(phi1) * -cos((lambda2 - lambda1))));
} else if (phi1 <= 7e-14) {
tmp = atan2(t_1, (sin(phi2) + (-1.0 * (phi1 * (cos(phi2) * t_2)))));
} else {
tmp = atan2((t_0 * (1.0 + (-0.5 * pow(phi2, 2.0)))), ((phi2 * cos(phi1)) - (t_2 * 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) :: t_2
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = t_0 * cos(phi2)
t_2 = cos((lambda1 - lambda2))
if (phi1 <= (-0.23d0)) then
tmp = atan2(t_1, (sin(phi1) * -cos((lambda2 - lambda1))))
else if (phi1 <= 7d-14) then
tmp = atan2(t_1, (sin(phi2) + ((-1.0d0) * (phi1 * (cos(phi2) * t_2)))))
else
tmp = atan2((t_0 * (1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0)))), ((phi2 * cos(phi1)) - (t_2 * 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 t_1 = t_0 * Math.cos(phi2);
double t_2 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.23) {
tmp = Math.atan2(t_1, (Math.sin(phi1) * -Math.cos((lambda2 - lambda1))));
} else if (phi1 <= 7e-14) {
tmp = Math.atan2(t_1, (Math.sin(phi2) + (-1.0 * (phi1 * (Math.cos(phi2) * t_2)))));
} else {
tmp = Math.atan2((t_0 * (1.0 + (-0.5 * Math.pow(phi2, 2.0)))), ((phi2 * Math.cos(phi1)) - (t_2 * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = t_0 * math.cos(phi2) t_2 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -0.23: tmp = math.atan2(t_1, (math.sin(phi1) * -math.cos((lambda2 - lambda1)))) elif phi1 <= 7e-14: tmp = math.atan2(t_1, (math.sin(phi2) + (-1.0 * (phi1 * (math.cos(phi2) * t_2))))) else: tmp = math.atan2((t_0 * (1.0 + (-0.5 * math.pow(phi2, 2.0)))), ((phi2 * math.cos(phi1)) - (t_2 * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(t_0 * cos(phi2)) t_2 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.23) tmp = atan(t_1, Float64(sin(phi1) * Float64(-cos(Float64(lambda2 - lambda1))))); elseif (phi1 <= 7e-14) tmp = atan(t_1, Float64(sin(phi2) + Float64(-1.0 * Float64(phi1 * Float64(cos(phi2) * t_2))))); else tmp = atan(Float64(t_0 * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))), Float64(Float64(phi2 * cos(phi1)) - Float64(t_2 * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = t_0 * cos(phi2); t_2 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -0.23) tmp = atan2(t_1, (sin(phi1) * -cos((lambda2 - lambda1)))); elseif (phi1 <= 7e-14) tmp = atan2(t_1, (sin(phi2) + (-1.0 * (phi1 * (cos(phi2) * t_2))))); else tmp = atan2((t_0 * (1.0 + (-0.5 * (phi2 ^ 2.0)))), ((phi2 * cos(phi1)) - (t_2 * sin(phi1)))); 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[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.23], N[ArcTan[t$95$1 / N[(N[Sin[phi1], $MachinePrecision] * (-N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 7e-14], N[ArcTan[t$95$1 / N[(N[Sin[phi2], $MachinePrecision] + N[(-1.0 * N[(phi1 * N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $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[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := t\_0 \cdot \cos \phi_2\\
t_2 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.23:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_1 \cdot \left(-\cos \left(\lambda_2 - \lambda_1\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 7 \cdot 10^{-14}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\sin \phi_2 + -1 \cdot \left(\phi_1 \cdot \left(\cos \phi_2 \cdot t\_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)}{\phi_2 \cdot \cos \phi_1 - t\_2 \cdot \sin \phi_1}\\
\end{array}
if phi1 < -0.23000000000000001Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6448.6%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6448.6%
Applied rewrites48.6%
if -0.23000000000000001 < phi1 < 7.0000000000000005e-14Initial program 79.6%
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--.f6448.1%
Applied rewrites48.1%
if 7.0000000000000005e-14 < phi1 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6446.1%
Applied rewrites46.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 -10500.0)
(atan2
t_2
(*
-1.0
(* t_0 (* phi1 (+ 1.0 (* -0.16666666666666666 (pow phi1 2.0)))))))
(if (<= phi2 8500000.0)
(atan2
(* t_1 (+ 1.0 (* -0.5 (pow phi2 2.0))))
(- (* phi2 (cos phi1)) (* t_0 (sin phi1))))
(atan2
t_2
(* -1.0 (* (sin (fma PI 0.5 (- lambda1 lambda2))) (sin phi1))))))))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 <= -10500.0) {
tmp = atan2(t_2, (-1.0 * (t_0 * (phi1 * (1.0 + (-0.16666666666666666 * pow(phi1, 2.0)))))));
} else if (phi2 <= 8500000.0) {
tmp = atan2((t_1 * (1.0 + (-0.5 * pow(phi2, 2.0)))), ((phi2 * cos(phi1)) - (t_0 * sin(phi1))));
} else {
tmp = atan2(t_2, (-1.0 * (sin(fma(((double) M_PI), 0.5, (lambda1 - lambda2))) * sin(phi1))));
}
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 <= -10500.0) tmp = atan(t_2, Float64(-1.0 * Float64(t_0 * Float64(phi1 * Float64(1.0 + Float64(-0.16666666666666666 * (phi1 ^ 2.0))))))); elseif (phi2 <= 8500000.0) tmp = atan(Float64(t_1 * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))), Float64(Float64(phi2 * cos(phi1)) - Float64(t_0 * sin(phi1)))); else tmp = atan(t_2, Float64(-1.0 * Float64(sin(fma(pi, 0.5, Float64(lambda1 - lambda2))) * sin(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -10500.0], 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], If[LessEqual[phi2, 8500000.0], N[ArcTan[N[(t$95$1 * N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(-1.0 * N[(N[Sin[N[(Pi * 0.5 + N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $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 -10500:\\
\;\;\;\;\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)}\\
\mathbf{elif}\;\phi_2 \leq 8500000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)}{\phi_2 \cdot \cos \phi_1 - t\_0 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{-1 \cdot \left(\sin \left(\mathsf{fma}\left(\pi, 0.5, \lambda_1 - \lambda_2\right)\right) \cdot \sin \phi_1\right)}\\
\end{array}
if phi2 < -10500Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6431.6%
Applied rewrites31.6%
if -10500 < phi2 < 8.5e6Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6446.1%
Applied rewrites46.1%
if 8.5e6 < phi2 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
+-commutativeN/A
mult-flipN/A
lower-fma.f64N/A
lower-PI.f64N/A
metadata-eval39.0%
Applied rewrites39.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 0.0001)
(atan2
t_0
(- (* phi2 (cos phi1)) (* (cos (- lambda1 lambda2)) (sin phi1))))
(atan2
t_0
(* -1.0 (* (sin (fma PI 0.5 (- lambda1 lambda2))) (sin phi1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= 0.0001) {
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (cos((lambda1 - lambda2)) * sin(phi1))));
} else {
tmp = atan2(t_0, (-1.0 * (sin(fma(((double) M_PI), 0.5, (lambda1 - lambda2))) * sin(phi1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= 0.0001) 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(fma(pi, 0.5, Float64(lambda1 - lambda2))) * sin(phi1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.0001], 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[(Pi * 0.5 + N[(lambda1 - lambda2), $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 0.0001:\\
\;\;\;\;\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(\mathsf{fma}\left(\pi, 0.5, \lambda_1 - \lambda_2\right)\right) \cdot \sin \phi_1\right)}\\
\end{array}
if phi2 < 1e-4Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
if 1e-4 < phi2 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
+-commutativeN/A
mult-flipN/A
lower-fma.f64N/A
lower-PI.f64N/A
metadata-eval39.0%
Applied rewrites39.0%
(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.25e-12)
(atan2 t_2 (+ phi2 (* -1.0 (* phi1 t_0))))
(if (<= phi2 26000.0)
(atan2
(* t_1 (+ 1.0 (* -0.5 (pow phi2 2.0))))
(* -1.0 (* t_0 (sin phi1))))
(atan2 t_2 (* -1.0 (* (cos lambda1) (sin phi1))))))))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.25e-12) {
tmp = atan2(t_2, (phi2 + (-1.0 * (phi1 * t_0))));
} else if (phi2 <= 26000.0) {
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 * (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) :: 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.25d-12)) then
tmp = atan2(t_2, (phi2 + ((-1.0d0) * (phi1 * t_0))))
else if (phi2 <= 26000.0d0) 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) * (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.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2));
double t_2 = t_1 * Math.cos(phi2);
double tmp;
if (phi2 <= -1.25e-12) {
tmp = Math.atan2(t_2, (phi2 + (-1.0 * (phi1 * t_0))));
} else if (phi2 <= 26000.0) {
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 * (Math.cos(lambda1) * Math.sin(phi1))));
}
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.25e-12: tmp = math.atan2(t_2, (phi2 + (-1.0 * (phi1 * t_0)))) elif phi2 <= 26000.0: 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 * (math.cos(lambda1) * math.sin(phi1)))) 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.25e-12) tmp = atan(t_2, Float64(phi2 + Float64(-1.0 * Float64(phi1 * t_0)))); elseif (phi2 <= 26000.0) 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(cos(lambda1) * sin(phi1)))); 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.25e-12) tmp = atan2(t_2, (phi2 + (-1.0 * (phi1 * t_0)))); elseif (phi2 <= 26000.0) tmp = atan2((t_1 * (1.0 + (-0.5 * (phi2 ^ 2.0)))), (-1.0 * (t_0 * sin(phi1)))); else tmp = atan2(t_2, (-1.0 * (cos(lambda1) * sin(phi1)))); 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.25e-12], N[ArcTan[t$95$2 / N[(phi2 + N[(-1.0 * N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 26000.0], 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[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $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.25 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{\phi_2 + -1 \cdot \left(\phi_1 \cdot t\_0\right)}\\
\mathbf{elif}\;\phi_2 \leq 26000:\\
\;\;\;\;\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(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\end{array}
if phi2 < -1.2499999999999999e-12Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6432.7%
Applied rewrites32.7%
if -1.2499999999999999e-12 < phi2 < 26000Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6444.1%
Applied rewrites44.1%
if 26000 < phi2 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.7%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6443.6%
Applied rewrites43.6%
(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 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
lift-*.f64N/A
mul-1-negN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
lower-neg.f6448.6%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6448.6%
Applied rewrites48.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi2 -1.25e-12)
(atan2 (* t_1 (cos phi2)) (+ phi2 (* -1.0 (* phi1 t_0))))
(atan2
(* t_1 (+ 1.0 (* -0.5 (pow phi2 2.0))))
(* -1.0 (* t_0 (sin phi1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.25e-12) {
tmp = atan2((t_1 * cos(phi2)), (phi2 + (-1.0 * (phi1 * t_0))));
} else {
tmp = atan2((t_1 * (1.0 + (-0.5 * pow(phi2, 2.0)))), (-1.0 * (t_0 * 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((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2))
if (phi2 <= (-1.25d-12)) then
tmp = atan2((t_1 * cos(phi2)), (phi2 + ((-1.0d0) * (phi1 * t_0))))
else
tmp = atan2((t_1 * (1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0)))), ((-1.0d0) * (t_0 * 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((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.25e-12) {
tmp = Math.atan2((t_1 * Math.cos(phi2)), (phi2 + (-1.0 * (phi1 * t_0))));
} else {
tmp = Math.atan2((t_1 * (1.0 + (-0.5 * Math.pow(phi2, 2.0)))), (-1.0 * (t_0 * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= -1.25e-12: tmp = math.atan2((t_1 * math.cos(phi2)), (phi2 + (-1.0 * (phi1 * t_0)))) else: tmp = math.atan2((t_1 * (1.0 + (-0.5 * math.pow(phi2, 2.0)))), (-1.0 * (t_0 * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.25e-12) tmp = atan(Float64(t_1 * cos(phi2)), Float64(phi2 + Float64(-1.0 * Float64(phi1 * t_0)))); else tmp = atan(Float64(t_1 * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))), Float64(-1.0 * Float64(t_0 * sin(phi1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= -1.25e-12) tmp = atan2((t_1 * cos(phi2)), (phi2 + (-1.0 * (phi1 * t_0)))); else tmp = atan2((t_1 * (1.0 + (-0.5 * (phi2 ^ 2.0)))), (-1.0 * (t_0 * sin(phi1)))); 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]}, If[LessEqual[phi2, -1.25e-12], N[ArcTan[N[(t$95$1 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(phi2 + N[(-1.0 * N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.25 \cdot 10^{-12}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1 \cdot \cos \phi_2}{\phi_2 + -1 \cdot \left(\phi_1 \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\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)}\\
\end{array}
if phi2 < -1.2499999999999999e-12Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6432.7%
Applied rewrites32.7%
if -1.2499999999999999e-12 < phi2 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6444.1%
Applied rewrites44.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (* t_0 (+ 1.0 (* -0.5 (pow phi2 2.0))))))
(if (<= phi1 -1.65e+31)
(atan2 t_1 (* -1.0 (* (cos (- lambda2)) (sin phi1))))
(if (<= phi1 1.2e-95)
(atan2
(* t_0 (cos phi2))
(+ phi2 (* -1.0 (* phi1 (cos (- lambda1 lambda2))))))
(atan2 t_1 (* -1.0 (* (cos lambda1) (sin phi1))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = t_0 * (1.0 + (-0.5 * pow(phi2, 2.0)));
double tmp;
if (phi1 <= -1.65e+31) {
tmp = atan2(t_1, (-1.0 * (cos(-lambda2) * sin(phi1))));
} else if (phi1 <= 1.2e-95) {
tmp = atan2((t_0 * cos(phi2)), (phi2 + (-1.0 * (phi1 * cos((lambda1 - lambda2))))));
} else {
tmp = atan2(t_1, (-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) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = t_0 * (1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0)))
if (phi1 <= (-1.65d+31)) then
tmp = atan2(t_1, ((-1.0d0) * (cos(-lambda2) * sin(phi1))))
else if (phi1 <= 1.2d-95) then
tmp = atan2((t_0 * cos(phi2)), (phi2 + ((-1.0d0) * (phi1 * cos((lambda1 - lambda2))))))
else
tmp = atan2(t_1, ((-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 t_1 = t_0 * (1.0 + (-0.5 * Math.pow(phi2, 2.0)));
double tmp;
if (phi1 <= -1.65e+31) {
tmp = Math.atan2(t_1, (-1.0 * (Math.cos(-lambda2) * Math.sin(phi1))));
} else if (phi1 <= 1.2e-95) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), (phi2 + (-1.0 * (phi1 * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2(t_1, (-1.0 * (Math.cos(lambda1) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = t_0 * (1.0 + (-0.5 * math.pow(phi2, 2.0))) tmp = 0 if phi1 <= -1.65e+31: tmp = math.atan2(t_1, (-1.0 * (math.cos(-lambda2) * math.sin(phi1)))) elif phi1 <= 1.2e-95: tmp = math.atan2((t_0 * math.cos(phi2)), (phi2 + (-1.0 * (phi1 * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2(t_1, (-1.0 * (math.cos(lambda1) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(t_0 * Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0)))) tmp = 0.0 if (phi1 <= -1.65e+31) tmp = atan(t_1, Float64(-1.0 * Float64(cos(Float64(-lambda2)) * sin(phi1)))); elseif (phi1 <= 1.2e-95) tmp = atan(Float64(t_0 * cos(phi2)), Float64(phi2 + Float64(-1.0 * Float64(phi1 * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(t_1, 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)); t_1 = t_0 * (1.0 + (-0.5 * (phi2 ^ 2.0))); tmp = 0.0; if (phi1 <= -1.65e+31) tmp = atan2(t_1, (-1.0 * (cos(-lambda2) * sin(phi1)))); elseif (phi1 <= 1.2e-95) tmp = atan2((t_0 * cos(phi2)), (phi2 + (-1.0 * (phi1 * cos((lambda1 - lambda2)))))); else tmp = atan2(t_1, (-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]}, Block[{t$95$1 = N[(t$95$0 * N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.65e+31], N[ArcTan[t$95$1 / N[(-1.0 * N[(N[Cos[(-lambda2)], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.2e-95], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(phi2 + N[(-1.0 * N[(phi1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / 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)\\
t_1 := t\_0 \cdot \left(1 + -0.5 \cdot {\phi_2}^{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1.65 \cdot 10^{+31}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{-1 \cdot \left(\cos \left(-\lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.2 \cdot 10^{-95}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\phi_2 + -1 \cdot \left(\phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{-1 \cdot \left(\cos \lambda_1 \cdot \sin \phi_1\right)}\\
\end{array}
if phi1 < -1.65e31Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.6%
Applied rewrites28.6%
Taylor expanded in lambda1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-sin.f6439.2%
Applied rewrites39.2%
if -1.65e31 < phi1 < 1.2000000000000001e-95Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6432.7%
Applied rewrites32.7%
if 1.2000000000000001e-95 < phi1 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.6%
Applied rewrites28.6%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6439.1%
Applied rewrites39.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 -1.55e-17)
(atan2
(* t_0 (cos phi2))
(+ phi2 (* -1.0 (* phi1 (cos (- lambda1 lambda2))))))
(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-17) {
tmp = atan2((t_0 * cos(phi2)), (phi2 + (-1.0 * (phi1 * cos((lambda1 - lambda2))))));
} 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-17)) then
tmp = atan2((t_0 * cos(phi2)), (phi2 + ((-1.0d0) * (phi1 * cos((lambda1 - lambda2))))))
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-17) {
tmp = Math.atan2((t_0 * Math.cos(phi2)), (phi2 + (-1.0 * (phi1 * Math.cos((lambda1 - lambda2))))));
} 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-17: tmp = math.atan2((t_0 * math.cos(phi2)), (phi2 + (-1.0 * (phi1 * math.cos((lambda1 - lambda2)))))) 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-17) tmp = atan(Float64(t_0 * cos(phi2)), Float64(phi2 + Float64(-1.0 * Float64(phi1 * cos(Float64(lambda1 - lambda2)))))); 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-17) tmp = atan2((t_0 * cos(phi2)), (phi2 + (-1.0 * (phi1 * cos((lambda1 - lambda2)))))); 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-17], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(phi2 + N[(-1.0 * N[(phi1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $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^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\phi_2 + -1 \cdot \left(\phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\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.5499999999999999e-17Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6432.7%
Applied rewrites32.7%
if -1.5499999999999999e-17 < phi2 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.6%
Applied rewrites28.6%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6439.1%
Applied rewrites39.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -4400000000000.0)
(atan2
t_0
(* -1.0 (* (+ 1.0 (* lambda2 (+ lambda1 (* -0.5 lambda2)))) (sin phi1))))
(if (<= phi1 1.8e+22)
(atan2 t_0 (+ phi2 (* -1.0 (* phi1 (cos (- lambda1 lambda2))))))
(atan2 t_0 (* -1.0 (* (+ 1.0 (* lambda1 lambda2)) (sin phi1))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -4400000000000.0) {
tmp = atan2(t_0, (-1.0 * ((1.0 + (lambda2 * (lambda1 + (-0.5 * lambda2)))) * sin(phi1))));
} else if (phi1 <= 1.8e+22) {
tmp = atan2(t_0, (phi2 + (-1.0 * (phi1 * cos((lambda1 - lambda2))))));
} else {
tmp = atan2(t_0, (-1.0 * ((1.0 + (lambda1 * lambda2)) * sin(phi1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-4400000000000.0d0)) then
tmp = atan2(t_0, ((-1.0d0) * ((1.0d0 + (lambda2 * (lambda1 + ((-0.5d0) * lambda2)))) * sin(phi1))))
else if (phi1 <= 1.8d+22) then
tmp = atan2(t_0, (phi2 + ((-1.0d0) * (phi1 * cos((lambda1 - lambda2))))))
else
tmp = atan2(t_0, ((-1.0d0) * ((1.0d0 + (lambda1 * lambda2)) * sin(phi1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -4400000000000.0) {
tmp = Math.atan2(t_0, (-1.0 * ((1.0 + (lambda2 * (lambda1 + (-0.5 * lambda2)))) * Math.sin(phi1))));
} else if (phi1 <= 1.8e+22) {
tmp = Math.atan2(t_0, (phi2 + (-1.0 * (phi1 * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2(t_0, (-1.0 * ((1.0 + (lambda1 * lambda2)) * Math.sin(phi1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -4400000000000.0: tmp = math.atan2(t_0, (-1.0 * ((1.0 + (lambda2 * (lambda1 + (-0.5 * lambda2)))) * math.sin(phi1)))) elif phi1 <= 1.8e+22: tmp = math.atan2(t_0, (phi2 + (-1.0 * (phi1 * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2(t_0, (-1.0 * ((1.0 + (lambda1 * lambda2)) * math.sin(phi1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -4400000000000.0) tmp = atan(t_0, Float64(-1.0 * Float64(Float64(1.0 + Float64(lambda2 * Float64(lambda1 + Float64(-0.5 * lambda2)))) * sin(phi1)))); elseif (phi1 <= 1.8e+22) tmp = atan(t_0, Float64(phi2 + Float64(-1.0 * Float64(phi1 * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(t_0, Float64(-1.0 * Float64(Float64(1.0 + Float64(lambda1 * lambda2)) * 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 (phi1 <= -4400000000000.0) tmp = atan2(t_0, (-1.0 * ((1.0 + (lambda2 * (lambda1 + (-0.5 * lambda2)))) * sin(phi1)))); elseif (phi1 <= 1.8e+22) tmp = atan2(t_0, (phi2 + (-1.0 * (phi1 * cos((lambda1 - lambda2)))))); else tmp = atan2(t_0, (-1.0 * ((1.0 + (lambda1 * lambda2)) * sin(phi1)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4400000000000.0], N[ArcTan[t$95$0 / N[(-1.0 * N[(N[(1.0 + N[(lambda2 * N[(lambda1 + N[(-0.5 * lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.8e+22], N[ArcTan[t$95$0 / N[(phi2 + N[(-1.0 * N[(phi1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(-1.0 * N[(N[(1.0 + N[(lambda1 * lambda2), $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_1 \leq -4400000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{-1 \cdot \left(\left(1 + \lambda_2 \cdot \left(\lambda_1 + -0.5 \cdot \lambda_2\right)\right) \cdot \sin \phi_1\right)}\\
\mathbf{elif}\;\phi_1 \leq 1.8 \cdot 10^{+22}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 + -1 \cdot \left(\phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{-1 \cdot \left(\left(1 + \lambda_1 \cdot \lambda_2\right) \cdot \sin \phi_1\right)}\\
\end{array}
if phi1 < -4.4e12Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-neg.f6440.4%
Applied rewrites40.4%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f6428.6%
Applied rewrites28.6%
if -4.4e12 < phi1 < 1.8e22Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6432.7%
Applied rewrites32.7%
if 1.8e22 < phi1 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-neg.f6440.4%
Applied rewrites40.4%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-*.f6432.8%
Applied rewrites32.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (atan2 t_0 (* -1.0 (* (+ 1.0 (* lambda1 lambda2)) (sin phi1))))))
(if (<= phi1 -5700000000000.0)
t_1
(if (<= phi1 1.8e+22)
(atan2 t_0 (+ phi2 (* -1.0 (* phi1 (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, (-1.0 * ((1.0 + (lambda1 * lambda2)) * sin(phi1))));
double tmp;
if (phi1 <= -5700000000000.0) {
tmp = t_1;
} else if (phi1 <= 1.8e+22) {
tmp = atan2(t_0, (phi2 + (-1.0 * (phi1 * 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, ((-1.0d0) * ((1.0d0 + (lambda1 * lambda2)) * sin(phi1))))
if (phi1 <= (-5700000000000.0d0)) then
tmp = t_1
else if (phi1 <= 1.8d+22) then
tmp = atan2(t_0, (phi2 + ((-1.0d0) * (phi1 * 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, (-1.0 * ((1.0 + (lambda1 * lambda2)) * Math.sin(phi1))));
double tmp;
if (phi1 <= -5700000000000.0) {
tmp = t_1;
} else if (phi1 <= 1.8e+22) {
tmp = Math.atan2(t_0, (phi2 + (-1.0 * (phi1 * 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, (-1.0 * ((1.0 + (lambda1 * lambda2)) * math.sin(phi1)))) tmp = 0 if phi1 <= -5700000000000.0: tmp = t_1 elif phi1 <= 1.8e+22: tmp = math.atan2(t_0, (phi2 + (-1.0 * (phi1 * 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(-1.0 * Float64(Float64(1.0 + Float64(lambda1 * lambda2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -5700000000000.0) tmp = t_1; elseif (phi1 <= 1.8e+22) tmp = atan(t_0, Float64(phi2 + Float64(-1.0 * Float64(phi1 * 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, (-1.0 * ((1.0 + (lambda1 * lambda2)) * sin(phi1)))); tmp = 0.0; if (phi1 <= -5700000000000.0) tmp = t_1; elseif (phi1 <= 1.8e+22) tmp = atan2(t_0, (phi2 + (-1.0 * (phi1 * 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[(-1.0 * N[(N[(1.0 + N[(lambda1 * lambda2), $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5700000000000.0], t$95$1, If[LessEqual[phi1, 1.8e+22], N[ArcTan[t$95$0 / N[(phi2 + N[(-1.0 * N[(phi1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $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}{-1 \cdot \left(\left(1 + \lambda_1 \cdot \lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\phi_1 \leq -5700000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 1.8 \cdot 10^{+22}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 + -1 \cdot \left(\phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi1 < -5.7e12 or 1.8e22 < phi1 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-neg.f6440.4%
Applied rewrites40.4%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-*.f6432.8%
Applied rewrites32.8%
if -5.7e12 < phi1 < 1.8e22Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6432.7%
Applied rewrites32.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi2 9.5e-29)
(atan2 t_0 (+ phi2 (* -1.0 (* phi1 (cos (- lambda1 lambda2))))))
(atan2 t_0 (* -1.0 (* phi1 (cos lambda1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi2 <= 9.5e-29) {
tmp = atan2(t_0, (phi2 + (-1.0 * (phi1 * cos((lambda1 - lambda2))))));
} else {
tmp = atan2(t_0, (-1.0 * (phi1 * cos(lambda1))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi2 <= 9.5d-29) then
tmp = atan2(t_0, (phi2 + ((-1.0d0) * (phi1 * cos((lambda1 - lambda2))))))
else
tmp = atan2(t_0, ((-1.0d0) * (phi1 * cos(lambda1))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi2 <= 9.5e-29) {
tmp = Math.atan2(t_0, (phi2 + (-1.0 * (phi1 * Math.cos((lambda1 - lambda2))))));
} else {
tmp = Math.atan2(t_0, (-1.0 * (phi1 * Math.cos(lambda1))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi2 <= 9.5e-29: tmp = math.atan2(t_0, (phi2 + (-1.0 * (phi1 * math.cos((lambda1 - lambda2)))))) else: tmp = math.atan2(t_0, (-1.0 * (phi1 * math.cos(lambda1)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi2 <= 9.5e-29) tmp = atan(t_0, Float64(phi2 + Float64(-1.0 * Float64(phi1 * cos(Float64(lambda1 - lambda2)))))); else tmp = atan(t_0, Float64(-1.0 * Float64(phi1 * cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi2 <= 9.5e-29) tmp = atan2(t_0, (phi2 + (-1.0 * (phi1 * cos((lambda1 - lambda2)))))); else tmp = atan2(t_0, (-1.0 * (phi1 * cos(lambda1)))); 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, 9.5e-29], N[ArcTan[t$95$0 / N[(phi2 + N[(-1.0 * N[(phi1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(-1.0 * N[(phi1 * N[Cos[lambda1], $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 9.5 \cdot 10^{-29}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 + -1 \cdot \left(\phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{-1 \cdot \left(\phi_1 \cdot \cos \lambda_1\right)}\\
\end{array}
if phi2 < 9.5000000000000002e-29Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.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.f6448.5%
Applied rewrites48.5%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6432.7%
Applied rewrites32.7%
if 9.5000000000000002e-29 < phi2 Initial program 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.7%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f6431.6%
Applied rewrites31.6%
(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 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.7%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f6431.6%
Applied rewrites31.6%
(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 79.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6448.6%
Applied rewrites48.6%
Taylor expanded in phi1 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f6431.7%
Applied rewrites31.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.6%
Applied rewrites28.6%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6428.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6428.6%
lower-*.f64N/A
Applied rewrites28.6%
herbie shell --seed 2025209
(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))))))