
(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 30 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda2) (sin lambda1))) (t_1 (sin (* 0.5 PI))))
(atan2
(*
(-
(fma (* t_1 (cos lambda2)) (sin lambda1) (* t_0 (cos (* 0.5 PI))))
(* (sin lambda2) (cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma
(fma (sin lambda2) (cos (* PI -0.5)) (* (cos lambda2) t_1))
(cos lambda1)
t_0))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda2) * sin(lambda1);
double t_1 = sin((0.5 * ((double) M_PI)));
return atan2(((fma((t_1 * cos(lambda2)), sin(lambda1), (t_0 * cos((0.5 * ((double) M_PI))))) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(fma(sin(lambda2), cos((((double) M_PI) * -0.5)), (cos(lambda2) * t_1)), cos(lambda1), t_0))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda2) * sin(lambda1)) t_1 = sin(Float64(0.5 * pi)) return atan(Float64(Float64(fma(Float64(t_1 * cos(lambda2)), sin(lambda1), Float64(t_0 * cos(Float64(0.5 * pi)))) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(fma(sin(lambda2), cos(Float64(pi * -0.5)), Float64(cos(lambda2) * t_1)), cos(lambda1), t_0)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[(t$95$1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(t$95$0 * N[Cos[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]), $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[(N[Sin[lambda2], $MachinePrecision] * N[Cos[N[(Pi * -0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \lambda_2 \cdot \sin \lambda_1\\
t_1 := \sin \left(0.5 \cdot \pi\right)\\
\tan^{-1}_* \frac{\left(\mathsf{fma}\left(t\_1 \cdot \cos \lambda_2, \sin \lambda_1, t\_0 \cdot \cos \left(0.5 \cdot \pi\right)\right) - \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(\mathsf{fma}\left(\sin \lambda_2, \cos \left(\pi \cdot -0.5\right), \cos \lambda_2 \cdot t\_1\right), \cos \lambda_1, t\_0\right)}
\end{array}
Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
lift-sin.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
lift-*.f64N/A
lower-fma.f64N/A
cos-neg-revN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lower-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites99.7%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
lift-sin.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
lift-*.f64N/A
lower-fma.f64N/A
cos-neg-revN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lower-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites99.7%
lift-*.f64N/A
lift-fma.f64N/A
+-commutativeN/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f64N/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(sin lambda2)
(cos (* PI -0.5))
(* (cos lambda2) (sin (* 0.5 PI))))))
(atan2
(* (- (* (sin lambda1) t_0) (* (sin lambda2) (cos lambda1))) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma t_0 (cos lambda1) (* (sin lambda2) (sin lambda1))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(sin(lambda2), cos((((double) M_PI) * -0.5)), (cos(lambda2) * sin((0.5 * ((double) M_PI)))));
return atan2((((sin(lambda1) * t_0) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(t_0, cos(lambda1), (sin(lambda2) * sin(lambda1))))));
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(sin(lambda2), cos(Float64(pi * -0.5)), Float64(cos(lambda2) * sin(Float64(0.5 * pi)))) return atan(Float64(Float64(Float64(sin(lambda1) * t_0) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(t_0, cos(lambda1), Float64(sin(lambda2) * sin(lambda1)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[N[(Pi * -0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Sin[N[(0.5 * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * t$95$0), $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[(t$95$0 * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(\sin \lambda_2, \cos \left(\pi \cdot -0.5\right), \cos \lambda_2 \cdot \sin \left(0.5 \cdot \pi\right)\right)\\
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot t\_0 - \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(t\_0, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)}
\end{array}
Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
lift-sin.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
lift-*.f64N/A
lower-fma.f64N/A
cos-neg-revN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lower-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
Applied rewrites99.7%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
lift-sin.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
lift-*.f64N/A
lower-fma.f64N/A
cos-neg-revN/A
lift-*.f64N/A
distribute-lft-neg-outN/A
lower-cos.f64N/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-PI.f64N/A
mult-flipN/A
metadata-evalN/A
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 (cos lambda2) (cos lambda1) (* (sin lambda2) (sin 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(cos(lambda2), cos(lambda1), (sin(lambda2) * sin(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(cos(lambda2), cos(lambda1), Float64(sin(lambda2) * sin(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[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[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(\cos \lambda_2, \cos \lambda_1, \sin \lambda_2 \cdot \sin \lambda_1\right)}
Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin lambda1) (cos lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (- t_1 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(t_3 (* (sin lambda2) (cos lambda1)))
(t_4 (* (- t_0 t_3) (cos phi2))))
(if (<= phi2 -0.98)
(atan2 (* (* (- 1.0 (/ t_3 t_0)) t_0) (cos phi2)) t_2)
(if (<= phi2 0.205)
(atan2
t_4
(-
t_1
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_4 t_2)))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(lambda1) * cos(lambda2);
double t_1 = cos(phi1) * sin(phi2);
double t_2 = t_1 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)));
double t_3 = sin(lambda2) * cos(lambda1);
double t_4 = (t_0 - t_3) * cos(phi2);
double tmp;
if (phi2 <= -0.98) {
tmp = atan2((((1.0 - (t_3 / t_0)) * t_0) * cos(phi2)), t_2);
} else if (phi2 <= 0.205) {
tmp = atan2(t_4, (t_1 - (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_4, t_2);
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(lambda1) * cos(lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(t_1 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))) t_3 = Float64(sin(lambda2) * cos(lambda1)) t_4 = Float64(Float64(t_0 - t_3) * cos(phi2)) tmp = 0.0 if (phi2 <= -0.98) tmp = atan(Float64(Float64(Float64(1.0 - Float64(t_3 / t_0)) * t_0) * cos(phi2)), t_2); elseif (phi2 <= 0.205) tmp = atan(t_4, Float64(t_1 - Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_4, t_2); 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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$0 - t$95$3), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.98], N[ArcTan[N[(N[(N[(1.0 - N[(t$95$3 / t$95$0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision], If[LessEqual[phi2, 0.205], N[ArcTan[t$95$4 / N[(t$95$1 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$4 / t$95$2], $MachinePrecision]]]]]]]]
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := t\_1 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
t_3 := \sin \lambda_2 \cdot \cos \lambda_1\\
t_4 := \left(t\_0 - t\_3\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.98:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\left(1 - \frac{t\_3}{t\_0}\right) \cdot t\_0\right) \cdot \cos \phi_2}{t\_2}\\
\mathbf{elif}\;\phi_2 \leq 0.205:\\
\;\;\;\;\tan^{-1}_* \frac{t\_4}{t\_1 - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_4}{t\_2}\\
\end{array}
if phi2 < -0.97999999999999998Initial program 79.2%
lift-sin.f64N/A
lift--.f64N/A
sin-diffN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-cos.f6489.3
Applied rewrites89.3%
if -0.97999999999999998 < phi2 < 0.204999999999999988Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi2 around 0
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.f6481.1
Applied rewrites81.1%
if 0.204999999999999988 < phi2 Initial program 79.2%
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%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2)))
(t_2 (* (sin phi1) (cos phi2))))
(if (<= phi2 -0.000235)
(atan2 t_1 (- t_0 (/ 1.0 (/ (/ 1.0 t_2) (cos (- lambda2 lambda1))))))
(if (<= phi2 1.02e-7)
(atan2
t_1
(-
(* phi2 (cos phi1))
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_1 (- t_0 (* t_2 (cos (- lambda1 lambda2)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2);
double t_2 = sin(phi1) * cos(phi2);
double tmp;
if (phi2 <= -0.000235) {
tmp = atan2(t_1, (t_0 - (1.0 / ((1.0 / t_2) / cos((lambda2 - lambda1))))));
} else if (phi2 <= 1.02e-7) {
tmp = atan2(t_1, ((phi2 * cos(phi1)) - (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, (t_0 - (t_2 * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)) t_2 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if (phi2 <= -0.000235) tmp = atan(t_1, Float64(t_0 - Float64(1.0 / Float64(Float64(1.0 / t_2) / cos(Float64(lambda2 - lambda1)))))); elseif (phi2 <= 1.02e-7) tmp = atan(t_1, Float64(Float64(phi2 * cos(phi1)) - Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, Float64(t_0 - Float64(t_2 * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(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$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.000235], N[ArcTan[t$95$1 / N[(t$95$0 - N[(1.0 / N[(N[(1.0 / t$95$2), $MachinePrecision] / N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1.02e-7], N[ArcTan[t$95$1 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $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], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.000235:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \frac{1}{\frac{\frac{1}{t\_2}}{\cos \left(\lambda_2 - \lambda_1\right)}}}\\
\mathbf{elif}\;\phi_2 \leq 1.02 \cdot 10^{-7}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\phi_2 \cdot \cos \phi_1 - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - t\_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
if phi2 < -2.34999999999999993e-4Initial program 79.2%
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
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
lift--.f64N/A
lift-sin.f64N/A
lift-+.f64N/A
lift-sin.f64N/A
+-commutativeN/A
lift-+.f64N/A
div-flip-revN/A
lift-/.f64N/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
Applied rewrites89.3%
if -2.34999999999999993e-4 < phi2 < 1.02e-7Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi2 around 0
lower--.f64N/A
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.f6457.1
Applied rewrites57.1%
if 1.02e-7 < phi2 Initial program 79.2%
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%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2)))
(t_2 (* (sin phi1) (cos phi2))))
(if (<= phi2 -0.98)
(atan2 t_1 (- t_0 (/ 1.0 (/ (/ 1.0 t_2) (cos (- lambda2 lambda1))))))
(if (<= phi2 0.205)
(atan2
t_1
(-
t_0
(*
(sin phi1)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(atan2 t_1 (- t_0 (* t_2 (cos (- lambda1 lambda2)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = ((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2);
double t_2 = sin(phi1) * cos(phi2);
double tmp;
if (phi2 <= -0.98) {
tmp = atan2(t_1, (t_0 - (1.0 / ((1.0 / t_2) / cos((lambda2 - lambda1))))));
} else if (phi2 <= 0.205) {
tmp = atan2(t_1, (t_0 - (sin(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = atan2(t_1, (t_0 - (t_2 * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)) t_2 = Float64(sin(phi1) * cos(phi2)) tmp = 0.0 if (phi2 <= -0.98) tmp = atan(t_1, Float64(t_0 - Float64(1.0 / Float64(Float64(1.0 / t_2) / cos(Float64(lambda2 - lambda1)))))); elseif (phi2 <= 0.205) tmp = atan(t_1, Float64(t_0 - Float64(sin(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = atan(t_1, Float64(t_0 - Float64(t_2 * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(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$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.98], N[ArcTan[t$95$1 / N[(t$95$0 - N[(1.0 / N[(N[(1.0 / t$95$2), $MachinePrecision] / N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 0.205], N[ArcTan[t$95$1 / N[(t$95$0 - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(t$95$0 - N[(t$95$2 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2\\
t_2 := \sin \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.98:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \frac{1}{\frac{\frac{1}{t\_2}}{\cos \left(\lambda_2 - \lambda_1\right)}}}\\
\mathbf{elif}\;\phi_2 \leq 0.205:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{t\_0 - t\_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
if phi2 < -0.97999999999999998Initial program 79.2%
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
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
lift--.f64N/A
lift-sin.f64N/A
lift-+.f64N/A
lift-sin.f64N/A
+-commutativeN/A
lift-+.f64N/A
div-flip-revN/A
lift-/.f64N/A
associate-*l/N/A
div-flipN/A
lower-unsound-/.f64N/A
Applied rewrites89.3%
if -0.97999999999999998 < phi2 < 0.204999999999999988Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi2 around 0
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.f6481.1
Applied rewrites81.1%
if 0.204999999999999988 < phi2 Initial program 79.2%
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%
(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 -8.5e-99)
t_1
(if (<= phi2 1.12e-7)
(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 <= -8.5e-99) {
tmp = t_1;
} else if (phi2 <= 1.12e-7) {
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 <= -8.5e-99) tmp = t_1; elseif (phi2 <= 1.12e-7) 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, -8.5e-99], t$95$1, If[LessEqual[phi2, 1.12e-7], 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 -8.5 \cdot 10^{-99}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 1.12 \cdot 10^{-7}:\\
\;\;\;\;\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 < -8.5000000000000004e-99 or 1.12e-7 < phi2 Initial program 79.2%
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 -8.5000000000000004e-99 < phi2 < 1.12e-7Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.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.f6457.3
Applied rewrites57.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1)))))))
(if (<= lambda1 -3400.0)
t_1
(if (<= lambda1 1.2e+27)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
t_0
(*
(* (sin phi1) (cos phi2))
(fma (sin lambda2) (sin lambda1) (* (cos lambda2) (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(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
double tmp;
if (lambda1 <= -3400.0) {
tmp = t_1;
} else if (lambda1 <= 1.2e+27) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), (cos(lambda2) * 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(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))) tmp = 0.0 if (lambda1 <= -3400.0) tmp = t_1; elseif (lambda1 <= 1.2e+27) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda2) * cos(lambda1)))))); else tmp = t_1; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[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[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -3400.0], t$95$1, If[LessEqual[lambda1, 1.2e+27], 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[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_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 -3400:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_1 \leq 1.2 \cdot 10^{+27}:\\
\;\;\;\;\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 \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if lambda1 < -3400 or 1.19999999999999999e27 < lambda1 Initial program 79.2%
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.6
Applied rewrites79.6%
if -3400 < lambda1 < 1.19999999999999999e27Initial program 79.2%
lift-cos.f64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f6479.4
Applied rewrites79.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (cos lambda1) (* (cos phi2) (sin phi1))))))
(t_1 (* (sin phi2) (cos phi1))))
(if (<= lambda1 -5300.0)
t_0
(if (<= lambda1 3.4e+31)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(*
(-
1.0
(/ (* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2)) t_1))
t_1))
t_0))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
double t_1 = sin(phi2) * cos(phi1);
double tmp;
if (lambda1 <= -5300.0) {
tmp = t_0;
} else if (lambda1 <= 3.4e+31) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((1.0 - (((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)) / t_1)) * t_1));
} 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) :: t_1
real(8) :: tmp
t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * (cos(phi2) * sin(phi1)))))
t_1 = sin(phi2) * cos(phi1)
if (lambda1 <= (-5300.0d0)) then
tmp = t_0
else if (lambda1 <= 3.4d+31) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((1.0d0 - (((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)) / t_1)) * t_1))
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) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(lambda1) * (Math.cos(phi2) * Math.sin(phi1)))));
double t_1 = Math.sin(phi2) * Math.cos(phi1);
double tmp;
if (lambda1 <= -5300.0) {
tmp = t_0;
} else if (lambda1 <= 3.4e+31) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((1.0 - (((Math.cos((lambda2 - lambda1)) * Math.sin(phi1)) * Math.cos(phi2)) / t_1)) * t_1));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) t_1 = math.sin(phi2) * math.cos(phi1) tmp = 0 if lambda1 <= -5300.0: tmp = t_0 elif lambda1 <= 3.4e+31: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((1.0 - (((math.cos((lambda2 - lambda1)) * math.sin(phi1)) * math.cos(phi2)) / t_1)) * t_1)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))) t_1 = Float64(sin(phi2) * cos(phi1)) tmp = 0.0 if (lambda1 <= -5300.0) tmp = t_0; elseif (lambda1 <= 3.4e+31) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(1.0 - Float64(Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)) / t_1)) * t_1)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (cos(lambda1) * (cos(phi2) * sin(phi1))))); t_1 = sin(phi2) * cos(phi1); tmp = 0.0; if (lambda1 <= -5300.0) tmp = t_0; elseif (lambda1 <= 3.4e+31) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((1.0 - (((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)) / t_1)) * t_1)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$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[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -5300.0], t$95$0, If[LessEqual[lambda1, 3.4e+31], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 - N[(N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision], t$95$0]]]]
\begin{array}{l}
t_0 := \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 \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
t_1 := \sin \phi_2 \cdot \cos \phi_1\\
\mathbf{if}\;\lambda_1 \leq -5300:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_1 \leq 3.4 \cdot 10^{+31}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\left(1 - \frac{\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}{t\_1}\right) \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if lambda1 < -5300 or 3.3999999999999998e31 < lambda1 Initial program 79.2%
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.6
Applied rewrites79.6%
if -5300 < lambda1 < 3.3999999999999998e31Initial program 79.2%
lift--.f64N/A
sub-to-multN/A
lower-unsound-*.f64N/A
Applied rewrites79.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin lambda1) (cos lambda2)))
(t_2
(atan2
(* (- t_1 (sin lambda2)) (cos phi2))
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))
(if (<= phi1 -0.0106)
t_2
(if (<= phi1 5e-155)
(atan2
(* (- t_1 (* (sin lambda2) (cos lambda1))) (cos phi2))
(+ (sin phi2) (* -1.0 (* phi1 (* (cos phi2) t_0)))))
t_2))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(lambda1) * cos(lambda2);
double t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -0.0106) {
tmp = t_2;
} else if (phi1 <= 5e-155) {
tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + (-1.0 * (phi1 * (cos(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 = cos((lambda1 - lambda2))
t_1 = sin(lambda1) * cos(lambda2)
t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)))
if (phi1 <= (-0.0106d0)) then
tmp = t_2
else if (phi1 <= 5d-155) then
tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + ((-1.0d0) * (phi1 * (cos(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.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)) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
double tmp;
if (phi1 <= -0.0106) {
tmp = t_2;
} else if (phi1 <= 5e-155) {
tmp = Math.atan2(((t_1 - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), (Math.sin(phi2) + (-1.0 * (phi1 * (Math.cos(phi2) * t_0)))));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = 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)) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) tmp = 0 if phi1 <= -0.0106: tmp = t_2 elif phi1 <= 5e-155: tmp = math.atan2(((t_1 - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), (math.sin(phi2) + (-1.0 * (phi1 * (math.cos(phi2) * t_0))))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = 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)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if (phi1 <= -0.0106) tmp = t_2; elseif (phi1 <= 5e-155) tmp = atan(Float64(Float64(t_1 - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(sin(phi2) + Float64(-1.0 * Float64(phi1 * Float64(cos(phi2) * t_0))))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(lambda1) * cos(lambda2); t_2 = atan2(((t_1 - sin(lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0))); tmp = 0.0; if (phi1 <= -0.0106) tmp = t_2; elseif (phi1 <= 5e-155) tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + (-1.0 * (phi1 * (cos(phi2) * t_0))))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, 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] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0106], t$95$2, If[LessEqual[phi1, 5e-155], 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] + N[(-1.0 * N[(phi1 * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \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 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\mathbf{if}\;\phi_1 \leq -0.0106:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 5 \cdot 10^{-155}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_1 - \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 t\_0\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if phi1 < -0.0106 or 4.9999999999999999e-155 < phi1 Initial program 79.2%
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.f6480.7
Applied rewrites80.7%
if -0.0106 < phi1 < 4.9999999999999999e-155Initial program 79.2%
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.9
Applied rewrites57.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (sin phi2) (cos phi1))
(* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2))))))
(if (<= phi1 -0.0004)
t_0
(if (<= phi1 1.42e-154)
(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)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))));
double tmp;
if (phi1 <= -0.0004) {
tmp = t_0;
} else if (phi1 <= 1.42e-154) {
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)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))))
if (phi1 <= (-0.0004d0)) then
tmp = t_0
else if (phi1 <= 1.42d-154) 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.sin(phi2) * Math.cos(phi1)) - ((Math.cos((lambda2 - lambda1)) * Math.sin(phi1)) * Math.cos(phi2))));
double tmp;
if (phi1 <= -0.0004) {
tmp = t_0;
} else if (phi1 <= 1.42e-154) {
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.sin(phi2) * math.cos(phi1)) - ((math.cos((lambda2 - lambda1)) * math.sin(phi1)) * math.cos(phi2)))) tmp = 0 if phi1 <= -0.0004: tmp = t_0 elif phi1 <= 1.42e-154: 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(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))) tmp = 0.0 if (phi1 <= -0.0004) tmp = t_0; elseif (phi1 <= 1.42e-154) 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)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); tmp = 0.0; if (phi1 <= -0.0004) tmp = t_0; elseif (phi1 <= 1.42e-154) 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[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0004], t$95$0, If[LessEqual[phi1, 1.42e-154], 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}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{if}\;\phi_1 \leq -0.0004:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 1.42 \cdot 10^{-154}:\\
\;\;\;\;\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 < -4.00000000000000019e-4 or 1.42e-154 < phi1 Initial program 79.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6479.2
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6479.2
Applied rewrites79.2%
if -4.00000000000000019e-4 < phi1 < 1.42e-154Initial program 79.2%
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.9
Applied rewrites57.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (sin phi2) (cos phi1))
(* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2))))))
(if (<= phi1 -6e-17)
t_0
(if (<= phi1 1.42e-154)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
t_0))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_0;
} else if (phi1 <= 1.42e-154) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} 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)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))))
if (phi1 <= (-6d-17)) then
tmp = t_0
else if (phi1 <= 1.42d-154) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
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.sin(phi2) * Math.cos(phi1)) - ((Math.cos((lambda2 - lambda1)) * Math.sin(phi1)) * Math.cos(phi2))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_0;
} else if (phi1 <= 1.42e-154) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - ((math.cos((lambda2 - lambda1)) * math.sin(phi1)) * math.cos(phi2)))) tmp = 0 if phi1 <= -6e-17: tmp = t_0 elif phi1 <= 1.42e-154: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))) tmp = 0.0 if (phi1 <= -6e-17) tmp = t_0; elseif (phi1 <= 1.42e-154) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); tmp = 0.0; if (phi1 <= -6e-17) tmp = t_0; elseif (phi1 <= 1.42e-154) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); 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[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -6e-17], t$95$0, If[LessEqual[phi1, 1.42e-154], 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[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{if}\;\phi_1 \leq -6 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 1.42 \cdot 10^{-154}:\\
\;\;\;\;\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}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if phi1 < -6.00000000000000012e-17 or 1.42e-154 < phi1 Initial program 79.2%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6479.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6479.2
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6479.2
Applied rewrites79.2%
if -6.00000000000000012e-17 < phi1 < 1.42e-154Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.f6458.6
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= phi1 -6e-17)
t_0
(if (<= phi1 1.42e-154)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
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)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_0;
} else if (phi1 <= 1.42e-154) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} 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)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
if (phi1 <= (-6d-17)) then
tmp = t_0
else if (phi1 <= 1.42d-154) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
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.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_0;
} else if (phi1 <= 1.42e-154) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), Math.sin(phi2));
} 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.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) tmp = 0 if phi1 <= -6e-17: tmp = t_0 elif phi1 <= 1.42e-154: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), math.sin(phi2)) 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(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (phi1 <= -6e-17) tmp = t_0; elseif (phi1 <= 1.42e-154) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); 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)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); tmp = 0.0; if (phi1 <= -6e-17) tmp = t_0; elseif (phi1 <= 1.42e-154) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); 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[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -6e-17], t$95$0, If[LessEqual[phi1, 1.42e-154], 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[Sin[phi2], $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(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\phi_1 \leq -6 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 1.42 \cdot 10^{-154}:\\
\;\;\;\;\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}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if phi1 < -6.00000000000000012e-17 or 1.42e-154 < phi1 Initial program 79.2%
if -6.00000000000000012e-17 < phi1 < 1.42e-154Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.f6458.6
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= lambda1 -5.2)
(atan2
t_0
(-
(* (sin phi2) (cos phi1))
(* (* (cos lambda1) (sin phi1)) (cos phi2))))
(if (<= lambda1 3.4e+31)
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (cos phi2) (* (cos (- lambda2)) (sin phi1)))))
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (lambda1 <= -5.2) {
tmp = atan2(t_0, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2))));
} else if (lambda1 <= 3.4e+31) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * (cos(-lambda2) * sin(phi1)))));
} else {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
if (lambda1 <= (-5.2d0)) then
tmp = atan2(t_0, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2))))
else if (lambda1 <= 3.4d+31) then
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * (cos(-lambda2) * sin(phi1)))))
else
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
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 (lambda1 <= -5.2) {
tmp = Math.atan2(t_0, ((Math.sin(phi2) * Math.cos(phi1)) - ((Math.cos(lambda1) * Math.sin(phi1)) * Math.cos(phi2))));
} else if (lambda1 <= 3.4e+31) {
tmp = Math.atan2(t_0, ((Math.cos(phi1) * Math.sin(phi2)) - (Math.cos(phi2) * (Math.cos(-lambda2) * Math.sin(phi1)))));
} else {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), Math.sin(phi2));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if lambda1 <= -5.2: tmp = math.atan2(t_0, ((math.sin(phi2) * math.cos(phi1)) - ((math.cos(lambda1) * math.sin(phi1)) * math.cos(phi2)))) elif lambda1 <= 3.4e+31: tmp = math.atan2(t_0, ((math.cos(phi1) * math.sin(phi2)) - (math.cos(phi2) * (math.cos(-lambda2) * math.sin(phi1))))) else: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), math.sin(phi2)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (lambda1 <= -5.2) tmp = atan(t_0, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(lambda1) * sin(phi1)) * cos(phi2)))); elseif (lambda1 <= 3.4e+31) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(cos(phi2) * Float64(cos(Float64(-lambda2)) * sin(phi1))))); else tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (lambda1 <= -5.2) tmp = atan2(t_0, ((sin(phi2) * cos(phi1)) - ((cos(lambda1) * sin(phi1)) * cos(phi2)))); elseif (lambda1 <= 3.4e+31) tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - (cos(phi2) * (cos(-lambda2) * sin(phi1))))); else tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); 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[lambda1, -5.2], N[ArcTan[t$95$0 / N[(N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[lambda1, 3.4e+31], N[ArcTan[t$95$0 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[(-lambda2)], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 \leq -5.2:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \lambda_1 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\lambda_1 \leq 3.4 \cdot 10^{+31}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \cos \phi_2 \cdot \left(\cos \left(-\lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;\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}\\
\end{array}
if lambda1 < -5.20000000000000018Initial program 79.2%
Taylor expanded in lambda2 around 0
lower-cos.f6469.5
Applied rewrites69.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.5
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6469.5
Applied rewrites69.5%
if -5.20000000000000018 < lambda1 < 3.3999999999999998e31Initial program 79.2%
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%
if 3.3999999999999998e31 < lambda1 Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.f6458.6
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda2)) (cos phi2))))
(if (<= lambda2 -800000000000.0)
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (<= lambda2 6e+22)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (sin phi1)) (* (cos lambda1) (cos phi2)))))
(atan2
t_0
(-
(* (sin phi2) (cos phi1))
(* (* (cos (- lambda2)) (sin phi1)) (cos phi2))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(-lambda2) * cos(phi2);
double tmp;
if (lambda2 <= -800000000000.0) {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else if (lambda2 <= 6e+22) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-sin(phi1) * (cos(lambda1) * cos(phi2)))));
} else {
tmp = atan2(t_0, ((sin(phi2) * cos(phi1)) - ((cos(-lambda2) * sin(phi1)) * cos(phi2))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(-lambda2)) * cos(phi2)) tmp = 0.0 if (lambda2 <= -800000000000.0) tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); elseif (lambda2 <= 6e+22) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-sin(phi1)) * Float64(cos(lambda1) * cos(phi2))))); else tmp = atan(t_0, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(-lambda2)) * sin(phi1)) * cos(phi2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -800000000000.0], 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[lambda2, 6e+22], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Sin[phi1], $MachinePrecision]) * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / 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]]]]
\begin{array}{l}
t_0 := \sin \left(-\lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -800000000000:\\
\;\;\;\;\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{elif}\;\lambda_2 \leq 6 \cdot 10^{+22}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1\right) \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(-\lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\end{array}
if lambda2 < -8e11Initial program 79.2%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-neg.f6447.8
Applied rewrites47.8%
if -8e11 < lambda2 < 6e22Initial program 79.2%
Taylor expanded in lambda2 around 0
lower-cos.f6469.5
Applied rewrites69.5%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites69.5%
if 6e22 < lambda2 Initial program 79.2%
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6465.9
Applied rewrites65.9%
Taylor expanded in lambda1 around 0
lower-*.f6441.0
Applied rewrites41.0%
Taylor expanded in lambda1 around 0
lower-*.f6441.0
Applied rewrites41.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6441.0
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
Applied rewrites47.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda2)) (cos phi2))
(-
(* (sin phi2) (cos phi1))
(* (* (cos (- lambda2)) (sin phi1)) (cos phi2))))))
(if (<= lambda2 -800000000000.0)
t_0
(if (<= lambda2 6e+22)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(fma
(sin phi2)
(cos phi1)
(* (- (sin phi1)) (* (cos lambda1) (cos phi2)))))
t_0))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin(-lambda2) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos(-lambda2) * sin(phi1)) * cos(phi2))));
double tmp;
if (lambda2 <= -800000000000.0) {
tmp = t_0;
} else if (lambda2 <= 6e+22) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), (-sin(phi1) * (cos(lambda1) * cos(phi2)))));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(-lambda2)) * sin(phi1)) * cos(phi2)))) tmp = 0.0 if (lambda2 <= -800000000000.0) tmp = t_0; elseif (lambda2 <= 6e+22) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(sin(phi2), cos(phi1), Float64(Float64(-sin(phi1)) * Float64(cos(lambda1) * cos(phi2))))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[(-lambda2)], $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, -800000000000.0], t$95$0, If[LessEqual[lambda2, 6e+22], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[((-N[Sin[phi1], $MachinePrecision]) * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(-\lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -800000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 6 \cdot 10^{+22}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, \left(-\sin \phi_1\right) \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if lambda2 < -8e11 or 6e22 < lambda2 Initial program 79.2%
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6465.9
Applied rewrites65.9%
Taylor expanded in lambda1 around 0
lower-*.f6441.0
Applied rewrites41.0%
Taylor expanded in lambda1 around 0
lower-*.f6441.0
Applied rewrites41.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6441.0
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
Applied rewrites47.8%
if -8e11 < lambda2 < 6e22Initial program 79.2%
Taylor expanded in lambda2 around 0
lower-cos.f6469.5
Applied rewrites69.5%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
lift-*.f64N/A
associate-*l*N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites69.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi2) (cos phi1)))
(t_1
(atan2
(* (sin (- lambda2)) (cos phi2))
(- t_0 (* (* (cos (- lambda2)) (sin phi1)) (cos phi2))))))
(if (<= lambda2 -800000000000.0)
t_1
(if (<= lambda2 6e+22)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(- t_0 (* (* (cos lambda1) (sin phi1)) (cos phi2))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi2) * cos(phi1);
double t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((cos(-lambda2) * sin(phi1)) * cos(phi2))));
double tmp;
if (lambda2 <= -800000000000.0) {
tmp = t_1;
} else if (lambda2 <= 6e+22) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * sin(phi1)) * cos(phi2))));
} 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(phi2) * cos(phi1)
t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((cos(-lambda2) * sin(phi1)) * cos(phi2))))
if (lambda2 <= (-800000000000.0d0)) then
tmp = t_1
else if (lambda2 <= 6d+22) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * sin(phi1)) * cos(phi2))))
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(phi2) * Math.cos(phi1);
double t_1 = Math.atan2((Math.sin(-lambda2) * Math.cos(phi2)), (t_0 - ((Math.cos(-lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
double tmp;
if (lambda2 <= -800000000000.0) {
tmp = t_1;
} else if (lambda2 <= 6e+22) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (t_0 - ((Math.cos(lambda1) * Math.sin(phi1)) * Math.cos(phi2))));
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi2) * math.cos(phi1) t_1 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), (t_0 - ((math.cos(-lambda2) * math.sin(phi1)) * math.cos(phi2)))) tmp = 0 if lambda2 <= -800000000000.0: tmp = t_1 elif lambda2 <= 6e+22: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (t_0 - ((math.cos(lambda1) * math.sin(phi1)) * math.cos(phi2)))) else: tmp = t_1 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi2) * cos(phi1)) t_1 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(Float64(-lambda2)) * sin(phi1)) * cos(phi2)))) tmp = 0.0 if (lambda2 <= -800000000000.0) tmp = t_1; elseif (lambda2 <= 6e+22) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(cos(lambda1) * sin(phi1)) * cos(phi2)))); else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin(phi2) * cos(phi1); t_1 = atan2((sin(-lambda2) * cos(phi2)), (t_0 - ((cos(-lambda2) * sin(phi1)) * cos(phi2)))); tmp = 0.0; if (lambda2 <= -800000000000.0) tmp = t_1; elseif (lambda2 <= 6e+22) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (t_0 - ((cos(lambda1) * sin(phi1)) * cos(phi2)))); else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[(-lambda2)], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -800000000000.0], t$95$1, If[LessEqual[lambda2, 6e+22], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sin \phi_2 \cdot \cos \phi_1\\
t_1 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \left(-\lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -800000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 6 \cdot 10^{+22}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\cos \lambda_1 \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if lambda2 < -8e11 or 6e22 < lambda2 Initial program 79.2%
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6465.9
Applied rewrites65.9%
Taylor expanded in lambda1 around 0
lower-*.f6441.0
Applied rewrites41.0%
Taylor expanded in lambda1 around 0
lower-*.f6441.0
Applied rewrites41.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6441.0
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
Applied rewrites47.8%
if -8e11 < lambda2 < 6e22Initial program 79.2%
Taylor expanded in lambda2 around 0
lower-cos.f6469.5
Applied rewrites69.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6469.5
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6469.5
Applied rewrites69.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda2)) (cos phi2))
(-
(* (sin phi2) (cos phi1))
(* (* (cos (- lambda2)) (sin phi1)) (cos phi2))))))
(if (<= lambda2 -800000000000.0)
t_0
(if (<= lambda2 6e+22)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos lambda1))))
t_0))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin(-lambda2) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos(-lambda2) * sin(phi1)) * cos(phi2))));
double tmp;
if (lambda2 <= -800000000000.0) {
tmp = t_0;
} else if (lambda2 <= 6e+22) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
} 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(-lambda2) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos(-lambda2) * sin(phi1)) * cos(phi2))))
if (lambda2 <= (-800000000000.0d0)) then
tmp = t_0
else if (lambda2 <= 6d+22) then
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos(lambda1))))
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(-lambda2) * Math.cos(phi2)), ((Math.sin(phi2) * Math.cos(phi1)) - ((Math.cos(-lambda2) * Math.sin(phi1)) * Math.cos(phi2))));
double tmp;
if (lambda2 <= -800000000000.0) {
tmp = t_0;
} else if (lambda2 <= 6e+22) {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - ((math.cos(-lambda2) * math.sin(phi1)) * math.cos(phi2)))) tmp = 0 if lambda2 <= -800000000000.0: tmp = t_0 elif lambda2 <= 6e+22: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda1)))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(-lambda2)) * sin(phi1)) * cos(phi2)))) tmp = 0.0 if (lambda2 <= -800000000000.0) tmp = t_0; elseif (lambda2 <= 6e+22) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin(-lambda2) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos(-lambda2) * sin(phi1)) * cos(phi2)))); tmp = 0.0; if (lambda2 <= -800000000000.0) tmp = t_0; elseif (lambda2 <= 6e+22) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos(lambda1)))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[(-lambda2)], $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, -800000000000.0], t$95$0, If[LessEqual[lambda2, 6e+22], 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[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(-\lambda_2\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -800000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 6 \cdot 10^{+22}:\\
\;\;\;\;\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 \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if lambda2 < -8e11 or 6e22 < lambda2 Initial program 79.2%
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6465.9
Applied rewrites65.9%
Taylor expanded in lambda1 around 0
lower-*.f6441.0
Applied rewrites41.0%
Taylor expanded in lambda1 around 0
lower-*.f6441.0
Applied rewrites41.0%
lift-*.f64N/A
mul-1-negN/A
lower-neg.f6441.0
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
lower-neg.f64N/A
Applied rewrites47.8%
if -8e11 < lambda2 < 6e22Initial program 79.2%
Taylor expanded in lambda2 around 0
lower-cos.f6469.5
Applied rewrites69.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -6e-17)
(atan2 t_2 (- t_0 (* t_1 (sin phi1))))
(if (<= phi1 1.42e-154)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
(atan2 t_2 (- t_0 (* (/ 1.0 (/ 1.0 (sin phi1))) t_1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = cos((lambda1 - lambda2));
double t_2 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -6e-17) {
tmp = atan2(t_2, (t_0 - (t_1 * sin(phi1))));
} else if (phi1 <= 1.42e-154) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_2, (t_0 - ((1.0 / (1.0 / sin(phi1))) * t_1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-6d-17)) then
tmp = atan2(t_2, (t_0 - (t_1 * sin(phi1))))
else if (phi1 <= 1.42d-154) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_2, (t_0 - ((1.0d0 / (1.0d0 / sin(phi1))) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -6e-17) {
tmp = Math.atan2(t_2, (t_0 - (t_1 * Math.sin(phi1))));
} else if (phi1 <= 1.42e-154) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = Math.atan2(t_2, (t_0 - ((1.0 / (1.0 / Math.sin(phi1))) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) t_2 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -6e-17: tmp = math.atan2(t_2, (t_0 - (t_1 * math.sin(phi1)))) elif phi1 <= 1.42e-154: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), math.sin(phi2)) else: tmp = math.atan2(t_2, (t_0 - ((1.0 / (1.0 / math.sin(phi1))) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -6e-17) tmp = atan(t_2, Float64(t_0 - Float64(t_1 * sin(phi1)))); elseif (phi1 <= 1.42e-154) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = atan(t_2, Float64(t_0 - Float64(Float64(1.0 / Float64(1.0 / sin(phi1))) * t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = cos((lambda1 - lambda2)); t_2 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi1 <= -6e-17) tmp = atan2(t_2, (t_0 - (t_1 * sin(phi1)))); elseif (phi1 <= 1.42e-154) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_2, (t_0 - ((1.0 / (1.0 / sin(phi1))) * 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -6e-17], N[ArcTan[t$95$2 / N[(t$95$0 - N[(t$95$1 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1.42e-154], 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[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$2 / N[(t$95$0 - N[(N[(1.0 / N[(1.0 / N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -6 \cdot 10^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - t\_1 \cdot \sin \phi_1}\\
\mathbf{elif}\;\phi_1 \leq 1.42 \cdot 10^{-154}:\\
\;\;\;\;\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}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_2}{t\_0 - \frac{1}{\frac{1}{\sin \phi_1}} \cdot t\_1}\\
\end{array}
if phi1 < -6.00000000000000012e-17Initial program 79.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6465.8
Applied rewrites65.8%
if -6.00000000000000012e-17 < phi1 < 1.42e-154Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.f6458.6
Applied rewrites58.6%
if 1.42e-154 < phi1 Initial program 79.2%
lift-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-cos-multN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
+-commutativeN/A
lower-+.f64N/A
lower-sin.f64N/A
lower-+.f64N/A
lower-sin.f64N/A
lower--.f6465.9
Applied rewrites65.9%
Taylor expanded in phi2 around 0
lower-/.f64N/A
lower-sin.f6465.8
Applied rewrites65.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (cos (- lambda1 lambda2)) (sin phi1))))))
(if (<= phi1 -6e-17)
t_0
(if (<= phi1 1.42e-154)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
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((lambda1 - lambda2)) * sin(phi1))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_0;
} else if (phi1 <= 1.42e-154) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} 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((lambda1 - lambda2)) * sin(phi1))))
if (phi1 <= (-6d-17)) then
tmp = t_0
else if (phi1 <= 1.42d-154) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
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((lambda1 - lambda2)) * Math.sin(phi1))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_0;
} else if (phi1 <= 1.42e-154) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), Math.sin(phi2));
} 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((lambda1 - lambda2)) * math.sin(phi1)))) tmp = 0 if phi1 <= -6e-17: tmp = t_0 elif phi1 <= 1.42e-154: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), math.sin(phi2)) 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(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -6e-17) tmp = t_0; elseif (phi1 <= 1.42e-154) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); 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((lambda1 - lambda2)) * sin(phi1)))); tmp = 0.0; if (phi1 <= -6e-17) tmp = t_0; elseif (phi1 <= 1.42e-154) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -6e-17], t$95$0, If[LessEqual[phi1, 1.42e-154], 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[Sin[phi2], $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 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{if}\;\phi_1 \leq -6 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 1.42 \cdot 10^{-154}:\\
\;\;\;\;\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}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if phi1 < -6.00000000000000012e-17 or 1.42e-154 < phi1 Initial program 79.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6465.8
Applied rewrites65.8%
if -6.00000000000000012e-17 < phi1 < 1.42e-154Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.f6458.6
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(* -1.0 (* (cos (- lambda1 lambda2)) (sin phi1))))))
(if (<= phi1 -6e-17)
t_0
(if (<= phi1 5.1e-17)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
t_0))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_0;
} else if (phi1 <= 5.1e-17) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} 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)), ((-1.0d0) * (cos((lambda1 - lambda2)) * sin(phi1))))
if (phi1 <= (-6d-17)) then
tmp = t_0
else if (phi1 <= 5.1d-17) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
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)), (-1.0 * (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_0;
} else if (phi1 <= 5.1e-17) {
tmp = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (-1.0 * (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) tmp = 0 if phi1 <= -6e-17: tmp = t_0 elif phi1 <= 5.1e-17: tmp = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(-1.0 * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -6e-17) tmp = t_0; elseif (phi1 <= 5.1e-17) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (-1.0 * (cos((lambda1 - lambda2)) * sin(phi1)))); tmp = 0.0; if (phi1 <= -6e-17) tmp = t_0; elseif (phi1 <= 5.1e-17) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); 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[(-1.0 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -6e-17], t$95$0, If[LessEqual[phi1, 5.1e-17], 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[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\phi_1 \leq -6 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 5.1 \cdot 10^{-17}:\\
\;\;\;\;\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}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if phi1 < -6.00000000000000012e-17 or 5.1000000000000003e-17 < phi1 Initial program 79.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6447.5
Applied rewrites47.5%
if -6.00000000000000012e-17 < phi1 < 5.1000000000000003e-17Initial program 79.2%
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
lift-cos.f64N/A
lift-cos.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.f64N/A
lift-sin.f64N/A
*-commutativeN/A
lower-*.f6499.7
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.f6458.6
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (atan2 t_0 (* -1.0 (* (cos (- lambda1 lambda2)) (sin phi1))))))
(if (<= phi1 -6e-17)
t_1
(if (<= phi1 5.1e-17) (atan2 t_0 (sin phi2)) 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 * (cos((lambda1 - lambda2)) * sin(phi1))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_1;
} else if (phi1 <= 5.1e-17) {
tmp = atan2(t_0, sin(phi2));
} 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) * (cos((lambda1 - lambda2)) * sin(phi1))))
if (phi1 <= (-6d-17)) then
tmp = t_1
else if (phi1 <= 5.1d-17) then
tmp = atan2(t_0, sin(phi2))
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 * (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
double tmp;
if (phi1 <= -6e-17) {
tmp = t_1;
} else if (phi1 <= 5.1e-17) {
tmp = Math.atan2(t_0, Math.sin(phi2));
} 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 * (math.cos((lambda1 - lambda2)) * math.sin(phi1)))) tmp = 0 if phi1 <= -6e-17: tmp = t_1 elif phi1 <= 5.1e-17: tmp = math.atan2(t_0, math.sin(phi2)) 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(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) tmp = 0.0 if (phi1 <= -6e-17) tmp = t_1; elseif (phi1 <= 5.1e-17) tmp = atan(t_0, sin(phi2)); 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 * (cos((lambda1 - lambda2)) * sin(phi1)))); tmp = 0.0; if (phi1 <= -6e-17) tmp = t_1; elseif (phi1 <= 5.1e-17) tmp = atan2(t_0, sin(phi2)); 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -6e-17], t$95$1, If[LessEqual[phi1, 5.1e-17], N[ArcTan[t$95$0 / N[Sin[phi2], $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(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\phi_1 \leq -6 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 5.1 \cdot 10^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi1 < -6.00000000000000012e-17 or 5.1000000000000003e-17 < phi1 Initial program 79.2%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6447.5
Applied rewrites47.5%
if -6.00000000000000012e-17 < phi1 < 5.1000000000000003e-17Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* 1.0 (sin phi2)) (* (cos (- lambda1 lambda2)) (sin phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((1.0 * sin(phi2)) - (cos((lambda1 - lambda2)) * 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)), ((1.0d0 * sin(phi2)) - (cos((lambda1 - lambda2)) * 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)), ((1.0 * Math.sin(phi2)) - (Math.cos((lambda1 - lambda2)) * Math.sin(phi1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((1.0 * math.sin(phi2)) - (math.cos((lambda1 - lambda2)) * math.sin(phi1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(1.0 * sin(phi2)) - Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((1.0 * sin(phi2)) - (cos((lambda1 - lambda2)) * 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[(1.0 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{1 \cdot \sin \phi_2 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}
Initial program 79.2%
Taylor expanded in phi1 around 0
Applied rewrites65.3%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6464.4
Applied rewrites64.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -3.1e-8)
t_1
(if (<= phi2 1.05e-6)
(atan2
(* t_0 (fma (* phi2 phi2) -0.5 1.0))
(* -1.0 (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -3.1e-8) {
tmp = t_1;
} else if (phi2 <= 1.05e-6) {
tmp = atan2((t_0 * fma((phi2 * phi2), -0.5, 1.0)), (-1.0 * (cos((lambda1 - lambda2)) * 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)), sin(phi2)) tmp = 0.0 if (phi2 <= -3.1e-8) tmp = t_1; elseif (phi2 <= 1.05e-6) tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(-1.0 * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1)))); else tmp = t_1; end return 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[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -3.1e-8], t$95$1, If[LessEqual[phi2, 1.05e-6], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -3.1 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 1.05 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{-1 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -3.1e-8 or 1.0499999999999999e-6 < phi2 Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
if -3.1e-8 < phi2 < 1.0499999999999999e-6Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6429.1
Applied rewrites29.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.1
Applied rewrites29.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower--.f64N/A
lower-sin.f6442.9
Applied rewrites42.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), Math.sin(phi2));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), math.sin(phi2))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), sin(phi2)) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), sin(phi2)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}
Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))))
(if (<= lambda2 -2.8e-167)
t_0
(if (<= lambda2 3e-63)
(atan2 (* (cos phi2) (sin lambda1)) (sin phi2))
t_0))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2));
double tmp;
if (lambda2 <= -2.8e-167) {
tmp = t_0;
} else if (lambda2 <= 3e-63) {
tmp = atan2((cos(phi2) * sin(lambda1)), sin(phi2));
} 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(-lambda2) * cos(phi2)), sin(phi2))
if (lambda2 <= (-2.8d-167)) then
tmp = t_0
else if (lambda2 <= 3d-63) then
tmp = atan2((cos(phi2) * sin(lambda1)), sin(phi2))
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(-lambda2) * Math.cos(phi2)), Math.sin(phi2));
double tmp;
if (lambda2 <= -2.8e-167) {
tmp = t_0;
} else if (lambda2 <= 3e-63) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), Math.sin(phi2));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.atan2((math.sin(-lambda2) * math.cos(phi2)), math.sin(phi2)) tmp = 0 if lambda2 <= -2.8e-167: tmp = t_0 elif lambda2 <= 3e-63: tmp = math.atan2((math.cos(phi2) * math.sin(lambda1)), math.sin(phi2)) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = atan(Float64(sin(Float64(-lambda2)) * cos(phi2)), sin(phi2)) tmp = 0.0 if (lambda2 <= -2.8e-167) tmp = t_0; elseif (lambda2 <= 3e-63) tmp = atan(Float64(cos(phi2) * sin(lambda1)), sin(phi2)); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = atan2((sin(-lambda2) * cos(phi2)), sin(phi2)); tmp = 0.0; if (lambda2 <= -2.8e-167) tmp = t_0; elseif (lambda2 <= 3e-63) tmp = atan2((cos(phi2) * sin(lambda1)), sin(phi2)); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -2.8e-167], t$95$0, If[LessEqual[lambda2, 3e-63], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\lambda_2 \leq -2.8 \cdot 10^{-167}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 3 \cdot 10^{-63}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if lambda2 < -2.79999999999999986e-167 or 2.99999999999999979e-63 < lambda2 Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-neg.f6432.4
Applied rewrites32.4%
if -2.79999999999999986e-167 < lambda2 < 2.99999999999999979e-63Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6429.1
Applied rewrites29.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.1
Applied rewrites29.1%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6432.2
Applied rewrites32.2%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -1220.0)
(atan2 (* (cos phi2) (sin lambda1)) (sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(* phi2 (+ 1.0 (* -0.16666666666666666 (pow phi2 2.0)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -1220.0) {
tmp = atan2((cos(phi2) * sin(lambda1)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (phi2 * (1.0 + (-0.16666666666666666 * pow(phi2, 2.0)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= (-1220.0d0)) then
tmp = atan2((cos(phi2) * sin(lambda1)), sin(phi2))
else
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (phi2 * (1.0d0 + ((-0.16666666666666666d0) * (phi2 ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -1220.0) {
tmp = Math.atan2((Math.cos(phi2) * Math.sin(lambda1)), Math.sin(phi2));
} else {
tmp = Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), (phi2 * (1.0 + (-0.16666666666666666 * Math.pow(phi2, 2.0)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -1220.0: tmp = math.atan2((math.cos(phi2) * math.sin(lambda1)), math.sin(phi2)) else: tmp = math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), (phi2 * (1.0 + (-0.16666666666666666 * math.pow(phi2, 2.0))))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -1220.0) tmp = atan(Float64(cos(phi2) * sin(lambda1)), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * (phi2 ^ 2.0))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -1220.0) tmp = atan2((cos(phi2) * sin(lambda1)), sin(phi2)); else tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (phi2 * (1.0 + (-0.16666666666666666 * (phi2 ^ 2.0))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -1220.0], N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1220:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \lambda_1}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot {\phi_2}^{2}\right)}\\
\end{array}
if phi2 < -1220Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6429.1
Applied rewrites29.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.1
Applied rewrites29.1%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f6432.2
Applied rewrites32.2%
if -1220 < phi2 Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6431.4
Applied rewrites31.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 -1.2e+32)
(atan2
(* t_0 (fma (* phi2 phi2) -0.5 1.0))
(*
phi2
(+
1.0
(*
(pow phi2 2.0)
(- (* 0.008333333333333333 (pow phi2 2.0)) 0.16666666666666666)))))
(atan2
(* t_0 (cos phi2))
(* phi2 (+ 1.0 (* -0.16666666666666666 (pow phi2 2.0))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.2e+32) {
tmp = atan2((t_0 * fma((phi2 * phi2), -0.5, 1.0)), (phi2 * (1.0 + (pow(phi2, 2.0) * ((0.008333333333333333 * pow(phi2, 2.0)) - 0.16666666666666666)))));
} else {
tmp = atan2((t_0 * cos(phi2)), (phi2 * (1.0 + (-0.16666666666666666 * pow(phi2, 2.0)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.2e+32) tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(phi2 * Float64(1.0 + Float64((phi2 ^ 2.0) * Float64(Float64(0.008333333333333333 * (phi2 ^ 2.0)) - 0.16666666666666666))))); else tmp = atan(Float64(t_0 * cos(phi2)), Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * (phi2 ^ 2.0))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.2e+32], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(N[Power[phi2, 2.0], $MachinePrecision] * N[(N[(0.008333333333333333 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.2 \cdot 10^{+32}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\phi_2 \cdot \left(1 + {\phi_2}^{2} \cdot \left(0.008333333333333333 \cdot {\phi_2}^{2} - 0.16666666666666666\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot {\phi_2}^{2}\right)}\\
\end{array}
if phi2 < -1.19999999999999996e32Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6429.1
Applied rewrites29.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.1
Applied rewrites29.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6428.8
Applied rewrites28.8%
if -1.19999999999999996e32 < phi2 Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6431.4
Applied rewrites31.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (fma (* phi2 phi2) -0.5 1.0))))
(if (<= phi2 -6.5e+19)
(atan2
t_0
(*
phi2
(+
1.0
(*
(pow phi2 2.0)
(- (* 0.008333333333333333 (pow phi2 2.0)) 0.16666666666666666)))))
(atan2 t_0 (* phi2 (+ 1.0 (* -0.16666666666666666 (pow phi2 2.0))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * fma((phi2 * phi2), -0.5, 1.0);
double tmp;
if (phi2 <= -6.5e+19) {
tmp = atan2(t_0, (phi2 * (1.0 + (pow(phi2, 2.0) * ((0.008333333333333333 * pow(phi2, 2.0)) - 0.16666666666666666)))));
} else {
tmp = atan2(t_0, (phi2 * (1.0 + (-0.16666666666666666 * pow(phi2, 2.0)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * fma(Float64(phi2 * phi2), -0.5, 1.0)) tmp = 0.0 if (phi2 <= -6.5e+19) tmp = atan(t_0, Float64(phi2 * Float64(1.0 + Float64((phi2 ^ 2.0) * Float64(Float64(0.008333333333333333 * (phi2 ^ 2.0)) - 0.16666666666666666))))); else tmp = atan(t_0, Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * (phi2 ^ 2.0))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -6.5e+19], N[ArcTan[t$95$0 / N[(phi2 * N[(1.0 + N[(N[Power[phi2, 2.0], $MachinePrecision] * N[(N[(0.008333333333333333 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision] - 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$0 / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\mathbf{if}\;\phi_2 \leq -6.5 \cdot 10^{+19}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \left(1 + {\phi_2}^{2} \cdot \left(0.008333333333333333 \cdot {\phi_2}^{2} - 0.16666666666666666\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot {\phi_2}^{2}\right)}\\
\end{array}
if phi2 < -6.5e19Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6429.1
Applied rewrites29.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.1
Applied rewrites29.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-pow.f6428.8
Applied rewrites28.8%
if -6.5e19 < phi2 Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6429.1
Applied rewrites29.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.1
Applied rewrites29.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.7
Applied rewrites28.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (fma (* phi2 phi2) -0.5 1.0)) (* phi2 (+ 1.0 (* -0.16666666666666666 (pow phi2 2.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * fma((phi2 * phi2), -0.5, 1.0)), (phi2 * (1.0 + (-0.16666666666666666 * pow(phi2, 2.0)))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(phi2 * Float64(1.0 + Float64(-0.16666666666666666 * (phi2 ^ 2.0))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot {\phi_2}^{2}\right)}
Initial program 79.2%
Taylor expanded in phi1 around 0
lower-sin.f6448.7
Applied rewrites48.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6429.1
Applied rewrites29.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-pow.f64N/A
pow2N/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.1
Applied rewrites29.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6428.7
Applied rewrites28.7%
herbie shell --seed 2025171
(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))))))