
(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 22 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) (cos lambda2)) (* (cos lambda1) (sin lambda2))))
(+
(cos phi1)
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * ((sin(lambda1) * cos(lambda2)) - (cos(lambda1) * sin(lambda2)))), (cos(phi1) + (cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * cos(lambda2)) - Float64(cos(lambda1) * sin(lambda2)))), Float64(cos(phi1) + Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))) end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \cos \lambda_2 - \cos \lambda_1 \cdot \sin \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.6
Applied rewrites98.6%
lift--.f64N/A
lift-sin.f64N/A
sin-diffN/A
lower--.f64N/A
lower-*.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-sin.f6499.6
Applied rewrites99.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(+
(cos phi1)
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(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[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $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 \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}
\end{array}
Initial program 98.5%
lift--.f64N/A
lift-cos.f64N/A
cos-diffN/A
cos-negN/A
lower-fma.f64N/A
lower-cos.f64N/A
cos-negN/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f6498.6
Applied rewrites98.6%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
lambda1
(atan2
(* (cos phi2) (- (sin lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))))
(if (<= lambda2 -9e-5)
t_0
(if (<= lambda2 1e-13)
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma (cos lambda1) (cos phi2) (cos phi1))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = lambda1 + atan2((cos(phi2) * -sin(lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
double tmp;
if (lambda2 <= -9e-5) {
tmp = t_0;
} else if (lambda2 <= 1e-13) {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(-sin(lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) tmp = 0.0 if (lambda2 <= -9e-5) tmp = t_0; elseif (lambda2 <= 1e-13) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda1), cos(phi2), cos(phi1)))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -9e-5], t$95$0, If[LessEqual[lambda2, 1e-13], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -9 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 10^{-13}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_1, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -9.00000000000000057e-5 or 1e-13 < lambda2 Initial program 97.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.5
Applied rewrites97.5%
Taylor expanded in lambda1 around 0
flip3--N/A
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6497.5
Applied rewrites97.5%
if -9.00000000000000057e-5 < lambda2 < 1e-13Initial program 99.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6499.5
Applied rewrites99.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
lambda1
(atan2
(* (cos phi2) (- (sin lambda2)))
(fma (cos lambda2) (cos phi2) (cos phi1))))))
(if (<= lambda2 -9e-5)
t_0
(if (<= lambda2 1e-13)
(+
lambda1
(atan2
(* (cos phi2) (sin (- lambda1 lambda2)))
(fma
(+
1.0
(*
(* lambda1 lambda1)
(-
(*
(* lambda1 lambda1)
(+
0.041666666666666664
(* -0.001388888888888889 (* lambda1 lambda1))))
0.5)))
(cos phi2)
(cos phi1))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = lambda1 + atan2((cos(phi2) * -sin(lambda2)), fma(cos(lambda2), cos(phi2), cos(phi1)));
double tmp;
if (lambda2 <= -9e-5) {
tmp = t_0;
} else if (lambda2 <= 1e-13) {
tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma((1.0 + ((lambda1 * lambda1) * (((lambda1 * lambda1) * (0.041666666666666664 + (-0.001388888888888889 * (lambda1 * lambda1)))) - 0.5))), cos(phi2), cos(phi1)));
} else {
tmp = t_0;
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(-sin(lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)))) tmp = 0.0 if (lambda2 <= -9e-5) tmp = t_0; elseif (lambda2 <= 1e-13) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(Float64(1.0 + Float64(Float64(lambda1 * lambda1) * Float64(Float64(Float64(lambda1 * lambda1) * Float64(0.041666666666666664 + Float64(-0.001388888888888889 * Float64(lambda1 * lambda1)))) - 0.5))), cos(phi2), cos(phi1)))); else tmp = t_0; end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -9e-5], t$95$0, If[LessEqual[lambda2, 1e-13], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(N[(lambda1 * lambda1), $MachinePrecision] * N[(N[(N[(lambda1 * lambda1), $MachinePrecision] * N[(0.041666666666666664 + N[(-0.001388888888888889 * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Cos[phi2], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -9 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 10^{-13}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(1 + \left(\lambda_1 \cdot \lambda_1\right) \cdot \left(\left(\lambda_1 \cdot \lambda_1\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(\lambda_1 \cdot \lambda_1\right)\right) - 0.5\right), \cos \phi_2, \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -9.00000000000000057e-5 or 1e-13 < lambda2 Initial program 97.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.5
Applied rewrites97.5%
Taylor expanded in lambda1 around 0
flip3--N/A
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6497.5
Applied rewrites97.5%
if -9.00000000000000057e-5 < lambda2 < 1e-13Initial program 99.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6499.5
Applied rewrites99.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6498.4
Applied rewrites98.4%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= (cos phi1) 0.9999998)
(+
lambda1
(atan2 (sin (- lambda1 lambda2)) (+ (cos phi1) (* (cos phi2) t_0))))
(+
lambda1
(atan2
(* (cos phi2) (+ (- (sin lambda2)) lambda1))
(fma t_0 (cos phi2) 1.0))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.9999998) {
tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + (cos(phi2) * t_0)));
} else {
tmp = lambda1 + atan2((cos(phi2) * (-sin(lambda2) + lambda1)), fma(t_0, cos(phi2), 1.0));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.9999998) tmp = Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(phi1) + Float64(cos(phi2) * t_0)))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(Float64(-sin(lambda2)) + lambda1)), fma(t_0, cos(phi2), 1.0))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.9999998], N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * N[((-N[Sin[lambda2], $MachinePrecision]) + lambda1), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[Cos[phi2], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.9999998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \phi_2 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(\left(-\sin \lambda_2\right) + \lambda_1\right)}{\mathsf{fma}\left(t\_0, \cos \phi_2, 1\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.999999799999999994Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.2
Applied rewrites77.2%
if 0.999999799999999994 < (cos.f64 phi1) Initial program 98.5%
Taylor expanded in phi1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f6498.3
Applied rewrites98.3%
Taylor expanded in lambda1 around 0
flip3--N/A
cos-neg-revN/A
lower-+.f64N/A
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f64N/A
lower-*.f64N/A
lift-cos.f6497.6
Applied rewrites97.6%
Taylor expanded in lambda2 around 0
Applied rewrites97.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi1) 0.9999998)
(+
lambda1
(atan2 t_0 (+ (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))))))
(+
lambda1
(atan2 (* (cos phi2) t_0) (+ 1.0 (* (cos phi2) (cos lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.9999998) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.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) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi1) <= 0.9999998d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2)))))
else
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.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 tmp;
if (Math.cos(phi1) <= 0.9999998) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + (Math.cos(phi2) * Math.cos(lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi1) <= 0.9999998: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + (math.cos(phi2) * math.cos(lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.9999998) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + Float64(cos(phi2) * cos(lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi1) <= 0.9999998) tmp = lambda1 + atan2(t_0, (cos(phi1) + (cos(phi2) * cos((lambda1 - lambda2))))); else tmp = lambda1 + atan2((cos(phi2) * t_0), (1.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]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.9999998], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * 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[(1.0 + 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)\\
\mathbf{if}\;\cos \phi_1 \leq 0.9999998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2 \cdot \cos \lambda_2}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.999999799999999994Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.2
Applied rewrites77.2%
if 0.999999799999999994 < (cos.f64 phi1) Initial program 98.5%
Taylor expanded in phi1 around 0
Applied rewrites98.3%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6497.7
Applied rewrites97.7%
(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}
Initial program 98.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.998)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ (cos phi1) (cos phi2))))
(+
lambda1
(atan2
(* (fma (* phi2 phi2) -0.5 1.0) t_0)
(+
(cos phi1)
(*
(+
1.0
(* (* phi2 phi2) (- (* 0.041666666666666664 (* phi2 phi2)) 0.5)))
(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.998) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (cos(phi1) + cos(phi2)));
} else {
tmp = lambda1 + atan2((fma((phi2 * phi2), -0.5, 1.0) * t_0), (cos(phi1) + ((1.0 + ((phi2 * phi2) * ((0.041666666666666664 * (phi2 * phi2)) - 0.5))) * cos((lambda1 - lambda2)))));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2) <= 0.998) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(cos(phi1) + cos(phi2)))); else tmp = Float64(lambda1 + atan(Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * t_0), Float64(cos(phi1) + Float64(Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5))) * cos(Float64(lambda1 - lambda2)))))); end return 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.998], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $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)\\
\mathbf{if}\;\cos \phi_2 \leq 0.998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{\cos \phi_1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot t\_0}{\cos \phi_1 + \left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.998Initial program 98.4%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.8
Applied rewrites97.8%
Taylor expanded in lambda2 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6479.3
Applied rewrites79.3%
if 0.998 < (cos.f64 phi2) Initial program 98.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6497.5
Applied rewrites97.5%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6497.5
Applied rewrites97.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2) (cos lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(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(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(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(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(lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2) * cos(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[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)}{\cos \phi_1 + \cos \phi_2 \cdot \cos \lambda_2}
\end{array}
Initial program 98.5%
Taylor expanded in lambda1 around 0
cos-negN/A
lower-cos.f6497.9
Applied rewrites97.9%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (* (cos phi2) (sin (- lambda1 lambda2))) (fma (cos lambda2) (cos phi2) (cos phi1)))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2((cos(phi2) * sin((lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), cos(phi1)));
}
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(Float64(cos(phi2) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda2), cos(phi2), 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[Cos[lambda2], $MachinePrecision] * N[Cos[phi2], $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 \lambda_2, \cos \phi_2, \cos \phi_1\right)}
\end{array}
Initial program 98.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.9
Applied rewrites97.9%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2) 0.97)
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ 1.0 (cos phi2))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (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.97) {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + 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.97d0) then
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + cos(phi2)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + 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.97) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + 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.97: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + math.cos(phi2))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + 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.97) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + cos(phi2)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + 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.97) tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + 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.97], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + 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.97:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.96999999999999997Initial program 98.5%
Taylor expanded in phi1 around 0
Applied rewrites77.1%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6476.8
Applied rewrites76.8%
Taylor expanded in lambda2 around 0
lift-cos.f6467.7
Applied rewrites67.7%
if 0.96999999999999997 < (cos.f64 phi2) Initial program 98.6%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6495.7
Applied rewrites95.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites95.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= (cos phi2) 0.88)
(+ lambda1 (atan2 (* (cos phi2) (- (sin lambda2))) (+ 1.0 (cos phi2))))
(+
lambda1
(atan2
(sin (- lambda1 lambda2))
(+ (cos phi1) (cos (- lambda1 lambda2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (cos(phi2) <= 0.88) {
tmp = lambda1 + atan2((cos(phi2) * -sin(lambda2)), (1.0 + cos(phi2)));
} else {
tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + 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) :: tmp
if (cos(phi2) <= 0.88d0) then
tmp = lambda1 + atan2((cos(phi2) * -sin(lambda2)), (1.0d0 + cos(phi2)))
else
tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2))))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (Math.cos(phi2) <= 0.88) {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * -Math.sin(lambda2)), (1.0 + Math.cos(phi2)));
} else {
tmp = lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if math.cos(phi2) <= 0.88: tmp = lambda1 + math.atan2((math.cos(phi2) * -math.sin(lambda2)), (1.0 + math.cos(phi2))) else: tmp = lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(phi1) + math.cos((lambda1 - lambda2)))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (cos(phi2) <= 0.88) tmp = Float64(lambda1 + atan(Float64(cos(phi2) * Float64(-sin(lambda2))), Float64(1.0 + cos(phi2)))); else tmp = Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (cos(phi2) <= 0.88) tmp = lambda1 + atan2((cos(phi2) * -sin(lambda2)), (1.0 + cos(phi2))); else tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2)))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[Cos[phi2], $MachinePrecision], 0.88], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2], $MachinePrecision] * (-N[Sin[lambda2], $MachinePrecision])), $MachinePrecision] / N[(1.0 + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\cos \phi_2 \leq 0.88:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot \left(-\sin \lambda_2\right)}{1 + \cos \phi_2}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi2) < 0.880000000000000004Initial program 98.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6497.8
Applied rewrites97.8%
Taylor expanded in lambda1 around 0
flip3--N/A
sin-neg-revN/A
lift-sin.f64N/A
lift-neg.f6487.8
Applied rewrites87.8%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6471.2
Applied rewrites71.2%
Taylor expanded in lambda2 around 0
lift-cos.f6462.2
Applied rewrites62.2%
if 0.880000000000000004 < (cos.f64 phi2) Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6493.1
Applied rewrites93.1%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites93.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi1) 0.9999998)
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos lambda1))))
(+ lambda1 (atan2 t_0 (+ 1.0 (cos (- lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.9999998) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(lambda1)));
} else {
tmp = lambda1 + atan2(t_0, (1.0 + 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) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi1) <= 0.9999998d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(lambda1)))
else
tmp = lambda1 + atan2(t_0, (1.0d0 + 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 tmp;
if (Math.cos(phi1) <= 0.9999998) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos(lambda1)));
} else {
tmp = lambda1 + Math.atan2(t_0, (1.0 + Math.cos(-lambda2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi1) <= 0.9999998: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos(lambda1))) else: tmp = lambda1 + math.atan2(t_0, (1.0 + math.cos(-lambda2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.9999998) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(lambda1)))); else tmp = Float64(lambda1 + atan(t_0, Float64(1.0 + cos(Float64(-lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi1) <= 0.9999998) tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(lambda1))); else tmp = lambda1 + atan2(t_0, (1.0 + cos(-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[phi1], $MachinePrecision], 0.9999998], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(1.0 + N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.9999998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{1 + \cos \left(-\lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.999999799999999994Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.2
Applied rewrites77.2%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites76.0%
Taylor expanded in lambda1 around inf
Applied rewrites66.9%
if 0.999999799999999994 < (cos.f64 phi1) Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.9
Applied rewrites77.9%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites78.0%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f64N/A
lift-+.f6477.8
Applied rewrites77.8%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-neg.f6477.5
Applied rewrites77.5%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 62000000000000.0)
(+
lambda1
(atan2
(*
(+
1.0
(* (* phi2 phi2) (- (* 0.041666666666666664 (* phi2 phi2)) 0.5)))
t_0)
(+
(cos phi1)
(* (fma (* phi2 phi2) -0.5 1.0) (cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ 1.0 (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 62000000000000.0) {
tmp = lambda1 + atan2(((1.0 + ((phi2 * phi2) * ((0.041666666666666664 * (phi2 * phi2)) - 0.5))) * t_0), (cos(phi1) + (fma((phi2 * phi2), -0.5, 1.0) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2)));
}
return tmp;
}
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 62000000000000.0) tmp = Float64(lambda1 + atan(Float64(Float64(1.0 + Float64(Float64(phi2 * phi2) * Float64(Float64(0.041666666666666664 * Float64(phi2 * phi2)) - 0.5))) * t_0), Float64(cos(phi1) + Float64(fma(Float64(phi2 * phi2), -0.5, 1.0) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + cos(phi2)))); end return tmp end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 62000000000000.0], N[(lambda1 + N[ArcTan[N[(N[(1.0 + N[(N[(phi2 * phi2), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(phi2 * phi2), $MachinePrecision] * -0.5 + 1.0), $MachinePrecision] * 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[(1.0 + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 62000000000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\left(1 + \left(\phi_2 \cdot \phi_2\right) \cdot \left(0.041666666666666664 \cdot \left(\phi_2 \cdot \phi_2\right) - 0.5\right)\right) \cdot t\_0}{\cos \phi_1 + \mathsf{fma}\left(\phi_2 \cdot \phi_2, -0.5, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2}\\
\end{array}
\end{array}
if phi2 < 6.2e13Initial program 98.5%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f6484.7
Applied rewrites84.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6482.7
Applied rewrites82.7%
if 6.2e13 < phi2 Initial program 98.5%
Taylor expanded in phi1 around 0
Applied rewrites77.6%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6477.5
Applied rewrites77.5%
Taylor expanded in lambda2 around 0
lift-cos.f6467.7
Applied rewrites67.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2 62000000000000.0)
(+
lambda1
(atan2
t_0
(+
(cos phi1)
(* (+ 1.0 (* -0.5 (* phi2 phi2))) (cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 (* (cos phi2) t_0) (+ 1.0 (cos phi2)))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 62000000000000.0) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + ((1.0 + (-0.5 * (phi2 * phi2))) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (phi2 <= 62000000000000.0d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + ((1.0d0 + ((-0.5d0) * (phi2 * phi2))) * cos((lambda1 - lambda2)))))
else
tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0d0 + cos(phi2)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (phi2 <= 62000000000000.0) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + ((1.0 + (-0.5 * (phi2 * phi2))) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + Math.atan2((Math.cos(phi2) * t_0), (1.0 + Math.cos(phi2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if phi2 <= 62000000000000.0: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + ((1.0 + (-0.5 * (phi2 * phi2))) * math.cos((lambda1 - lambda2))))) else: tmp = lambda1 + math.atan2((math.cos(phi2) * t_0), (1.0 + math.cos(phi2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= 62000000000000.0) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(Float64(1.0 + Float64(-0.5 * Float64(phi2 * phi2))) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2) * t_0), Float64(1.0 + cos(phi2)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (phi2 <= 62000000000000.0) tmp = lambda1 + atan2(t_0, (cos(phi1) + ((1.0 + (-0.5 * (phi2 * phi2))) * cos((lambda1 - lambda2))))); else tmp = lambda1 + atan2((cos(phi2) * t_0), (1.0 + cos(phi2))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 62000000000000.0], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(1.0 + N[(-0.5 * N[(phi2 * phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 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[(1.0 + N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq 62000000000000:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos \phi_2 \cdot t\_0}{1 + \cos \phi_2}\\
\end{array}
\end{array}
if phi2 < 6.2e13Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6483.9
Applied rewrites83.9%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6482.6
Applied rewrites82.6%
if 6.2e13 < phi2 Initial program 98.5%
Taylor expanded in phi1 around 0
Applied rewrites77.6%
Taylor expanded in lambda1 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
cos-neg-revN/A
lower-*.f64N/A
lift-cos.f64N/A
lift-cos.f6477.5
Applied rewrites77.5%
Taylor expanded in lambda2 around 0
lift-cos.f6467.7
Applied rewrites67.7%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
lambda1
(atan2 (sin (- lambda2)) (+ (cos phi1) (cos (- lambda1 lambda2)))))))
(if (<= lambda2 -20000000.0)
t_0
(if (<= lambda2 2e-14)
(+
lambda1
(atan2 (sin (- lambda1 lambda2)) (+ (cos phi1) (cos lambda1))))
t_0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = lambda1 + atan2(sin(-lambda2), (cos(phi1) + cos((lambda1 - lambda2))));
double tmp;
if (lambda2 <= -20000000.0) {
tmp = t_0;
} else if (lambda2 <= 2e-14) {
tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos(lambda1)));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = lambda1 + atan2(sin(-lambda2), (cos(phi1) + cos((lambda1 - lambda2))))
if (lambda2 <= (-20000000.0d0)) then
tmp = t_0
else if (lambda2 <= 2d-14) then
tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos(lambda1)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = lambda1 + Math.atan2(Math.sin(-lambda2), (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
double tmp;
if (lambda2 <= -20000000.0) {
tmp = t_0;
} else if (lambda2 <= 2e-14) {
tmp = lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(phi1) + Math.cos(lambda1)));
} else {
tmp = t_0;
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = lambda1 + math.atan2(math.sin(-lambda2), (math.cos(phi1) + math.cos((lambda1 - lambda2)))) tmp = 0 if lambda2 <= -20000000.0: tmp = t_0 elif lambda2 <= 2e-14: tmp = lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(phi1) + math.cos(lambda1))) else: tmp = t_0 return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = Float64(lambda1 + atan(sin(Float64(-lambda2)), Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))) tmp = 0.0 if (lambda2 <= -20000000.0) tmp = t_0; elseif (lambda2 <= 2e-14) tmp = Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(phi1) + cos(lambda1)))); else tmp = t_0; end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = lambda1 + atan2(sin(-lambda2), (cos(phi1) + cos((lambda1 - lambda2)))); tmp = 0.0; if (lambda2 <= -20000000.0) tmp = t_0; elseif (lambda2 <= 2e-14) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos(lambda1))); else tmp = t_0; end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(lambda1 + N[ArcTan[N[Sin[(-lambda2)], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -20000000.0], t$95$0, If[LessEqual[lambda2, 2e-14], N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \lambda_1 + \tan^{-1}_* \frac{\sin \left(-\lambda_2\right)}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{if}\;\lambda_2 \leq -20000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\lambda_2 \leq 2 \cdot 10^{-14}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \lambda_1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if lambda2 < -2e7 or 2e-14 < lambda2 Initial program 97.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6476.7
Applied rewrites76.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites76.6%
Taylor expanded in lambda1 around 0
lower-sin.f64N/A
lower-neg.f6476.5
Applied rewrites76.5%
if -2e7 < lambda2 < 2e-14Initial program 99.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6478.4
Applied rewrites78.4%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites77.3%
Taylor expanded in lambda1 around inf
Applied rewrites77.0%
(FPCore (lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi1) 0.9999998)
(+ lambda1 (atan2 t_0 (+ (cos phi1) 1.0)))
(+ lambda1 (atan2 t_0 (+ 1.0 (cos (- lambda2))))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.9999998) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0));
} else {
tmp = lambda1 + atan2(t_0, (1.0 + 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) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi1) <= 0.9999998d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0d0))
else
tmp = lambda1 + atan2(t_0, (1.0d0 + 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 tmp;
if (Math.cos(phi1) <= 0.9999998) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + 1.0));
} else {
tmp = lambda1 + Math.atan2(t_0, (1.0 + Math.cos(-lambda2)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi1) <= 0.9999998: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + 1.0)) else: tmp = lambda1 + math.atan2(t_0, (1.0 + math.cos(-lambda2))) return tmp
function code(lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.9999998) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + 1.0))); else tmp = Float64(lambda1 + atan(t_0, Float64(1.0 + cos(Float64(-lambda2))))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi1) <= 0.9999998) tmp = lambda1 + atan2(t_0, (cos(phi1) + 1.0)); else tmp = lambda1 + atan2(t_0, (1.0 + cos(-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[phi1], $MachinePrecision], 0.9999998], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(1.0 + N[Cos[(-lambda2)], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.9999998:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + 1}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{1 + \cos \left(-\lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.999999799999999994Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.2
Applied rewrites77.2%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites76.0%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-neg.f6475.7
Applied rewrites75.7%
Taylor expanded in lambda2 around 0
Applied rewrites66.6%
if 0.999999799999999994 < (cos.f64 phi1) Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.9
Applied rewrites77.9%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites78.0%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f64N/A
lift-+.f6477.8
Applied rewrites77.8%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-neg.f6477.5
Applied rewrites77.5%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + 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(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(phi1) + math.cos((lambda1 - lambda2))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.5
Applied rewrites77.5%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites77.0%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -9.5e-99) (+ lambda1 (atan2 lambda1 (+ (cos phi1) (cos (- lambda1 lambda2))))) (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ 1.0 (cos lambda1))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -9.5e-99) {
tmp = lambda1 + atan2(lambda1, (cos(phi1) + cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (1.0 + cos(lambda1)));
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-9.5d-99)) then
tmp = lambda1 + atan2(lambda1, (cos(phi1) + cos((lambda1 - lambda2))))
else
tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (1.0d0 + cos(lambda1)))
end if
code = tmp
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -9.5e-99) {
tmp = lambda1 + Math.atan2(lambda1, (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
} else {
tmp = lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (1.0 + Math.cos(lambda1)));
}
return tmp;
}
def code(lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -9.5e-99: tmp = lambda1 + math.atan2(lambda1, (math.cos(phi1) + math.cos((lambda1 - lambda2)))) else: tmp = lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (1.0 + math.cos(lambda1))) return tmp
function code(lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -9.5e-99) tmp = Float64(lambda1 + atan(lambda1, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); else tmp = Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(1.0 + cos(lambda1)))); end return tmp end
function tmp_2 = code(lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -9.5e-99) tmp = lambda1 + atan2(lambda1, (cos(phi1) + cos((lambda1 - lambda2)))); else tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (1.0 + cos(lambda1))); end tmp_2 = tmp; end
code[lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -9.5e-99], N[(lambda1 + N[ArcTan[lambda1 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(1.0 + N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -9.5 \cdot 10^{-99}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\lambda_1}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \lambda_1}\\
\end{array}
\end{array}
if lambda1 < -9.5000000000000008e-99Initial program 98.0%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6487.3
Applied rewrites87.3%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites87.0%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f6486.5
Applied rewrites86.5%
Taylor expanded in lambda2 around 0
Applied rewrites80.6%
if -9.5000000000000008e-99 < lambda1 Initial program 98.8%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6472.7
Applied rewrites72.7%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites72.0%
Taylor expanded in phi1 around 0
lift-cos.f64N/A
lift--.f64N/A
lift-+.f6459.8
Applied rewrites59.8%
Taylor expanded in lambda2 around 0
lift-cos.f6453.2
Applied rewrites53.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos phi1) 1.0))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + 1.0));
}
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(sin((lambda1 - lambda2)), (cos(phi1) + 1.0d0))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(phi1) + 1.0));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(phi1) + 1.0))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(phi1) + 1.0))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + 1.0)); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + 1}
\end{array}
Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.5
Applied rewrites77.5%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites77.0%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-cos.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-neg.f6476.7
Applied rewrites76.7%
Taylor expanded in lambda2 around 0
Applied rewrites67.2%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 (+ lambda1 (atan2 lambda1 (+ (cos phi1) (cos (- lambda1 lambda2))))))
double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + atan2(lambda1, (cos(phi1) + 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(lambda1, (cos(phi1) + cos((lambda1 - lambda2))))
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1 + Math.atan2(lambda1, (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
}
def code(lambda1, lambda2, phi1, phi2): return lambda1 + math.atan2(lambda1, (math.cos(phi1) + math.cos((lambda1 - lambda2))))
function code(lambda1, lambda2, phi1, phi2) return Float64(lambda1 + atan(lambda1, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))) end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1 + atan2(lambda1, (cos(phi1) + cos((lambda1 - lambda2)))); end
code[lambda1_, lambda2_, phi1_, phi2_] := N[(lambda1 + N[ArcTan[lambda1 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\lambda_1}{\cos \phi_1 + \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 98.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6477.5
Applied rewrites77.5%
Taylor expanded in phi2 around 0
sin-+PI/2-revN/A
lift-/.f64N/A
lift-PI.f64N/A
sin-sum-revN/A
lift-PI.f64N/A
lift-/.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
lower-+.f64N/A
Applied rewrites77.0%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lower-sin.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-neg.f6476.6
Applied rewrites76.6%
Taylor expanded in lambda2 around 0
Applied rewrites58.4%
(FPCore (lambda1 lambda2 phi1 phi2) :precision binary64 lambda1)
double code(double lambda1, double lambda2, double phi1, double phi2) {
return 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 = lambda1
end function
public static double code(double lambda1, double lambda2, double phi1, double phi2) {
return lambda1;
}
def code(lambda1, lambda2, phi1, phi2): return lambda1
function code(lambda1, lambda2, phi1, phi2) return lambda1 end
function tmp = code(lambda1, lambda2, phi1, phi2) tmp = lambda1; end
code[lambda1_, lambda2_, phi1_, phi2_] := lambda1
\begin{array}{l}
\\
\lambda_1
\end{array}
Initial program 98.5%
Taylor expanded in lambda1 around inf
Applied rewrites52.8%
herbie shell --seed 2025092
(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)))))))