
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(+
lambda1
(atan2
(* (* (sin theta) (sin delta)) (cos phi1))
(-
(cos delta)
(*
(sin phi1)
(sin
(asin
(+
(* (sin phi1) (cos delta))
(* (* (cos phi1) (sin delta)) (cos theta))))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
}
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, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
code = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))))
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + Math.atan2(((Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1)), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.sin(phi1) * Math.cos(delta)) + ((Math.cos(phi1) * Math.sin(delta)) * Math.cos(theta))))))));
}
def code(lambda1, phi1, phi2, delta, theta): return lambda1 + math.atan2(((math.sin(theta) * math.sin(delta)) * math.cos(phi1)), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.sin(phi1) * math.cos(delta)) + ((math.cos(phi1) * math.sin(delta)) * math.cos(theta))))))))
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(sin(phi1) * cos(delta)) + Float64(Float64(cos(phi1) * sin(delta)) * cos(theta))))))))) end
function tmp = code(lambda1, phi1, phi2, delta, theta) tmp = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta)))))))); end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}
\end{array}
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(+
lambda1
(atan2
(* (* (sin theta) (sin delta)) (cos phi1))
(-
(cos delta)
(*
(sin phi1)
(sin
(asin
(+
(* (sin phi1) (cos delta))
(* (* (cos phi1) (sin delta)) (cos theta))))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
}
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, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
code = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))))
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + Math.atan2(((Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1)), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.sin(phi1) * Math.cos(delta)) + ((Math.cos(phi1) * Math.sin(delta)) * Math.cos(theta))))))));
}
def code(lambda1, phi1, phi2, delta, theta): return lambda1 + math.atan2(((math.sin(theta) * math.sin(delta)) * math.cos(phi1)), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.sin(phi1) * math.cos(delta)) + ((math.cos(phi1) * math.sin(delta)) * math.cos(theta))))))))
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(sin(phi1) * cos(delta)) + Float64(Float64(cos(phi1) * sin(delta)) * cos(theta))))))))) end
function tmp = code(lambda1, phi1, phi2, delta, theta) tmp = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta)))))))); end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}
\end{array}
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(let* ((t_1
(*
(fma
(* (cos theta) (sin delta))
(cos phi1)
(* (sin phi1) (cos delta)))
(sin phi1))))
(+
lambda1
(atan2
(* (* (cos phi1) (sin delta)) (sin theta))
(/
(- (* (pow (cos delta) 2.0) (cos delta)) (pow t_1 3.0))
(fma (cos delta) (cos delta) (+ (pow t_1 2.0) (* (cos delta) t_1))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = fma((cos(theta) * sin(delta)), cos(phi1), (sin(phi1) * cos(delta))) * sin(phi1);
return lambda1 + atan2(((cos(phi1) * sin(delta)) * sin(theta)), (((pow(cos(delta), 2.0) * cos(delta)) - pow(t_1, 3.0)) / fma(cos(delta), cos(delta), (pow(t_1, 2.0) + (cos(delta) * t_1)))));
}
function code(lambda1, phi1, phi2, delta, theta) t_1 = Float64(fma(Float64(cos(theta) * sin(delta)), cos(phi1), Float64(sin(phi1) * cos(delta))) * sin(phi1)) return Float64(lambda1 + atan(Float64(Float64(cos(phi1) * sin(delta)) * sin(theta)), Float64(Float64(Float64((cos(delta) ^ 2.0) * cos(delta)) - (t_1 ^ 3.0)) / fma(cos(delta), cos(delta), Float64((t_1 ^ 2.0) + Float64(cos(delta) * t_1)))))) end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[(N[(N[Cos[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision] / N[(N[(N[(N[Power[N[Cos[delta], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision] - N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] * N[Cos[delta], $MachinePrecision] + N[(N[Power[t$95$1, 2.0], $MachinePrecision] + N[(N[Cos[delta], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\cos theta \cdot \sin delta, \cos \phi_1, \sin \phi_1 \cdot \cos delta\right) \cdot \sin \phi_1\\
\lambda_1 + \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\frac{{\cos delta}^{2} \cdot \cos delta - {t\_1}^{3}}{\mathsf{fma}\left(\cos delta, \cos delta, {t\_1}^{2} + \cos delta \cdot t\_1\right)}}
\end{array}
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.7%
Applied rewrites99.7%
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(let* ((t_1 (* theta (sin delta)))
(t_2
(atan2
(* (* (sin theta) (sin delta)) (cos phi1))
(-
(cos delta)
(*
(sin phi1)
(sin
(asin
(+
(* (sin phi1) (cos delta))
(* (* (cos phi1) (sin delta)) (cos theta))))))))))
(if (<= t_2 -2e-113)
(+ lambda1 (atan2 (* t_1 1.0) (cos delta)))
(if (<= t_2 1e-40)
lambda1
(+
lambda1
(atan2
(* t_1 (cos phi1))
(+
1.0
(*
(* delta delta)
(-
(*
(* delta delta)
(+
0.041666666666666664
(* -0.001388888888888889 (* delta delta))))
0.5)))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = theta * sin(delta);
double t_2 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
double tmp;
if (t_2 <= -2e-113) {
tmp = lambda1 + atan2((t_1 * 1.0), cos(delta));
} else if (t_2 <= 1e-40) {
tmp = lambda1;
} else {
tmp = lambda1 + atan2((t_1 * cos(phi1)), (1.0 + ((delta * delta) * (((delta * delta) * (0.041666666666666664 + (-0.001388888888888889 * (delta * delta)))) - 0.5))));
}
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, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = theta * sin(delta)
t_2 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))))
if (t_2 <= (-2d-113)) then
tmp = lambda1 + atan2((t_1 * 1.0d0), cos(delta))
else if (t_2 <= 1d-40) then
tmp = lambda1
else
tmp = lambda1 + atan2((t_1 * cos(phi1)), (1.0d0 + ((delta * delta) * (((delta * delta) * (0.041666666666666664d0 + ((-0.001388888888888889d0) * (delta * delta)))) - 0.5d0))))
end if
code = tmp
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = theta * Math.sin(delta);
double t_2 = Math.atan2(((Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1)), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.sin(phi1) * Math.cos(delta)) + ((Math.cos(phi1) * Math.sin(delta)) * Math.cos(theta))))))));
double tmp;
if (t_2 <= -2e-113) {
tmp = lambda1 + Math.atan2((t_1 * 1.0), Math.cos(delta));
} else if (t_2 <= 1e-40) {
tmp = lambda1;
} else {
tmp = lambda1 + Math.atan2((t_1 * Math.cos(phi1)), (1.0 + ((delta * delta) * (((delta * delta) * (0.041666666666666664 + (-0.001388888888888889 * (delta * delta)))) - 0.5))));
}
return tmp;
}
def code(lambda1, phi1, phi2, delta, theta): t_1 = theta * math.sin(delta) t_2 = math.atan2(((math.sin(theta) * math.sin(delta)) * math.cos(phi1)), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.sin(phi1) * math.cos(delta)) + ((math.cos(phi1) * math.sin(delta)) * math.cos(theta)))))))) tmp = 0 if t_2 <= -2e-113: tmp = lambda1 + math.atan2((t_1 * 1.0), math.cos(delta)) elif t_2 <= 1e-40: tmp = lambda1 else: tmp = lambda1 + math.atan2((t_1 * math.cos(phi1)), (1.0 + ((delta * delta) * (((delta * delta) * (0.041666666666666664 + (-0.001388888888888889 * (delta * delta)))) - 0.5)))) return tmp
function code(lambda1, phi1, phi2, delta, theta) t_1 = Float64(theta * sin(delta)) t_2 = atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(sin(phi1) * cos(delta)) + Float64(Float64(cos(phi1) * sin(delta)) * cos(theta)))))))) tmp = 0.0 if (t_2 <= -2e-113) tmp = Float64(lambda1 + atan(Float64(t_1 * 1.0), cos(delta))); elseif (t_2 <= 1e-40) tmp = lambda1; else tmp = Float64(lambda1 + atan(Float64(t_1 * cos(phi1)), Float64(1.0 + Float64(Float64(delta * delta) * Float64(Float64(Float64(delta * delta) * Float64(0.041666666666666664 + Float64(-0.001388888888888889 * Float64(delta * delta)))) - 0.5))))); end return tmp end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta) t_1 = theta * sin(delta); t_2 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta)))))))); tmp = 0.0; if (t_2 <= -2e-113) tmp = lambda1 + atan2((t_1 * 1.0), cos(delta)); elseif (t_2 <= 1e-40) tmp = lambda1; else tmp = lambda1 + atan2((t_1 * cos(phi1)), (1.0 + ((delta * delta) * (((delta * delta) * (0.041666666666666664 + (-0.001388888888888889 * (delta * delta)))) - 0.5)))); end tmp_2 = tmp; end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -2e-113], N[(lambda1 + N[ArcTan[N[(t$95$1 * 1.0), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-40], lambda1, N[(lambda1 + N[ArcTan[N[(t$95$1 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[(delta * delta), $MachinePrecision] * N[(N[(N[(delta * delta), $MachinePrecision] * N[(0.041666666666666664 + N[(-0.001388888888888889 * N[(delta * delta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := theta \cdot \sin delta\\
t_2 := \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{-113}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot 1}{\cos delta}\\
\mathbf{elif}\;t\_2 \leq 10^{-40}:\\
\;\;\;\;\lambda_1\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot \cos \phi_1}{1 + \left(delta \cdot delta\right) \cdot \left(\left(delta \cdot delta\right) \cdot \left(0.041666666666666664 + -0.001388888888888889 \cdot \left(delta \cdot delta\right)\right) - 0.5\right)}\\
\end{array}
\end{array}
if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -1.99999999999999996e-113Initial program 99.7%
Taylor expanded in phi1 around 0
Applied rewrites83.2%
Taylor expanded in theta around 0
Applied rewrites66.4%
Taylor expanded in phi1 around 0
Applied rewrites63.7%
if -1.99999999999999996e-113 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 9.9999999999999993e-41Initial program 99.8%
Taylor expanded in lambda1 around inf
Applied rewrites86.6%
if 9.9999999999999993e-41 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) Initial program 99.7%
Taylor expanded in phi1 around 0
Applied rewrites83.7%
Taylor expanded in theta around 0
Applied rewrites67.4%
Taylor expanded in delta around 0
Applied rewrites67.6%
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(let* ((t_1 (* theta (sin delta)))
(t_2
(atan2
(* (* (sin theta) (sin delta)) (cos phi1))
(-
(cos delta)
(*
(sin phi1)
(sin
(asin
(+
(* (sin phi1) (cos delta))
(* (* (cos phi1) (sin delta)) (cos theta))))))))))
(if (<= t_2 -2e-113)
(+ lambda1 (atan2 (* t_1 1.0) (cos delta)))
(if (<= t_2 1e-40)
lambda1
(+
lambda1
(atan2 (* t_1 (cos phi1)) (+ 1.0 (* -0.5 (* delta delta)))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = theta * sin(delta);
double t_2 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
double tmp;
if (t_2 <= -2e-113) {
tmp = lambda1 + atan2((t_1 * 1.0), cos(delta));
} else if (t_2 <= 1e-40) {
tmp = lambda1;
} else {
tmp = lambda1 + atan2((t_1 * cos(phi1)), (1.0 + (-0.5 * (delta * delta))));
}
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, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = theta * sin(delta)
t_2 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))))
if (t_2 <= (-2d-113)) then
tmp = lambda1 + atan2((t_1 * 1.0d0), cos(delta))
else if (t_2 <= 1d-40) then
tmp = lambda1
else
tmp = lambda1 + atan2((t_1 * cos(phi1)), (1.0d0 + ((-0.5d0) * (delta * delta))))
end if
code = tmp
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = theta * Math.sin(delta);
double t_2 = Math.atan2(((Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1)), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.sin(phi1) * Math.cos(delta)) + ((Math.cos(phi1) * Math.sin(delta)) * Math.cos(theta))))))));
double tmp;
if (t_2 <= -2e-113) {
tmp = lambda1 + Math.atan2((t_1 * 1.0), Math.cos(delta));
} else if (t_2 <= 1e-40) {
tmp = lambda1;
} else {
tmp = lambda1 + Math.atan2((t_1 * Math.cos(phi1)), (1.0 + (-0.5 * (delta * delta))));
}
return tmp;
}
def code(lambda1, phi1, phi2, delta, theta): t_1 = theta * math.sin(delta) t_2 = math.atan2(((math.sin(theta) * math.sin(delta)) * math.cos(phi1)), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.sin(phi1) * math.cos(delta)) + ((math.cos(phi1) * math.sin(delta)) * math.cos(theta)))))))) tmp = 0 if t_2 <= -2e-113: tmp = lambda1 + math.atan2((t_1 * 1.0), math.cos(delta)) elif t_2 <= 1e-40: tmp = lambda1 else: tmp = lambda1 + math.atan2((t_1 * math.cos(phi1)), (1.0 + (-0.5 * (delta * delta)))) return tmp
function code(lambda1, phi1, phi2, delta, theta) t_1 = Float64(theta * sin(delta)) t_2 = atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(sin(phi1) * cos(delta)) + Float64(Float64(cos(phi1) * sin(delta)) * cos(theta)))))))) tmp = 0.0 if (t_2 <= -2e-113) tmp = Float64(lambda1 + atan(Float64(t_1 * 1.0), cos(delta))); elseif (t_2 <= 1e-40) tmp = lambda1; else tmp = Float64(lambda1 + atan(Float64(t_1 * cos(phi1)), Float64(1.0 + Float64(-0.5 * Float64(delta * delta))))); end return tmp end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta) t_1 = theta * sin(delta); t_2 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta)))))))); tmp = 0.0; if (t_2 <= -2e-113) tmp = lambda1 + atan2((t_1 * 1.0), cos(delta)); elseif (t_2 <= 1e-40) tmp = lambda1; else tmp = lambda1 + atan2((t_1 * cos(phi1)), (1.0 + (-0.5 * (delta * delta)))); end tmp_2 = tmp; end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -2e-113], N[(lambda1 + N[ArcTan[N[(t$95$1 * 1.0), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e-40], lambda1, N[(lambda1 + N[ArcTan[N[(t$95$1 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(-0.5 * N[(delta * delta), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := theta \cdot \sin delta\\
t_2 := \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{-113}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot 1}{\cos delta}\\
\mathbf{elif}\;t\_2 \leq 10^{-40}:\\
\;\;\;\;\lambda_1\\
\mathbf{else}:\\
\;\;\;\;\lambda_1 + \tan^{-1}_* \frac{t\_1 \cdot \cos \phi_1}{1 + -0.5 \cdot \left(delta \cdot delta\right)}\\
\end{array}
\end{array}
if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -1.99999999999999996e-113Initial program 99.7%
Taylor expanded in phi1 around 0
Applied rewrites83.2%
Taylor expanded in theta around 0
Applied rewrites66.4%
Taylor expanded in phi1 around 0
Applied rewrites63.7%
if -1.99999999999999996e-113 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 9.9999999999999993e-41Initial program 99.8%
Taylor expanded in lambda1 around inf
Applied rewrites86.6%
if 9.9999999999999993e-41 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) Initial program 99.7%
Taylor expanded in phi1 around 0
Applied rewrites83.7%
Taylor expanded in theta around 0
Applied rewrites67.4%
Taylor expanded in delta around 0
Applied rewrites67.6%
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(let* ((t_1
(*
(fma
(* (cos theta) (sin delta))
(cos phi1)
(* (sin phi1) (cos delta)))
(sin phi1))))
(+
lambda1
(atan2
(* (* (cos phi1) (sin delta)) (sin theta))
(/
(- (pow (cos delta) 3.0) (pow t_1 3.0))
(fma (cos delta) (cos delta) (+ (pow t_1 2.0) (* (cos delta) t_1))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = fma((cos(theta) * sin(delta)), cos(phi1), (sin(phi1) * cos(delta))) * sin(phi1);
return lambda1 + atan2(((cos(phi1) * sin(delta)) * sin(theta)), ((pow(cos(delta), 3.0) - pow(t_1, 3.0)) / fma(cos(delta), cos(delta), (pow(t_1, 2.0) + (cos(delta) * t_1)))));
}
function code(lambda1, phi1, phi2, delta, theta) t_1 = Float64(fma(Float64(cos(theta) * sin(delta)), cos(phi1), Float64(sin(phi1) * cos(delta))) * sin(phi1)) return Float64(lambda1 + atan(Float64(Float64(cos(phi1) * sin(delta)) * sin(theta)), Float64(Float64((cos(delta) ^ 3.0) - (t_1 ^ 3.0)) / fma(cos(delta), cos(delta), Float64((t_1 ^ 2.0) + Float64(cos(delta) * t_1)))))) end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(N[(N[(N[Cos[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]}, N[(lambda1 + N[ArcTan[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision] / N[(N[(N[Power[N[Cos[delta], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] * N[Cos[delta], $MachinePrecision] + N[(N[Power[t$95$1, 2.0], $MachinePrecision] + N[(N[Cos[delta], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\cos theta \cdot \sin delta, \cos \phi_1, \sin \phi_1 \cdot \cos delta\right) \cdot \sin \phi_1\\
\lambda_1 + \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\frac{{\cos delta}^{3} - {t\_1}^{3}}{\mathsf{fma}\left(\cos delta, \cos delta, {t\_1}^{2} + \cos delta \cdot t\_1\right)}}
\end{array}
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Applied rewrites99.8%
Applied rewrites99.7%
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(let* ((t_1
(atan2
(* (* (sin theta) (sin delta)) (cos phi1))
(-
(cos delta)
(*
(sin phi1)
(sin
(asin
(+
(* (sin phi1) (cos delta))
(* (* (cos phi1) (sin delta)) (cos theta)))))))))
(t_2 (+ lambda1 (atan2 (* (* theta delta) (cos phi1)) (cos delta)))))
(if (<= t_1 -0.05) t_2 (if (<= t_1 1e-40) lambda1 t_2))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))));
double t_2 = lambda1 + atan2(((theta * delta) * cos(phi1)), cos(delta));
double tmp;
if (t_1 <= -0.05) {
tmp = t_2;
} else if (t_1 <= 1e-40) {
tmp = lambda1;
} else {
tmp = t_2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta))))))))
t_2 = lambda1 + atan2(((theta * delta) * cos(phi1)), cos(delta))
if (t_1 <= (-0.05d0)) then
tmp = t_2
else if (t_1 <= 1d-40) then
tmp = lambda1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = Math.atan2(((Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1)), (Math.cos(delta) - (Math.sin(phi1) * Math.sin(Math.asin(((Math.sin(phi1) * Math.cos(delta)) + ((Math.cos(phi1) * Math.sin(delta)) * Math.cos(theta))))))));
double t_2 = lambda1 + Math.atan2(((theta * delta) * Math.cos(phi1)), Math.cos(delta));
double tmp;
if (t_1 <= -0.05) {
tmp = t_2;
} else if (t_1 <= 1e-40) {
tmp = lambda1;
} else {
tmp = t_2;
}
return tmp;
}
def code(lambda1, phi1, phi2, delta, theta): t_1 = math.atan2(((math.sin(theta) * math.sin(delta)) * math.cos(phi1)), (math.cos(delta) - (math.sin(phi1) * math.sin(math.asin(((math.sin(phi1) * math.cos(delta)) + ((math.cos(phi1) * math.sin(delta)) * math.cos(theta)))))))) t_2 = lambda1 + math.atan2(((theta * delta) * math.cos(phi1)), math.cos(delta)) tmp = 0 if t_1 <= -0.05: tmp = t_2 elif t_1 <= 1e-40: tmp = lambda1 else: tmp = t_2 return tmp
function code(lambda1, phi1, phi2, delta, theta) t_1 = atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - Float64(sin(phi1) * sin(asin(Float64(Float64(sin(phi1) * cos(delta)) + Float64(Float64(cos(phi1) * sin(delta)) * cos(theta)))))))) t_2 = Float64(lambda1 + atan(Float64(Float64(theta * delta) * cos(phi1)), cos(delta))) tmp = 0.0 if (t_1 <= -0.05) tmp = t_2; elseif (t_1 <= 1e-40) tmp = lambda1; else tmp = t_2; end return tmp end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta) t_1 = atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * sin(asin(((sin(phi1) * cos(delta)) + ((cos(phi1) * sin(delta)) * cos(theta)))))))); t_2 = lambda1 + atan2(((theta * delta) * cos(phi1)), cos(delta)); tmp = 0.0; if (t_1 <= -0.05) tmp = t_2; elseif (t_1 <= 1e-40) tmp = lambda1; else tmp = t_2; end tmp_2 = tmp; end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[Sin[N[ArcSin[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[theta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(lambda1 + N[ArcTan[N[(N[(theta * delta), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -0.05], t$95$2, If[LessEqual[t$95$1, 1e-40], lambda1, t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \sin \sin^{-1} \left(\sin \phi_1 \cdot \cos delta + \left(\cos \phi_1 \cdot \sin delta\right) \cdot \cos theta\right)}\\
t_2 := \lambda_1 + \tan^{-1}_* \frac{\left(theta \cdot delta\right) \cdot \cos \phi_1}{\cos delta}\\
\mathbf{if}\;t\_1 \leq -0.05:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 10^{-40}:\\
\;\;\;\;\lambda_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < -0.050000000000000003 or 9.9999999999999993e-41 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) Initial program 99.8%
Taylor expanded in phi1 around 0
Applied rewrites83.7%
Taylor expanded in theta around 0
Applied rewrites67.4%
Taylor expanded in delta around 0
Applied rewrites56.6%
if -0.050000000000000003 < (atan2.f64 (*.f64 (*.f64 (sin.f64 theta) (sin.f64 delta)) (cos.f64 phi1)) (-.f64 (cos.f64 delta) (*.f64 (sin.f64 phi1) (sin.f64 (asin.f64 (+.f64 (*.f64 (sin.f64 phi1) (cos.f64 delta)) (*.f64 (*.f64 (cos.f64 phi1) (sin.f64 delta)) (cos.f64 theta)))))))) < 9.9999999999999993e-41Initial program 99.7%
Taylor expanded in lambda1 around inf
Applied rewrites82.8%
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(+
lambda1
(atan2
(* (* (cos phi1) (sin delta)) (sin theta))
(-
(cos delta)
(*
(sin phi1)
(fma
(* (cos theta) (cos phi1))
(sin delta)
(* (sin phi1) (cos delta))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2(((cos(phi1) * sin(delta)) * sin(theta)), (cos(delta) - (sin(phi1) * fma((cos(theta) * cos(phi1)), sin(delta), (sin(phi1) * cos(delta))))));
}
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(Float64(cos(phi1) * sin(delta)) * sin(theta)), Float64(cos(delta) - Float64(sin(phi1) * fma(Float64(cos(theta) * cos(phi1)), sin(delta), Float64(sin(phi1) * cos(delta))))))) end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Sin[delta], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\cos theta \cdot \cos \phi_1, \sin delta, \sin \phi_1 \cdot \cos delta\right)}
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Applied rewrites99.8%
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(+
(atan2
(* (sin theta) (* (sin delta) (cos phi1)))
(-
(cos delta)
(* (fma (cos phi1) (sin delta) (* (sin phi1) (cos delta))) (sin phi1))))
lambda1))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return atan2((sin(theta) * (sin(delta) * cos(phi1))), (cos(delta) - (fma(cos(phi1), sin(delta), (sin(phi1) * cos(delta))) * sin(phi1)))) + lambda1;
}
function code(lambda1, phi1, phi2, delta, theta) return Float64(atan(Float64(sin(theta) * Float64(sin(delta) * cos(phi1))), Float64(cos(delta) - Float64(fma(cos(phi1), sin(delta), Float64(sin(phi1) * cos(delta))) * sin(phi1)))) + lambda1) end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(N[ArcTan[N[(N[Sin[theta], $MachinePrecision] * N[(N[Sin[delta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + lambda1), $MachinePrecision]
\begin{array}{l}
\\
\tan^{-1}_* \frac{\sin theta \cdot \left(\sin delta \cdot \cos \phi_1\right)}{\cos delta - \mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1 \cdot \cos delta\right) \cdot \sin \phi_1} + \lambda_1
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in theta around 0
Applied rewrites94.5%
Applied rewrites94.5%
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(+
lambda1
(atan2
(* (* (sin theta) (sin delta)) (cos phi1))
(-
(cos delta)
(* (sin phi1) (fma (cos phi1) (sin delta) (* (sin phi1) (cos delta))))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * fma(cos(phi1), sin(delta), (sin(phi1) * cos(delta))))));
}
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - Float64(sin(phi1) * fma(cos(phi1), sin(delta), Float64(sin(phi1) * cos(delta))))))) end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Cos[delta], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1 \cdot \cos delta\right)}
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in theta around 0
Applied rewrites94.5%
(FPCore (lambda1 phi1 phi2 delta theta)
:precision binary64
(+
lambda1
(atan2
(* (* (cos phi1) (sin delta)) (sin theta))
(-
(cos delta)
(* (sin phi1) (fma (* (cos theta) (cos phi1)) (sin delta) (sin phi1)))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2(((cos(phi1) * sin(delta)) * sin(theta)), (cos(delta) - (sin(phi1) * fma((cos(theta) * cos(phi1)), sin(delta), sin(phi1)))));
}
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(Float64(cos(phi1) * sin(delta)) * sin(theta)), Float64(cos(delta) - Float64(sin(phi1) * fma(Float64(cos(theta) * cos(phi1)), sin(delta), sin(phi1)))))) end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[(N[Cos[theta], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] * N[Sin[delta], $MachinePrecision] + N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(\cos \phi_1 \cdot \sin delta\right) \cdot \sin theta}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\cos theta \cdot \cos \phi_1, \sin delta, \sin \phi_1\right)}
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Applied rewrites99.8%
Taylor expanded in delta around 0
Applied rewrites92.7%
(FPCore (lambda1 phi1 phi2 delta theta) :precision binary64 (+ lambda1 (atan2 (* (* (sin theta) (sin delta)) (cos phi1)) (- (cos delta) (* (sin phi1) (fma (cos phi1) (sin delta) (sin phi1)))))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) * fma(cos(phi1), sin(delta), sin(phi1)))));
}
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - Float64(sin(phi1) * fma(cos(phi1), sin(delta), sin(phi1)))))) end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[(N[Sin[phi1], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[delta], $MachinePrecision] + N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - \sin \phi_1 \cdot \mathsf{fma}\left(\cos \phi_1, \sin delta, \sin \phi_1\right)}
\end{array}
Initial program 99.7%
Applied rewrites99.8%
Taylor expanded in theta around 0
Applied rewrites94.5%
Taylor expanded in delta around 0
Applied rewrites92.5%
(FPCore (lambda1 phi1 phi2 delta theta) :precision binary64 (+ lambda1 (atan2 (* (* (sin theta) (sin delta)) (cos phi1)) (- (cos delta) (pow (sin phi1) 2.0)))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - pow(sin(phi1), 2.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, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
code = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) ** 2.0d0)))
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + Math.atan2(((Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1)), (Math.cos(delta) - Math.pow(Math.sin(phi1), 2.0)));
}
def code(lambda1, phi1, phi2, delta, theta): return lambda1 + math.atan2(((math.sin(theta) * math.sin(delta)) * math.cos(phi1)), (math.cos(delta) - math.pow(math.sin(phi1), 2.0)))
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), Float64(cos(delta) - (sin(phi1) ^ 2.0)))) end
function tmp = code(lambda1, phi1, phi2, delta, theta) tmp = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), (cos(delta) - (sin(phi1) ^ 2.0))); end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[(N[Cos[delta], $MachinePrecision] - N[Power[N[Sin[phi1], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta - {\sin \phi_1}^{2}}
\end{array}
Initial program 99.7%
Taylor expanded in delta around 0
Applied rewrites92.2%
(FPCore (lambda1 phi1 phi2 delta theta) :precision binary64 (+ lambda1 (atan2 (* (* (sin theta) (sin delta)) (cos phi1)) (cos delta))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), cos(delta));
}
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, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
code = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), cos(delta))
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + Math.atan2(((Math.sin(theta) * Math.sin(delta)) * Math.cos(phi1)), Math.cos(delta));
}
def code(lambda1, phi1, phi2, delta, theta): return lambda1 + math.atan2(((math.sin(theta) * math.sin(delta)) * math.cos(phi1)), math.cos(delta))
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(Float64(sin(theta) * sin(delta)) * cos(phi1)), cos(delta))) end
function tmp = code(lambda1, phi1, phi2, delta, theta) tmp = lambda1 + atan2(((sin(theta) * sin(delta)) * cos(phi1)), cos(delta)); end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[(N[Sin[theta], $MachinePrecision] * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\left(\sin theta \cdot \sin delta\right) \cdot \cos \phi_1}{\cos delta}
\end{array}
Initial program 99.7%
Taylor expanded in phi1 around 0
Applied rewrites88.4%
(FPCore (lambda1 phi1 phi2 delta theta) :precision binary64 (+ lambda1 (atan2 (* (sin delta) (sin theta)) (cos delta))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + atan2((sin(delta) * sin(theta)), cos(delta));
}
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, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
code = lambda1 + atan2((sin(delta) * sin(theta)), cos(delta))
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1 + Math.atan2((Math.sin(delta) * Math.sin(theta)), Math.cos(delta));
}
def code(lambda1, phi1, phi2, delta, theta): return lambda1 + math.atan2((math.sin(delta) * math.sin(theta)), math.cos(delta))
function code(lambda1, phi1, phi2, delta, theta) return Float64(lambda1 + atan(Float64(sin(delta) * sin(theta)), cos(delta))) end
function tmp = code(lambda1, phi1, phi2, delta, theta) tmp = lambda1 + atan2((sin(delta) * sin(theta)), cos(delta)); end
code[lambda1_, phi1_, phi2_, delta_, theta_] := N[(lambda1 + N[ArcTan[N[(N[Sin[delta], $MachinePrecision] * N[Sin[theta], $MachinePrecision]), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\lambda_1 + \tan^{-1}_* \frac{\sin delta \cdot \sin theta}{\cos delta}
\end{array}
Initial program 99.7%
Taylor expanded in phi1 around 0
Applied rewrites88.4%
Taylor expanded in theta around 0
Applied rewrites74.9%
Taylor expanded in phi1 around 0
Applied rewrites86.1%
(FPCore (lambda1 phi1 phi2 delta theta) :precision binary64 (let* ((t_1 (+ lambda1 (atan2 (* (* theta (sin delta)) 1.0) (cos delta))))) (if (<= delta -4.6e-217) t_1 (if (<= delta 2.25e-33) lambda1 t_1))))
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = lambda1 + atan2(((theta * sin(delta)) * 1.0), cos(delta));
double tmp;
if (delta <= -4.6e-217) {
tmp = t_1;
} else if (delta <= 2.25e-33) {
tmp = lambda1;
} else {
tmp = t_1;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(lambda1, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
real(8) :: t_1
real(8) :: tmp
t_1 = lambda1 + atan2(((theta * sin(delta)) * 1.0d0), cos(delta))
if (delta <= (-4.6d-217)) then
tmp = t_1
else if (delta <= 2.25d-33) then
tmp = lambda1
else
tmp = t_1
end if
code = tmp
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
double t_1 = lambda1 + Math.atan2(((theta * Math.sin(delta)) * 1.0), Math.cos(delta));
double tmp;
if (delta <= -4.6e-217) {
tmp = t_1;
} else if (delta <= 2.25e-33) {
tmp = lambda1;
} else {
tmp = t_1;
}
return tmp;
}
def code(lambda1, phi1, phi2, delta, theta): t_1 = lambda1 + math.atan2(((theta * math.sin(delta)) * 1.0), math.cos(delta)) tmp = 0 if delta <= -4.6e-217: tmp = t_1 elif delta <= 2.25e-33: tmp = lambda1 else: tmp = t_1 return tmp
function code(lambda1, phi1, phi2, delta, theta) t_1 = Float64(lambda1 + atan(Float64(Float64(theta * sin(delta)) * 1.0), cos(delta))) tmp = 0.0 if (delta <= -4.6e-217) tmp = t_1; elseif (delta <= 2.25e-33) tmp = lambda1; else tmp = t_1; end return tmp end
function tmp_2 = code(lambda1, phi1, phi2, delta, theta) t_1 = lambda1 + atan2(((theta * sin(delta)) * 1.0), cos(delta)); tmp = 0.0; if (delta <= -4.6e-217) tmp = t_1; elseif (delta <= 2.25e-33) tmp = lambda1; else tmp = t_1; end tmp_2 = tmp; end
code[lambda1_, phi1_, phi2_, delta_, theta_] := Block[{t$95$1 = N[(lambda1 + N[ArcTan[N[(N[(theta * N[Sin[delta], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision] / N[Cos[delta], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[delta, -4.6e-217], t$95$1, If[LessEqual[delta, 2.25e-33], lambda1, t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \lambda_1 + \tan^{-1}_* \frac{\left(theta \cdot \sin delta\right) \cdot 1}{\cos delta}\\
\mathbf{if}\;delta \leq -4.6 \cdot 10^{-217}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;delta \leq 2.25 \cdot 10^{-33}:\\
\;\;\;\;\lambda_1\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if delta < -4.6000000000000001e-217 or 2.24999999999999995e-33 < delta Initial program 99.7%
Taylor expanded in phi1 around 0
Applied rewrites85.9%
Taylor expanded in theta around 0
Applied rewrites73.1%
Taylor expanded in phi1 around 0
Applied rewrites71.1%
if -4.6000000000000001e-217 < delta < 2.24999999999999995e-33Initial program 99.8%
Taylor expanded in lambda1 around inf
Applied rewrites87.8%
(FPCore (lambda1 phi1 phi2 delta theta) :precision binary64 lambda1)
double code(double lambda1, double phi1, double phi2, double delta, double theta) {
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, phi1, phi2, delta, theta)
use fmin_fmax_functions
real(8), intent (in) :: lambda1
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8), intent (in) :: delta
real(8), intent (in) :: theta
code = lambda1
end function
public static double code(double lambda1, double phi1, double phi2, double delta, double theta) {
return lambda1;
}
def code(lambda1, phi1, phi2, delta, theta): return lambda1
function code(lambda1, phi1, phi2, delta, theta) return lambda1 end
function tmp = code(lambda1, phi1, phi2, delta, theta) tmp = lambda1; end
code[lambda1_, phi1_, phi2_, delta_, theta_] := lambda1
\begin{array}{l}
\\
\lambda_1
\end{array}
Initial program 99.7%
Taylor expanded in lambda1 around inf
Applied rewrites70.2%
herbie shell --seed 2025106
(FPCore (lambda1 phi1 phi2 delta theta)
:name "Destination given bearing on a great circle"
:precision binary64
(+ lambda1 (atan2 (* (* (sin theta) (sin delta)) (cos phi1)) (- (cos delta) (* (sin phi1) (sin (asin (+ (* (sin phi1) (cos delta)) (* (* (cos phi1) (sin delta)) (cos theta))))))))))