
(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 15 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
(- phi2 phi1)
(*
(-
(* (cos (* 0.5 phi1)) (cos (* 0.5 phi2)))
(* (sin (* 0.5 phi1)) (sin (* 0.5 phi2))))
(- lambda1 lambda2)))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi2 - phi1), (((cos((0.5 * phi1)) * cos((0.5 * phi2))) - (sin((0.5 * phi1)) * sin((0.5 * phi2)))) * (lambda1 - lambda2))) * R;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.hypot((phi2 - phi1), (((Math.cos((0.5 * phi1)) * Math.cos((0.5 * phi2))) - (Math.sin((0.5 * phi1)) * Math.sin((0.5 * phi2)))) * (lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.hypot((phi2 - phi1), (((math.cos((0.5 * phi1)) * math.cos((0.5 * phi2))) - (math.sin((0.5 * phi1)) * math.sin((0.5 * phi2)))) * (lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi2 - phi1), Float64(Float64(Float64(cos(Float64(0.5 * phi1)) * cos(Float64(0.5 * phi2))) - Float64(sin(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) * Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = hypot((phi2 - phi1), (((cos((0.5 * phi1)) * cos((0.5 * phi2))) - (sin((0.5 * phi1)) * sin((0.5 * phi2)))) * (lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[(N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_2 - \phi_1, \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
lift-cos.f64N/A
cos-neg-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
div-addN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= (- lambda1 lambda2) -2e+179)
(*
(hypot
phi2
(*
(-
(* (cos (* 0.5 phi1)) (cos (* 0.5 phi2)))
(* (sin (* 0.5 phi1)) (sin (* 0.5 phi2))))
(- lambda1 lambda2)))
R)
(*
(hypot (- phi2 phi1) (* (cos (* (+ phi2 phi1) -0.5)) (- lambda1 lambda2)))
R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 - lambda2) <= -2e+179) {
tmp = hypot(phi2, (((cos((0.5 * phi1)) * cos((0.5 * phi2))) - (sin((0.5 * phi1)) * sin((0.5 * phi2)))) * (lambda1 - lambda2))) * R;
} else {
tmp = hypot((phi2 - phi1), (cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 - lambda2) <= -2e+179) {
tmp = Math.hypot(phi2, (((Math.cos((0.5 * phi1)) * Math.cos((0.5 * phi2))) - (Math.sin((0.5 * phi1)) * Math.sin((0.5 * phi2)))) * (lambda1 - lambda2))) * R;
} else {
tmp = Math.hypot((phi2 - phi1), (Math.cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda1 - lambda2) <= -2e+179: tmp = math.hypot(phi2, (((math.cos((0.5 * phi1)) * math.cos((0.5 * phi2))) - (math.sin((0.5 * phi1)) * math.sin((0.5 * phi2)))) * (lambda1 - lambda2))) * R else: tmp = math.hypot((phi2 - phi1), (math.cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -2e+179) tmp = Float64(hypot(phi2, Float64(Float64(Float64(cos(Float64(0.5 * phi1)) * cos(Float64(0.5 * phi2))) - Float64(sin(Float64(0.5 * phi1)) * sin(Float64(0.5 * phi2)))) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(Float64(phi2 + phi1) * -0.5)) * Float64(lambda1 - lambda2))) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda1 - lambda2) <= -2e+179) tmp = hypot(phi2, (((cos((0.5 * phi1)) * cos((0.5 * phi2))) - (sin((0.5 * phi1)) * sin((0.5 * phi2)))) * (lambda1 - lambda2))) * R; else tmp = hypot((phi2 - phi1), (cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -2e+179], N[(N[Sqrt[phi2 ^ 2 + N[(N[(N[(N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -2 \cdot 10^{+179}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2, \left(\cos \left(0.5 \cdot \phi_1\right) \cdot \cos \left(0.5 \cdot \phi_2\right) - \sin \left(0.5 \cdot \phi_1\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(\left(\phi_2 + \phi_1\right) \cdot -0.5\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.99999999999999996e179Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
lift-cos.f64N/A
cos-neg-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
div-addN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
Taylor expanded in phi1 around 0
Applied rewrites79.7%
if -1.99999999999999996e179 < (-.f64 lambda1 lambda2) Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -6.7e-7) (* (hypot (- phi2 phi1) (* (cos (* -0.5 phi1)) (- lambda1 lambda2))) R) (* (hypot (- phi2 phi1) (* (cos (* -0.5 phi2)) (- lambda1 lambda2))) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -6.7e-7) {
tmp = hypot((phi2 - phi1), (cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = hypot((phi2 - phi1), (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 <= -6.7e-7) {
tmp = Math.hypot((phi2 - phi1), (Math.cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R;
} else {
tmp = Math.hypot((phi2 - phi1), (Math.cos((-0.5 * phi2)) * (lambda1 - lambda2))) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -6.7e-7: tmp = math.hypot((phi2 - phi1), (math.cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R else: tmp = math.hypot((phi2 - phi1), (math.cos((-0.5 * phi2)) * (lambda1 - lambda2))) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -6.7e-7) tmp = Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(-0.5 * phi1)) * Float64(lambda1 - lambda2))) * R); else tmp = Float64(hypot(Float64(phi2 - phi1), 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 <= -6.7e-7) tmp = hypot((phi2 - phi1), (cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R; else tmp = hypot((phi2 - phi1), (cos((-0.5 * phi2)) * (lambda1 - lambda2))) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -6.7e-7], N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(-0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision], N[(N[Sqrt[N[(phi2 - phi1), $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 -6.7 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{hypot}\left(\phi_2 - \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_2 - \phi_1, \cos \left(-0.5 \cdot \phi_2\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\end{array}
\end{array}
if phi1 < -6.70000000000000044e-7Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
Taylor expanded in phi1 around inf
lower-*.f6490.3
Applied rewrites90.3%
if -6.70000000000000044e-7 < phi1 Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
Taylor expanded in phi1 around 0
lower-*.f6490.4
Applied rewrites90.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (hypot (- phi2 phi1) (* (cos (* (+ phi2 phi1) -0.5)) (- lambda1 lambda2))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi2 - phi1), (cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.hypot((phi2 - phi1), (Math.cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.hypot((phi2 - phi1), (math.cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(Float64(phi2 + phi1) * -0.5)) * Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = hypot((phi2 - phi1), (cos(((phi2 + phi1) * -0.5)) * (lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(N[(phi2 + phi1), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(\left(\phi_2 + \phi_1\right) \cdot -0.5\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* (hypot (- phi2 phi1) (* (cos (* -0.5 phi1)) (- lambda1 lambda2))) R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return hypot((phi2 - phi1), (cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.hypot((phi2 - phi1), (Math.cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.hypot((phi2 - phi1), (math.cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(hypot(Float64(phi2 - phi1), Float64(cos(Float64(-0.5 * phi1)) * Float64(lambda1 - lambda2))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = hypot((phi2 - phi1), (cos((-0.5 * phi1)) * (lambda1 - lambda2))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[Sqrt[N[(phi2 - phi1), $MachinePrecision] ^ 2 + N[(N[Cos[N[(-0.5 * phi1), $MachinePrecision]], $MachinePrecision] * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{hypot}\left(\phi_2 - \phi_1, \cos \left(-0.5 \cdot \phi_1\right) \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
Taylor expanded in phi1 around inf
lower-*.f6490.3
Applied rewrites90.3%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 1.55e+128) (* R (fabs (- phi1 phi2))) (* (* (fabs (cos (* (+ phi1 phi2) 0.5))) lambda2) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 1.55e+128) {
tmp = R * fabs((phi1 - phi2));
} else {
tmp = (fabs(cos(((phi1 + phi2) * 0.5))) * lambda2) * R;
}
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 <= 1.55d+128) then
tmp = r * abs((phi1 - phi2))
else
tmp = (abs(cos(((phi1 + phi2) * 0.5d0))) * lambda2) * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 1.55e+128) {
tmp = R * Math.abs((phi1 - phi2));
} else {
tmp = (Math.abs(Math.cos(((phi1 + phi2) * 0.5))) * lambda2) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 1.55e+128: tmp = R * math.fabs((phi1 - phi2)) else: tmp = (math.fabs(math.cos(((phi1 + phi2) * 0.5))) * lambda2) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 1.55e+128) tmp = Float64(R * abs(Float64(phi1 - phi2))); else tmp = Float64(Float64(abs(cos(Float64(Float64(phi1 + phi2) * 0.5))) * lambda2) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 1.55e+128) tmp = R * abs((phi1 - phi2)); else tmp = (abs(cos(((phi1 + phi2) * 0.5))) * lambda2) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 1.55e+128], N[(R * N[Abs[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[N[Cos[N[(N[(phi1 + phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * lambda2), $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 1.55 \cdot 10^{+128}:\\
\;\;\;\;R \cdot \left|\phi_1 - \phi_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left(\left|\cos \left(\left(\phi_1 + \phi_2\right) \cdot 0.5\right)\right| \cdot \lambda_2\right) \cdot R\\
\end{array}
\end{array}
if lambda2 < 1.55000000000000002e128Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
lift-cos.f64N/A
cos-neg-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
div-addN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
Applied rewrites89.4%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-fabs.f64N/A
lower--.f6457.1
Applied rewrites57.1%
if 1.55000000000000002e128 < lambda2 Initial program 58.9%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-+.f6417.2
Applied rewrites17.2%
lift-pow.f64N/A
unpow2N/A
lift-cos.f64N/A
lift-cos.f64N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6417.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6417.1
Applied rewrites17.1%
Applied rewrites17.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 3.6e+128) (* R (fabs (- phi1 phi2))) (* (* (fabs (cos (* 0.5 phi2))) lambda2) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 3.6e+128) {
tmp = R * fabs((phi1 - phi2));
} else {
tmp = (fabs(cos((0.5 * phi2))) * lambda2) * R;
}
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.6d+128) then
tmp = r * abs((phi1 - phi2))
else
tmp = (abs(cos((0.5d0 * phi2))) * lambda2) * r
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.6e+128) {
tmp = R * Math.abs((phi1 - phi2));
} else {
tmp = (Math.abs(Math.cos((0.5 * phi2))) * lambda2) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 3.6e+128: tmp = R * math.fabs((phi1 - phi2)) else: tmp = (math.fabs(math.cos((0.5 * phi2))) * lambda2) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 3.6e+128) tmp = Float64(R * abs(Float64(phi1 - phi2))); else tmp = Float64(Float64(abs(cos(Float64(0.5 * phi2))) * lambda2) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 3.6e+128) tmp = R * abs((phi1 - phi2)); else tmp = (abs(cos((0.5 * phi2))) * lambda2) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 3.6e+128], N[(R * N[Abs[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * lambda2), $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 3.6 \cdot 10^{+128}:\\
\;\;\;\;R \cdot \left|\phi_1 - \phi_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left(\left|\cos \left(0.5 \cdot \phi_2\right)\right| \cdot \lambda_2\right) \cdot R\\
\end{array}
\end{array}
if lambda2 < 3.60000000000000027e128Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
lift-cos.f64N/A
cos-neg-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
div-addN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
Applied rewrites89.4%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-fabs.f64N/A
lower--.f6457.1
Applied rewrites57.1%
if 3.60000000000000027e128 < lambda2 Initial program 58.9%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-+.f6417.2
Applied rewrites17.2%
lift-pow.f64N/A
unpow2N/A
lift-cos.f64N/A
lift-cos.f64N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6417.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6417.1
Applied rewrites17.1%
Applied rewrites17.2%
Taylor expanded in phi1 around 0
lower-*.f6415.9
Applied rewrites15.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 3.1e+128) (* R (fabs (- phi1 phi2))) (* (* (fabs (cos (* 0.5 phi1))) lambda2) R)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 3.1e+128) {
tmp = R * fabs((phi1 - phi2));
} else {
tmp = (fabs(cos((0.5 * phi1))) * lambda2) * R;
}
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.1d+128) then
tmp = r * abs((phi1 - phi2))
else
tmp = (abs(cos((0.5d0 * phi1))) * lambda2) * r
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.1e+128) {
tmp = R * Math.abs((phi1 - phi2));
} else {
tmp = (Math.abs(Math.cos((0.5 * phi1))) * lambda2) * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 3.1e+128: tmp = R * math.fabs((phi1 - phi2)) else: tmp = (math.fabs(math.cos((0.5 * phi1))) * lambda2) * R return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 3.1e+128) tmp = Float64(R * abs(Float64(phi1 - phi2))); else tmp = Float64(Float64(abs(cos(Float64(0.5 * phi1))) * lambda2) * R); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 3.1e+128) tmp = R * abs((phi1 - phi2)); else tmp = (abs(cos((0.5 * phi1))) * lambda2) * R; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 3.1e+128], N[(R * N[Abs[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Abs[N[Cos[N[(0.5 * phi1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * lambda2), $MachinePrecision] * R), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 3.1 \cdot 10^{+128}:\\
\;\;\;\;R \cdot \left|\phi_1 - \phi_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left(\left|\cos \left(0.5 \cdot \phi_1\right)\right| \cdot \lambda_2\right) \cdot R\\
\end{array}
\end{array}
if lambda2 < 3.10000000000000004e128Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
lift-cos.f64N/A
cos-neg-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
div-addN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
Applied rewrites89.4%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-fabs.f64N/A
lower--.f6457.1
Applied rewrites57.1%
if 3.10000000000000004e128 < lambda2 Initial program 58.9%
Taylor expanded in lambda2 around inf
lower-*.f64N/A
lower-sqrt.f64N/A
lower-pow.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-+.f6417.2
Applied rewrites17.2%
lift-pow.f64N/A
unpow2N/A
lift-cos.f64N/A
lift-cos.f64N/A
sqr-cos-aN/A
lower-+.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6417.1
lift-*.f64N/A
*-commutativeN/A
lower-*.f6417.1
Applied rewrites17.1%
Applied rewrites17.2%
Taylor expanded in phi2 around 0
lower-cos.f64N/A
lower-*.f6415.7
Applied rewrites15.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= (- lambda1 lambda2) -3e+194) (* -1.0 (* phi1 (* phi2 (fma -1.0 (/ R phi1) (/ R phi2))))) (* R (fabs (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda1 - lambda2) <= -3e+194) {
tmp = -1.0 * (phi1 * (phi2 * fma(-1.0, (R / phi1), (R / phi2))));
} else {
tmp = R * fabs((phi1 - phi2));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -3e+194) tmp = Float64(-1.0 * Float64(phi1 * Float64(phi2 * fma(-1.0, Float64(R / phi1), Float64(R / phi2))))); else tmp = Float64(R * abs(Float64(phi1 - phi2))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -3e+194], N[(-1.0 * N[(phi1 * N[(phi2 * N[(-1.0 * N[(R / phi1), $MachinePrecision] + N[(R / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[Abs[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -3 \cdot 10^{+194}:\\
\;\;\;\;-1 \cdot \left(\phi_1 \cdot \left(\phi_2 \cdot \mathsf{fma}\left(-1, \frac{R}{\phi_1}, \frac{R}{\phi_2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left|\phi_1 - \phi_2\right|\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -3.0000000000000003e194Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6429.0
Applied rewrites29.0%
Taylor expanded in phi2 around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6428.0
Applied rewrites28.0%
if -3.0000000000000003e194 < (-.f64 lambda1 lambda2) Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
lift-cos.f64N/A
cos-neg-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
div-addN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
Applied rewrites89.4%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-fabs.f64N/A
lower--.f6457.1
Applied rewrites57.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -1e+119) (* -1.0 (* phi1 (fma (* (/ -1.0 phi1) R) phi2 R))) (* R (fabs (- phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1e+119) {
tmp = -1.0 * (phi1 * fma(((-1.0 / phi1) * R), phi2, R));
} else {
tmp = R * fabs((phi1 - phi2));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -1e+119) tmp = Float64(-1.0 * Float64(phi1 * fma(Float64(Float64(-1.0 / phi1) * R), phi2, R))); else tmp = Float64(R * abs(Float64(phi1 - phi2))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -1e+119], N[(-1.0 * N[(phi1 * N[(N[(N[(-1.0 / phi1), $MachinePrecision] * R), $MachinePrecision] * phi2 + R), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[Abs[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1 \cdot 10^{+119}:\\
\;\;\;\;-1 \cdot \left(\phi_1 \cdot \mathsf{fma}\left(\frac{-1}{\phi_1} \cdot R, \phi_2, R\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left|\phi_1 - \phi_2\right|\\
\end{array}
\end{array}
if lambda1 < -9.99999999999999944e118Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
Taylor expanded in phi1 around -inf
lower-*.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6429.0
Applied rewrites29.0%
lift-*.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lower-/.f64N/A
lower-/.f6429.0
Applied rewrites29.0%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f6429.2
Applied rewrites29.2%
if -9.99999999999999944e118 < lambda1 Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
lift-cos.f64N/A
cos-neg-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
div-addN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
Applied rewrites89.4%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-fabs.f64N/A
lower--.f6457.1
Applied rewrites57.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (fabs (- phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * fabs((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
code = r * abs((phi1 - phi2))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.abs((phi1 - phi2));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.fabs((phi1 - phi2))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * abs(Float64(phi1 - phi2))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * abs((phi1 - phi2)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Abs[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left|\phi_1 - \phi_2\right|
\end{array}
Initial program 58.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6458.9
Applied rewrites95.9%
lift-cos.f64N/A
cos-neg-revN/A
lift-*.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
mult-flipN/A
lift-+.f64N/A
div-addN/A
cos-sumN/A
lower--.f64N/A
Applied rewrites99.9%
Applied rewrites89.4%
Taylor expanded in phi1 around inf
lower-*.f64N/A
lower-fabs.f64N/A
lower--.f6457.1
Applied rewrites57.1%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -8.6e+85) (* R (* -1.0 phi1)) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -8.6e+85) {
tmp = R * (-1.0 * 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 (phi1 <= (-8.6d+85)) then
tmp = r * ((-1.0d0) * 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 (phi1 <= -8.6e+85) {
tmp = R * (-1.0 * phi1);
} else {
tmp = R * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -8.6e+85: tmp = R * (-1.0 * phi1) else: tmp = R * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -8.6e+85) tmp = Float64(R * Float64(-1.0 * phi1)); else tmp = Float64(R * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -8.6e+85) tmp = R * (-1.0 * phi1); else tmp = R * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -8.6e+85], N[(R * N[(-1.0 * phi1), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -8.6 \cdot 10^{+85}:\\
\;\;\;\;R \cdot \left(-1 \cdot \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\
\end{array}
\end{array}
if phi1 < -8.5999999999999998e85Initial program 58.9%
Taylor expanded in phi1 around -inf
lower-*.f6417.2
Applied rewrites17.2%
if -8.5999999999999998e85 < phi1 Initial program 58.9%
Taylor expanded in phi2 around inf
lower-*.f6417.5
Applied rewrites17.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 -2.65e-291) (* -1.0 (* R phi2)) (* R phi2)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= -2.65e-291) {
tmp = -1.0 * (R * phi2);
} 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 <= (-2.65d-291)) then
tmp = (-1.0d0) * (r * phi2)
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 <= -2.65e-291) {
tmp = -1.0 * (R * phi2);
} else {
tmp = R * phi2;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= -2.65e-291: tmp = -1.0 * (R * phi2) else: tmp = R * phi2 return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= -2.65e-291) tmp = Float64(-1.0 * Float64(R * phi2)); else tmp = Float64(R * phi2); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= -2.65e-291) tmp = -1.0 * (R * phi2); else tmp = R * phi2; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, -2.65e-291], N[(-1.0 * N[(R * phi2), $MachinePrecision]), $MachinePrecision], N[(R * phi2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -2.65 \cdot 10^{-291}:\\
\;\;\;\;-1 \cdot \left(R \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \phi_2\\
\end{array}
\end{array}
if phi2 < -2.65000000000000007e-291Initial program 58.9%
Taylor expanded in phi2 around -inf
lower-*.f64N/A
lower-*.f6417.2
Applied rewrites17.2%
if -2.65000000000000007e-291 < phi2 Initial program 58.9%
Taylor expanded in phi2 around inf
lower-*.f6417.5
Applied rewrites17.5%
(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 58.9%
Taylor expanded in phi2 around inf
lower-*.f6417.5
Applied rewrites17.5%
(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 58.9%
Taylor expanded in phi1 around inf
lower-*.f6417.7
Applied rewrites17.7%
herbie shell --seed 2025156
(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))))))