
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Herbie found 19 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2)))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(*
(fma (cos (- lambda2 lambda1)) (/ (cos phi2) (cos phi1)) 1.0)
(cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (fma(cos((lambda2 - lambda1)), (cos(phi2) / cos(phi1)), 1.0) * cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(fma(cos(Float64(lambda2 - lambda1)), Float64(cos(phi2) / cos(phi1)), 1.0) * cos(phi1)))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] / N[Cos[phi1], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right), \frac{\cos \phi_2}{\cos \phi_1}, 1\right) \cdot \cos \phi_1}
\end{array}
Initial program 98.7%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift--.f64N/A
sub-negate-revN/A
lower--.f64N/A
lower-/.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (fma (cos (- lambda2 lambda1)) (cos phi2) (cos phi1))) lambda1))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(cos((lambda2 - lambda1)), cos(phi2), cos(phi1))) + lambda1;
}
function code(lambda1, lambda2, phi1, phi2) return Float64(atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(cos(Float64(lambda2 - lambda1)), cos(phi2), cos(phi1))) + lambda1) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right), \cos \phi_2, \cos \phi_1\right)} + \lambda_1
\end{array}
Initial program 98.7%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ (atan2 (* (sin (- lambda1 lambda2)) (cos phi2)) (fma (cos lambda2) (cos phi2) (cos phi1))) lambda1))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return atan2((sin((lambda1 - lambda2)) * cos(phi2)), fma(cos(lambda2), cos(phi2), cos(phi1))) + lambda1;
}
function code(lambda1, lambda2, phi1, phi2) return Float64(atan(Float64(sin(Float64(lambda1 - lambda2)) * cos(phi2)), fma(cos(lambda2), cos(phi2), cos(phi1))) + lambda1) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcTan[N[(N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)} + \lambda_1
\end{array}
Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6497.9
Applied rewrites97.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(if (<= phi2 0.0065)
(+
lambda1
(atan2 (* t_1 t_0) (+ (cos phi1) (* t_1 (cos (- lambda1 lambda2))))))
(+
(atan2
(* t_0 (cos phi2))
(fma
(cos (- lambda2 lambda1))
(cos phi2)
(+ 1.0 (* -0.5 (pow phi1 2.0)))))
lambda1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = 1.0 + (-0.5 * pow(phi2, 2.0));
double tmp;
if (phi2 <= 0.0065) {
tmp = lambda1 + atan2((t_1 * t_0), (cos(phi1) + (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = atan2((t_0 * cos(phi2)), fma(cos((lambda2 - lambda1)), cos(phi2), (1.0 + (-0.5 * pow(phi1, 2.0))))) + lambda1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) tmp = 0.0 if (phi2 <= 0.0065) tmp = Float64(lambda1 + atan(Float64(t_1 * t_0), Float64(cos(phi1) + Float64(t_1 * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(atan(Float64(t_0 * cos(phi2)), fma(cos(Float64(lambda2 - lambda1)), cos(phi2), Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))))) + lambda1); 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[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.0065], N[(lambda1 + N[ArcTan[N[(t$95$1 * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[(t$95$0 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := 1 + -0.5 \cdot {\phi_2}^{2}\\
\mathbf{if}\;\phi_2 \leq 0.0065:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot t\_0}{\cos \phi_1 + t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{t\_0 \cdot \cos \phi_2}{\mathsf{fma}\left(\cos \left(\lambda_2 - \lambda_1\right), \cos \phi_2, 1 + -0.5 \cdot {\phi_1}^{2}\right)} + \lambda_1\\
\end{array}
\end{array}
if phi2 < 0.0064999999999999997Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.7
Applied rewrites76.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6477.3
Applied rewrites77.3%
if 0.0064999999999999997 < phi2 Initial program 98.7%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6498.7
Applied rewrites98.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6480.1
Applied rewrites80.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(if (<= phi2 0.0065)
(+ lambda1 (atan2 (* t_2 t_0) (+ (cos phi1) (* t_2 t_1))))
(+
lambda1
(atan2
(* (cos phi2) t_0)
(+ 1.0 (fma -0.5 (pow phi1 2.0) (* (cos phi2) t_1))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos((lambda1 - lambda2));
double t_2 = 1.0 + (-0.5 * pow(phi2, 2.0));
double tmp;
if (phi2 <= 0.0065) {
tmp = lambda1 + atan2((t_2 * t_0), (cos(phi1) + (t_2 * t_1)));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + fma(-0.5, pow(phi1, 2.0), (cos(phi2) * t_1))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) tmp = 0.0 if (phi2 <= 0.0065) tmp = Float64(lambda1 + atan(Float64(t_2 * t_0), Float64(cos(phi1) + Float64(t_2 * t_1)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + fma(-0.5, (phi1 ^ 2.0), Float64(cos(phi2) * 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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.0065], N[(lambda1 + N[ArcTan[N[(t$95$2 * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := 1 + -0.5 \cdot {\phi_2}^{2}\\
\mathbf{if}\;\phi_2 \leq 0.0065:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2 \cdot t\_0}{\cos \phi_1 + t\_2 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \mathsf{fma}\left(-0.5, {\phi_1}^{2}, \cos \phi_2 \cdot t\_1\right)}\\
\end{array}
\end{array}
if phi2 < 0.0064999999999999997Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.7
Applied rewrites76.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6477.3
Applied rewrites77.3%
if 0.0064999999999999997 < phi2 Initial program 98.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6480.1
Applied rewrites80.1%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(if (<= phi2 0.0065)
(+
lambda1
(atan2 (* t_1 t_0) (+ (cos phi1) (* t_1 (cos (- lambda1 lambda2))))))
(+
lambda1
(atan2
(* (cos phi2) t_0)
(+
(+ 1.0 (* -0.5 (pow phi1 2.0)))
(* (cos phi2) (cos (- lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = 1.0 + (-0.5 * pow(phi2, 2.0));
double tmp;
if (phi2 <= 0.0065) {
tmp = lambda1 + atan2((t_1 * t_0), (cos(phi1) + (t_1 * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0 + (-0.5 * pow(phi1, 2.0))) + (cos(phi2) * cos(-lambda2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = 1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))
if (phi2 <= 0.0065d0) then
tmp = lambda1 + atan2((t_1 * t_0), (cos(phi1) + (t_1 * cos((lambda1 - lambda2)))))
else
tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) + (cos(phi2) * cos(-lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = 1.0 + (-0.5 * Math.pow(phi2, 2.0));
double tmp;
if (phi2 <= 0.0065) {
tmp = lambda1 + Math.atan2((t_1 * t_0), (Math.cos(phi1) + (t_1 * Math.cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) + (Math.cos(phi2) * Math.cos(-lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = 1.0 + (-0.5 * math.pow(phi2, 2.0)) tmp = 0 if phi2 <= 0.0065: tmp = lambda1 + math.atan2((t_1 * t_0), (math.cos(phi1) + (t_1 * math.cos((lambda1 - lambda2))))) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), ((1.0 + (-0.5 * math.pow(phi1, 2.0))) + (math.cos(phi2) * math.cos(-lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) tmp = 0.0 if (phi2 <= 0.0065) tmp = Float64(lambda1 + atan(Float64(t_1 * t_0), Float64(cos(phi1) + Float64(t_1 * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) + Float64(cos(phi2) * cos(Float64(-lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = 1.0 + (-0.5 * (phi2 ^ 2.0)); tmp = 0.0; if (phi2 <= 0.0065) tmp = lambda1 + atan2((t_1 * t_0), (cos(phi1) + (t_1 * cos((lambda1 - lambda2))))); else tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0 + (-0.5 * (phi1 ^ 2.0))) + (cos(phi2) * cos(-lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.0065], N[(lambda1 + N[ArcTan[N[(t$95$1 * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$1 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := 1 + -0.5 \cdot {\phi_2}^{2}\\
\mathbf{if}\;\phi_2 \leq 0.0065:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot t\_0}{\cos \phi_1 + t\_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\left(1 + -0.5 \cdot {\phi_1}^{2}\right) + \cos \phi_2 \cdot \cos \left(-\lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < 0.0064999999999999997Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.7
Applied rewrites76.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6477.3
Applied rewrites77.3%
if 0.0064999999999999997 < phi2 Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6479.8
Applied rewrites79.8%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2)))
(t_1 (cos (- lambda1 lambda2)))
(t_2 (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(if (<= phi2 0.023)
(+ lambda1 (atan2 (* t_2 t_0) (+ (cos phi1) (* t_2 t_1))))
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ 1.0 (* (cos phi2) t_1)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos((lambda1 - lambda2));
double t_2 = 1.0 + (-0.5 * pow(phi2, 2.0));
double tmp;
if (phi2 <= 0.023) {
tmp = lambda1 + atan2((t_2 * t_0), (cos(phi1) + (t_2 * t_1)));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + (cos(phi2) * t_1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = cos((lambda1 - lambda2))
t_2 = 1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))
if (phi2 <= 0.023d0) then
tmp = lambda1 + atan2((t_2 * t_0), (cos(phi1) + (t_2 * t_1)))
else
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + (cos(phi2) * t_1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.cos((lambda1 - lambda2));
double t_2 = 1.0 + (-0.5 * Math.pow(phi2, 2.0));
double tmp;
if (phi2 <= 0.023) {
tmp = lambda1 + Math.atan2((t_2 * t_0), (Math.cos(phi1) + (t_2 * t_1)));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + (Math.cos(phi2) * t_1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.cos((lambda1 - lambda2)) t_2 = 1.0 + (-0.5 * math.pow(phi2, 2.0)) tmp = 0 if phi2 <= 0.023: tmp = lambda1 + math.atan2((t_2 * t_0), (math.cos(phi1) + (t_2 * t_1))) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + (math.cos(phi2) * t_1))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) t_2 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) tmp = 0.0 if (phi2 <= 0.023) tmp = Float64(lambda1 + atan(Float64(t_2 * t_0), Float64(cos(phi1) + Float64(t_2 * t_1)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + Float64(cos(phi2) * t_1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = cos((lambda1 - lambda2)); t_2 = 1.0 + (-0.5 * (phi2 ^ 2.0)); tmp = 0.0; if (phi2 <= 0.023) tmp = lambda1 + atan2((t_2 * t_0), (cos(phi1) + (t_2 * t_1))); else tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + (cos(phi2) * t_1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.023], N[(lambda1 + N[ArcTan[N[(t$95$2 * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_2 := 1 + -0.5 \cdot {\phi_2}^{2}\\
\mathbf{if}\;\phi_2 \leq 0.023:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_2 \cdot t\_0}{\cos \phi_1 + t\_2 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2 \cdot t\_1}\\
\end{array}
\end{array}
if phi2 < 0.023Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.7
Applied rewrites76.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6477.3
Applied rewrites77.3%
if 0.023 < phi2 Initial program 98.7%
Taylor expanded in phi1 around 0
Applied rewrites78.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (+ 1.0 (* -0.5 (pow phi2 2.0)))))
(if (<= phi2 0.023)
(+ lambda1 (atan2 (* t_1 t_0) (+ (cos phi1) (* t_1 (cos (- lambda2))))))
(+
lambda1
(atan2
(* (cos phi2) t_0)
(+ 1.0 (* (cos phi2) (cos (- lambda1 lambda2)))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = 1.0 + (-0.5 * pow(phi2, 2.0));
double tmp;
if (phi2 <= 0.023) {
tmp = lambda1 + atan2((t_1 * t_0), (cos(phi1) + (t_1 * cos(-lambda2))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + (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) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = 1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))
if (phi2 <= 0.023d0) then
tmp = lambda1 + atan2((t_1 * t_0), (cos(phi1) + (t_1 * cos(-lambda2))))
else
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + (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));
double t_1 = 1.0 + (-0.5 * Math.pow(phi2, 2.0));
double tmp;
if (phi2 <= 0.023) {
tmp = lambda1 + Math.atan2((t_1 * t_0), (Math.cos(phi1) + (t_1 * Math.cos(-lambda2))));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = 1.0 + (-0.5 * math.pow(phi2, 2.0)) tmp = 0 if phi2 <= 0.023: tmp = lambda1 + math.atan2((t_1 * t_0), (math.cos(phi1) + (t_1 * math.cos(-lambda2)))) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) tmp = 0.0 if (phi2 <= 0.023) tmp = Float64(lambda1 + atan(Float64(t_1 * t_0), Float64(cos(phi1) + Float64(t_1 * cos(Float64(-lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = 1.0 + (-0.5 * (phi2 ^ 2.0)); tmp = 0.0; if (phi2 <= 0.023) tmp = lambda1 + atan2((t_1 * t_0), (cos(phi1) + (t_1 * cos(-lambda2)))); else tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + (cos(phi2) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.023], N[(lambda1 + N[ArcTan[N[(t$95$1 * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$1 * N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := 1 + -0.5 \cdot {\phi_2}^{2}\\
\mathbf{if}\;\phi_2 \leq 0.023:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot t\_0}{\cos \phi_1 + t\_1 \cdot \cos \left(-\lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if phi2 < 0.023Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.3
Applied rewrites76.3%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.9
Applied rewrites76.9%
if 0.023 < phi2 Initial program 98.7%
Taylor expanded in phi1 around 0
Applied rewrites78.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (cos phi2) (sin (- lambda1 lambda2)))))
(if (<= phi1 0.29)
(+ lambda1 (atan2 t_1 (+ 1.0 (* (cos phi2) t_0))))
(+ lambda1 (atan2 t_1 (+ (cos phi1) t_0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = cos(phi2) * sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 0.29) {
tmp = lambda1 + atan2(t_1, (1.0 + (cos(phi2) * t_0)));
} else {
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
t_1 = cos(phi2) * sin((lambda1 - lambda2))
if (phi1 <= 0.29d0) then
tmp = lambda1 + atan2(t_1, (1.0d0 + (cos(phi2) * t_0)))
else
tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.cos(phi2) * Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 0.29) {
tmp = lambda1 + Math.atan2(t_1, (1.0 + (Math.cos(phi2) * t_0)));
} else {
tmp = lambda1 + Math.atan2(t_1, (Math.cos(phi1) + t_0));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.cos(phi2) * math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= 0.29: tmp = lambda1 + math.atan2(t_1, (1.0 + (math.cos(phi2) * t_0))) else: tmp = lambda1 + math.atan2(t_1, (math.cos(phi1) + t_0)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= 0.29) tmp = Float64(lambda1 + atan(t_1, Float64(1.0 + Float64(cos(phi2) * t_0)))); else tmp = Float64(lambda1 + atan(t_1, Float64(cos(phi1) + t_0))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = cos(phi2) * sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= 0.29) tmp = lambda1 + atan2(t_1, (1.0 + (cos(phi2) * t_0))); else tmp = lambda1 + atan2(t_1, (cos(phi1) + t_0)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, 0.29], N[(lambda1 + N[ArcTan[t$95$1 / N[(1.0 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$1 / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 0.29:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1}{\cos \phi_1 + t\_0}\\
\end{array}
\end{array}
if phi1 < 0.28999999999999998Initial program 98.7%
Taylor expanded in phi1 around 0
Applied rewrites78.4%
if 0.28999999999999998 < phi1 Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 0.000102)
(+
lambda1
(atan2
(* (+ 1.0 (* -0.5 (pow phi2 2.0))) t_0)
(+ (cos phi1) (cos (- lambda1 lambda2)))))
(+ (atan2 (* (cos phi2) t_0) (fma (cos phi2) 1.0 (cos phi1))) lambda1))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.000102) {
tmp = lambda1 + atan2(((1.0 + (-0.5 * pow(phi2, 2.0))) * t_0), (cos(phi1) + cos((lambda1 - lambda2))));
} else {
tmp = atan2((cos(phi2) * t_0), fma(cos(phi2), 1.0, cos(phi1))) + lambda1;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 0.000102) tmp = Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) * t_0), Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); else tmp = Float64(atan(Float64(cos(phi2) * t_0), fma(cos(phi2), 1.0, cos(phi1))) + lambda1); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.000102], N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi2], $MachinePrecision] * 1.0 + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 0.000102:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot {\phi_2}^{2}\right) \cdot t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\mathsf{fma}\left(\cos \phi_2, 1, \cos \phi_1\right)} + \lambda_1\\
\end{array}
\end{array}
if phi2 < 1.01999999999999999e-4Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.1
Applied rewrites76.1%
if 1.01999999999999999e-4 < phi2 Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in lambda2 around 0
Applied rewrites79.4%
lift-+.f64N/A
+-commutativeN/A
lower-+.f6479.4
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6479.4
Applied rewrites79.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 0.0012)
(+
lambda1
(atan2
(* (+ 1.0 (* -0.5 (pow phi2 2.0))) t_0)
(+ (cos phi1) (cos (- lambda1 lambda2)))))
(+
lambda1
(atan2
(* (cos phi2) t_0)
(+ (+ 1.0 (* -0.5 (pow phi1 2.0))) (* (cos phi2) 1.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.0012) {
tmp = lambda1 + atan2(((1.0 + (-0.5 * pow(phi2, 2.0))) * t_0), (cos(phi1) + cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0 + (-0.5 * pow(phi1, 2.0))) + (cos(phi2) * 1.0)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (phi2 <= 0.0012d0) then
tmp = lambda1 + atan2(((1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))) * t_0), (cos(phi1) + cos((lambda1 - lambda2))))
else
tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) + (cos(phi2) * 1.0d0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.0012) {
tmp = lambda1 + Math.atan2(((1.0 + (-0.5 * Math.pow(phi2, 2.0))) * t_0), (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) + (Math.cos(phi2) * 1.0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 0.0012: tmp = lambda1 + math.atan2(((1.0 + (-0.5 * math.pow(phi2, 2.0))) * t_0), (math.cos(phi1) + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), ((1.0 + (-0.5 * math.pow(phi1, 2.0))) + (math.cos(phi2) * 1.0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 0.0012) tmp = Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) * t_0), Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) + Float64(cos(phi2) * 1.0)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 0.0012) tmp = lambda1 + atan2(((1.0 + (-0.5 * (phi2 ^ 2.0))) * t_0), (cos(phi1) + cos((lambda1 - lambda2)))); else tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0 + (-0.5 * (phi1 ^ 2.0))) + (cos(phi2) * 1.0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.0012], N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 0.0012:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot {\phi_2}^{2}\right) \cdot t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\left(1 + -0.5 \cdot {\phi_1}^{2}\right) + \cos \phi_2 \cdot 1}\\
\end{array}
\end{array}
if phi2 < 0.00119999999999999989Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.1
Applied rewrites76.1%
if 0.00119999999999999989 < phi2 Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in lambda2 around 0
Applied rewrites79.4%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6470.4
Applied rewrites70.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi2 0.014)
(+
lambda1
(atan2 (* (+ 1.0 (* -0.5 (pow phi2 2.0))) t_0) (+ (cos phi1) t_1)))
(+
lambda1
(atan2 (* (cos phi2) t_0) (+ (+ 1.0 (* -0.5 (pow phi1 2.0))) t_1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.014) {
tmp = lambda1 + atan2(((1.0 + (-0.5 * pow(phi2, 2.0))) * t_0), (cos(phi1) + t_1));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0 + (-0.5 * pow(phi1, 2.0))) + t_1));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
t_1 = cos((lambda1 - lambda2))
if (phi2 <= 0.014d0) then
tmp = lambda1 + atan2(((1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))) * t_0), (cos(phi1) + t_1))
else
tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) + t_1))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi2 <= 0.014) {
tmp = lambda1 + Math.atan2(((1.0 + (-0.5 * Math.pow(phi2, 2.0))) * t_0), (Math.cos(phi1) + t_1));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) + t_1));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if phi2 <= 0.014: tmp = lambda1 + math.atan2(((1.0 + (-0.5 * math.pow(phi2, 2.0))) * t_0), (math.cos(phi1) + t_1)) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), ((1.0 + (-0.5 * math.pow(phi1, 2.0))) + t_1)) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 0.014) tmp = Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) * t_0), Float64(cos(phi1) + t_1))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) + t_1))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 0.014) tmp = lambda1 + atan2(((1.0 + (-0.5 * (phi2 ^ 2.0))) * t_0), (cos(phi1) + t_1)); else tmp = lambda1 + atan2((cos(phi2) * t_0), ((1.0 + (-0.5 * (phi1 ^ 2.0))) + t_1)); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 0.014], N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 0.014:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot {\phi_2}^{2}\right) \cdot t\_0}{\cos \phi_1 + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\left(1 + -0.5 \cdot {\phi_1}^{2}\right) + t\_1}\\
\end{array}
\end{array}
if phi2 < 0.0140000000000000003Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6476.1
Applied rewrites76.1%
if 0.0140000000000000003 < phi2 Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6470.5
Applied rewrites70.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (+ 1.0 (* -0.5 (pow phi2 2.0)))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi1 2.5e+64)
(+
lambda1
(atan2
(* (cos phi2) t_1)
(+ (+ 1.0 (* -0.5 (pow phi1 2.0))) (cos (- lambda1 lambda2)))))
(+ lambda1 (atan2 (* t_0 t_1) (+ (cos phi1) (* t_0 1.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 + (-0.5 * pow(phi2, 2.0));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 2.5e+64) {
tmp = lambda1 + atan2((cos(phi2) * t_1), ((1.0 + (-0.5 * pow(phi1, 2.0))) + cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + atan2((t_0 * t_1), (cos(phi1) + (t_0 * 1.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 = 1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))
t_1 = sin((lambda1 - lambda2))
if (phi1 <= 2.5d+64) then
tmp = lambda1 + atan2((cos(phi2) * t_1), ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) + cos((lambda1 - lambda2))))
else
tmp = lambda1 + atan2((t_0 * t_1), (cos(phi1) + (t_0 * 1.0d0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 + (-0.5 * Math.pow(phi2, 2.0));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 2.5e+64) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_1), ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + Math.atan2((t_0 * t_1), (Math.cos(phi1) + (t_0 * 1.0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = 1.0 + (-0.5 * math.pow(phi2, 2.0)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= 2.5e+64: tmp = lambda1 + math.atan2((math.cos(phi2) * t_1), ((1.0 + (-0.5 * math.pow(phi1, 2.0))) + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 + math.atan2((t_0 * t_1), (math.cos(phi1) + (t_0 * 1.0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= 2.5e+64) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) + cos(Float64(lambda1 - lambda2))))); else tmp = Float64(lambda1 + atan(Float64(t_0 * t_1), Float64(cos(phi1) + Float64(t_0 * 1.0)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = 1.0 + (-0.5 * (phi2 ^ 2.0)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= 2.5e+64) tmp = lambda1 + atan2((cos(phi2) * t_1), ((1.0 + (-0.5 * (phi1 ^ 2.0))) + cos((lambda1 - lambda2)))); else tmp = lambda1 + atan2((t_0 * t_1), (cos(phi1) + (t_0 * 1.0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 2.5e+64], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(t$95$0 * t$95$1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -0.5 \cdot {\phi_2}^{2}\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 2.5 \cdot 10^{+64}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{\left(1 + -0.5 \cdot {\phi_1}^{2}\right) + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot t\_1}{\cos \phi_1 + t\_0 \cdot 1}\\
\end{array}
\end{array}
if phi1 < 2.5e64Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6470.5
Applied rewrites70.5%
if 2.5e64 < phi1 Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in lambda2 around 0
Applied rewrites79.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6466.8
Applied rewrites66.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6467.3
Applied rewrites67.3%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (+ 1.0 (* -0.5 (pow phi2 2.0)))) (t_1 (sin (- lambda1 lambda2))))
(if (<= phi1 1.06e+51)
(+ lambda1 (atan2 (* (cos phi2) t_1) (+ 1.0 (cos (- lambda1 lambda2)))))
(+ lambda1 (atan2 (* t_0 t_1) (+ (cos phi1) (* t_0 1.0)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 + (-0.5 * pow(phi2, 2.0));
double t_1 = sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 1.06e+51) {
tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0 + cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + atan2((t_0 * t_1), (cos(phi1) + (t_0 * 1.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 = 1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))
t_1 = sin((lambda1 - lambda2))
if (phi1 <= 1.06d+51) then
tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0d0 + cos((lambda1 - lambda2))))
else
tmp = lambda1 + atan2((t_0 * t_1), (cos(phi1) + (t_0 * 1.0d0)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 + (-0.5 * Math.pow(phi2, 2.0));
double t_1 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi1 <= 1.06e+51) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_1), (1.0 + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + Math.atan2((t_0 * t_1), (Math.cos(phi1) + (t_0 * 1.0)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = 1.0 + (-0.5 * math.pow(phi2, 2.0)) t_1 = math.sin((lambda1 - lambda2)) tmp = 0 if phi1 <= 1.06e+51: tmp = lambda1 + math.atan2((math.cos(phi2) * t_1), (1.0 + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 + math.atan2((t_0 * t_1), (math.cos(phi1) + (t_0 * 1.0))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) t_1 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= 1.06e+51) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_1), Float64(1.0 + cos(Float64(lambda1 - lambda2))))); else tmp = Float64(lambda1 + atan(Float64(t_0 * t_1), Float64(cos(phi1) + Float64(t_0 * 1.0)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = 1.0 + (-0.5 * (phi2 ^ 2.0)); t_1 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= 1.06e+51) tmp = lambda1 + atan2((cos(phi2) * t_1), (1.0 + cos((lambda1 - lambda2)))); else tmp = lambda1 + atan2((t_0 * t_1), (cos(phi1) + (t_0 * 1.0))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 1.06e+51], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(t$95$0 * t$95$1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(t$95$0 * 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -0.5 \cdot {\phi_2}^{2}\\
t_1 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq 1.06 \cdot 10^{+51}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_1}{1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0 \cdot t\_1}{\cos \phi_1 + t\_0 \cdot 1}\\
\end{array}
\end{array}
if phi1 < 1.06000000000000004e51Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6468.7
Applied rewrites68.7%
if 1.06000000000000004e51 < phi1 Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
Taylor expanded in lambda2 around 0
Applied rewrites79.4%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6466.8
Applied rewrites66.8%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6467.3
Applied rewrites67.3%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ 1.0 (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (1.0 + 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 = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (1.0d0 + cos((lambda1 - lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2((Math.cos(phi2) * Math.sin((lambda1 - lambda2))), (1.0 + Math.cos((lambda1 - lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2((math.cos(phi2) * math.sin((lambda1 - lambda2))), (1.0 + math.cos((lambda1 - lambda2))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(1.0 + cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (1.0 + cos((lambda1 - lambda2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6468.7
Applied rewrites68.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (+ 1.0 (cos (- lambda1 lambda2)))))
(if (<= (cos phi2) 0.9998)
(+ lambda1 (atan2 (* (cos phi2) (sin (- lambda2))) t_0))
(+
lambda1
(atan2
(* (+ 1.0 (* -0.5 (pow phi2 2.0))) (sin (- lambda1 lambda2)))
t_0)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 + cos((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.9998) {
tmp = lambda1 + atan2((cos(phi2) * sin(-lambda2)), t_0);
} else {
tmp = lambda1 + atan2(((1.0 + (-0.5 * pow(phi2, 2.0))) * sin((lambda1 - lambda2))), 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 = 1.0d0 + cos((lambda1 - lambda2))
if (cos(phi2) <= 0.9998d0) then
tmp = lambda1 + atan2((cos(phi2) * sin(-lambda2)), t_0)
else
tmp = lambda1 + atan2(((1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))) * sin((lambda1 - lambda2))), t_0)
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 + Math.cos((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.9998) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * Math.sin(-lambda2)), t_0);
} else {
tmp = lambda1 + Math.atan2(((1.0 + (-0.5 * Math.pow(phi2, 2.0))) * Math.sin((lambda1 - lambda2))), t_0);
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = 1.0 + math.cos((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.9998: tmp = lambda1 + math.atan2((math.cos(phi2) * math.sin(-lambda2)), t_0) else: tmp = lambda1 + math.atan2(((1.0 + (-0.5 * math.pow(phi2, 2.0))) * math.sin((lambda1 - lambda2))), t_0) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(1.0 + cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (cos(phi2) <= 0.9998) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(-lambda2))), t_0)); else tmp = Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) * sin(Float64(lambda1 - lambda2))), t_0)); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = 1.0 + cos((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.9998) tmp = lambda1 + atan2((cos(phi2) * sin(-lambda2)), t_0); else tmp = lambda1 + atan2(((1.0 + (-0.5 * (phi2 ^ 2.0))) * sin((lambda1 - lambda2))), t_0); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.9998], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.9998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(-\lambda_2\right)}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot {\phi_2}^{2}\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.99980000000000002Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6468.7
Applied rewrites68.7%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-neg.f6465.8
Applied rewrites65.8%
if 0.99980000000000002 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6468.7
Applied rewrites68.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6466.4
Applied rewrites66.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.999999995)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ 1.0 (cos lambda1))))
(+
lambda1
(atan2
(* (+ 1.0 (* -0.5 (pow phi2 2.0))) t_0)
(+ 1.0 (cos (- lambda1 lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2) <= 0.999999995) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(lambda1)));
} else {
tmp = lambda1 + atan2(((1.0 + (-0.5 * pow(phi2, 2.0))) * t_0), (1.0 + cos((lambda1 - lambda2))));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi2) <= 0.999999995d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + cos(lambda1)))
else
tmp = lambda1 + atan2(((1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))) * t_0), (1.0d0 + cos((lambda1 - lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2) <= 0.999999995) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + Math.cos(lambda1)));
} else {
tmp = lambda1 + Math.atan2(((1.0 + (-0.5 * Math.pow(phi2, 2.0))) * t_0), (1.0 + Math.cos((lambda1 - lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2) <= 0.999999995: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + math.cos(lambda1))) else: tmp = lambda1 + math.atan2(((1.0 + (-0.5 * math.pow(phi2, 2.0))) * t_0), (1.0 + math.cos((lambda1 - lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.999999995) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + cos(lambda1)))); else tmp = Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) * t_0), Float64(1.0 + cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2) <= 0.999999995) tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(lambda1))); else tmp = lambda1 + atan2(((1.0 + (-0.5 * (phi2 ^ 2.0))) * t_0), (1.0 + cos((lambda1 - lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.999999995], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_2 \leq 0.999999995:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot {\phi_2}^{2}\right) \cdot t\_0}{1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.99999999500000003Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6468.7
Applied rewrites68.7%
Taylor expanded in lambda2 around 0
lower-cos.f6463.6
Applied rewrites63.6%
if 0.99999999500000003 < (cos.f64 phi2) Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6468.7
Applied rewrites68.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6466.4
Applied rewrites66.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (+ 1.0 (* -0.5 (pow phi2 2.0))) (sin (- lambda1 lambda2))) (+ 1.0 (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(((1.0 + (-0.5 * pow(phi2, 2.0))) * sin((lambda1 - lambda2))), (1.0 + 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 = lambda1 + atan2(((1.0d0 + ((-0.5d0) * (phi2 ** 2.0d0))) * sin((lambda1 - lambda2))), (1.0d0 + cos((lambda1 - lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(((1.0 + (-0.5 * Math.pow(phi2, 2.0))) * Math.sin((lambda1 - lambda2))), (1.0 + Math.cos((lambda1 - lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(((1.0 + (-0.5 * math.pow(phi2, 2.0))) * math.sin((lambda1 - lambda2))), (1.0 + math.cos((lambda1 - lambda2))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(-0.5 * (phi2 ^ 2.0))) * sin(Float64(lambda1 - lambda2))), Float64(1.0 + cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(((1.0 + (-0.5 * (phi2 ^ 2.0))) * sin((lambda1 - lambda2))), (1.0 + cos((lambda1 - lambda2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(-0.5 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(1 + -0.5 \cdot {\phi_2}^{2}\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-cos.f64N/A
lower--.f6478.7
Applied rewrites78.7%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower--.f6468.7
Applied rewrites68.7%
Taylor expanded in phi2 around 0
lower-+.f64N/A
lower-*.f64N/A
lower-pow.f6466.4
Applied rewrites66.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (* 1.0 lambda1))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return 1.0 * 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 = 1.0d0 * lambda1
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return 1.0 * lambda1;
}
def code(lambda1, lambda2, phi1, phi2): return 1.0 * lambda1
function code(lambda1, lambda2, phi1, phi2) return Float64(1.0 * lambda1) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = 1.0 * lambda1; end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(1.0 * lambda1), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot \lambda_1
\end{array}
Initial program 98.7%
Taylor expanded in lambda1 around 0
lower-cos.f64N/A
lower-neg.f6497.9
Applied rewrites97.9%
lift-+.f64N/A
sum-to-multN/A
lower-*.f64N/A
Applied rewrites97.9%
Taylor expanded in lambda1 around inf
Applied rewrites53.0%
herbie shell --seed 2025144
(FPCore (lambda1 lambda2 phi1 phi2)
:name "Midpoint on a great circle"
:precision binary64
(+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2)))))))