
(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 32 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((Math.sin((lambda1 - lambda2)) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((math.sin((lambda1 - lambda2)) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(*
(* (sin phi1) (* (cos phi2) (fma (tan lambda2) (tan lambda1) 1.0)))
(cos lambda2))
(cos lambda1)))))double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (((sin(phi1) * (cos(phi2) * fma(tan(lambda2), tan(lambda1), 1.0))) * cos(lambda2)) * cos(lambda1))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(Float64(sin(phi1) * Float64(cos(phi2) * fma(tan(lambda2), tan(lambda1), 1.0))) * cos(lambda2)) * cos(lambda1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Tan[lambda2], $MachinePrecision] * N[Tan[lambda1], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $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(\left(\sin \phi_1 \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(\tan \lambda_2, \tan \lambda_1, 1\right)\right)\right) \cdot \cos \lambda_2\right) \cdot \cos \lambda_1}
Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/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 (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2)))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)}
Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
+-commutativeN/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(-
(* (cos phi1) (sin phi2))
(*
(* (sin phi1) (cos phi2))
(fma (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 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
lift-cos.64N/A
lift-cos.64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f6499.7%
Applied rewrites99.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1))))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(if (<= phi2 -0.65)
(atan2
(fma
-1.0
(* (cos lambda1) (* (cos phi2) (sin lambda2)))
(* (cos lambda2) (* (cos phi2) (sin lambda1))))
(- t_1 (* (cos phi2) (* (cos (- lambda1 lambda2)) (sin phi1)))))
(if (<= phi2 1e-55)
(atan2
(* t_0 t_2)
(-
t_1
(*
(*
(* (sin phi1) (* t_2 (fma (tan lambda2) (tan lambda1) 1.0)))
(cos lambda2))
(cos lambda1))))
(atan2
(* t_0 (cos phi2))
(-
t_1
(* (* (* (sin phi1) (cos phi2)) (cos lambda2)) (cos lambda1))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = 1.0 + (-0.5 * pow(phi2, 2.0));
double tmp;
if (phi2 <= -0.65) {
tmp = atan2(fma(-1.0, (cos(lambda1) * (cos(phi2) * sin(lambda2))), (cos(lambda2) * (cos(phi2) * sin(lambda1)))), (t_1 - (cos(phi2) * (cos((lambda1 - lambda2)) * sin(phi1)))));
} else if (phi2 <= 1e-55) {
tmp = atan2((t_0 * t_2), (t_1 - (((sin(phi1) * (t_2 * fma(tan(lambda2), tan(lambda1), 1.0))) * cos(lambda2)) * cos(lambda1))));
} else {
tmp = atan2((t_0 * cos(phi2)), (t_1 - (((sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) tmp = 0.0 if (phi2 <= -0.65) tmp = atan(fma(-1.0, Float64(cos(lambda1) * Float64(cos(phi2) * sin(lambda2))), Float64(cos(lambda2) * Float64(cos(phi2) * sin(lambda1)))), Float64(t_1 - Float64(cos(phi2) * Float64(cos(Float64(lambda1 - lambda2)) * sin(phi1))))); elseif (phi2 <= 1e-55) tmp = atan(Float64(t_0 * t_2), Float64(t_1 - Float64(Float64(Float64(sin(phi1) * Float64(t_2 * fma(tan(lambda2), tan(lambda1), 1.0))) * cos(lambda2)) * cos(lambda1)))); else tmp = atan(Float64(t_0 * cos(phi2)), Float64(t_1 - Float64(Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.65], N[ArcTan[N[(-1.0 * N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi2, 1e-55], N[ArcTan[N[(t$95$0 * t$95$2), $MachinePrecision] / N[(t$95$1 - N[(N[(N[(N[Sin[phi1], $MachinePrecision] * N[(t$95$2 * N[(N[Tan[lambda2], $MachinePrecision] * N[Tan[lambda1], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - N[(N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := 1 + -0.5 \cdot {\phi_2}^{2}\\
\mathbf{if}\;\phi_2 \leq -0.65:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-1, \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \lambda_2\right), \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \lambda_1\right)\right)}{t\_1 - \cos \phi_2 \cdot \left(\cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1\right)}\\
\mathbf{elif}\;\phi_2 \leq 10^{-55}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot t\_2}{t\_1 - \left(\left(\sin \phi_1 \cdot \left(t\_2 \cdot \mathsf{fma}\left(\tan \lambda_2, \tan \lambda_1, 1\right)\right)\right) \cdot \cos \lambda_2\right) \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{t\_1 - \left(\left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right) \cdot \cos \lambda_1}\\
\end{array}
if phi2 < -0.650000000000000022Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-*.f64N/A
*-commutativeN/A
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.64N/A
lift-cos.64N/A
lift-*.f64N/A
lift-cos.64N/A
lift-sin.64N/A
*-commutativeN/A
lift-*.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
Applied rewrites31.9%
Taylor expanded in lambda1 around 0
lower-atan2.64N/A
Applied rewrites89.1%
if -0.650000000000000022 < phi2 < 9.99999999999999995e-56Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6454.8%
Applied rewrites54.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6455.3%
Applied rewrites55.3%
if 9.99999999999999995e-56 < phi2 Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
lower-cos.6489.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 lambda2)) (cos lambda1))))))
(if (<= phi2 -5.2e-6)
t_1
(if (<= phi2 1e-55)
(atan2
t_0
(-
(* phi2 (cos phi1))
(*
(*
(* (sin phi1) (* (cos phi2) (fma (tan lambda2) (tan lambda1) 1.0)))
(cos lambda2))
(cos lambda1))))
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(lambda2)) * cos(lambda1))));
double tmp;
if (phi2 <= -5.2e-6) {
tmp = t_1;
} else if (phi2 <= 1e-55) {
tmp = atan2(t_0, ((phi2 * cos(phi1)) - (((sin(phi1) * (cos(phi2) * fma(tan(lambda2), tan(lambda1), 1.0))) * cos(lambda2)) * cos(lambda1))));
} 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(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1)))) tmp = 0.0 if (phi2 <= -5.2e-6) tmp = t_1; elseif (phi2 <= 1e-55) tmp = atan(t_0, Float64(Float64(phi2 * cos(phi1)) - Float64(Float64(Float64(sin(phi1) * Float64(cos(phi2) * fma(tan(lambda2), tan(lambda1), 1.0))) * cos(lambda2)) * cos(lambda1)))); 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[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -5.2e-6], t$95$1, If[LessEqual[phi2, 1e-55], N[ArcTan[t$95$0 / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Tan[lambda2], $MachinePrecision] * N[Tan[lambda1], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $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(\left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right) \cdot \cos \lambda_1}\\
\mathbf{if}\;\phi_2 \leq -5.2 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 10^{-55}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\phi_2 \cdot \cos \phi_1 - \left(\left(\sin \phi_1 \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(\tan \lambda_2, \tan \lambda_1, 1\right)\right)\right) \cdot \cos \lambda_2\right) \cdot \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -5.20000000000000019e-6 or 9.99999999999999995e-56 < phi2 Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
lower-cos.6489.3%
Applied rewrites89.3%
if -5.20000000000000019e-6 < phi2 < 9.99999999999999995e-56Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.6457.7%
Applied rewrites57.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)) (cos lambda2)) (cos lambda1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (((sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (((sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - (((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda2)) * Math.cos(lambda1))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - (((math.sin(phi1) * math.cos(phi2)) * math.cos(lambda2)) * math.cos(lambda1))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1)))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - (((sin(phi1) * cos(phi2)) * cos(lambda2)) * cos(lambda1)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $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(\left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right) \cdot \cos \lambda_1}
Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
lift-*.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
lower-cos.6489.3%
Applied rewrites89.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1))) (cos phi2)) (- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
(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))
(* (* (sin phi1) (cos phi2)) (cos lambda2))))))
(if (<= lambda2 -7e-35)
t_0
(if (<= lambda2 4.6e-17)
(atan2
(* (- (sin lambda1) (* (cos lambda1) lambda2)) (cos phi2))
(-
(* (sin phi2) (cos phi1))
(* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2))))
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)) - ((sin(phi1) * cos(phi2)) * cos(lambda2))));
double tmp;
if (lambda2 <= -7e-35) {
tmp = t_0;
} else if (lambda2 <= 4.6e-17) {
tmp = atan2(((sin(lambda1) - (cos(lambda1) * lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(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) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos(lambda2))))
if (lambda2 <= (-7d-35)) then
tmp = t_0
else if (lambda2 <= 4.6d-17) then
tmp = atan2(((sin(lambda1) - (cos(lambda1) * lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(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) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos(lambda2))));
double tmp;
if (lambda2 <= -7e-35) {
tmp = t_0;
} else if (lambda2 <= 4.6e-17) {
tmp = Math.atan2(((Math.sin(lambda1) - (Math.cos(lambda1) * lambda2)) * Math.cos(phi2)), ((Math.sin(phi2) * Math.cos(phi1)) - ((Math.cos((lambda2 - lambda1)) * Math.sin(phi1)) * Math.cos(phi2))));
} 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.sin(phi1) * math.cos(phi2)) * math.cos(lambda2)))) tmp = 0 if lambda2 <= -7e-35: tmp = t_0 elif lambda2 <= 4.6e-17: tmp = math.atan2(((math.sin(lambda1) - (math.cos(lambda1) * lambda2)) * math.cos(phi2)), ((math.sin(phi2) * math.cos(phi1)) - ((math.cos((lambda2 - lambda1)) * math.sin(phi1)) * math.cos(phi2)))) 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(Float64(sin(phi1) * cos(phi2)) * cos(lambda2)))) tmp = 0.0 if (lambda2 <= -7e-35) tmp = t_0; elseif (lambda2 <= 4.6e-17) tmp = atan(Float64(Float64(sin(lambda1) - Float64(cos(lambda1) * lambda2)) * cos(phi2)), Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); 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)) - ((sin(phi1) * cos(phi2)) * cos(lambda2)))); tmp = 0.0; if (lambda2 <= -7e-35) tmp = t_0; elseif (lambda2 <= 4.6e-17) tmp = atan2(((sin(lambda1) - (cos(lambda1) * lambda2)) * cos(phi2)), ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); 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[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -7e-35], t$95$0, If[LessEqual[lambda2, 4.6e-17], N[ArcTan[N[(N[(N[Sin[lambda1], $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * 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], 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 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2}\\
\mathbf{if}\;\lambda_2 \leq -7 \cdot 10^{-35}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 4.6 \cdot 10^{-17}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\sin \lambda_1 - \cos \lambda_1 \cdot \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{else}:\\
\;\;\;\;t\_0\\
\end{array}
if lambda2 < -6.99999999999999992e-35 or 4.60000000000000018e-17 < lambda2 Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in lambda1 around 0
lower-cos.6479.5%
Applied rewrites79.5%
if -6.99999999999999992e-35 < lambda2 < 4.60000000000000018e-17Initial program 78.9%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-sin.64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.6459.1%
Applied rewrites59.1%
lift-+.f64N/A
lift-*.f64N/A
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
*-lft-identity59.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6459.1%
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
Applied rewrites59.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (* (sin lambda2) (cos lambda1)))
(t_2
(atan2
(* (- (* (sin lambda1) (cos lambda2)) t_1) (cos phi2))
(- t_0 (* (cos lambda1) (* (cos phi2) (sin phi1)))))))
(if (<= lambda1 -1.4e-8)
t_2
(if (<= lambda1 2.1e-6)
(atan2
(* (- (* lambda1 (cos lambda2)) t_1) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
t_2))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * sin(phi2);
double t_1 = sin(lambda2) * cos(lambda1);
double t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))));
double tmp;
if (lambda1 <= -1.4e-8) {
tmp = t_2;
} else if (lambda1 <= 2.1e-6) {
tmp = atan2((((lambda1 * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = sin(lambda2) * cos(lambda1)
t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1)))))
if (lambda1 <= (-1.4d-8)) then
tmp = t_2
else if (lambda1 <= 2.1d-6) then
tmp = atan2((((lambda1 * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.sin(phi2);
double t_1 = Math.sin(lambda2) * Math.cos(lambda1);
double t_2 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - t_1) * Math.cos(phi2)), (t_0 - (Math.cos(lambda1) * (Math.cos(phi2) * Math.sin(phi1)))));
double tmp;
if (lambda1 <= -1.4e-8) {
tmp = t_2;
} else if (lambda1 <= 2.1e-6) {
tmp = Math.atan2((((lambda1 * Math.cos(lambda2)) - t_1) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.sin(phi2) t_1 = math.sin(lambda2) * math.cos(lambda1) t_2 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - t_1) * math.cos(phi2)), (t_0 - (math.cos(lambda1) * (math.cos(phi2) * math.sin(phi1))))) tmp = 0 if lambda1 <= -1.4e-8: tmp = t_2 elif lambda1 <= 2.1e-6: tmp = math.atan2((((lambda1 * math.cos(lambda2)) - t_1) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = t_2 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * sin(phi2)) t_1 = Float64(sin(lambda2) * cos(lambda1)) t_2 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), Float64(t_0 - Float64(cos(lambda1) * Float64(cos(phi2) * sin(phi1))))) tmp = 0.0 if (lambda1 <= -1.4e-8) tmp = t_2; elseif (lambda1 <= 2.1e-6) tmp = atan(Float64(Float64(Float64(lambda1 * cos(lambda2)) - t_1) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * sin(phi2); t_1 = sin(lambda2) * cos(lambda1); t_2 = atan2((((sin(lambda1) * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - (cos(lambda1) * (cos(phi2) * sin(phi1))))); tmp = 0.0; if (lambda1 <= -1.4e-8) tmp = t_2; elseif (lambda1 <= 2.1e-6) tmp = atan2((((lambda1 * cos(lambda2)) - t_1) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.4e-8], t$95$2, If[LessEqual[lambda1, 2.1e-6], N[ArcTan[N[(N[(N[(lambda1 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$2]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_2 \cdot \cos \lambda_1\\
t_2 := \tan^{-1}_* \frac{\left(\sin \lambda_1 \cdot \cos \lambda_2 - t\_1\right) \cdot \cos \phi_2}{t\_0 - \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\lambda_1 \leq -1.4 \cdot 10^{-8}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\lambda_1 \leq 2.1 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\lambda_1 \cdot \cos \lambda_2 - t\_1\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if lambda1 < -1.4e-8 or 2.0999999999999998e-6 < lambda1 Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in lambda2 around 0
lower-*.f64N/A
lower-cos.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-sin.6479.3%
Applied rewrites79.3%
if -1.4e-8 < lambda1 < 2.0999999999999998e-6Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in lambda1 around 0
Applied rewrites59.4%
(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 -580000000.0)
t_2
(if (<= phi1 360000.0)
(atan2
(* (- t_1 (* (sin lambda2) (cos lambda1))) (cos phi2))
(+
(sin phi2)
(* phi1 (- (* -0.5 (* phi1 (sin phi2))) (* (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 <= -580000000.0) {
tmp = t_2;
} else if (phi1 <= 360000.0) {
tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + (phi1 * ((-0.5 * (phi1 * sin(phi2))) - (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 <= (-580000000.0d0)) then
tmp = t_2
else if (phi1 <= 360000.0d0) then
tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + (phi1 * (((-0.5d0) * (phi1 * sin(phi2))) - (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 <= -580000000.0) {
tmp = t_2;
} else if (phi1 <= 360000.0) {
tmp = Math.atan2(((t_1 - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), (Math.sin(phi2) + (phi1 * ((-0.5 * (phi1 * Math.sin(phi2))) - (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 <= -580000000.0: tmp = t_2 elif phi1 <= 360000.0: tmp = math.atan2(((t_1 - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), (math.sin(phi2) + (phi1 * ((-0.5 * (phi1 * math.sin(phi2))) - (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 <= -580000000.0) tmp = t_2; elseif (phi1 <= 360000.0) tmp = atan(Float64(Float64(t_1 - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(sin(phi2) + Float64(phi1 * Float64(Float64(-0.5 * Float64(phi1 * sin(phi2))) - 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 <= -580000000.0) tmp = t_2; elseif (phi1 <= 360000.0) tmp = atan2(((t_1 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + (phi1 * ((-0.5 * (phi1 * sin(phi2))) - (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, -580000000.0], t$95$2, If[LessEqual[phi1, 360000.0], N[ArcTan[N[(N[(t$95$1 - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] + N[(phi1 * N[(N[(-0.5 * N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 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 -580000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 360000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_1 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{\sin \phi_2 + \phi_1 \cdot \left(-0.5 \cdot \left(\phi_1 \cdot \sin \phi_2\right) - \cos \phi_2 \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
if phi1 < -5.8e8 or 3.6e5 < phi1 Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in lambda1 around 0
lower-sin.6480.9%
Applied rewrites80.9%
if -5.8e8 < phi1 < 3.6e5Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-sin.64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-cos.64N/A
lower--.f6457.4%
Applied rewrites57.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (sin phi2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (* (sin lambda1) (cos lambda2)))
(t_3
(atan2
(* (- t_2 (sin lambda2)) (cos phi2))
(- t_0 (* (* (sin phi1) (cos phi2)) t_1)))))
(if (<= phi1 -2.95e+31)
t_3
(if (<= phi1 270000000.0)
(atan2
(* (- t_2 (* (sin lambda2) (cos lambda1))) (cos phi2))
(- t_0 (* t_1 (sin phi1))))
t_3))))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) * cos(lambda2);
double t_3 = atan2(((t_2 - sin(lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)));
double tmp;
if (phi1 <= -2.95e+31) {
tmp = t_3;
} else if (phi1 <= 270000000.0) {
tmp = atan2(((t_2 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (t_1 * sin(phi1))));
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * sin(phi2)
t_1 = cos((lambda1 - lambda2))
t_2 = sin(lambda1) * cos(lambda2)
t_3 = atan2(((t_2 - sin(lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1)))
if (phi1 <= (-2.95d+31)) then
tmp = t_3
else if (phi1 <= 270000000.0d0) then
tmp = atan2(((t_2 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (t_1 * sin(phi1))))
else
tmp = t_3
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) * Math.cos(lambda2);
double t_3 = Math.atan2(((t_2 - Math.sin(lambda2)) * Math.cos(phi2)), (t_0 - ((Math.sin(phi1) * Math.cos(phi2)) * t_1)));
double tmp;
if (phi1 <= -2.95e+31) {
tmp = t_3;
} else if (phi1 <= 270000000.0) {
tmp = Math.atan2(((t_2 - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), (t_0 - (t_1 * Math.sin(phi1))));
} else {
tmp = t_3;
}
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) * math.cos(lambda2) t_3 = math.atan2(((t_2 - math.sin(lambda2)) * math.cos(phi2)), (t_0 - ((math.sin(phi1) * math.cos(phi2)) * t_1))) tmp = 0 if phi1 <= -2.95e+31: tmp = t_3 elif phi1 <= 270000000.0: tmp = math.atan2(((t_2 - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), (t_0 - (t_1 * math.sin(phi1)))) else: tmp = t_3 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(lambda1) * cos(lambda2)) t_3 = atan(Float64(Float64(t_2 - sin(lambda2)) * cos(phi2)), Float64(t_0 - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))) tmp = 0.0 if (phi1 <= -2.95e+31) tmp = t_3; elseif (phi1 <= 270000000.0) tmp = atan(Float64(Float64(t_2 - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(t_0 - Float64(t_1 * sin(phi1)))); else tmp = t_3; 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) * cos(lambda2); t_3 = atan2(((t_2 - sin(lambda2)) * cos(phi2)), (t_0 - ((sin(phi1) * cos(phi2)) * t_1))); tmp = 0.0; if (phi1 <= -2.95e+31) tmp = t_3; elseif (phi1 <= 270000000.0) tmp = atan2(((t_2 - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (t_0 - (t_1 * sin(phi1)))); else tmp = t_3; 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[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[(t$95$2 - N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.95e+31], t$95$3, If[LessEqual[phi1, 270000000.0], N[ArcTan[N[(N[(t$95$2 - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - N[(t$95$1 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := \sin \lambda_1 \cdot \cos \lambda_2\\
t_3 := \tan^{-1}_* \frac{\left(t\_2 - \sin \lambda_2\right) \cdot \cos \phi_2}{t\_0 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\mathbf{if}\;\phi_1 \leq -2.95 \cdot 10^{+31}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\phi_1 \leq 270000000:\\
\;\;\;\;\tan^{-1}_* \frac{\left(t\_2 - \sin \lambda_2 \cdot \cos \lambda_1\right) \cdot \cos \phi_2}{t\_0 - t\_1 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if phi1 < -2.9500000000000002e31 or 2.7e8 < phi1 Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in lambda1 around 0
lower-sin.6480.9%
Applied rewrites80.9%
if -2.9500000000000002e31 < phi1 < 2.7e8Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6475.8%
Applied rewrites75.8%
(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 -70000000000000.0)
t_2
(if (<= phi1 360000.0)
(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 <= -70000000000000.0) {
tmp = t_2;
} else if (phi1 <= 360000.0) {
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 <= (-70000000000000.0d0)) then
tmp = t_2
else if (phi1 <= 360000.0d0) 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 <= -70000000000000.0) {
tmp = t_2;
} else if (phi1 <= 360000.0) {
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 <= -70000000000000.0: tmp = t_2 elif phi1 <= 360000.0: 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 <= -70000000000000.0) tmp = t_2; elseif (phi1 <= 360000.0) 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 <= -70000000000000.0) tmp = t_2; elseif (phi1 <= 360000.0) 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, -70000000000000.0], t$95$2, If[LessEqual[phi1, 360000.0], N[ArcTan[N[(N[(t$95$1 - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] + 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 -70000000000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 360000:\\
\;\;\;\;\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 < -7e13 or 3.6e5 < phi1 Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in lambda1 around 0
lower-sin.6480.9%
Applied rewrites80.9%
if -7e13 < phi1 < 3.6e5Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-sin.64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-cos.64N/A
lower--.f6457.7%
Applied rewrites57.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -58000000000000.0)
(atan2
t_0
(fma
(sin phi2)
(cos phi1)
(- (* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2)))))
(if (<= phi1 145000000.0)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(+ (sin phi2) (* -1.0 (* phi1 (* (cos phi2) t_1)))))
(atan2
t_0
(- (* (cos phi1) (sin phi2)) (* (* (sin phi1) (cos phi2)) t_1)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -58000000000000.0) {
tmp = atan2(t_0, fma(sin(phi2), cos(phi1), -((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 145000000.0) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), (sin(phi2) + (-1.0 * (phi1 * (cos(phi2) * t_1)))));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_1)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -58000000000000.0) tmp = atan(t_0, fma(sin(phi2), cos(phi1), Float64(-Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2))))); elseif (phi1 <= 145000000.0) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), Float64(sin(phi2) + Float64(-1.0 * Float64(phi1 * Float64(cos(phi2) * t_1))))); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_1))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -58000000000000.0], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $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, 145000000.0], N[ArcTan[N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Sin[phi2], $MachinePrecision] + N[(-1.0 * N[(phi1 * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 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] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -58000000000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, -\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2\right)}\\
\mathbf{elif}\;\phi_1 \leq 145000000:\\
\;\;\;\;\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 t\_1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}\\
\end{array}
if phi1 < -5.8e13Initial program 78.9%
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
lower-neg.f6478.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites78.9%
if -5.8e13 < phi1 < 1.45e8Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-sin.64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-cos.64N/A
lower--.f6457.7%
Applied rewrites57.7%
if 1.45e8 < phi1 Initial program 78.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -1.14e+27)
(atan2
t_0
(fma
(sin phi2)
(cos phi1)
(- (* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2)))))
(if (<= phi1 1460000000.0)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -1.14e+27) {
tmp = atan2(t_0, fma(sin(phi2), cos(phi1), -((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 1460000000.0) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -1.14e+27) tmp = atan(t_0, fma(sin(phi2), cos(phi1), Float64(-Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2))))); elseif (phi1 <= 1460000000.0) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.14e+27], N[ArcTan[t$95$0 / N[(N[Sin[phi2], $MachinePrecision] * N[Cos[phi1], $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, 1460000000.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[Sin[phi2], $MachinePrecision]], $MachinePrecision], 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]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.14 \cdot 10^{+27}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\mathsf{fma}\left(\sin \phi_2, \cos \phi_1, -\left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2\right)}\\
\mathbf{elif}\;\phi_1 \leq 1460000000:\\
\;\;\;\;\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\_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)}\\
\end{array}
if phi1 < -1.1400000000000001e27Initial program 78.9%
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
lower-neg.f6478.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites78.9%
if -1.1400000000000001e27 < phi1 < 1.46e9Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.6%
Applied rewrites58.6%
if 1.46e9 < phi1 Initial program 78.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -1.14e+27)
(atan2
t_0
(-
(* (sin phi2) (cos phi1))
(* (* (cos (- lambda2 lambda1)) (sin phi1)) (cos phi2))))
(if (<= phi1 1460000000.0)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
(atan2
t_0
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -1.14e+27) {
tmp = atan2(t_0, ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))));
} else if (phi1 <= 1460000000.0) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-1.14d+27)) then
tmp = atan2(t_0, ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2))))
else if (phi1 <= 1460000000.0d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -1.14e+27) {
tmp = Math.atan2(t_0, ((Math.sin(phi2) * Math.cos(phi1)) - ((Math.cos((lambda2 - lambda1)) * Math.sin(phi1)) * Math.cos(phi2))));
} else if (phi1 <= 1460000000.0) {
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_0, ((Math.cos(phi1) * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -1.14e+27: tmp = math.atan2(t_0, ((math.sin(phi2) * math.cos(phi1)) - ((math.cos((lambda2 - lambda1)) * math.sin(phi1)) * math.cos(phi2)))) elif phi1 <= 1460000000.0: 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_0, ((math.cos(phi1) * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -1.14e+27) tmp = atan(t_0, Float64(Float64(sin(phi2) * cos(phi1)) - Float64(Float64(cos(Float64(lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 1460000000.0) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = atan(t_0, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi1 <= -1.14e+27) tmp = atan2(t_0, ((sin(phi2) * cos(phi1)) - ((cos((lambda2 - lambda1)) * sin(phi1)) * cos(phi2)))); elseif (phi1 <= 1460000000.0) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_0, ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.14e+27], N[ArcTan[t$95$0 / 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, 1460000000.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[Sin[phi2], $MachinePrecision]], $MachinePrecision], 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]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.14 \cdot 10^{+27}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2 \cdot \cos \phi_1 - \left(\cos \left(\lambda_2 - \lambda_1\right) \cdot \sin \phi_1\right) \cdot \cos \phi_2}\\
\mathbf{elif}\;\phi_1 \leq 1460000000:\\
\;\;\;\;\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\_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)}\\
\end{array}
if phi1 < -1.1400000000000001e27Initial program 78.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6478.9%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6478.9%
lift-cos.64N/A
cos-neg-revN/A
lower-cos.64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f6478.9%
Applied rewrites78.9%
if -1.1400000000000001e27 < phi1 < 1.46e9Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.6%
Applied rewrites58.6%
if 1.46e9 < phi1 Initial program 78.9%
(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 -1.14e+27)
t_0
(if (<= phi1 1460000000.0)
(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 <= -1.14e+27) {
tmp = t_0;
} else if (phi1 <= 1460000000.0) {
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 <= (-1.14d+27)) then
tmp = t_0
else if (phi1 <= 1460000000.0d0) 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 <= -1.14e+27) {
tmp = t_0;
} else if (phi1 <= 1460000000.0) {
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 <= -1.14e+27: tmp = t_0 elif phi1 <= 1460000000.0: 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 <= -1.14e+27) tmp = t_0; elseif (phi1 <= 1460000000.0) 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 <= -1.14e+27) tmp = t_0; elseif (phi1 <= 1460000000.0) 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, -1.14e+27], t$95$0, If[LessEqual[phi1, 1460000000.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[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 -1.14 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 1460000000:\\
\;\;\;\;\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 < -1.1400000000000001e27 or 1.46e9 < phi1 Initial program 78.9%
if -1.1400000000000001e27 < phi1 < 1.46e9Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.6%
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -1.9)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
(if (<= lambda2 9.5e-9)
(atan2
(* (sin (- lambda1 lambda2)) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos lambda1))))
(atan2
(fma
-1.0
(* (cos lambda1) (* (cos phi2) (sin lambda2)))
(* (cos lambda2) (* (cos phi2) (sin lambda1))))
(sin phi2)))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -1.9) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} else if (lambda2 <= 9.5e-9) {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = atan2(fma(-1.0, (cos(lambda1) * (cos(phi2) * sin(lambda2))), (cos(lambda2) * (cos(phi2) * sin(lambda1)))), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -1.9) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); elseif (lambda2 <= 9.5e-9) 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 = atan(fma(-1.0, Float64(cos(lambda1) * Float64(cos(phi2) * sin(lambda2))), Float64(cos(lambda2) * Float64(cos(phi2) * sin(lambda1)))), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -1.9], 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], If[LessEqual[lambda2, 9.5e-9], 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], N[ArcTan[N[(-1.0 * N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -1.9:\\
\;\;\;\;\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{elif}\;\lambda_2 \leq 9.5 \cdot 10^{-9}:\\
\;\;\;\;\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}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-1, \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \lambda_2\right), \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \lambda_1\right)\right)}{\sin \phi_2}\\
\end{array}
if lambda2 < -1.8999999999999999Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.6%
Applied rewrites58.6%
if -1.8999999999999999 < lambda2 < 9.5000000000000007e-9Initial program 78.9%
Taylor expanded in lambda2 around 0
lower-cos.6469.1%
Applied rewrites69.1%
if 9.5000000000000007e-9 < lambda2 Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-*.f64N/A
*-commutativeN/A
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.64N/A
lift-cos.64N/A
lift-*.f64N/A
lift-cos.64N/A
lift-sin.64N/A
*-commutativeN/A
lift-*.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
Applied rewrites31.9%
Taylor expanded in lambda1 around inf
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-sin.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-sin.6458.6%
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi1) (sin phi2)))
(t_2 (* (* (sin phi1) (cos phi2)) t_0))
(t_3
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2)))
(t_4 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= (- lambda1 lambda2) -1e+193)
t_3
(if (<= (- lambda1 lambda2) -500.0)
(atan2 t_4 (- (* 1.0 (sin phi2)) t_2))
(if (<= (- lambda1 lambda2) 4e-6)
(atan2 (* (+ lambda1 (* -1.0 lambda2)) (cos phi2)) (- t_1 t_2))
(if (<= (- lambda1 lambda2) 4e+100)
(atan2 t_4 (- t_1 (* t_0 (sin phi1))))
t_3))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi1) * sin(phi2);
double t_2 = (sin(phi1) * cos(phi2)) * t_0;
double t_3 = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
double t_4 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if ((lambda1 - lambda2) <= -1e+193) {
tmp = t_3;
} else if ((lambda1 - lambda2) <= -500.0) {
tmp = atan2(t_4, ((1.0 * sin(phi2)) - t_2));
} else if ((lambda1 - lambda2) <= 4e-6) {
tmp = atan2(((lambda1 + (-1.0 * lambda2)) * cos(phi2)), (t_1 - t_2));
} else if ((lambda1 - lambda2) <= 4e+100) {
tmp = atan2(t_4, (t_1 - (t_0 * sin(phi1))));
} else {
tmp = t_3;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = cos(phi1) * sin(phi2)
t_2 = (sin(phi1) * cos(phi2)) * t_0
t_3 = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
t_4 = sin((lambda1 - lambda2)) * cos(phi2)
if ((lambda1 - lambda2) <= (-1d+193)) then
tmp = t_3
else if ((lambda1 - lambda2) <= (-500.0d0)) then
tmp = atan2(t_4, ((1.0d0 * sin(phi2)) - t_2))
else if ((lambda1 - lambda2) <= 4d-6) then
tmp = atan2(((lambda1 + ((-1.0d0) * lambda2)) * cos(phi2)), (t_1 - t_2))
else if ((lambda1 - lambda2) <= 4d+100) then
tmp = atan2(t_4, (t_1 - (t_0 * sin(phi1))))
else
tmp = t_3
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.cos(phi1) * Math.sin(phi2);
double t_2 = (Math.sin(phi1) * Math.cos(phi2)) * t_0;
double t_3 = Math.atan2((((Math.sin(lambda1) * Math.cos(lambda2)) - (Math.sin(lambda2) * Math.cos(lambda1))) * Math.cos(phi2)), Math.sin(phi2));
double t_4 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if ((lambda1 - lambda2) <= -1e+193) {
tmp = t_3;
} else if ((lambda1 - lambda2) <= -500.0) {
tmp = Math.atan2(t_4, ((1.0 * Math.sin(phi2)) - t_2));
} else if ((lambda1 - lambda2) <= 4e-6) {
tmp = Math.atan2(((lambda1 + (-1.0 * lambda2)) * Math.cos(phi2)), (t_1 - t_2));
} else if ((lambda1 - lambda2) <= 4e+100) {
tmp = Math.atan2(t_4, (t_1 - (t_0 * Math.sin(phi1))));
} else {
tmp = t_3;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(phi1) * math.sin(phi2) t_2 = (math.sin(phi1) * math.cos(phi2)) * t_0 t_3 = math.atan2((((math.sin(lambda1) * math.cos(lambda2)) - (math.sin(lambda2) * math.cos(lambda1))) * math.cos(phi2)), math.sin(phi2)) t_4 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if (lambda1 - lambda2) <= -1e+193: tmp = t_3 elif (lambda1 - lambda2) <= -500.0: tmp = math.atan2(t_4, ((1.0 * math.sin(phi2)) - t_2)) elif (lambda1 - lambda2) <= 4e-6: tmp = math.atan2(((lambda1 + (-1.0 * lambda2)) * math.cos(phi2)), (t_1 - t_2)) elif (lambda1 - lambda2) <= 4e+100: tmp = math.atan2(t_4, (t_1 - (t_0 * math.sin(phi1)))) else: tmp = t_3 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi1) * sin(phi2)) t_2 = Float64(Float64(sin(phi1) * cos(phi2)) * t_0) t_3 = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)) t_4 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1e+193) tmp = t_3; elseif (Float64(lambda1 - lambda2) <= -500.0) tmp = atan(t_4, Float64(Float64(1.0 * sin(phi2)) - t_2)); elseif (Float64(lambda1 - lambda2) <= 4e-6) tmp = atan(Float64(Float64(lambda1 + Float64(-1.0 * lambda2)) * cos(phi2)), Float64(t_1 - t_2)); elseif (Float64(lambda1 - lambda2) <= 4e+100) tmp = atan(t_4, Float64(t_1 - Float64(t_0 * sin(phi1)))); else tmp = t_3; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(phi1) * sin(phi2); t_2 = (sin(phi1) * cos(phi2)) * t_0; t_3 = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); t_4 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if ((lambda1 - lambda2) <= -1e+193) tmp = t_3; elseif ((lambda1 - lambda2) <= -500.0) tmp = atan2(t_4, ((1.0 * sin(phi2)) - t_2)); elseif ((lambda1 - lambda2) <= 4e-6) tmp = atan2(((lambda1 + (-1.0 * lambda2)) * cos(phi2)), (t_1 - t_2)); elseif ((lambda1 - lambda2) <= 4e+100) tmp = atan2(t_4, (t_1 - (t_0 * sin(phi1)))); else tmp = t_3; 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[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$3 = 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]}, Block[{t$95$4 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+193], t$95$3, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -500.0], N[ArcTan[t$95$4 / N[(N[(1.0 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 4e-6], N[ArcTan[N[(N[(lambda1 + N[(-1.0 * lambda2), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - t$95$2), $MachinePrecision]], $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 4e+100], N[ArcTan[t$95$4 / N[(t$95$1 - N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_1 \cdot \sin \phi_2\\
t_2 := \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\\
t_3 := \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}\\
t_4 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+193}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq -500:\\
\;\;\;\;\tan^{-1}_* \frac{t\_4}{1 \cdot \sin \phi_2 - t\_2}\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\left(\lambda_1 + -1 \cdot \lambda_2\right) \cdot \cos \phi_2}{t\_1 - t\_2}\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 4 \cdot 10^{+100}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_4}{t\_1 - t\_0 \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000007e193 or 4.00000000000000006e100 < (-.f64 lambda1 lambda2) Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.6%
Applied rewrites58.6%
if -1.00000000000000007e193 < (-.f64 lambda1 lambda2) < -500Initial program 78.9%
Taylor expanded in phi1 around 0
Applied rewrites65.6%
if -500 < (-.f64 lambda1 lambda2) < 3.99999999999999982e-6Initial program 78.9%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lower-sin.64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.6459.1%
Applied rewrites59.1%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-*.f6439.3%
Applied rewrites39.3%
if 3.99999999999999982e-6 < (-.f64 lambda1 lambda2) < 4.00000000000000006e100Initial program 78.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6465.8%
Applied rewrites65.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -7e-21)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
(if (<= lambda2 2.7e-9)
(atan2
(* (sin lambda1) (cos phi2))
(-
(* (cos phi1) (sin phi2))
(* (* (sin phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(atan2
(fma
-1.0
(* (cos lambda1) (* (cos phi2) (sin lambda2)))
(* (cos lambda2) (* (cos phi2) (sin lambda1))))
(sin phi2)))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -7e-21) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} else if (lambda2 <= 2.7e-9) {
tmp = atan2((sin(lambda1) * cos(phi2)), ((cos(phi1) * sin(phi2)) - ((sin(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = atan2(fma(-1.0, (cos(lambda1) * (cos(phi2) * sin(lambda2))), (cos(lambda2) * (cos(phi2) * sin(lambda1)))), sin(phi2));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -7e-21) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); elseif (lambda2 <= 2.7e-9) tmp = atan(Float64(sin(lambda1) * cos(phi2)), Float64(Float64(cos(phi1) * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))); else tmp = atan(fma(-1.0, Float64(cos(lambda1) * Float64(cos(phi2) * sin(lambda2))), Float64(cos(lambda2) * Float64(cos(phi2) * sin(lambda1)))), sin(phi2)); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -7e-21], 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], If[LessEqual[lambda2, 2.7e-9], N[ArcTan[N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(-1.0 * N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -7 \cdot 10^{-21}:\\
\;\;\;\;\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{elif}\;\lambda_2 \leq 2.7 \cdot 10^{-9}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \lambda_1 \cdot \cos \phi_2}{\cos \phi_1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{fma}\left(-1, \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \sin \lambda_2\right), \cos \lambda_2 \cdot \left(\cos \phi_2 \cdot \sin \lambda_1\right)\right)}{\sin \phi_2}\\
\end{array}
if lambda2 < -7.0000000000000007e-21Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.6%
Applied rewrites58.6%
if -7.0000000000000007e-21 < lambda2 < 2.7000000000000002e-9Initial program 78.9%
Taylor expanded in lambda2 around 0
lower-sin.6447.4%
Applied rewrites47.4%
if 2.7000000000000002e-9 < lambda2 Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-*.f64N/A
*-commutativeN/A
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lift-sin.64N/A
lift-cos.64N/A
lift-*.f64N/A
lift-cos.64N/A
lift-sin.64N/A
*-commutativeN/A
lift-*.f64N/A
sub-flipN/A
distribute-rgt-inN/A
lower-fma.f64N/A
Applied rewrites31.9%
Taylor expanded in lambda1 around inf
lower-fma.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-sin.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-sin.6458.6%
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2))))
(if (<= phi1 -1.14e+27)
(atan2 t_1 (- (* (cos phi1) (sin phi2)) (* t_0 (sin phi1))))
(if (<= phi1 1460000000.0)
(atan2
(*
(- (* (sin lambda1) (cos lambda2)) (* (sin lambda2) (cos lambda1)))
(cos phi2))
(sin phi2))
(atan2 t_1 (- (* 1.0 (sin phi2)) (* (* (sin phi1) (cos phi2)) t_0)))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((lambda1 - lambda2)) * cos(phi2);
double tmp;
if (phi1 <= -1.14e+27) {
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_0 * sin(phi1))));
} else if (phi1 <= 1460000000.0) {
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2));
} else {
tmp = atan2(t_1, ((1.0 * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = sin((lambda1 - lambda2)) * cos(phi2)
if (phi1 <= (-1.14d+27)) then
tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_0 * sin(phi1))))
else if (phi1 <= 1460000000.0d0) then
tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2))
else
tmp = atan2(t_1, ((1.0d0 * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((lambda1 - lambda2)) * Math.cos(phi2);
double tmp;
if (phi1 <= -1.14e+27) {
tmp = Math.atan2(t_1, ((Math.cos(phi1) * Math.sin(phi2)) - (t_0 * Math.sin(phi1))));
} else if (phi1 <= 1460000000.0) {
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_1, ((1.0 * Math.sin(phi2)) - ((Math.sin(phi1) * Math.cos(phi2)) * t_0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((lambda1 - lambda2)) * math.cos(phi2) tmp = 0 if phi1 <= -1.14e+27: tmp = math.atan2(t_1, ((math.cos(phi1) * math.sin(phi2)) - (t_0 * math.sin(phi1)))) elif phi1 <= 1460000000.0: 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_1, ((1.0 * math.sin(phi2)) - ((math.sin(phi1) * math.cos(phi2)) * t_0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)) tmp = 0.0 if (phi1 <= -1.14e+27) tmp = atan(t_1, Float64(Float64(cos(phi1) * sin(phi2)) - Float64(t_0 * sin(phi1)))); elseif (phi1 <= 1460000000.0) tmp = atan(Float64(Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = atan(t_1, Float64(Float64(1.0 * sin(phi2)) - Float64(Float64(sin(phi1) * cos(phi2)) * t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((lambda1 - lambda2)) * cos(phi2); tmp = 0.0; if (phi1 <= -1.14e+27) tmp = atan2(t_1, ((cos(phi1) * sin(phi2)) - (t_0 * sin(phi1)))); elseif (phi1 <= 1460000000.0) tmp = atan2((((sin(lambda1) * cos(lambda2)) - (sin(lambda2) * cos(lambda1))) * cos(phi2)), sin(phi2)); else tmp = atan2(t_1, ((1.0 * sin(phi2)) - ((sin(phi1) * cos(phi2)) * t_0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.14e+27], N[ArcTan[t$95$1 / N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[phi1, 1460000000.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[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[t$95$1 / N[(N[(1.0 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -1.14 \cdot 10^{+27}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\cos \phi_1 \cdot \sin \phi_2 - t\_0 \cdot \sin \phi_1}\\
\mathbf{elif}\;\phi_1 \leq 1460000000:\\
\;\;\;\;\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\_1}{1 \cdot \sin \phi_2 - \left(\sin \phi_1 \cdot \cos \phi_2\right) \cdot t\_0}\\
\end{array}
if phi1 < -1.1400000000000001e27Initial program 78.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6465.8%
Applied rewrites65.8%
if -1.1400000000000001e27 < phi1 < 1.46e9Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.6%
Applied rewrites58.6%
if 1.46e9 < phi1 Initial program 78.9%
Taylor expanded in phi1 around 0
Applied rewrites65.6%
(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 -1.14e+27)
t_0
(if (<= phi1 1460000000.0)
(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 <= -1.14e+27) {
tmp = t_0;
} else if (phi1 <= 1460000000.0) {
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 <= (-1.14d+27)) then
tmp = t_0
else if (phi1 <= 1460000000.0d0) 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 <= -1.14e+27) {
tmp = t_0;
} else if (phi1 <= 1460000000.0) {
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 <= -1.14e+27: tmp = t_0 elif phi1 <= 1460000000.0: 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 <= -1.14e+27) tmp = t_0; elseif (phi1 <= 1460000000.0) 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 <= -1.14e+27) tmp = t_0; elseif (phi1 <= 1460000000.0) 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, -1.14e+27], t$95$0, If[LessEqual[phi1, 1460000000.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[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 -1.14 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 1460000000:\\
\;\;\;\;\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 < -1.1400000000000001e27 or 1.46e9 < phi1 Initial program 78.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6465.8%
Applied rewrites65.8%
if -1.1400000000000001e27 < phi1 < 1.46e9Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.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 -1.14e+27)
t_0
(if (<= phi1 1460000000.0)
(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 <= -1.14e+27) {
tmp = t_0;
} else if (phi1 <= 1460000000.0) {
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 <= (-1.14d+27)) then
tmp = t_0
else if (phi1 <= 1460000000.0d0) 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 <= -1.14e+27) {
tmp = t_0;
} else if (phi1 <= 1460000000.0) {
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 <= -1.14e+27: tmp = t_0 elif phi1 <= 1460000000.0: 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 <= -1.14e+27) tmp = t_0; elseif (phi1 <= 1460000000.0) 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 <= -1.14e+27) tmp = t_0; elseif (phi1 <= 1460000000.0) 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, -1.14e+27], t$95$0, If[LessEqual[phi1, 1460000000.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[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 -1.14 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq 1460000000:\\
\;\;\;\;\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 < -1.1400000000000001e27 or 1.46e9 < phi1 Initial program 78.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6448.3%
Applied rewrites48.3%
if -1.1400000000000001e27 < phi1 < 1.46e9Initial program 78.9%
lift-sin.64N/A
lift--.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.64N/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.64N/A
lower-cos.6489.1%
Applied rewrites89.1%
lift-cos.64N/A
lift--.f64N/A
cos-diffN/A
sum-to-multN/A
lower-unsound-*.f64N/A
lower-unsound-+.f64N/A
lower-unsound-/.f64N/A
lift-sin.64N/A
lift-sin.64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f64N/A
lift-cos.64N/A
lift-cos.64N/A
lower-*.f6499.7%
Applied rewrites99.7%
Taylor expanded in phi1 around 0
lower-sin.6458.6%
Applied rewrites58.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin (- lambda1 lambda2)) (cos phi2)))
(t_2 (atan2 t_1 (* -1.0 (* t_0 (sin phi1))))))
(if (<= phi1 -0.72)
t_2
(if (<= phi1 260000.0)
(atan2 t_1 (+ (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 - lambda2)) * cos(phi2);
double t_2 = atan2(t_1, (-1.0 * (t_0 * sin(phi1))));
double tmp;
if (phi1 <= -0.72) {
tmp = t_2;
} else if (phi1 <= 260000.0) {
tmp = atan2(t_1, (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 - lambda2)) * cos(phi2)
t_2 = atan2(t_1, ((-1.0d0) * (t_0 * sin(phi1))))
if (phi1 <= (-0.72d0)) then
tmp = t_2
else if (phi1 <= 260000.0d0) then
tmp = atan2(t_1, (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 - lambda2)) * Math.cos(phi2);
double t_2 = Math.atan2(t_1, (-1.0 * (t_0 * Math.sin(phi1))));
double tmp;
if (phi1 <= -0.72) {
tmp = t_2;
} else if (phi1 <= 260000.0) {
tmp = Math.atan2(t_1, (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 - lambda2)) * math.cos(phi2) t_2 = math.atan2(t_1, (-1.0 * (t_0 * math.sin(phi1)))) tmp = 0 if phi1 <= -0.72: tmp = t_2 elif phi1 <= 260000.0: tmp = math.atan2(t_1, (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(Float64(lambda1 - lambda2)) * cos(phi2)) t_2 = atan(t_1, Float64(-1.0 * Float64(t_0 * sin(phi1)))) tmp = 0.0 if (phi1 <= -0.72) tmp = t_2; elseif (phi1 <= 260000.0) tmp = atan(t_1, 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 - lambda2)) * cos(phi2); t_2 = atan2(t_1, (-1.0 * (t_0 * sin(phi1)))); tmp = 0.0; if (phi1 <= -0.72) tmp = t_2; elseif (phi1 <= 260000.0) tmp = atan2(t_1, (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[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[t$95$1 / N[(-1.0 * N[(t$95$0 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.72], t$95$2, If[LessEqual[phi1, 260000.0], N[ArcTan[t$95$1 / 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 \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\\
t_2 := \tan^{-1}_* \frac{t\_1}{-1 \cdot \left(t\_0 \cdot \sin \phi_1\right)}\\
\mathbf{if}\;\phi_1 \leq -0.72:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;\phi_1 \leq 260000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_1}{\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.71999999999999997 or 2.6e5 < phi1 Initial program 78.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6448.3%
Applied rewrites48.3%
if -0.71999999999999997 < phi1 < 2.6e5Initial program 78.9%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-sin.64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-cos.64N/A
lower--.f6448.4%
Applied rewrites48.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 -0.000125)
t_1
(if (<= phi2 9.5e-16)
(atan2
(* t_0 (fma (* phi2 phi2) -0.5 1.0))
(- (* phi2 (cos phi1)) (* (cos (- lambda1 lambda2)) (sin phi1))))
t_1))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = atan2((t_0 * cos(phi2)), sin(phi2));
double tmp;
if (phi2 <= -0.000125) {
tmp = t_1;
} else if (phi2 <= 9.5e-16) {
tmp = atan2((t_0 * fma((phi2 * phi2), -0.5, 1.0)), ((phi2 * cos(phi1)) - (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 <= -0.000125) tmp = t_1; elseif (phi2 <= 9.5e-16) tmp = atan(Float64(t_0 * fma(Float64(phi2 * phi2), -0.5, 1.0)), Float64(Float64(phi2 * cos(phi1)) - 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, -0.000125], t$95$1, If[LessEqual[phi2, 9.5e-16], N[ArcTan[N[(t$95$0 * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(phi2 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\sin \phi_2}\\
\mathbf{if}\;\phi_2 \leq -0.000125:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 9.5 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\phi_2 \cdot \cos \phi_1 - \cos \left(\lambda_1 - \lambda_2\right) \cdot \sin \phi_1}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi2 < -1.25e-4 or 9.5000000000000005e-16 < phi2 Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
if -1.25e-4 < phi2 < 9.5000000000000005e-16Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.5%
lift-pow.64N/A
unpow2N/A
lower-*.f6429.5%
Applied rewrites29.5%
Taylor expanded in phi2 around 0
lower--.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6445.6%
Applied rewrites45.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 -2.8)
t_1
(if (<= phi1 1460000000.0) (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 <= -2.8) {
tmp = t_1;
} else if (phi1 <= 1460000000.0) {
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 <= (-2.8d0)) then
tmp = t_1
else if (phi1 <= 1460000000.0d0) 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 <= -2.8) {
tmp = t_1;
} else if (phi1 <= 1460000000.0) {
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 <= -2.8: tmp = t_1 elif phi1 <= 1460000000.0: 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 <= -2.8) tmp = t_1; elseif (phi1 <= 1460000000.0) 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 <= -2.8) tmp = t_1; elseif (phi1 <= 1460000000.0) 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, -2.8], t$95$1, If[LessEqual[phi1, 1460000000.0], 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 -2.8:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_1 \leq 1460000000:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if phi1 < -2.7999999999999998 or 1.46e9 < phi1 Initial program 78.9%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6448.3%
Applied rewrites48.3%
if -2.7999999999999998 < phi1 < 1.46e9Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (atan2 (* t_0 (cos phi2)) (sin phi2))))
(if (<= phi2 -0.00084)
t_1
(if (<= phi2 2.25e-20)
(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 <= -0.00084) {
tmp = t_1;
} else if (phi2 <= 2.25e-20) {
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 <= -0.00084) tmp = t_1; elseif (phi2 <= 2.25e-20) 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, -0.00084], t$95$1, If[LessEqual[phi2, 2.25e-20], 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 -0.00084:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\phi_2 \leq 2.25 \cdot 10^{-20}:\\
\;\;\;\;\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 < -8.4000000000000003e-4 or 2.2500000000000001e-20 < phi2 Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
if -8.4000000000000003e-4 < phi2 < 2.2500000000000001e-20Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.5%
lift-pow.64N/A
unpow2N/A
lower-*.f6429.5%
Applied rewrites29.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-*.f64N/A
lower-cos.64N/A
lower--.f64N/A
lower-sin.6443.8%
Applied rewrites43.8%
(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 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (atan2 (* (sin (- lambda2)) (cos phi2)) (sin phi2))))
(if (<= phi2 -4.4e-11)
t_0
(if (<= phi2 9e-16)
(atan2
(* (sin (- lambda1 lambda2)) (fma (* phi2 phi2) -0.5 1.0))
(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 (phi2 <= -4.4e-11) {
tmp = t_0;
} else if (phi2 <= 9e-16) {
tmp = atan2((sin((lambda1 - lambda2)) * fma((phi2 * phi2), -0.5, 1.0)), 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 (phi2 <= -4.4e-11) tmp = t_0; elseif (phi2 <= 9e-16) tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * fma(Float64(phi2 * phi2), -0.5, 1.0)), sin(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[Sin[phi2], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.4e-11], t$95$0, If[LessEqual[phi2, 9e-16], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $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}\;\phi_2 \leq -4.4 \cdot 10^{-11}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 9 \cdot 10^{-16}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if phi2 < -4.4000000000000003e-11 or 9.0000000000000003e-16 < phi2 Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in lambda1 around 0
lower-sin.64N/A
lower-neg.f6432.9%
Applied rewrites32.9%
if -4.4000000000000003e-11 < phi2 < 9.0000000000000003e-16Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.5%
lift-pow.64N/A
unpow2N/A
lower-*.f6429.5%
Applied rewrites29.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 -4.4e-11)
(atan2 (* (sin (- lambda2)) (fma (* phi2 phi2) -0.5 1.0)) (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 <= -4.4e-11) {
tmp = atan2((sin(-lambda2) * fma((phi2 * phi2), -0.5, 1.0)), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * cos(phi2)), (phi2 * (1.0 + (-0.16666666666666666 * pow(phi2, 2.0)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -4.4e-11) tmp = atan(Float64(sin(Float64(-lambda2)) * fma(Float64(phi2 * phi2), -0.5, 1.0)), 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
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -4.4e-11], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $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 -4.4 \cdot 10^{-11}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)}{\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 < -4.4000000000000003e-11Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.5%
lift-pow.64N/A
unpow2N/A
lower-*.f6429.5%
Applied rewrites29.5%
Taylor expanded in lambda1 around 0
lower-sin.64N/A
lower-neg.f6422.9%
Applied rewrites22.9%
if -4.4000000000000003e-11 < phi2 Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6431.7%
Applied rewrites31.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (fma (* phi2 phi2) -0.5 1.0)))
(if (<= phi2 -4.4e-11)
(atan2 (* (sin (- lambda2)) t_0) (sin phi2))
(atan2
(* (sin (- lambda1 lambda2)) t_0)
(* phi2 (+ 1.0 (* -0.16666666666666666 (pow phi2 2.0))))))))double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma((phi2 * phi2), -0.5, 1.0);
double tmp;
if (phi2 <= -4.4e-11) {
tmp = atan2((sin(-lambda2) * t_0), sin(phi2));
} else {
tmp = atan2((sin((lambda1 - lambda2)) * t_0), (phi2 * (1.0 + (-0.16666666666666666 * pow(phi2, 2.0)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = fma(Float64(phi2 * phi2), -0.5, 1.0) tmp = 0.0 if (phi2 <= -4.4e-11) tmp = atan(Float64(sin(Float64(-lambda2)) * t_0), sin(phi2)); else tmp = atan(Float64(sin(Float64(lambda1 - lambda2)) * 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[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision]}, If[LessEqual[phi2, -4.4e-11], N[ArcTan[N[(N[Sin[(-lambda2)], $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[phi2], $MachinePrecision]], $MachinePrecision], N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(phi2 * N[(1.0 + N[(-0.16666666666666666 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_0 := \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right)\\
\mathbf{if}\;\phi_2 \leq -4.4 \cdot 10^{-11}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(-\lambda_2\right) \cdot t\_0}{\sin \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot t\_0}{\phi_2 \cdot \left(1 + -0.16666666666666666 \cdot {\phi_2}^{2}\right)}\\
\end{array}
if phi2 < -4.4000000000000003e-11Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.5%
lift-pow.64N/A
unpow2N/A
lower-*.f6429.5%
Applied rewrites29.5%
Taylor expanded in lambda1 around 0
lower-sin.64N/A
lower-neg.f6422.9%
Applied rewrites22.9%
if -4.4000000000000003e-11 < phi2 Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.5%
lift-pow.64N/A
unpow2N/A
lower-*.f6429.5%
Applied rewrites29.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.1%
Applied rewrites29.1%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (atan2 (* (sin (- lambda1 lambda2)) (fma (* phi2 phi2) -0.5 1.0)) (sin phi2)))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * fma((phi2 * phi2), -0.5, 1.0)), sin(phi2));
}
function code(lambda1, lambda2, phi1, phi2) return atan(Float64(sin(Float64(lambda1 - lambda2)) * fma(Float64(phi2 * phi2), -0.5, 1.0)), sin(phi2)) 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[Sin[phi2], $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)}{\sin \phi_2}
Initial program 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.5%
lift-pow.64N/A
unpow2N/A
lower-*.f6429.5%
Applied rewrites29.5%
(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 78.9%
Taylor expanded in phi1 around 0
lower-sin.6448.6%
Applied rewrites48.6%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.5%
Applied rewrites29.5%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6429.5%
lift-pow.64N/A
unpow2N/A
lower-*.f6429.5%
Applied rewrites29.5%
Taylor expanded in phi2 around 0
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-pow.6429.1%
Applied rewrites29.1%
herbie shell --seed 2025183
(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))))))