
(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}
Sampling outcomes in binary64 precision:
Herbie found 21 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}
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(+
lambda1
(atan2
(* (cos phi2_m) (sin (- lambda1 lambda2)))
(+
(cos phi1)
(*
(fma (sin phi2_m) (cos (/ (PI) 2.0)) (cos phi2_m))
(cos (- lambda1 lambda2)))))))\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \mathsf{fma}\left(\sin phi2\_m, \cos \left(\frac{\mathsf{PI}\left(\right)}{2}\right), \cos phi2\_m\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 99.0%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-PI.f6499.0
Applied rewrites99.0%
lift-sin.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
sin-PI/299.0
Applied rewrites99.0%
Final simplification99.0%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1
(+
lambda1
(atan2
(* (cos phi2_m) (sin lambda1))
(fma (cos lambda1) (cos phi2_m) (cos phi1)))))
(t_2 (sin (- lambda1 lambda2)))
(t_3 (atan2 (* t_2 (cos phi2_m)) (fma t_0 (cos phi2_m) (cos phi1))))
(t_4 (+ (cos phi1) (* (cos phi2_m) t_0)))
(t_5 (+ lambda1 (atan2 (* (cos phi2_m) t_2) t_4))))
(if (<= t_5 -3.14)
t_1
(if (<= t_5 -0.02)
t_3
(if (<= t_5 5e-17)
(+
lambda1
(atan2
(* (cos phi2_m) (* (fma (/ lambda2 lambda1) -1.0 1.0) lambda1))
t_4))
(if (<= t_5 5.0) t_3 t_1))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = lambda1 + atan2((cos(phi2_m) * sin(lambda1)), fma(cos(lambda1), cos(phi2_m), cos(phi1)));
double t_2 = sin((lambda1 - lambda2));
double t_3 = atan2((t_2 * cos(phi2_m)), fma(t_0, cos(phi2_m), cos(phi1)));
double t_4 = cos(phi1) + (cos(phi2_m) * t_0);
double t_5 = lambda1 + atan2((cos(phi2_m) * t_2), t_4);
double tmp;
if (t_5 <= -3.14) {
tmp = t_1;
} else if (t_5 <= -0.02) {
tmp = t_3;
} else if (t_5 <= 5e-17) {
tmp = lambda1 + atan2((cos(phi2_m) * (fma((lambda2 / lambda1), -1.0, 1.0) * lambda1)), t_4);
} else if (t_5 <= 5.0) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(lambda1 + atan(Float64(cos(phi2_m) * sin(lambda1)), fma(cos(lambda1), cos(phi2_m), cos(phi1)))) t_2 = sin(Float64(lambda1 - lambda2)) t_3 = atan(Float64(t_2 * cos(phi2_m)), fma(t_0, cos(phi2_m), cos(phi1))) t_4 = Float64(cos(phi1) + Float64(cos(phi2_m) * t_0)) t_5 = Float64(lambda1 + atan(Float64(cos(phi2_m) * t_2), t_4)) tmp = 0.0 if (t_5 <= -3.14) tmp = t_1; elseif (t_5 <= -0.02) tmp = t_3; elseif (t_5 <= 5e-17) tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * Float64(fma(Float64(lambda2 / lambda1), -1.0, 1.0) * lambda1)), t_4)); elseif (t_5 <= 5.0) tmp = t_3; else tmp = t_1; end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[phi2$95$m], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(t$95$2 * N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 * N[Cos[phi2$95$m], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2$95$m], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * t$95$2), $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$5, -3.14], t$95$1, If[LessEqual[t$95$5, -0.02], t$95$3, If[LessEqual[t$95$5, 5e-17], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * N[(N[(N[(lambda2 / lambda1), $MachinePrecision] * -1.0 + 1.0), $MachinePrecision] * lambda1), $MachinePrecision]), $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 5.0], t$95$3, t$95$1]]]]]]]]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot \sin \lambda_1}{\mathsf{fma}\left(\cos \lambda_1, \cos phi2\_m, \cos \phi_1\right)}\\
t_2 := \sin \left(\lambda_1 - \lambda_2\right)\\
t_3 := \tan^{-1}_* \frac{t\_2 \cdot \cos phi2\_m}{\mathsf{fma}\left(t\_0, \cos phi2\_m, \cos \phi_1\right)}\\
t_4 := \cos \phi_1 + \cos phi2\_m \cdot t\_0\\
t_5 := \lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot t\_2}{t\_4}\\
\mathbf{if}\;t\_5 \leq -3.14:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_5 \leq -0.02:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_5 \leq 5 \cdot 10^{-17}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot \left(\mathsf{fma}\left(\frac{\lambda_2}{\lambda_1}, -1, 1\right) \cdot \lambda_1\right)}{t\_4}\\
\mathbf{elif}\;t\_5 \leq 5:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -3.14000000000000012 or 5 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) Initial program 100.0%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f64100.0
Applied rewrites100.0%
Taylor expanded in lambda1 around inf
Applied rewrites100.0%
if -3.14000000000000012 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < -0.0200000000000000004 or 4.9999999999999999e-17 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 5Initial program 97.0%
Taylor expanded in lambda1 around 0
lower-atan2.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-sin.f64N/A
lift--.f64N/A
lift-cos.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift--.f64N/A
lift-cos.f64N/A
lift-cos.f6495.5
Applied rewrites95.5%
if -0.0200000000000000004 < (+.f64 lambda1 (atan2.f64 (*.f64 (cos.f64 phi2) (sin.f64 (-.f64 lambda1 lambda2))) (+.f64 (cos.f64 phi1) (*.f64 (cos.f64 phi2) (cos.f64 (-.f64 lambda1 lambda2)))))) < 4.9999999999999999e-17Initial program 98.5%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-negN/A
lower-cos.f64N/A
sin-negN/A
lower-neg.f64N/A
lower-sin.f6498.5
Applied rewrites98.5%
Taylor expanded in lambda1 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-sin.f64N/A
lift-cos.f6498.5
Applied rewrites98.5%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6498.5
Applied rewrites98.5%
phi2_m = (fabs.f64 phi2) (FPCore (lambda1 lambda2 phi1 phi2_m) :precision binary64 (+ lambda1 (atan2 (* (cos phi2_m) (sin (- lambda1 lambda2))) (+ (cos phi1) (* (cos phi2_m) (cos (- lambda1 lambda2)))))))
phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1 + atan2((cos(phi2_m) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2_m) * cos((lambda1 - lambda2)))));
}
phi2_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2_m
code = lambda1 + atan2((cos(phi2_m) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2_m) * cos((lambda1 - lambda2)))))
end function
phi2_m = Math.abs(phi2);
public static double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1 + Math.atan2((Math.cos(phi2_m) * Math.sin((lambda1 - lambda2))), (Math.cos(phi1) + (Math.cos(phi2_m) * Math.cos((lambda1 - lambda2)))));
}
phi2_m = math.fabs(phi2) def code(lambda1, lambda2, phi1, phi2_m): return lambda1 + math.atan2((math.cos(phi2_m) * math.sin((lambda1 - lambda2))), (math.cos(phi1) + (math.cos(phi2_m) * math.cos((lambda1 - lambda2)))))
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) return Float64(lambda1 + atan(Float64(cos(phi2_m) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(cos(phi2_m) * cos(Float64(lambda1 - lambda2)))))) end
phi2_m = abs(phi2); function tmp = code(lambda1, lambda2, phi1, phi2_m) tmp = lambda1 + atan2((cos(phi2_m) * sin((lambda1 - lambda2))), (cos(phi1) + (cos(phi2_m) * cos((lambda1 - lambda2))))); end
phi2_m = N[Abs[phi2], $MachinePrecision] code[lambda1_, lambda2_, phi1_, phi2$95$m_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \cos phi2\_m \cdot \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 99.0%
phi2_m = (fabs.f64 phi2) (FPCore (lambda1 lambda2 phi1 phi2_m) :precision binary64 (+ lambda1 (atan2 (* (cos phi2_m) (sin (- lambda1 lambda2))) (fma (cos lambda2) (cos phi2_m) (cos phi1)))))
phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1 + atan2((cos(phi2_m) * sin((lambda1 - lambda2))), fma(cos(lambda2), cos(phi2_m), cos(phi1)));
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) return Float64(lambda1 + atan(Float64(cos(phi2_m) * sin(Float64(lambda1 - lambda2))), fma(cos(lambda2), cos(phi2_m), cos(phi1)))) end
phi2_m = N[Abs[phi2], $MachinePrecision] code[lambda1_, lambda2_, phi1_, phi2$95$m_] := N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[phi2$95$m], $MachinePrecision] + N[Cos[phi1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\mathsf{fma}\left(\cos \lambda_2, \cos phi2\_m, \cos \phi_1\right)}
\end{array}
Initial program 99.0%
lift-cos.f64N/A
sin-+PI/2-revN/A
sin-sumN/A
lower-fma.f64N/A
lower-sin.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-PI.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-sin.f64N/A
lower-/.f64N/A
lower-PI.f6499.0
Applied rewrites99.0%
lift-sin.f64N/A
lift-PI.f64N/A
lift-/.f64N/A
sin-PI/299.0
Applied rewrites99.0%
lift-sin.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-cos.f64N/A
flip3-+N/A
lower-/.f64N/A
Applied rewrites99.0%
Taylor expanded in lambda1 around 0
+-commutativeN/A
cos-neg-revN/A
*-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6498.4
Applied rewrites98.4%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (* (cos phi2_m) (sin (- lambda1 lambda2)))))
(if (<= phi2_m 0.28)
(+
lambda1
(atan2
t_0
(+
(cos phi1)
(*
(fma
(-
(*
(fma (* phi2_m phi2_m) -0.001388888888888889 0.041666666666666664)
(* phi2_m phi2_m))
0.5)
(* phi2_m phi2_m)
1.0)
(cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos phi2_m)))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = cos(phi2_m) * sin((lambda1 - lambda2));
double tmp;
if (phi2_m <= 0.28) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (fma(((fma((phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * (phi2_m * phi2_m)) - 0.5), (phi2_m * phi2_m), 1.0) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2_m)));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = Float64(cos(phi2_m) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2_m <= 0.28) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(fma(Float64(Float64(fma(Float64(phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * Float64(phi2_m * phi2_m)) - 0.5), Float64(phi2_m * phi2_m), 1.0) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(phi2_m)))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2$95$m, 0.28], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \cos phi2\_m \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;phi2\_m \leq 0.28:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \mathsf{fma}\left(\mathsf{fma}\left(phi2\_m \cdot phi2\_m, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(phi2\_m \cdot phi2\_m\right) - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos phi2\_m}\\
\end{array}
\end{array}
if phi2 < 0.28000000000000003Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6491.1
Applied rewrites91.1%
if 0.28000000000000003 < phi2 Initial program 99.2%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6485.5
Applied rewrites85.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6484.2
Applied rewrites84.2%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2_m 0.28)
(+
lambda1
(atan2
(*
(fma
(-
(*
(fma (* phi2_m phi2_m) -0.001388888888888889 0.041666666666666664)
(* phi2_m phi2_m))
0.5)
(* phi2_m phi2_m)
1.0)
t_0)
(+ (cos phi1) (* (cos phi2_m) (cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 (* (cos phi2_m) t_0) (+ (cos phi1) (cos phi2_m)))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2_m <= 0.28) {
tmp = lambda1 + atan2((fma(((fma((phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * (phi2_m * phi2_m)) - 0.5), (phi2_m * phi2_m), 1.0) * t_0), (cos(phi1) + (cos(phi2_m) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2_m) * t_0), (cos(phi1) + cos(phi2_m)));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2_m <= 0.28) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(fma(Float64(phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * Float64(phi2_m * phi2_m)) - 0.5), Float64(phi2_m * phi2_m), 1.0) * t_0), Float64(cos(phi1) + Float64(cos(phi2_m) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * t_0), Float64(cos(phi1) + cos(phi2_m)))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2$95$m, 0.28], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;phi2\_m \leq 0.28:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\mathsf{fma}\left(phi2\_m \cdot phi2\_m, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(phi2\_m \cdot phi2\_m\right) - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot t\_0}{\cos \phi_1 + \cos phi2\_m \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot t\_0}{\cos \phi_1 + \cos phi2\_m}\\
\end{array}
\end{array}
if phi2 < 0.28000000000000003Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.9
Applied rewrites87.9%
if 0.28000000000000003 < phi2 Initial program 99.2%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6485.5
Applied rewrites85.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6484.2
Applied rewrites84.2%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (* (cos phi2_m) (sin (- lambda1 lambda2)))))
(if (<= phi2_m 0.28)
(+
lambda1
(atan2
t_0
(+
(cos phi1)
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
(cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos phi2_m)))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = cos(phi2_m) * sin((lambda1 - lambda2));
double tmp;
if (phi2_m <= 0.28) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + (fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2_m)));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = Float64(cos(phi2_m) * sin(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi2_m <= 0.28) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(phi2_m)))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2$95$m, 0.28], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \cos phi2\_m \cdot \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;phi2\_m \leq 0.28:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos phi2\_m}\\
\end{array}
\end{array}
if phi2 < 0.28000000000000003Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.9
Applied rewrites87.9%
if 0.28000000000000003 < phi2 Initial program 99.2%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6485.5
Applied rewrites85.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6484.2
Applied rewrites84.2%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2_m 0.28)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
t_0)
(+ (cos phi1) (* (cos phi2_m) (cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 (* (cos phi2_m) t_0) (+ (cos phi1) (cos phi2_m)))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2_m <= 0.28) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * t_0), (cos(phi1) + (cos(phi2_m) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2_m) * t_0), (cos(phi1) + cos(phi2_m)));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2_m <= 0.28) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * t_0), Float64(cos(phi1) + Float64(cos(phi2_m) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * t_0), Float64(cos(phi1) + cos(phi2_m)))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2$95$m, 0.28], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;phi2\_m \leq 0.28:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot t\_0}{\cos \phi_1 + \cos phi2\_m \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot t\_0}{\cos \phi_1 + \cos phi2\_m}\\
\end{array}
\end{array}
if phi2 < 0.28000000000000003Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.9
Applied rewrites87.9%
if 0.28000000000000003 < phi2 Initial program 99.2%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6485.5
Applied rewrites85.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6484.2
Applied rewrites84.2%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (+ (cos phi1) (cos phi2_m))))
(if (<= phi2_m 2.7)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
(sin (- lambda1 lambda2)))
(+
(cos phi1)
(*
(fma
(-
(*
(fma (* phi2_m phi2_m) -0.001388888888888889 0.041666666666666664)
(* phi2_m phi2_m))
0.5)
(* phi2_m phi2_m)
1.0)
(cos (- lambda1 lambda2))))))
(if (<= phi2_m 1e+113)
(+ lambda1 (atan2 (* (cos phi2_m) (sin lambda1)) t_0))
(+ lambda1 (atan2 (* (cos phi2_m) (sin (- lambda2))) t_0))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = cos(phi1) + cos(phi2_m);
double tmp;
if (phi2_m <= 2.7) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * sin((lambda1 - lambda2))), (cos(phi1) + (fma(((fma((phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * (phi2_m * phi2_m)) - 0.5), (phi2_m * phi2_m), 1.0) * cos((lambda1 - lambda2)))));
} else if (phi2_m <= 1e+113) {
tmp = lambda1 + atan2((cos(phi2_m) * sin(lambda1)), t_0);
} else {
tmp = lambda1 + atan2((cos(phi2_m) * sin(-lambda2)), t_0);
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = Float64(cos(phi1) + cos(phi2_m)) tmp = 0.0 if (phi2_m <= 2.7) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(fma(Float64(Float64(fma(Float64(phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * Float64(phi2_m * phi2_m)) - 0.5), Float64(phi2_m * phi2_m), 1.0) * cos(Float64(lambda1 - lambda2)))))); elseif (phi2_m <= 1e+113) tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * sin(lambda1)), t_0)); else tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * sin(Float64(-lambda2))), t_0)); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2$95$m, 2.7], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2$95$m, 1e+113], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Sin[(-lambda2)], $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \cos \phi_1 + \cos phi2\_m\\
\mathbf{if}\;phi2\_m \leq 2.7:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \mathsf{fma}\left(\mathsf{fma}\left(phi2\_m \cdot phi2\_m, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(phi2\_m \cdot phi2\_m\right) - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{elif}\;phi2\_m \leq 10^{+113}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot \sin \lambda_1}{t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot \sin \left(-\lambda_2\right)}{t\_0}\\
\end{array}
\end{array}
if phi2 < 2.7000000000000002Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.6
Applied rewrites87.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6487.9
Applied rewrites87.9%
if 2.7000000000000002 < phi2 < 1e113Initial program 99.7%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6493.1
Applied rewrites93.1%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6493.1
Applied rewrites93.1%
Taylor expanded in lambda1 around inf
Applied rewrites87.3%
if 1e113 < phi2 Initial program 99.2%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6480.7
Applied rewrites80.7%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.7
Applied rewrites78.7%
Taylor expanded in lambda1 around 0
mul-1-negN/A
lower-neg.f6472.0
Applied rewrites72.0%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2_m 0.28)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
t_0)
(+
(cos phi1)
(*
(fma
(-
(*
(fma (* phi2_m phi2_m) -0.001388888888888889 0.041666666666666664)
(* phi2_m phi2_m))
0.5)
(* phi2_m phi2_m)
1.0)
(cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 (* (cos phi2_m) t_0) (+ (cos phi1) (cos phi2_m)))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2_m <= 0.28) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * t_0), (cos(phi1) + (fma(((fma((phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * (phi2_m * phi2_m)) - 0.5), (phi2_m * phi2_m), 1.0) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2_m) * t_0), (cos(phi1) + cos(phi2_m)));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2_m <= 0.28) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * t_0), Float64(cos(phi1) + Float64(fma(Float64(Float64(fma(Float64(phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * Float64(phi2_m * phi2_m)) - 0.5), Float64(phi2_m * phi2_m), 1.0) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * t_0), Float64(cos(phi1) + cos(phi2_m)))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2$95$m, 0.28], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;phi2\_m \leq 0.28:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot t\_0}{\cos \phi_1 + \mathsf{fma}\left(\mathsf{fma}\left(phi2\_m \cdot phi2\_m, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(phi2\_m \cdot phi2\_m\right) - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot t\_0}{\cos \phi_1 + \cos phi2\_m}\\
\end{array}
\end{array}
if phi2 < 0.28000000000000003Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.9
Applied rewrites87.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6488.1
Applied rewrites88.1%
if 0.28000000000000003 < phi2 Initial program 99.2%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6485.5
Applied rewrites85.5%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6484.2
Applied rewrites84.2%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi2_m) 0.855)
(+ lambda1 (atan2 (* (cos phi2_m) t_0) (+ 1.0 (cos phi2_m))))
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos (- lambda1 lambda2))))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi2_m) <= 0.855) {
tmp = lambda1 + atan2((cos(phi2_m) * t_0), (1.0 + cos(phi2_m)));
} else {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))));
}
return tmp;
}
phi2_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2_m
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi2_m) <= 0.855d0) then
tmp = lambda1 + atan2((cos(phi2_m) * t_0), (1.0d0 + cos(phi2_m)))
else
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2))))
end if
code = tmp
end function
phi2_m = Math.abs(phi2);
public static double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi2_m) <= 0.855) {
tmp = lambda1 + Math.atan2((Math.cos(phi2_m) * t_0), (1.0 + Math.cos(phi2_m)));
} else {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
}
return tmp;
}
phi2_m = math.fabs(phi2) def code(lambda1, lambda2, phi1, phi2_m): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi2_m) <= 0.855: tmp = lambda1 + math.atan2((math.cos(phi2_m) * t_0), (1.0 + math.cos(phi2_m))) else: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos((lambda1 - lambda2)))) return tmp
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi2_m) <= 0.855) tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * t_0), Float64(1.0 + cos(phi2_m)))); else tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))); end return tmp end
phi2_m = abs(phi2); function tmp_2 = code(lambda1, lambda2, phi1, phi2_m) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi2_m) <= 0.855) tmp = lambda1 + atan2((cos(phi2_m) * t_0), (1.0 + cos(phi2_m))); else tmp = lambda1 + atan2(t_0, (cos(phi1) + cos((lambda1 - lambda2)))); end tmp_2 = tmp; end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi2$95$m], $MachinePrecision], 0.855], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[phi2$95$m], $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}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos phi2\_m \leq 0.855:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot t\_0}{1 + \cos phi2\_m}\\
\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.85499999999999998Initial program 99.3%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6488.6
Applied rewrites88.6%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6487.8
Applied rewrites87.8%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f6471.0
Applied rewrites71.0%
if 0.85499999999999998 < (cos.f64 phi2) Initial program 98.8%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6495.5
Applied rewrites95.5%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6495.5
Applied rewrites95.5%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(if (<= phi2_m 2.7)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
(sin (- lambda1 lambda2)))
(+
(cos phi1)
(*
(fma
(-
(*
(fma (* phi2_m phi2_m) -0.001388888888888889 0.041666666666666664)
(* phi2_m phi2_m))
0.5)
(* phi2_m phi2_m)
1.0)
(cos (- lambda1 lambda2))))))
(+
lambda1
(atan2 (* (cos phi2_m) (sin lambda1)) (+ (cos phi1) (cos phi2_m))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double tmp;
if (phi2_m <= 2.7) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * sin((lambda1 - lambda2))), (cos(phi1) + (fma(((fma((phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * (phi2_m * phi2_m)) - 0.5), (phi2_m * phi2_m), 1.0) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2_m) * sin(lambda1)), (cos(phi1) + cos(phi2_m)));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) tmp = 0.0 if (phi2_m <= 2.7) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * sin(Float64(lambda1 - lambda2))), Float64(cos(phi1) + Float64(fma(Float64(Float64(fma(Float64(phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * Float64(phi2_m * phi2_m)) - 0.5), Float64(phi2_m * phi2_m), 1.0) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * sin(lambda1)), Float64(cos(phi1) + cos(phi2_m)))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision] code[lambda1_, lambda2_, phi1_, phi2$95$m_] := If[LessEqual[phi2$95$m, 2.7], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
\mathbf{if}\;phi2\_m \leq 2.7:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \sin \left(\lambda_1 - \lambda_2\right)}{\cos \phi_1 + \mathsf{fma}\left(\mathsf{fma}\left(phi2\_m \cdot phi2\_m, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(phi2\_m \cdot phi2\_m\right) - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot \sin \lambda_1}{\cos \phi_1 + \cos phi2\_m}\\
\end{array}
\end{array}
if phi2 < 2.7000000000000002Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.6
Applied rewrites87.6%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6487.9
Applied rewrites87.9%
if 2.7000000000000002 < phi2 Initial program 99.4%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6485.4
Applied rewrites85.4%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6484.1
Applied rewrites84.1%
Taylor expanded in lambda1 around inf
Applied rewrites72.2%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= (cos phi1) 0.965)
(+ lambda1 (atan2 t_0 (+ (cos phi1) (cos phi2_m))))
(+ lambda1 (atan2 (* 1.0 t_0) (+ 1.0 (cos (- lambda1 lambda2))))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.965) {
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2_m)));
} else {
tmp = lambda1 + atan2((1.0 * t_0), (1.0 + cos((lambda1 - lambda2))));
}
return tmp;
}
phi2_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2_m
real(8) :: t_0
real(8) :: tmp
t_0 = sin((lambda1 - lambda2))
if (cos(phi1) <= 0.965d0) then
tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2_m)))
else
tmp = lambda1 + atan2((1.0d0 * t_0), (1.0d0 + cos((lambda1 - lambda2))))
end if
code = tmp
end function
phi2_m = Math.abs(phi2);
public static double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = Math.sin((lambda1 - lambda2));
double tmp;
if (Math.cos(phi1) <= 0.965) {
tmp = lambda1 + Math.atan2(t_0, (Math.cos(phi1) + Math.cos(phi2_m)));
} else {
tmp = lambda1 + Math.atan2((1.0 * t_0), (1.0 + Math.cos((lambda1 - lambda2))));
}
return tmp;
}
phi2_m = math.fabs(phi2) def code(lambda1, lambda2, phi1, phi2_m): t_0 = math.sin((lambda1 - lambda2)) tmp = 0 if math.cos(phi1) <= 0.965: tmp = lambda1 + math.atan2(t_0, (math.cos(phi1) + math.cos(phi2_m))) else: tmp = lambda1 + math.atan2((1.0 * t_0), (1.0 + math.cos((lambda1 - lambda2)))) return tmp
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.965) tmp = Float64(lambda1 + atan(t_0, Float64(cos(phi1) + cos(phi2_m)))); else tmp = Float64(lambda1 + atan(Float64(1.0 * t_0), Float64(1.0 + cos(Float64(lambda1 - lambda2))))); end return tmp end
phi2_m = abs(phi2); function tmp_2 = code(lambda1, lambda2, phi1, phi2_m) t_0 = sin((lambda1 - lambda2)); tmp = 0.0; if (cos(phi1) <= 0.965) tmp = lambda1 + atan2(t_0, (cos(phi1) + cos(phi2_m))); else tmp = lambda1 + atan2((1.0 * t_0), (1.0 + cos((lambda1 - lambda2)))); end tmp_2 = tmp; end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.965], N[(lambda1 + N[ArcTan[t$95$0 / N[(N[Cos[phi1], $MachinePrecision] + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.965:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_0}{\cos \phi_1 + \cos phi2\_m}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot t\_0}{1 + \cos \left(\lambda_1 - \lambda_2\right)}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.964999999999999969Initial program 99.0%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6479.2
Applied rewrites79.2%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6478.6
Applied rewrites78.6%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6465.7
Applied rewrites65.7%
if 0.964999999999999969 < (cos.f64 phi1) Initial program 99.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6484.1
Applied rewrites84.1%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6484.1
Applied rewrites84.1%
Taylor expanded in phi1 around 0
Applied rewrites81.9%
Taylor expanded in phi2 around 0
Applied rewrites82.8%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2_m 1.45e+14)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
t_0)
(+
(cos phi1)
(*
(fma
(-
(*
(fma (* phi2_m phi2_m) -0.001388888888888889 0.041666666666666664)
(* phi2_m phi2_m))
0.5)
(* phi2_m phi2_m)
1.0)
(cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 (* (cos phi2_m) t_0) (+ 1.0 (cos phi2_m)))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2_m <= 1.45e+14) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * t_0), (cos(phi1) + (fma(((fma((phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * (phi2_m * phi2_m)) - 0.5), (phi2_m * phi2_m), 1.0) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2_m) * t_0), (1.0 + cos(phi2_m)));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2_m <= 1.45e+14) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * t_0), Float64(cos(phi1) + Float64(fma(Float64(Float64(fma(Float64(phi2_m * phi2_m), -0.001388888888888889, 0.041666666666666664) * Float64(phi2_m * phi2_m)) - 0.5), Float64(phi2_m * phi2_m), 1.0) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * t_0), Float64(1.0 + cos(phi2_m)))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2$95$m, 1.45e+14], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * -0.001388888888888889 + 0.041666666666666664), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(N[Cos[phi2$95$m], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;phi2\_m \leq 1.45 \cdot 10^{+14}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot t\_0}{\cos \phi_1 + \mathsf{fma}\left(\mathsf{fma}\left(phi2\_m \cdot phi2\_m, -0.001388888888888889, 0.041666666666666664\right) \cdot \left(phi2\_m \cdot phi2\_m\right) - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot t\_0}{1 + \cos phi2\_m}\\
\end{array}
\end{array}
if phi2 < 1.45e14Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.7
Applied rewrites87.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6488.0
Applied rewrites88.0%
if 1.45e14 < phi2 Initial program 99.3%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6484.9
Applied rewrites84.9%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6483.6
Applied rewrites83.6%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f6470.8
Applied rewrites70.8%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= (cos phi1) 0.946)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
(fma
(- (* (fma 0.16666666666666666 lambda2 (* -0.5 lambda1)) lambda2) 1.0)
lambda2
lambda1))
(+ (cos phi1) t_0)))
(+ lambda1 (atan2 (* 1.0 (sin (- lambda1 lambda2))) (+ 1.0 t_0))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.946) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * fma(((fma(0.16666666666666666, lambda2, (-0.5 * lambda1)) * lambda2) - 1.0), lambda2, lambda1)), (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + t_0));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.946) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * fma(Float64(Float64(fma(0.16666666666666666, lambda2, Float64(-0.5 * lambda1)) * lambda2) - 1.0), lambda2, lambda1)), Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(1.0 + t_0))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.946], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[(N[(N[(N[(0.16666666666666666 * lambda2 + N[(-0.5 * lambda1), $MachinePrecision]), $MachinePrecision] * lambda2), $MachinePrecision] - 1.0), $MachinePrecision] * lambda2 + lambda1), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.946:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, \lambda_2, -0.5 \cdot \lambda_1\right) \cdot \lambda_2 - 1, \lambda_2, \lambda_1\right)}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.94599999999999995Initial program 99.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6476.8
Applied rewrites76.8%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
sin-neg-revN/A
lower-neg.f64N/A
lift-sin.f6476.9
Applied rewrites76.9%
Taylor expanded in lambda2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lift-*.f6462.1
Applied rewrites62.1%
if 0.94599999999999995 < (cos.f64 phi1) Initial program 99.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.2
Applied rewrites83.2%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6483.2
Applied rewrites83.2%
Taylor expanded in phi1 around 0
Applied rewrites81.1%
Taylor expanded in phi2 around 0
Applied rewrites82.2%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (sin (- lambda1 lambda2))))
(if (<= phi2_m 1.45e+14)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
t_0)
(+
(cos phi1)
(* (fma (* phi2_m phi2_m) -0.5 1.0) (cos (- lambda1 lambda2))))))
(+ lambda1 (atan2 (* (cos phi2_m) t_0) (+ 1.0 (cos phi2_m)))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = sin((lambda1 - lambda2));
double tmp;
if (phi2_m <= 1.45e+14) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * t_0), (cos(phi1) + (fma((phi2_m * phi2_m), -0.5, 1.0) * cos((lambda1 - lambda2)))));
} else {
tmp = lambda1 + atan2((cos(phi2_m) * t_0), (1.0 + cos(phi2_m)));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = sin(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2_m <= 1.45e+14) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * t_0), Float64(cos(phi1) + Float64(fma(Float64(phi2_m * phi2_m), -0.5, 1.0) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(lambda1 + atan(Float64(cos(phi2_m) * t_0), Float64(1.0 + cos(phi2_m)))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2$95$m, 1.45e+14], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + N[(N[(N[(phi2$95$m * phi2$95$m), $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$95$m], $MachinePrecision] * t$95$0), $MachinePrecision] / N[(1.0 + N[Cos[phi2$95$m], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \sin \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;phi2\_m \leq 1.45 \cdot 10^{+14}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot t\_0}{\cos \phi_1 + \mathsf{fma}\left(phi2\_m \cdot phi2\_m, -0.5, 1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\cos phi2\_m \cdot t\_0}{1 + \cos phi2\_m}\\
\end{array}
\end{array}
if phi2 < 1.45e14Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6487.7
Applied rewrites87.7%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
pow2N/A
lift-*.f6487.8
Applied rewrites87.8%
if 1.45e14 < phi2 Initial program 99.3%
Taylor expanded in lambda2 around 0
+-commutativeN/A
lower-fma.f64N/A
lower-cos.f64N/A
lift-cos.f64N/A
lift-cos.f6484.9
Applied rewrites84.9%
Taylor expanded in lambda1 around 0
lower-+.f64N/A
lift-cos.f64N/A
lift-cos.f6483.6
Applied rewrites83.6%
Taylor expanded in phi1 around 0
lower-+.f64N/A
lift-cos.f6470.8
Applied rewrites70.8%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= (cos phi1) 0.946)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
(fma -1.0 lambda2 lambda1))
(+ (cos phi1) t_0)))
(+ lambda1 (atan2 (* 1.0 (sin (- lambda1 lambda2))) (+ 1.0 t_0))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.946) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * fma(-1.0, lambda2, lambda1)), (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + t_0));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.946) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * fma(-1.0, lambda2, lambda1)), Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(1.0 + t_0))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.946], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * N[(-1.0 * lambda2 + lambda1), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.946:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \mathsf{fma}\left(-1, \lambda_2, \lambda_1\right)}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.94599999999999995Initial program 99.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6477.6
Applied rewrites77.6%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6476.8
Applied rewrites76.8%
Taylor expanded in lambda1 around 0
cos-neg-revN/A
*-commutativeN/A
+-commutativeN/A
lower-fma.f64N/A
lift-cos.f64N/A
sin-neg-revN/A
lower-neg.f64N/A
lift-sin.f6476.9
Applied rewrites76.9%
Taylor expanded in lambda2 around 0
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
lower-fma.f6460.7
Applied rewrites60.7%
if 0.94599999999999995 < (cos.f64 phi1) Initial program 99.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6483.2
Applied rewrites83.2%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6483.2
Applied rewrites83.2%
Taylor expanded in phi1 around 0
Applied rewrites81.1%
Taylor expanded in phi2 around 0
Applied rewrites82.2%
phi2_m = (fabs.f64 phi2)
(FPCore (lambda1 lambda2 phi1 phi2_m)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= (cos phi1) 0.65)
(+
lambda1
(atan2
(*
(fma
(- (* (* phi2_m phi2_m) 0.041666666666666664) 0.5)
(* phi2_m phi2_m)
1.0)
lambda1)
(+ (cos phi1) t_0)))
(+ lambda1 (atan2 (* 1.0 (sin (- lambda1 lambda2))) (+ 1.0 t_0))))))phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (cos(phi1) <= 0.65) {
tmp = lambda1 + atan2((fma((((phi2_m * phi2_m) * 0.041666666666666664) - 0.5), (phi2_m * phi2_m), 1.0) * lambda1), (cos(phi1) + t_0));
} else {
tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + t_0));
}
return tmp;
}
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (cos(phi1) <= 0.65) tmp = Float64(lambda1 + atan(Float64(fma(Float64(Float64(Float64(phi2_m * phi2_m) * 0.041666666666666664) - 0.5), Float64(phi2_m * phi2_m), 1.0) * lambda1), Float64(cos(phi1) + t_0))); else tmp = Float64(lambda1 + atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(1.0 + t_0))); end return tmp end
phi2_m = N[Abs[phi2], $MachinePrecision]
code[lambda1_, lambda2_, phi1_, phi2$95$m_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Cos[phi1], $MachinePrecision], 0.65], N[(lambda1 + N[ArcTan[N[(N[(N[(N[(N[(phi2$95$m * phi2$95$m), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] - 0.5), $MachinePrecision] * N[(phi2$95$m * phi2$95$m), $MachinePrecision] + 1.0), $MachinePrecision] * lambda1), $MachinePrecision] / N[(N[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos \phi_1 \leq 0.65:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{\mathsf{fma}\left(\left(phi2\_m \cdot phi2\_m\right) \cdot 0.041666666666666664 - 0.5, phi2\_m \cdot phi2\_m, 1\right) \cdot \lambda_1}{\cos \phi_1 + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + t\_0}\\
\end{array}
\end{array}
if (cos.f64 phi1) < 0.650000000000000022Initial program 98.9%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6478.5
Applied rewrites78.5%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6477.8
Applied rewrites77.8%
Taylor expanded in lambda1 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
cos-neg-revN/A
+-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
sin-neg-revN/A
lower-neg.f64N/A
lift-sin.f64N/A
lift-cos.f64N/A
sin-neg-revN/A
lower-neg.f64N/A
lift-sin.f6477.8
Applied rewrites77.8%
Taylor expanded in lambda2 around 0
Applied rewrites56.8%
if 0.650000000000000022 < (cos.f64 phi1) Initial program 99.1%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6481.6
Applied rewrites81.6%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6481.4
Applied rewrites81.4%
Taylor expanded in phi1 around 0
Applied rewrites76.8%
Taylor expanded in phi2 around 0
Applied rewrites78.3%
phi2_m = (fabs.f64 phi2) (FPCore (lambda1 lambda2 phi1 phi2_m) :precision binary64 (+ lambda1 (atan2 (sin (- lambda1 lambda2)) (+ (cos phi1) (cos (- lambda1 lambda2))))))
phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2))));
}
phi2_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2_m
code = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2))))
end function
phi2_m = Math.abs(phi2);
public static double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1 + Math.atan2(Math.sin((lambda1 - lambda2)), (Math.cos(phi1) + Math.cos((lambda1 - lambda2))));
}
phi2_m = math.fabs(phi2) def code(lambda1, lambda2, phi1, phi2_m): return lambda1 + math.atan2(math.sin((lambda1 - lambda2)), (math.cos(phi1) + math.cos((lambda1 - lambda2))))
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) return Float64(lambda1 + atan(sin(Float64(lambda1 - lambda2)), Float64(cos(phi1) + cos(Float64(lambda1 - lambda2))))) end
phi2_m = abs(phi2); function tmp = code(lambda1, lambda2, phi1, phi2_m) tmp = lambda1 + atan2(sin((lambda1 - lambda2)), (cos(phi1) + cos((lambda1 - lambda2)))); end
phi2_m = N[Abs[phi2], $MachinePrecision] code[lambda1_, lambda2_, phi1_, phi2$95$m_] := 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}
phi2_m = \left|\phi_2\right|
\\
\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 99.0%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6482.1
Applied rewrites82.1%
Taylor expanded in phi2 around 0
lift-sin.f64N/A
lift--.f6481.1
Applied rewrites81.1%
phi2_m = (fabs.f64 phi2) (FPCore (lambda1 lambda2 phi1 phi2_m) :precision binary64 (+ lambda1 (atan2 (* 1.0 (sin (- lambda1 lambda2))) (+ 1.0 (cos (- lambda1 lambda2))))))
phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + cos((lambda1 - lambda2))));
}
phi2_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2_m
code = lambda1 + atan2((1.0d0 * sin((lambda1 - lambda2))), (1.0d0 + cos((lambda1 - lambda2))))
end function
phi2_m = Math.abs(phi2);
public static double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1 + Math.atan2((1.0 * Math.sin((lambda1 - lambda2))), (1.0 + Math.cos((lambda1 - lambda2))));
}
phi2_m = math.fabs(phi2) def code(lambda1, lambda2, phi1, phi2_m): return lambda1 + math.atan2((1.0 * math.sin((lambda1 - lambda2))), (1.0 + math.cos((lambda1 - lambda2))))
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) return Float64(lambda1 + atan(Float64(1.0 * sin(Float64(lambda1 - lambda2))), Float64(1.0 + cos(Float64(lambda1 - lambda2))))) end
phi2_m = abs(phi2); function tmp = code(lambda1, lambda2, phi1, phi2_m) tmp = lambda1 + atan2((1.0 * sin((lambda1 - lambda2))), (1.0 + cos((lambda1 - lambda2)))); end
phi2_m = N[Abs[phi2], $MachinePrecision] code[lambda1_, lambda2_, phi1_, phi2$95$m_] := N[(lambda1 + N[ArcTan[N[(1.0 * N[Sin[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\lambda_1 + \tan^{-1}_* \frac{1 \cdot \sin \left(\lambda_1 - \lambda_2\right)}{1 + \cos \left(\lambda_1 - \lambda_2\right)}
\end{array}
Initial program 99.0%
Taylor expanded in phi2 around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6480.4
Applied rewrites80.4%
Taylor expanded in phi2 around 0
lift-cos.f64N/A
lift--.f6480.0
Applied rewrites80.0%
Taylor expanded in phi1 around 0
Applied rewrites67.2%
Taylor expanded in phi2 around 0
Applied rewrites68.1%
phi2_m = (fabs.f64 phi2) (FPCore (lambda1 lambda2 phi1 phi2_m) :precision binary64 lambda1)
phi2_m = fabs(phi2);
double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1;
}
phi2_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2_m
code = lambda1
end function
phi2_m = Math.abs(phi2);
public static double code(double lambda1, double lambda2, double phi1, double phi2_m) {
return lambda1;
}
phi2_m = math.fabs(phi2) def code(lambda1, lambda2, phi1, phi2_m): return lambda1
phi2_m = abs(phi2) function code(lambda1, lambda2, phi1, phi2_m) return lambda1 end
phi2_m = abs(phi2); function tmp = code(lambda1, lambda2, phi1, phi2_m) tmp = lambda1; end
phi2_m = N[Abs[phi2], $MachinePrecision] code[lambda1_, lambda2_, phi1_, phi2$95$m_] := lambda1
\begin{array}{l}
phi2_m = \left|\phi_2\right|
\\
\lambda_1
\end{array}
Initial program 99.0%
Taylor expanded in lambda1 around inf
Applied rewrites56.3%
herbie shell --seed 2025052
(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)))))))