
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))))) (* R (sqrt (+ (* t_0 t_0) (* (- phi1 phi2) (- phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0));
return R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0d0))
code = r * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * Math.cos(((phi1 + phi2) / 2.0));
return R * Math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * math.cos(((phi1 + phi2) / 2.0)) return R * math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) / 2.0))) return Float64(R * sqrt(Float64(Float64(t_0 * t_0) + Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0)); tmp = R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
R \cdot \sqrt{t\_0 \cdot t\_0 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}
\end{array}
\end{array}
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))))) (* R (sqrt (+ (* t_0 t_0) (* (- phi1 phi2) (- phi1 phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0));
return R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0d0))
code = r * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * Math.cos(((phi1 + phi2) / 2.0));
return R * Math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * math.cos(((phi1 + phi2) / 2.0)) return R * math.sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * cos(Float64(Float64(phi1 + phi2) / 2.0))) return Float64(R * sqrt(Float64(Float64(t_0 * t_0) + Float64(Float64(phi1 - phi2) * Float64(phi1 - phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * cos(((phi1 + phi2) / 2.0)); tmp = R * sqrt(((t_0 * t_0) + ((phi1 - phi2) * (phi1 - phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[Sqrt[N[(N[(t$95$0 * t$95$0), $MachinePrecision] + N[(N[(phi1 - phi2), $MachinePrecision] * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot \cos \left(\frac{\phi_1 + \phi_2}{2}\right)\\
R \cdot \sqrt{t\_0 \cdot t\_0 + \left(\phi_1 - \phi_2\right) \cdot \left(\phi_1 - \phi_2\right)}
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (hypot (- phi1 phi2) (* (cos (/ (+ phi2 phi1) 2.0)) (- lambda1 lambda2))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi1 - phi2), (cos(((phi2 + phi1) / 2.0)) * (lambda1 - lambda2))) * R;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.hypot((phi1 - phi2), (Math.cos(((phi2 + phi1) / 2.0)) * (lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.hypot((phi1 - phi2), (math.cos(((phi2 + phi1) / 2.0)) * (lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi1 - phi2), Float64(cos(Float64(Float64(phi2 + phi1) / 2.0)) * Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = hypot((phi1 - phi2), (cos(((phi2 + phi1) / 2.0)) * (lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi1 - phi2), $MachinePrecision] ^ 2 + N[(N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_1 - \phi_2, \cos \left(\frac{\phi_2 + \phi_1}{2}\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 60.3%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites95.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -3.5e-6) (* (hypot (- phi1 phi2) (* (cos (* 0.5 phi1)) (- lambda1 lambda2))) R) (* (hypot (- phi1 phi2) (* (cos (* 0.5 phi2)) (- lambda1 lambda2))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -3.5e-6) {
tmp = hypot((phi1 - phi2), (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = hypot((phi1 - phi2), (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -3.5e-6) {
tmp = Math.hypot((phi1 - phi2), (Math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = Math.hypot((phi1 - phi2), (Math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -3.5e-6: tmp = math.hypot((phi1 - phi2), (math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R else: tmp = math.hypot((phi1 - phi2), (math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -3.5e-6) tmp = Float64(hypot(Float64(phi1 - phi2), Float64(cos(Float64(0.5 * phi1)) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(hypot(Float64(phi1 - phi2), Float64(cos(Float64(0.5 * phi2)) * Float64(lambda1 - lambda2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -3.5e-6) tmp = hypot((phi1 - phi2), (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R; else tmp = hypot((phi1 - phi2), (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -3.5e-6], N[(N[Sqrt[N[(phi1 - phi2), $MachinePrecision] ^ 2 + N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[N[(phi1 - phi2), $MachinePrecision] ^ 2 + N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.5 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1 - \phi_2, \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1 - \phi_2, \cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -3.49999999999999995e-6Initial program 54.7%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites92.1%
Taylor expanded in phi1 around inf
lower-*.f6492.0
Applied rewrites92.0%
if -3.49999999999999995e-6 < phi1 Initial program 62.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites97.2%
Taylor expanded in phi1 around 0
lower-*.f6493.1
Applied rewrites93.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(hypot (- phi1 phi2) (* (cos (* 0.5 phi1)) (- lambda1 lambda2)))
R)))
(if (<= phi2 1.35e+14)
t_0
(if (<= phi2 2.8e+75)
(* (hypot phi1 (* (cos (* 0.5 phi2)) (- lambda1 lambda2))) R)
t_0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = hypot((phi1 - phi2), (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
double tmp;
if (phi2 <= 1.35e+14) {
tmp = t_0;
} else if (phi2 <= 2.8e+75) {
tmp = hypot(phi1, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.hypot((phi1 - phi2), (Math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
double tmp;
if (phi2 <= 1.35e+14) {
tmp = t_0;
} else if (phi2 <= 2.8e+75) {
tmp = Math.hypot(phi1, (Math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
} else {
tmp = t_0;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.hypot((phi1 - phi2), (math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R tmp = 0 if phi2 <= 1.35e+14: tmp = t_0 elif phi2 <= 2.8e+75: tmp = math.hypot(phi1, (math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R else: tmp = t_0 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(hypot(Float64(phi1 - phi2), Float64(cos(Float64(0.5 * phi1)) * Float64(lambda1 - lambda2))) * R) tmp = 0.0 if (phi2 <= 1.35e+14) tmp = t_0; elseif (phi2 <= 2.8e+75) tmp = Float64(hypot(phi1, Float64(cos(Float64(0.5 * phi2)) * Float64(lambda1 - lambda2))) * R); else tmp = t_0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = hypot((phi1 - phi2), (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R; tmp = 0.0; if (phi2 <= 1.35e+14) tmp = t_0; elseif (phi2 <= 2.8e+75) tmp = hypot(phi1, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R; else tmp = t_0; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sqrt[N[(phi1 - phi2), $MachinePrecision] ^ 2 + N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]}, If[LessEqual[phi2, 1.35e+14], t$95$0, If[LessEqual[phi2, 2.8e+75], N[(N[Sqrt[phi1 ^ 2 + N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(\phi_1 - \phi_2, \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{if}\;\phi_2 \leq 1.35 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_2 \leq 2.8 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1, \cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if phi2 < 1.35e14 or 2.80000000000000012e75 < phi2 Initial program 60.0%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.4%
Taylor expanded in phi1 around inf
lower-*.f6491.6
Applied rewrites91.6%
if 1.35e14 < phi2 < 2.80000000000000012e75Initial program 65.7%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites87.9%
Taylor expanded in phi1 around 0
lower-*.f6487.8
Applied rewrites87.8%
Taylor expanded in phi1 around inf
Applied rewrites71.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* 0.5 phi1))))
(if (<= phi2 2.45e-7)
(* (hypot phi1 (* t_0 (- lambda1 lambda2))) R)
(if (<= phi2 3.7e+75)
(* (hypot phi1 (* (cos (* 0.5 phi2)) (- lambda1 lambda2))) R)
(* (hypot (- phi1 phi2) (* t_0 lambda1)) R)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((0.5 * phi1));
double tmp;
if (phi2 <= 2.45e-7) {
tmp = hypot(phi1, (t_0 * (lambda1 - lambda2))) * R;
} else if (phi2 <= 3.7e+75) {
tmp = hypot(phi1, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
} else {
tmp = hypot((phi1 - phi2), (t_0 * lambda1)) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((0.5 * phi1));
double tmp;
if (phi2 <= 2.45e-7) {
tmp = Math.hypot(phi1, (t_0 * (lambda1 - lambda2))) * R;
} else if (phi2 <= 3.7e+75) {
tmp = Math.hypot(phi1, (Math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
} else {
tmp = Math.hypot((phi1 - phi2), (t_0 * lambda1)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((0.5 * phi1)) tmp = 0 if phi2 <= 2.45e-7: tmp = math.hypot(phi1, (t_0 * (lambda1 - lambda2))) * R elif phi2 <= 3.7e+75: tmp = math.hypot(phi1, (math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R else: tmp = math.hypot((phi1 - phi2), (t_0 * lambda1)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(0.5 * phi1)) tmp = 0.0 if (phi2 <= 2.45e-7) tmp = Float64(hypot(phi1, Float64(t_0 * Float64(lambda1 - lambda2))) * R); elseif (phi2 <= 3.7e+75) tmp = Float64(hypot(phi1, Float64(cos(Float64(0.5 * phi2)) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(hypot(Float64(phi1 - phi2), Float64(t_0 * lambda1)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((0.5 * phi1)); tmp = 0.0; if (phi2 <= 2.45e-7) tmp = hypot(phi1, (t_0 * (lambda1 - lambda2))) * R; elseif (phi2 <= 3.7e+75) tmp = hypot(phi1, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R; else tmp = hypot((phi1 - phi2), (t_0 * lambda1)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 2.45e-7], N[(N[Sqrt[phi1 ^ 2 + N[(t$95$0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 3.7e+75], N[(N[Sqrt[phi1 ^ 2 + N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[N[(phi1 - phi2), $MachinePrecision] ^ 2 + N[(t$95$0 * lambda1), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot \phi_1\right)\\
\mathbf{if}\;\phi_2 \leq 2.45 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1, t\_0 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 3.7 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1, \cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1 - \phi_2, t\_0 \cdot \lambda_1\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 2.4499999999999998e-7Initial program 62.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites97.3%
Taylor expanded in phi1 around inf
lower-*.f6493.9
Applied rewrites93.9%
Taylor expanded in phi1 around inf
Applied rewrites79.4%
if 2.4499999999999998e-7 < phi2 < 3.70000000000000011e75Initial program 66.3%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites88.8%
Taylor expanded in phi1 around 0
lower-*.f6488.3
Applied rewrites88.3%
Taylor expanded in phi1 around inf
Applied rewrites71.3%
if 3.70000000000000011e75 < phi2 Initial program 51.2%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites93.2%
Taylor expanded in phi1 around inf
lower-*.f6484.3
Applied rewrites84.3%
Taylor expanded in lambda1 around inf
Applied rewrites81.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 0.00034) (* (hypot phi1 (* (cos (* 0.5 phi1)) (- lambda1 lambda2))) R) (* (hypot (- phi1 phi2) (* (cos (* 0.5 phi2)) lambda1)) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00034) {
tmp = hypot(phi1, (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = hypot((phi1 - phi2), (cos((0.5 * phi2)) * lambda1)) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00034) {
tmp = Math.hypot(phi1, (Math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = Math.hypot((phi1 - phi2), (Math.cos((0.5 * phi2)) * lambda1)) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.00034: tmp = math.hypot(phi1, (math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R else: tmp = math.hypot((phi1 - phi2), (math.cos((0.5 * phi2)) * lambda1)) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.00034) tmp = Float64(hypot(phi1, Float64(cos(Float64(0.5 * phi1)) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(hypot(Float64(phi1 - phi2), Float64(cos(Float64(0.5 * phi2)) * lambda1)) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.00034) tmp = hypot(phi1, (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R; else tmp = hypot((phi1 - phi2), (cos((0.5 * phi2)) * lambda1)) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.00034], N[(N[Sqrt[phi1 ^ 2 + N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[N[(phi1 - phi2), $MachinePrecision] ^ 2 + N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * lambda1), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.00034:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1, \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1 - \phi_2, \cos \left(0.5 \cdot \phi_2\right) \cdot \lambda_1\right) \cdot R\\
\end{array}
\end{array}
if phi2 < 3.4e-4Initial program 62.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites97.3%
Taylor expanded in phi1 around inf
lower-*.f6493.8
Applied rewrites93.8%
Taylor expanded in phi1 around inf
Applied rewrites79.3%
if 3.4e-4 < phi2 Initial program 55.0%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites92.0%
Taylor expanded in phi1 around 0
lower-*.f6491.9
Applied rewrites91.9%
Taylor expanded in lambda1 around inf
Applied rewrites82.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 2.45e-7)
(* (hypot phi1 (* (cos (* 0.5 phi1)) (- lambda1 lambda2))) R)
(if (<= phi2 3.7e+75)
(* (hypot phi1 (* (cos (* 0.5 phi2)) (- lambda1 lambda2))) R)
(* R (* (+ (/ (- phi1) phi2) 1.0) phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.45e-7) {
tmp = hypot(phi1, (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else if (phi2 <= 3.7e+75) {
tmp = hypot(phi1, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
} else {
tmp = R * (((-phi1 / phi2) + 1.0) * phi2);
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 2.45e-7) {
tmp = Math.hypot(phi1, (Math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else if (phi2 <= 3.7e+75) {
tmp = Math.hypot(phi1, (Math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R;
} else {
tmp = R * (((-phi1 / phi2) + 1.0) * phi2);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 2.45e-7: tmp = math.hypot(phi1, (math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R elif phi2 <= 3.7e+75: tmp = math.hypot(phi1, (math.cos((0.5 * phi2)) * (lambda1 - lambda2))) * R else: tmp = R * (((-phi1 / phi2) + 1.0) * phi2) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 2.45e-7) tmp = Float64(hypot(phi1, Float64(cos(Float64(0.5 * phi1)) * Float64(lambda1 - lambda2))) * R); elseif (phi2 <= 3.7e+75) tmp = Float64(hypot(phi1, Float64(cos(Float64(0.5 * phi2)) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(R * Float64(Float64(Float64(Float64(-phi1) / phi2) + 1.0) * phi2)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 2.45e-7) tmp = hypot(phi1, (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R; elseif (phi2 <= 3.7e+75) tmp = hypot(phi1, (cos((0.5 * phi2)) * (lambda1 - lambda2))) * R; else tmp = R * (((-phi1 / phi2) + 1.0) * phi2); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 2.45e-7], N[(N[Sqrt[phi1 ^ 2 + N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], If[LessEqual[phi2, 3.7e+75], N[(N[Sqrt[phi1 ^ 2 + N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(R * N[(N[(N[((-phi1) / phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.45 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1, \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 3.7 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1, \cos \left(0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\left(\frac{-\phi_1}{\phi_2} + 1\right) \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi2 < 2.4499999999999998e-7Initial program 62.1%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites97.3%
Taylor expanded in phi1 around inf
lower-*.f6493.9
Applied rewrites93.9%
Taylor expanded in phi1 around inf
Applied rewrites79.4%
if 2.4499999999999998e-7 < phi2 < 3.70000000000000011e75Initial program 66.3%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites88.8%
Taylor expanded in phi1 around 0
lower-*.f6488.3
Applied rewrites88.3%
Taylor expanded in phi1 around inf
Applied rewrites71.3%
if 3.70000000000000011e75 < phi2 Initial program 51.2%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6471.1
Applied rewrites71.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 3.45e+75) (* (hypot phi1 (* (cos (* 0.5 phi1)) (- lambda1 lambda2))) R) (* R (* (+ (/ (- phi1) phi2) 1.0) phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 3.45e+75) {
tmp = hypot(phi1, (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = R * (((-phi1 / phi2) + 1.0) * phi2);
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 3.45e+75) {
tmp = Math.hypot(phi1, (Math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = R * (((-phi1 / phi2) + 1.0) * phi2);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 3.45e+75: tmp = math.hypot(phi1, (math.cos((0.5 * phi1)) * (lambda1 - lambda2))) * R else: tmp = R * (((-phi1 / phi2) + 1.0) * phi2) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 3.45e+75) tmp = Float64(hypot(phi1, Float64(cos(Float64(0.5 * phi1)) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(R * Float64(Float64(Float64(Float64(-phi1) / phi2) + 1.0) * phi2)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 3.45e+75) tmp = hypot(phi1, (cos((0.5 * phi1)) * (lambda1 - lambda2))) * R; else tmp = R * (((-phi1 / phi2) + 1.0) * phi2); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 3.45e+75], N[(N[Sqrt[phi1 ^ 2 + N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(R * N[(N[(N[((-phi1) / phi2), $MachinePrecision] + 1.0), $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 3.45 \cdot 10^{+75}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_1, \cos \left(0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\left(\frac{-\phi_1}{\phi_2} + 1\right) \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi2 < 3.4500000000000002e75Initial program 62.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
Applied rewrites96.6%
Taylor expanded in phi1 around inf
lower-*.f6492.1
Applied rewrites92.1%
Taylor expanded in phi1 around inf
Applied rewrites77.5%
if 3.4500000000000002e75 < phi2 Initial program 51.2%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6471.1
Applied rewrites71.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -8.4e+220)
(- (* (* (cos (* 0.5 (+ phi2 phi1))) lambda1) R))
(if (<= lambda1 -1.6e+50)
(* R (sqrt (* (* lambda1 lambda1) (- 0.5 (* -0.5 (cos phi2))))))
(* R (+ phi2 (- phi1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8.4e+220) {
tmp = -((cos((0.5 * (phi2 + phi1))) * lambda1) * R);
} else if (lambda1 <= -1.6e+50) {
tmp = R * sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * cos(phi2)))));
} else {
tmp = R * (phi2 + -phi1);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-8.4d+220)) then
tmp = -((cos((0.5d0 * (phi2 + phi1))) * lambda1) * r)
else if (lambda1 <= (-1.6d+50)) then
tmp = r * sqrt(((lambda1 * lambda1) * (0.5d0 - ((-0.5d0) * cos(phi2)))))
else
tmp = r * (phi2 + -phi1)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8.4e+220) {
tmp = -((Math.cos((0.5 * (phi2 + phi1))) * lambda1) * R);
} else if (lambda1 <= -1.6e+50) {
tmp = R * Math.sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * Math.cos(phi2)))));
} else {
tmp = R * (phi2 + -phi1);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -8.4e+220: tmp = -((math.cos((0.5 * (phi2 + phi1))) * lambda1) * R) elif lambda1 <= -1.6e+50: tmp = R * math.sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * math.cos(phi2))))) else: tmp = R * (phi2 + -phi1) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -8.4e+220) tmp = Float64(-Float64(Float64(cos(Float64(0.5 * Float64(phi2 + phi1))) * lambda1) * R)); elseif (lambda1 <= -1.6e+50) tmp = Float64(R * sqrt(Float64(Float64(lambda1 * lambda1) * Float64(0.5 - Float64(-0.5 * cos(phi2)))))); else tmp = Float64(R * Float64(phi2 + Float64(-phi1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -8.4e+220) tmp = -((cos((0.5 * (phi2 + phi1))) * lambda1) * R); elseif (lambda1 <= -1.6e+50) tmp = R * sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * cos(phi2))))); else tmp = R * (phi2 + -phi1); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -8.4e+220], (-N[(N[(N[Cos[N[(0.5 * N[(phi2 + phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * lambda1), $MachinePrecision] * R), $MachinePrecision]), If[LessEqual[lambda1, -1.6e+50], N[(R * N[Sqrt[N[(N[(lambda1 * lambda1), $MachinePrecision] * N[(0.5 - N[(-0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(phi2 + (-phi1)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -8.4 \cdot 10^{+220}:\\
\;\;\;\;-\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq -1.6 \cdot 10^{+50}:\\
\;\;\;\;R \cdot \sqrt{\left(\lambda_1 \cdot \lambda_1\right) \cdot \left(0.5 - -0.5 \cdot \cos \phi_2\right)}\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\phi_2 + \left(-\phi_1\right)\right)\\
\end{array}
\end{array}
if lambda1 < -8.40000000000000027e220Initial program 46.7%
Taylor expanded in lambda1 around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6452.1
Applied rewrites52.1%
if -8.40000000000000027e220 < lambda1 < -1.59999999999999991e50Initial program 55.7%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6440.1
Applied rewrites40.1%
Taylor expanded in phi1 around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6438.4
Applied rewrites38.4%
if -1.59999999999999991e50 < lambda1 Initial program 62.3%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6429.3
Applied rewrites29.3%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6431.8
Applied rewrites31.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda1 -8.4e+220)
(- (* (* (cos (* 0.5 (+ phi2 phi1))) lambda1) R))
(if (<= lambda1 -2.2e+119)
(* R (sqrt (* (* lambda1 lambda1) (- 0.5 (* -0.5 (cos phi1))))))
(* R (+ phi2 (- phi1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8.4e+220) {
tmp = -((cos((0.5 * (phi2 + phi1))) * lambda1) * R);
} else if (lambda1 <= -2.2e+119) {
tmp = R * sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * cos(phi1)))));
} else {
tmp = R * (phi2 + -phi1);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-8.4d+220)) then
tmp = -((cos((0.5d0 * (phi2 + phi1))) * lambda1) * r)
else if (lambda1 <= (-2.2d+119)) then
tmp = r * sqrt(((lambda1 * lambda1) * (0.5d0 - ((-0.5d0) * cos(phi1)))))
else
tmp = r * (phi2 + -phi1)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -8.4e+220) {
tmp = -((Math.cos((0.5 * (phi2 + phi1))) * lambda1) * R);
} else if (lambda1 <= -2.2e+119) {
tmp = R * Math.sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * Math.cos(phi1)))));
} else {
tmp = R * (phi2 + -phi1);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -8.4e+220: tmp = -((math.cos((0.5 * (phi2 + phi1))) * lambda1) * R) elif lambda1 <= -2.2e+119: tmp = R * math.sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * math.cos(phi1))))) else: tmp = R * (phi2 + -phi1) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -8.4e+220) tmp = Float64(-Float64(Float64(cos(Float64(0.5 * Float64(phi2 + phi1))) * lambda1) * R)); elseif (lambda1 <= -2.2e+119) tmp = Float64(R * sqrt(Float64(Float64(lambda1 * lambda1) * Float64(0.5 - Float64(-0.5 * cos(phi1)))))); else tmp = Float64(R * Float64(phi2 + Float64(-phi1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -8.4e+220) tmp = -((cos((0.5 * (phi2 + phi1))) * lambda1) * R); elseif (lambda1 <= -2.2e+119) tmp = R * sqrt(((lambda1 * lambda1) * (0.5 - (-0.5 * cos(phi1))))); else tmp = R * (phi2 + -phi1); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -8.4e+220], (-N[(N[(N[Cos[N[(0.5 * N[(phi2 + phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * lambda1), $MachinePrecision] * R), $MachinePrecision]), If[LessEqual[lambda1, -2.2e+119], N[(R * N[Sqrt[N[(N[(lambda1 * lambda1), $MachinePrecision] * N[(0.5 - N[(-0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(phi2 + (-phi1)), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -8.4 \cdot 10^{+220}:\\
\;\;\;\;-\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1\right) \cdot R\\
\mathbf{elif}\;\lambda_1 \leq -2.2 \cdot 10^{+119}:\\
\;\;\;\;R \cdot \sqrt{\left(\lambda_1 \cdot \lambda_1\right) \cdot \left(0.5 - -0.5 \cdot \cos \phi_1\right)}\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\phi_2 + \left(-\phi_1\right)\right)\\
\end{array}
\end{array}
if lambda1 < -8.40000000000000027e220Initial program 46.7%
Taylor expanded in lambda1 around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6452.1
Applied rewrites52.1%
if -8.40000000000000027e220 < lambda1 < -2.2000000000000001e119Initial program 49.3%
Taylor expanded in lambda1 around inf
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6444.6
Applied rewrites44.6%
Taylor expanded in phi2 around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f64N/A
lower-*.f64N/A
lower-cos.f6442.5
Applied rewrites42.5%
if -2.2000000000000001e119 < lambda1 Initial program 62.5%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6429.2
Applied rewrites29.2%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6431.8
Applied rewrites31.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -1.95e+120) (- (* (* (cos (* 0.5 (+ phi2 phi1))) lambda1) R)) (* R (+ phi2 (- phi1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.95e+120) {
tmp = -((cos((0.5 * (phi2 + phi1))) * lambda1) * R);
} else {
tmp = R * (phi2 + -phi1);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda1 <= (-1.95d+120)) then
tmp = -((cos((0.5d0 * (phi2 + phi1))) * lambda1) * r)
else
tmp = r * (phi2 + -phi1)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.95e+120) {
tmp = -((Math.cos((0.5 * (phi2 + phi1))) * lambda1) * R);
} else {
tmp = R * (phi2 + -phi1);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -1.95e+120: tmp = -((math.cos((0.5 * (phi2 + phi1))) * lambda1) * R) else: tmp = R * (phi2 + -phi1) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -1.95e+120) tmp = Float64(-Float64(Float64(cos(Float64(0.5 * Float64(phi2 + phi1))) * lambda1) * R)); else tmp = Float64(R * Float64(phi2 + Float64(-phi1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -1.95e+120) tmp = -((cos((0.5 * (phi2 + phi1))) * lambda1) * R); else tmp = R * (phi2 + -phi1); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -1.95e+120], (-N[(N[(N[Cos[N[(0.5 * N[(phi2 + phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * lambda1), $MachinePrecision] * R), $MachinePrecision]), N[(R * N[(phi2 + (-phi1)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.95 \cdot 10^{+120}:\\
\;\;\;\;-\left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\phi_2 + \left(-\phi_1\right)\right)\\
\end{array}
\end{array}
if lambda1 < -1.9499999999999999e120Initial program 47.9%
Taylor expanded in lambda1 around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6446.8
Applied rewrites46.8%
if -1.9499999999999999e120 < lambda1 Initial program 62.5%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6429.2
Applied rewrites29.2%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6431.8
Applied rewrites31.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 3.2e+249) (* R (+ phi2 (- phi1))) (* R (* (cos (* 0.5 (+ phi2 phi1))) lambda2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 3.2e+249) {
tmp = R * (phi2 + -phi1);
} else {
tmp = R * (cos((0.5 * (phi2 + phi1))) * lambda2);
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 3.2d+249) then
tmp = r * (phi2 + -phi1)
else
tmp = r * (cos((0.5d0 * (phi2 + phi1))) * lambda2)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 3.2e+249) {
tmp = R * (phi2 + -phi1);
} else {
tmp = R * (Math.cos((0.5 * (phi2 + phi1))) * lambda2);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 3.2e+249: tmp = R * (phi2 + -phi1) else: tmp = R * (math.cos((0.5 * (phi2 + phi1))) * lambda2) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 3.2e+249) tmp = Float64(R * Float64(phi2 + Float64(-phi1))); else tmp = Float64(R * Float64(cos(Float64(0.5 * Float64(phi2 + phi1))) * lambda2)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 3.2e+249) tmp = R * (phi2 + -phi1); else tmp = R * (cos((0.5 * (phi2 + phi1))) * lambda2); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 3.2e+249], N[(R * N[(phi2 + (-phi1)), $MachinePrecision]), $MachinePrecision], N[(R * N[(N[Cos[N[(0.5 * N[(phi2 + phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * lambda2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 3.2 \cdot 10^{+249}:\\
\;\;\;\;R \cdot \left(\phi_2 + \left(-\phi_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\cos \left(0.5 \cdot \left(\phi_2 + \phi_1\right)\right) \cdot \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 3.20000000000000014e249Initial program 60.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6427.9
Applied rewrites27.9%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6430.4
Applied rewrites30.4%
if 3.20000000000000014e249 < lambda2 Initial program 49.2%
Taylor expanded in lambda2 around inf
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6453.4
Applied rewrites53.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 3.2e+249) (* R (+ phi2 (- phi1))) (* (* (cos (* 0.5 (+ phi1 phi2))) R) lambda2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 3.2e+249) {
tmp = R * (phi2 + -phi1);
} else {
tmp = (cos((0.5 * (phi1 + phi2))) * R) * lambda2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 3.2d+249) then
tmp = r * (phi2 + -phi1)
else
tmp = (cos((0.5d0 * (phi1 + phi2))) * r) * lambda2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 3.2e+249) {
tmp = R * (phi2 + -phi1);
} else {
tmp = (Math.cos((0.5 * (phi1 + phi2))) * R) * lambda2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 3.2e+249: tmp = R * (phi2 + -phi1) else: tmp = (math.cos((0.5 * (phi1 + phi2))) * R) * lambda2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 3.2e+249) tmp = Float64(R * Float64(phi2 + Float64(-phi1))); else tmp = Float64(Float64(cos(Float64(0.5 * Float64(phi1 + phi2))) * R) * lambda2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 3.2e+249) tmp = R * (phi2 + -phi1); else tmp = (cos((0.5 * (phi1 + phi2))) * R) * lambda2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 3.2e+249], N[(R * N[(phi2 + (-phi1)), $MachinePrecision]), $MachinePrecision], N[(N[(N[Cos[N[(0.5 * N[(phi1 + phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision] * lambda2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 3.2 \cdot 10^{+249}:\\
\;\;\;\;R \cdot \left(\phi_2 + \left(-\phi_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\cos \left(0.5 \cdot \left(\phi_1 + \phi_2\right)\right) \cdot R\right) \cdot \lambda_2\\
\end{array}
\end{array}
if lambda2 < 3.20000000000000014e249Initial program 60.9%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6427.9
Applied rewrites27.9%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6430.4
Applied rewrites30.4%
if 3.20000000000000014e249 < lambda2 Initial program 49.2%
Taylor expanded in lambda2 around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites52.5%
Taylor expanded in lambda1 around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-+.f6453.4
Applied rewrites53.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= (- lambda1 lambda2) -5e+177) (* (+ (/ (- (* phi1 R)) phi2) R) phi2) (* R (+ phi2 (- phi1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 - lambda2) <= -5e+177) {
tmp = ((-(phi1 * R) / phi2) + R) * phi2;
} else {
tmp = R * (phi2 + -phi1);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda1 - lambda2) <= (-5d+177)) then
tmp = ((-(phi1 * r) / phi2) + r) * phi2
else
tmp = r * (phi2 + -phi1)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 - lambda2) <= -5e+177) {
tmp = ((-(phi1 * R) / phi2) + R) * phi2;
} else {
tmp = R * (phi2 + -phi1);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 - lambda2) <= -5e+177: tmp = ((-(phi1 * R) / phi2) + R) * phi2 else: tmp = R * (phi2 + -phi1) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -5e+177) tmp = Float64(Float64(Float64(Float64(-Float64(phi1 * R)) / phi2) + R) * phi2); else tmp = Float64(R * Float64(phi2 + Float64(-phi1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 - lambda2) <= -5e+177) tmp = ((-(phi1 * R) / phi2) + R) * phi2; else tmp = R * (phi2 + -phi1); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -5e+177], N[(N[(N[((-N[(phi1 * R), $MachinePrecision]) / phi2), $MachinePrecision] + R), $MachinePrecision] * phi2), $MachinePrecision], N[(R * N[(phi2 + (-phi1)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{+177}:\\
\;\;\;\;\left(\frac{-\phi_1 \cdot R}{\phi_2} + R\right) \cdot \phi_2\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\phi_2 + \left(-\phi_1\right)\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -5.0000000000000003e177Initial program 43.8%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f6419.0
Applied rewrites19.0%
if -5.0000000000000003e177 < (-.f64 lambda1 lambda2) Initial program 64.1%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6429.7
Applied rewrites29.7%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6432.5
Applied rewrites32.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (+ phi2 (- phi1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (phi2 + -phi1);
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (phi2 + -phi1)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (phi2 + -phi1);
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (phi2 + -phi1)
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(phi2 + Float64(-phi1))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (phi2 + -phi1); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(phi2 + (-phi1)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(\phi_2 + \left(-\phi_1\right)\right)
\end{array}
Initial program 60.3%
Taylor expanded in phi2 around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6427.2
Applied rewrites27.2%
Taylor expanded in phi1 around 0
mul-1-negN/A
lift-neg.f64N/A
lower-+.f6429.5
Applied rewrites29.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 7.5e+72) (* R (- phi1)) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 7.5e+72) {
tmp = R * -phi1;
} else {
tmp = R * phi2;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 7.5d+72) then
tmp = r * -phi1
else
tmp = r * phi2
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 7.5e+72) {
tmp = R * -phi1;
} else {
tmp = R * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 7.5e+72: tmp = R * -phi1 else: tmp = R * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 7.5e+72) tmp = Float64(R * Float64(-phi1)); else tmp = Float64(R * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 7.5e+72) tmp = R * -phi1; else tmp = R * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 7.5e+72], N[(R * (-phi1)), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 7.5 \cdot 10^{+72}:\\
\;\;\;\;R \cdot \left(-\phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\
\end{array}
\end{array}
if phi2 < 7.50000000000000027e72Initial program 62.5%
Taylor expanded in phi1 around -inf
mul-1-negN/A
lower-neg.f6418.1
Applied rewrites18.1%
if 7.50000000000000027e72 < phi2 Initial program 51.3%
Taylor expanded in phi2 around inf
Applied rewrites67.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R phi2))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * phi2;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * phi2
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * phi2;
}
def code(R, lambda1, lambda2, phi1, phi2): return R * phi2
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * phi2) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * phi2; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * phi2), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \phi_2
\end{array}
Initial program 60.3%
Taylor expanded in phi2 around inf
Applied rewrites17.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R phi1))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * phi1;
}
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(r, lambda1, lambda2, phi1, phi2)
use fmin_fmax_functions
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * phi1
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * phi1;
}
def code(R, lambda1, lambda2, phi1, phi2): return R * phi1
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * phi1) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * phi1; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * phi1), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \phi_1
\end{array}
Initial program 60.3%
Taylor expanded in phi1 around inf
Applied rewrites17.5%
herbie shell --seed 2025122
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Equirectangular approximation to distance on a great circle"
:precision binary64
(* R (sqrt (+ (* (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0))) (* (- lambda1 lambda2) (cos (/ (+ phi1 phi2) 2.0)))) (* (- phi1 phi2) (- phi1 phi2))))))