
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
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(v, w, r)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (v w r) :precision binary64 (- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))
double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
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(v, w, r)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r
code = ((3.0d0 + (2.0d0 / (r * r))) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r) * r)) / (1.0d0 - v))) - 4.5d0
end function
public static double code(double v, double w, double r) {
return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5;
}
def code(v, w, r): return ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5
function code(v, w, r) return Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r * r))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r) * r)) / Float64(1.0 - v))) - 4.5) end
function tmp = code(v, w, r) tmp = ((3.0 + (2.0 / (r * r))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r) * r)) / (1.0 - v))) - 4.5; end
code[v_, w_, r_] := N[(N[(N[(3.0 + N[(2.0 / N[(r * r), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r), $MachinePrecision] * r), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(3 + \frac{2}{r \cdot r}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\right) \cdot r\right)}{1 - v}\right) - 4.5
\end{array}
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (+ (/ 2.0 (* r_m r_m)) 3.0)))
(if (<= r_m 0.001)
(-
t_0
(fma (* (* w r_m) (* r_m (/ w (- 1.0 v)))) (fma -0.25 v 0.375) 4.5))
(-
t_0
(fma
r_m
(* w (* (* 0.125 (fma -2.0 v 3.0)) (* (/ r_m (- 1.0 v)) w)))
4.5)))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = (2.0 / (r_m * r_m)) + 3.0;
double tmp;
if (r_m <= 0.001) {
tmp = t_0 - fma(((w * r_m) * (r_m * (w / (1.0 - v)))), fma(-0.25, v, 0.375), 4.5);
} else {
tmp = t_0 - fma(r_m, (w * ((0.125 * fma(-2.0, v, 3.0)) * ((r_m / (1.0 - v)) * w))), 4.5);
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(Float64(2.0 / Float64(r_m * r_m)) + 3.0) tmp = 0.0 if (r_m <= 0.001) tmp = Float64(t_0 - fma(Float64(Float64(w * r_m) * Float64(r_m * Float64(w / Float64(1.0 - v)))), fma(-0.25, v, 0.375), 4.5)); else tmp = Float64(t_0 - fma(r_m, Float64(w * Float64(Float64(0.125 * fma(-2.0, v, 3.0)) * Float64(Float64(r_m / Float64(1.0 - v)) * w))), 4.5)); end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision]}, If[LessEqual[r$95$m, 0.001], N[(t$95$0 - N[(N[(N[(w * r$95$m), $MachinePrecision] * N[(r$95$m * N[(w / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.25 * v + 0.375), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(r$95$m * N[(w * N[(N[(0.125 * N[(-2.0 * v + 3.0), $MachinePrecision]), $MachinePrecision] * N[(N[(r$95$m / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m} + 3\\
\mathbf{if}\;r\_m \leq 0.001:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(w \cdot r\_m\right) \cdot \left(r\_m \cdot \frac{w}{1 - v}\right), \mathsf{fma}\left(-0.25, v, 0.375\right), 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(r\_m, w \cdot \left(\left(0.125 \cdot \mathsf{fma}\left(-2, v, 3\right)\right) \cdot \left(\frac{r\_m}{1 - v} \cdot w\right)\right), 4.5\right)\\
\end{array}
\end{array}
if r < 1e-3Initial program 82.1%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites96.4%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.3%
if 1e-3 < r Initial program 87.8%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites99.8%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0
(-
(-
(+ 3.0 (/ 2.0 (* r_m r_m)))
(/
(* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r_m) r_m))
(- 1.0 v)))
4.5)))
(if (<= t_0 (- INFINITY))
(* (* (* -0.25 (* r_m r_m)) w) w)
(if (<= t_0 -200000000.0)
(* (* (* (* w w) 3.0) (* -0.125 r_m)) r_m)
(- (/ (/ 2.0 r_m) r_m) 1.5)))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = ((3.0 + (2.0 / (r_m * r_m))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5;
double tmp;
if (t_0 <= -((double) INFINITY)) {
tmp = ((-0.25 * (r_m * r_m)) * w) * w;
} else if (t_0 <= -200000000.0) {
tmp = (((w * w) * 3.0) * (-0.125 * r_m)) * r_m;
} else {
tmp = ((2.0 / r_m) / r_m) - 1.5;
}
return tmp;
}
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double t_0 = ((3.0 + (2.0 / (r_m * r_m))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5;
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = ((-0.25 * (r_m * r_m)) * w) * w;
} else if (t_0 <= -200000000.0) {
tmp = (((w * w) * 3.0) * (-0.125 * r_m)) * r_m;
} else {
tmp = ((2.0 / r_m) / r_m) - 1.5;
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): t_0 = ((3.0 + (2.0 / (r_m * r_m))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5 tmp = 0 if t_0 <= -math.inf: tmp = ((-0.25 * (r_m * r_m)) * w) * w elif t_0 <= -200000000.0: tmp = (((w * w) * 3.0) * (-0.125 * r_m)) * r_m else: tmp = ((2.0 / r_m) / r_m) - 1.5 return tmp
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(Float64(Float64(3.0 + Float64(2.0 / Float64(r_m * r_m))) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r_m) * r_m)) / Float64(1.0 - v))) - 4.5) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(Float64(-0.25 * Float64(r_m * r_m)) * w) * w); elseif (t_0 <= -200000000.0) tmp = Float64(Float64(Float64(Float64(w * w) * 3.0) * Float64(-0.125 * r_m)) * r_m); else tmp = Float64(Float64(Float64(2.0 / r_m) / r_m) - 1.5); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) t_0 = ((3.0 + (2.0 / (r_m * r_m))) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5; tmp = 0.0; if (t_0 <= -Inf) tmp = ((-0.25 * (r_m * r_m)) * w) * w; elseif (t_0 <= -200000000.0) tmp = (((w * w) * 3.0) * (-0.125 * r_m)) * r_m; else tmp = ((2.0 / r_m) / r_m) - 1.5; end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(N[(N[(3.0 + N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(N[(-0.25 * N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * w), $MachinePrecision], If[LessEqual[t$95$0, -200000000.0], N[(N[(N[(N[(w * w), $MachinePrecision] * 3.0), $MachinePrecision] * N[(-0.125 * r$95$m), $MachinePrecision]), $MachinePrecision] * r$95$m), $MachinePrecision], N[(N[(N[(2.0 / r$95$m), $MachinePrecision] / r$95$m), $MachinePrecision] - 1.5), $MachinePrecision]]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \left(\left(3 + \frac{2}{r\_m \cdot r\_m}\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\_m\right) \cdot r\_m\right)}{1 - v}\right) - 4.5\\
\mathbf{if}\;t\_0 \leq -\infty:\\
\;\;\;\;\left(\left(-0.25 \cdot \left(r\_m \cdot r\_m\right)\right) \cdot w\right) \cdot w\\
\mathbf{elif}\;t\_0 \leq -200000000:\\
\;\;\;\;\left(\left(\left(w \cdot w\right) \cdot 3\right) \cdot \left(-0.125 \cdot r\_m\right)\right) \cdot r\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r\_m}}{r\_m} - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -inf.0Initial program 78.3%
Taylor expanded in w around inf
Applied rewrites81.1%
Taylor expanded in v around inf
Applied rewrites84.4%
if -inf.0 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -2e8Initial program 98.3%
Taylor expanded in w around inf
Applied rewrites67.2%
Taylor expanded in v around 0
Applied rewrites40.3%
Applied rewrites65.4%
if -2e8 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.0%
Taylor expanded in v around 0
Applied rewrites91.9%
Taylor expanded in w around 0
Applied rewrites95.6%
Applied rewrites95.6%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m)))
(t_1
(-
(-
(+ 3.0 t_0)
(/
(* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r_m) r_m))
(- 1.0 v)))
4.5)))
(if (<= t_1 (- INFINITY))
(* (* (* -0.25 (* r_m r_m)) w) w)
(if (<= t_1 -200000000.0)
(* (* (* (* w w) 3.0) (* -0.125 r_m)) r_m)
(- t_0 1.5)))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double t_1 = ((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = ((-0.25 * (r_m * r_m)) * w) * w;
} else if (t_1 <= -200000000.0) {
tmp = (((w * w) * 3.0) * (-0.125 * r_m)) * r_m;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double t_1 = ((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = ((-0.25 * (r_m * r_m)) * w) * w;
} else if (t_1 <= -200000000.0) {
tmp = (((w * w) * 3.0) * (-0.125 * r_m)) * r_m;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): t_0 = 2.0 / (r_m * r_m) t_1 = ((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5 tmp = 0 if t_1 <= -math.inf: tmp = ((-0.25 * (r_m * r_m)) * w) * w elif t_1 <= -200000000.0: tmp = (((w * w) * 3.0) * (-0.125 * r_m)) * r_m else: tmp = t_0 - 1.5 return tmp
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) t_1 = Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r_m) * r_m)) / Float64(1.0 - v))) - 4.5) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(Float64(-0.25 * Float64(r_m * r_m)) * w) * w); elseif (t_1 <= -200000000.0) tmp = Float64(Float64(Float64(Float64(w * w) * 3.0) * Float64(-0.125 * r_m)) * r_m); else tmp = Float64(t_0 - 1.5); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) t_0 = 2.0 / (r_m * r_m); t_1 = ((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5; tmp = 0.0; if (t_1 <= -Inf) tmp = ((-0.25 * (r_m * r_m)) * w) * w; elseif (t_1 <= -200000000.0) tmp = (((w * w) * 3.0) * (-0.125 * r_m)) * r_m; else tmp = t_0 - 1.5; end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(-0.25 * N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * w), $MachinePrecision], If[LessEqual[t$95$1, -200000000.0], N[(N[(N[(N[(w * w), $MachinePrecision] * 3.0), $MachinePrecision] * N[(-0.125 * r$95$m), $MachinePrecision]), $MachinePrecision] * r$95$m), $MachinePrecision], N[(t$95$0 - 1.5), $MachinePrecision]]]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
t_1 := \left(\left(3 + t\_0\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\_m\right) \cdot r\_m\right)}{1 - v}\right) - 4.5\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;\left(\left(-0.25 \cdot \left(r\_m \cdot r\_m\right)\right) \cdot w\right) \cdot w\\
\mathbf{elif}\;t\_1 \leq -200000000:\\
\;\;\;\;\left(\left(\left(w \cdot w\right) \cdot 3\right) \cdot \left(-0.125 \cdot r\_m\right)\right) \cdot r\_m\\
\mathbf{else}:\\
\;\;\;\;t\_0 - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -inf.0Initial program 78.3%
Taylor expanded in w around inf
Applied rewrites81.1%
Taylor expanded in v around inf
Applied rewrites84.4%
if -inf.0 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -2e8Initial program 98.3%
Taylor expanded in w around inf
Applied rewrites67.2%
Taylor expanded in v around 0
Applied rewrites40.3%
Applied rewrites65.4%
if -2e8 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.0%
Taylor expanded in w around 0
Applied rewrites95.6%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (<=
(-
(-
(+ 3.0 t_0)
(/
(* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r_m) r_m))
(- 1.0 v)))
4.5)
-200000000.0)
(- t_0 (* (* (* w r_m) (* 0.375 w)) r_m))
(- (/ (/ 2.0 r_m) r_m) 1.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) {
tmp = t_0 - (((w * r_m) * (0.375 * w)) * r_m);
} else {
tmp = ((2.0 / r_m) / r_m) - 1.5;
}
return tmp;
}
r_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r_m * r_m)
if ((((3.0d0 + t_0) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r_m) * r_m)) / (1.0d0 - v))) - 4.5d0) <= (-200000000.0d0)) then
tmp = t_0 - (((w * r_m) * (0.375d0 * w)) * r_m)
else
tmp = ((2.0d0 / r_m) / r_m) - 1.5d0
end if
code = tmp
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) {
tmp = t_0 - (((w * r_m) * (0.375 * w)) * r_m);
} else {
tmp = ((2.0 / r_m) / r_m) - 1.5;
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): t_0 = 2.0 / (r_m * r_m) tmp = 0 if (((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0: tmp = t_0 - (((w * r_m) * (0.375 * w)) * r_m) else: tmp = ((2.0 / r_m) / r_m) - 1.5 return tmp
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) tmp = 0.0 if (Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r_m) * r_m)) / Float64(1.0 - v))) - 4.5) <= -200000000.0) tmp = Float64(t_0 - Float64(Float64(Float64(w * r_m) * Float64(0.375 * w)) * r_m)); else tmp = Float64(Float64(Float64(2.0 / r_m) / r_m) - 1.5); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) t_0 = 2.0 / (r_m * r_m); tmp = 0.0; if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) tmp = t_0 - (((w * r_m) * (0.375 * w)) * r_m); else tmp = ((2.0 / r_m) / r_m) - 1.5; end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], -200000000.0], N[(t$95$0 - N[(N[(N[(w * r$95$m), $MachinePrecision] * N[(0.375 * w), $MachinePrecision]), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r$95$m), $MachinePrecision] / r$95$m), $MachinePrecision] - 1.5), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\mathbf{if}\;\left(\left(3 + t\_0\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\_m\right) \cdot r\_m\right)}{1 - v}\right) - 4.5 \leq -200000000:\\
\;\;\;\;t\_0 - \left(\left(w \cdot r\_m\right) \cdot \left(0.375 \cdot w\right)\right) \cdot r\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r\_m}}{r\_m} - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -2e8Initial program 82.7%
Taylor expanded in v around 0
Applied rewrites79.6%
Taylor expanded in w around inf
Applied rewrites77.2%
Applied rewrites82.9%
if -2e8 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.0%
Taylor expanded in v around 0
Applied rewrites91.9%
Taylor expanded in w around 0
Applied rewrites95.6%
Applied rewrites95.6%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (<=
(-
(-
(+ 3.0 t_0)
(/
(* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r_m) r_m))
(- 1.0 v)))
4.5)
-200000000.0)
(- t_0 (* (* w (* (* 0.375 w) r_m)) r_m))
(- (/ (/ 2.0 r_m) r_m) 1.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) {
tmp = t_0 - ((w * ((0.375 * w) * r_m)) * r_m);
} else {
tmp = ((2.0 / r_m) / r_m) - 1.5;
}
return tmp;
}
r_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r_m * r_m)
if ((((3.0d0 + t_0) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r_m) * r_m)) / (1.0d0 - v))) - 4.5d0) <= (-200000000.0d0)) then
tmp = t_0 - ((w * ((0.375d0 * w) * r_m)) * r_m)
else
tmp = ((2.0d0 / r_m) / r_m) - 1.5d0
end if
code = tmp
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) {
tmp = t_0 - ((w * ((0.375 * w) * r_m)) * r_m);
} else {
tmp = ((2.0 / r_m) / r_m) - 1.5;
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): t_0 = 2.0 / (r_m * r_m) tmp = 0 if (((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0: tmp = t_0 - ((w * ((0.375 * w) * r_m)) * r_m) else: tmp = ((2.0 / r_m) / r_m) - 1.5 return tmp
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) tmp = 0.0 if (Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r_m) * r_m)) / Float64(1.0 - v))) - 4.5) <= -200000000.0) tmp = Float64(t_0 - Float64(Float64(w * Float64(Float64(0.375 * w) * r_m)) * r_m)); else tmp = Float64(Float64(Float64(2.0 / r_m) / r_m) - 1.5); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) t_0 = 2.0 / (r_m * r_m); tmp = 0.0; if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) tmp = t_0 - ((w * ((0.375 * w) * r_m)) * r_m); else tmp = ((2.0 / r_m) / r_m) - 1.5; end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], -200000000.0], N[(t$95$0 - N[(N[(w * N[(N[(0.375 * w), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r$95$m), $MachinePrecision] / r$95$m), $MachinePrecision] - 1.5), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\mathbf{if}\;\left(\left(3 + t\_0\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\_m\right) \cdot r\_m\right)}{1 - v}\right) - 4.5 \leq -200000000:\\
\;\;\;\;t\_0 - \left(w \cdot \left(\left(0.375 \cdot w\right) \cdot r\_m\right)\right) \cdot r\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r\_m}}{r\_m} - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -2e8Initial program 82.7%
Taylor expanded in v around 0
Applied rewrites79.6%
Taylor expanded in w around inf
Applied rewrites77.2%
Applied rewrites82.9%
if -2e8 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.0%
Taylor expanded in v around 0
Applied rewrites91.9%
Taylor expanded in w around 0
Applied rewrites95.6%
Applied rewrites95.6%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (<=
(-
(-
(+ 3.0 t_0)
(/
(* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r_m) r_m))
(- 1.0 v)))
4.5)
-200000000.0)
(- t_0 (* (* w (* w (* 0.375 r_m))) r_m))
(- (/ (/ 2.0 r_m) r_m) 1.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) {
tmp = t_0 - ((w * (w * (0.375 * r_m))) * r_m);
} else {
tmp = ((2.0 / r_m) / r_m) - 1.5;
}
return tmp;
}
r_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r_m * r_m)
if ((((3.0d0 + t_0) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r_m) * r_m)) / (1.0d0 - v))) - 4.5d0) <= (-200000000.0d0)) then
tmp = t_0 - ((w * (w * (0.375d0 * r_m))) * r_m)
else
tmp = ((2.0d0 / r_m) / r_m) - 1.5d0
end if
code = tmp
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) {
tmp = t_0 - ((w * (w * (0.375 * r_m))) * r_m);
} else {
tmp = ((2.0 / r_m) / r_m) - 1.5;
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): t_0 = 2.0 / (r_m * r_m) tmp = 0 if (((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0: tmp = t_0 - ((w * (w * (0.375 * r_m))) * r_m) else: tmp = ((2.0 / r_m) / r_m) - 1.5 return tmp
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) tmp = 0.0 if (Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r_m) * r_m)) / Float64(1.0 - v))) - 4.5) <= -200000000.0) tmp = Float64(t_0 - Float64(Float64(w * Float64(w * Float64(0.375 * r_m))) * r_m)); else tmp = Float64(Float64(Float64(2.0 / r_m) / r_m) - 1.5); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) t_0 = 2.0 / (r_m * r_m); tmp = 0.0; if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) tmp = t_0 - ((w * (w * (0.375 * r_m))) * r_m); else tmp = ((2.0 / r_m) / r_m) - 1.5; end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], -200000000.0], N[(t$95$0 - N[(N[(w * N[(w * N[(0.375 * r$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(2.0 / r$95$m), $MachinePrecision] / r$95$m), $MachinePrecision] - 1.5), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\mathbf{if}\;\left(\left(3 + t\_0\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\_m\right) \cdot r\_m\right)}{1 - v}\right) - 4.5 \leq -200000000:\\
\;\;\;\;t\_0 - \left(w \cdot \left(w \cdot \left(0.375 \cdot r\_m\right)\right)\right) \cdot r\_m\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{r\_m}}{r\_m} - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -2e8Initial program 82.7%
Taylor expanded in v around 0
Applied rewrites79.6%
Taylor expanded in w around inf
Applied rewrites77.2%
Applied rewrites82.9%
if -2e8 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.0%
Taylor expanded in v around 0
Applied rewrites91.9%
Taylor expanded in w around 0
Applied rewrites95.6%
Applied rewrites95.6%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (<=
(-
(-
(+ 3.0 t_0)
(/
(* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r_m) r_m))
(- 1.0 v)))
4.5)
-200000000.0)
(* (* (* -0.25 (* r_m r_m)) w) w)
(- t_0 1.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) {
tmp = ((-0.25 * (r_m * r_m)) * w) * w;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
r_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
real(8) :: t_0
real(8) :: tmp
t_0 = 2.0d0 / (r_m * r_m)
if ((((3.0d0 + t_0) - (((0.125d0 * (3.0d0 - (2.0d0 * v))) * (((w * w) * r_m) * r_m)) / (1.0d0 - v))) - 4.5d0) <= (-200000000.0d0)) then
tmp = (((-0.25d0) * (r_m * r_m)) * w) * w
else
tmp = t_0 - 1.5d0
end if
code = tmp
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) {
tmp = ((-0.25 * (r_m * r_m)) * w) * w;
} else {
tmp = t_0 - 1.5;
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): t_0 = 2.0 / (r_m * r_m) tmp = 0 if (((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0: tmp = ((-0.25 * (r_m * r_m)) * w) * w else: tmp = t_0 - 1.5 return tmp
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) tmp = 0.0 if (Float64(Float64(Float64(3.0 + t_0) - Float64(Float64(Float64(0.125 * Float64(3.0 - Float64(2.0 * v))) * Float64(Float64(Float64(w * w) * r_m) * r_m)) / Float64(1.0 - v))) - 4.5) <= -200000000.0) tmp = Float64(Float64(Float64(-0.25 * Float64(r_m * r_m)) * w) * w); else tmp = Float64(t_0 - 1.5); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) t_0 = 2.0 / (r_m * r_m); tmp = 0.0; if ((((3.0 + t_0) - (((0.125 * (3.0 - (2.0 * v))) * (((w * w) * r_m) * r_m)) / (1.0 - v))) - 4.5) <= -200000000.0) tmp = ((-0.25 * (r_m * r_m)) * w) * w; else tmp = t_0 - 1.5; end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(N[(3.0 + t$95$0), $MachinePrecision] - N[(N[(N[(0.125 * N[(3.0 - N[(2.0 * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(w * w), $MachinePrecision] * r$95$m), $MachinePrecision] * r$95$m), $MachinePrecision]), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], -200000000.0], N[(N[(N[(-0.25 * N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * w), $MachinePrecision], N[(t$95$0 - 1.5), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\mathbf{if}\;\left(\left(3 + t\_0\right) - \frac{\left(0.125 \cdot \left(3 - 2 \cdot v\right)\right) \cdot \left(\left(\left(w \cdot w\right) \cdot r\_m\right) \cdot r\_m\right)}{1 - v}\right) - 4.5 \leq -200000000:\\
\;\;\;\;\left(\left(-0.25 \cdot \left(r\_m \cdot r\_m\right)\right) \cdot w\right) \cdot w\\
\mathbf{else}:\\
\;\;\;\;t\_0 - 1.5\\
\end{array}
\end{array}
if (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) < -2e8Initial program 82.7%
Taylor expanded in w around inf
Applied rewrites78.1%
Taylor expanded in v around inf
Applied rewrites75.2%
if -2e8 < (-.f64 (-.f64 (+.f64 #s(literal 3 binary64) (/.f64 #s(literal 2 binary64) (*.f64 r r))) (/.f64 (*.f64 (*.f64 #s(literal 1/8 binary64) (-.f64 #s(literal 3 binary64) (*.f64 #s(literal 2 binary64) v))) (*.f64 (*.f64 (*.f64 w w) r) r)) (-.f64 #s(literal 1 binary64) v))) #s(literal 9/2 binary64)) Initial program 85.0%
Taylor expanded in w around 0
Applied rewrites95.6%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(if (<= r_m 4100000.0)
(-
(+ (/ 2.0 (* r_m r_m)) 3.0)
(fma (* (* w r_m) (* r_m (/ w (- 1.0 v)))) (fma -0.25 v 0.375) 4.5))
(-
3.0
(fma
(* (* w r_m) (/ (* w r_m) (- 1.0 v)))
(* (fma -2.0 v 3.0) 0.125)
4.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double tmp;
if (r_m <= 4100000.0) {
tmp = ((2.0 / (r_m * r_m)) + 3.0) - fma(((w * r_m) * (r_m * (w / (1.0 - v)))), fma(-0.25, v, 0.375), 4.5);
} else {
tmp = 3.0 - fma(((w * r_m) * ((w * r_m) / (1.0 - v))), (fma(-2.0, v, 3.0) * 0.125), 4.5);
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) tmp = 0.0 if (r_m <= 4100000.0) tmp = Float64(Float64(Float64(2.0 / Float64(r_m * r_m)) + 3.0) - fma(Float64(Float64(w * r_m) * Float64(r_m * Float64(w / Float64(1.0 - v)))), fma(-0.25, v, 0.375), 4.5)); else tmp = Float64(3.0 - fma(Float64(Float64(w * r_m) * Float64(Float64(w * r_m) / Float64(1.0 - v))), Float64(fma(-2.0, v, 3.0) * 0.125), 4.5)); end return tmp end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := If[LessEqual[r$95$m, 4100000.0], N[(N[(N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - N[(N[(N[(w * r$95$m), $MachinePrecision] * N[(r$95$m * N[(w / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-0.25 * v + 0.375), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(N[(N[(w * r$95$m), $MachinePrecision] * N[(N[(w * r$95$m), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(-2.0 * v + 3.0), $MachinePrecision] * 0.125), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
\mathbf{if}\;r\_m \leq 4100000:\\
\;\;\;\;\left(\frac{2}{r\_m \cdot r\_m} + 3\right) - \mathsf{fma}\left(\left(w \cdot r\_m\right) \cdot \left(r\_m \cdot \frac{w}{1 - v}\right), \mathsf{fma}\left(-0.25, v, 0.375\right), 4.5\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \mathsf{fma}\left(\left(w \cdot r\_m\right) \cdot \frac{w \cdot r\_m}{1 - v}, \mathsf{fma}\left(-2, v, 3\right) \cdot 0.125, 4.5\right)\\
\end{array}
\end{array}
if r < 4.1e6Initial program 82.5%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites96.5%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites99.3%
if 4.1e6 < r Initial program 87.2%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in r around inf
Applied rewrites99.8%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (- (+ (/ 2.0 (* r_m r_m)) 3.0) (fma (* (* w r_m) (/ (* w r_m) (- 1.0 v))) (* (fma -2.0 v 3.0) 0.125) 4.5)))
r_m = fabs(r);
double code(double v, double w, double r_m) {
return ((2.0 / (r_m * r_m)) + 3.0) - fma(((w * r_m) * ((w * r_m) / (1.0 - v))), (fma(-2.0, v, 3.0) * 0.125), 4.5);
}
r_m = abs(r) function code(v, w, r_m) return Float64(Float64(Float64(2.0 / Float64(r_m * r_m)) + 3.0) - fma(Float64(Float64(w * r_m) * Float64(Float64(w * r_m) / Float64(1.0 - v))), Float64(fma(-2.0, v, 3.0) * 0.125), 4.5)) end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := N[(N[(N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] + 3.0), $MachinePrecision] - N[(N[(N[(w * r$95$m), $MachinePrecision] * N[(N[(w * r$95$m), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(-2.0 * v + 3.0), $MachinePrecision] * 0.125), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
r_m = \left|r\right|
\\
\left(\frac{2}{r\_m \cdot r\_m} + 3\right) - \mathsf{fma}\left(\left(w \cdot r\_m\right) \cdot \frac{w \cdot r\_m}{1 - v}, \mathsf{fma}\left(-2, v, 3\right) \cdot 0.125, 4.5\right)
\end{array}
Initial program 83.9%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.8%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (or (<= v -5e-32) (not (<= v 5e-9)))
(- (fma (* -0.25 (* w r_m)) (* w r_m) (- t_0 -3.0)) 4.5)
(- t_0 (fma (* (* w (* 0.375 r_m)) r_m) w 1.5)))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if ((v <= -5e-32) || !(v <= 5e-9)) {
tmp = fma((-0.25 * (w * r_m)), (w * r_m), (t_0 - -3.0)) - 4.5;
} else {
tmp = t_0 - fma(((w * (0.375 * r_m)) * r_m), w, 1.5);
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) tmp = 0.0 if ((v <= -5e-32) || !(v <= 5e-9)) tmp = Float64(fma(Float64(-0.25 * Float64(w * r_m)), Float64(w * r_m), Float64(t_0 - -3.0)) - 4.5); else tmp = Float64(t_0 - fma(Float64(Float64(w * Float64(0.375 * r_m)) * r_m), w, 1.5)); end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[v, -5e-32], N[Not[LessEqual[v, 5e-9]], $MachinePrecision]], N[(N[(N[(-0.25 * N[(w * r$95$m), $MachinePrecision]), $MachinePrecision] * N[(w * r$95$m), $MachinePrecision] + N[(t$95$0 - -3.0), $MachinePrecision]), $MachinePrecision] - 4.5), $MachinePrecision], N[(t$95$0 - N[(N[(N[(w * N[(0.375 * r$95$m), $MachinePrecision]), $MachinePrecision] * r$95$m), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\mathbf{if}\;v \leq -5 \cdot 10^{-32} \lor \neg \left(v \leq 5 \cdot 10^{-9}\right):\\
\;\;\;\;\mathsf{fma}\left(-0.25 \cdot \left(w \cdot r\_m\right), w \cdot r\_m, t\_0 - -3\right) - 4.5\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(w \cdot \left(0.375 \cdot r\_m\right)\right) \cdot r\_m, w, 1.5\right)\\
\end{array}
\end{array}
if v < -5e-32 or 5.0000000000000001e-9 < v Initial program 79.8%
Taylor expanded in v around inf
Applied rewrites79.0%
Applied rewrites99.3%
if -5e-32 < v < 5.0000000000000001e-9Initial program 90.1%
Taylor expanded in v around 0
Applied rewrites90.5%
Applied rewrites96.2%
Final simplification98.1%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(if (<= r_m 550.0)
(- (/ 2.0 (* r_m r_m)) (fma (* (* 0.375 (* r_m r_m)) w) w 1.5))
(-
3.0
(fma
(* (* w r_m) (/ (* w r_m) (- 1.0 v)))
(* (fma -2.0 v 3.0) 0.125)
4.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double tmp;
if (r_m <= 550.0) {
tmp = (2.0 / (r_m * r_m)) - fma(((0.375 * (r_m * r_m)) * w), w, 1.5);
} else {
tmp = 3.0 - fma(((w * r_m) * ((w * r_m) / (1.0 - v))), (fma(-2.0, v, 3.0) * 0.125), 4.5);
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) tmp = 0.0 if (r_m <= 550.0) tmp = Float64(Float64(2.0 / Float64(r_m * r_m)) - fma(Float64(Float64(0.375 * Float64(r_m * r_m)) * w), w, 1.5)); else tmp = Float64(3.0 - fma(Float64(Float64(w * r_m) * Float64(Float64(w * r_m) / Float64(1.0 - v))), Float64(fma(-2.0, v, 3.0) * 0.125), 4.5)); end return tmp end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := If[LessEqual[r$95$m, 550.0], N[(N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.375 * N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(N[(N[(w * r$95$m), $MachinePrecision] * N[(N[(w * r$95$m), $MachinePrecision] / N[(1.0 - v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(-2.0 * v + 3.0), $MachinePrecision] * 0.125), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
\mathbf{if}\;r\_m \leq 550:\\
\;\;\;\;\frac{2}{r\_m \cdot r\_m} - \mathsf{fma}\left(\left(0.375 \cdot \left(r\_m \cdot r\_m\right)\right) \cdot w, w, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \mathsf{fma}\left(\left(w \cdot r\_m\right) \cdot \frac{w \cdot r\_m}{1 - v}, \mathsf{fma}\left(-2, v, 3\right) \cdot 0.125, 4.5\right)\\
\end{array}
\end{array}
if r < 550Initial program 82.4%
Taylor expanded in v around 0
Applied rewrites91.0%
if 550 < r Initial program 87.4%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
Taylor expanded in r around inf
Applied rewrites99.8%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(if (<= r_m 550.0)
(- (/ 2.0 (* r_m r_m)) (fma (* (* 0.375 (* r_m r_m)) w) w 1.5))
(-
3.0
(fma
r_m
(* w (* (* 0.125 (fma -2.0 v 3.0)) (* (/ r_m (- 1.0 v)) w)))
4.5))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double tmp;
if (r_m <= 550.0) {
tmp = (2.0 / (r_m * r_m)) - fma(((0.375 * (r_m * r_m)) * w), w, 1.5);
} else {
tmp = 3.0 - fma(r_m, (w * ((0.125 * fma(-2.0, v, 3.0)) * ((r_m / (1.0 - v)) * w))), 4.5);
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) tmp = 0.0 if (r_m <= 550.0) tmp = Float64(Float64(2.0 / Float64(r_m * r_m)) - fma(Float64(Float64(0.375 * Float64(r_m * r_m)) * w), w, 1.5)); else tmp = Float64(3.0 - fma(r_m, Float64(w * Float64(Float64(0.125 * fma(-2.0, v, 3.0)) * Float64(Float64(r_m / Float64(1.0 - v)) * w))), 4.5)); end return tmp end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := If[LessEqual[r$95$m, 550.0], N[(N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(0.375 * N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision], N[(3.0 - N[(r$95$m * N[(w * N[(N[(0.125 * N[(-2.0 * v + 3.0), $MachinePrecision]), $MachinePrecision] * N[(N[(r$95$m / N[(1.0 - v), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 4.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
\mathbf{if}\;r\_m \leq 550:\\
\;\;\;\;\frac{2}{r\_m \cdot r\_m} - \mathsf{fma}\left(\left(0.375 \cdot \left(r\_m \cdot r\_m\right)\right) \cdot w, w, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;3 - \mathsf{fma}\left(r\_m, w \cdot \left(\left(0.125 \cdot \mathsf{fma}\left(-2, v, 3\right)\right) \cdot \left(\frac{r\_m}{1 - v} \cdot w\right)\right), 4.5\right)\\
\end{array}
\end{array}
if r < 550Initial program 82.4%
Taylor expanded in v around 0
Applied rewrites91.0%
if 550 < r Initial program 87.4%
lift--.f64N/A
lift--.f64N/A
associate--l-N/A
lower--.f64N/A
lift-+.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites99.7%
lift-/.f64N/A
lift-pow.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
lift-fma.f64N/A
lift-*.f64N/A
associate-*l*N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f64N/A
Applied rewrites99.8%
Taylor expanded in r around inf
Applied rewrites99.8%
r_m = (fabs.f64 r)
(FPCore (v w r_m)
:precision binary64
(let* ((t_0 (/ 2.0 (* r_m r_m))))
(if (<= r_m 1.3e+121)
(- t_0 (fma (* (* 0.25 (* r_m r_m)) w) w 1.5))
(- t_0 (fma (* 0.375 r_m) (* (* w w) r_m) 1.5)))))r_m = fabs(r);
double code(double v, double w, double r_m) {
double t_0 = 2.0 / (r_m * r_m);
double tmp;
if (r_m <= 1.3e+121) {
tmp = t_0 - fma(((0.25 * (r_m * r_m)) * w), w, 1.5);
} else {
tmp = t_0 - fma((0.375 * r_m), ((w * w) * r_m), 1.5);
}
return tmp;
}
r_m = abs(r) function code(v, w, r_m) t_0 = Float64(2.0 / Float64(r_m * r_m)) tmp = 0.0 if (r_m <= 1.3e+121) tmp = Float64(t_0 - fma(Float64(Float64(0.25 * Float64(r_m * r_m)) * w), w, 1.5)); else tmp = Float64(t_0 - fma(Float64(0.375 * r_m), Float64(Float64(w * w) * r_m), 1.5)); end return tmp end
r_m = N[Abs[r], $MachinePrecision]
code[v_, w_, r$95$m_] := Block[{t$95$0 = N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[r$95$m, 1.3e+121], N[(t$95$0 - N[(N[(N[(0.25 * N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] * w), $MachinePrecision] * w + 1.5), $MachinePrecision]), $MachinePrecision], N[(t$95$0 - N[(N[(0.375 * r$95$m), $MachinePrecision] * N[(N[(w * w), $MachinePrecision] * r$95$m), $MachinePrecision] + 1.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
t_0 := \frac{2}{r\_m \cdot r\_m}\\
\mathbf{if}\;r\_m \leq 1.3 \cdot 10^{+121}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(\left(0.25 \cdot \left(r\_m \cdot r\_m\right)\right) \cdot w, w, 1.5\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \mathsf{fma}\left(0.375 \cdot r\_m, \left(w \cdot w\right) \cdot r\_m, 1.5\right)\\
\end{array}
\end{array}
if r < 1.2999999999999999e121Initial program 84.0%
Taylor expanded in v around inf
Applied rewrites91.5%
if 1.2999999999999999e121 < r Initial program 83.3%
Taylor expanded in v around 0
Applied rewrites68.0%
Applied rewrites83.5%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (if (<= r_m 1.15) (/ 2.0 (* r_m r_m)) (- 3.0 4.5)))
r_m = fabs(r);
double code(double v, double w, double r_m) {
double tmp;
if (r_m <= 1.15) {
tmp = 2.0 / (r_m * r_m);
} else {
tmp = 3.0 - 4.5;
}
return tmp;
}
r_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
real(8) :: tmp
if (r_m <= 1.15d0) then
tmp = 2.0d0 / (r_m * r_m)
else
tmp = 3.0d0 - 4.5d0
end if
code = tmp
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
double tmp;
if (r_m <= 1.15) {
tmp = 2.0 / (r_m * r_m);
} else {
tmp = 3.0 - 4.5;
}
return tmp;
}
r_m = math.fabs(r) def code(v, w, r_m): tmp = 0 if r_m <= 1.15: tmp = 2.0 / (r_m * r_m) else: tmp = 3.0 - 4.5 return tmp
r_m = abs(r) function code(v, w, r_m) tmp = 0.0 if (r_m <= 1.15) tmp = Float64(2.0 / Float64(r_m * r_m)); else tmp = Float64(3.0 - 4.5); end return tmp end
r_m = abs(r); function tmp_2 = code(v, w, r_m) tmp = 0.0; if (r_m <= 1.15) tmp = 2.0 / (r_m * r_m); else tmp = 3.0 - 4.5; end tmp_2 = tmp; end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := If[LessEqual[r$95$m, 1.15], N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision], N[(3.0 - 4.5), $MachinePrecision]]
\begin{array}{l}
r_m = \left|r\right|
\\
\begin{array}{l}
\mathbf{if}\;r\_m \leq 1.15:\\
\;\;\;\;\frac{2}{r\_m \cdot r\_m}\\
\mathbf{else}:\\
\;\;\;\;3 - 4.5\\
\end{array}
\end{array}
if r < 1.1499999999999999Initial program 82.1%
Taylor expanded in r around 0
Applied rewrites59.1%
if 1.1499999999999999 < r Initial program 87.8%
Taylor expanded in r around 0
Applied rewrites18.5%
Taylor expanded in r around inf
Applied rewrites20.7%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (- (/ 2.0 (* r_m r_m)) 1.5))
r_m = fabs(r);
double code(double v, double w, double r_m) {
return (2.0 / (r_m * r_m)) - 1.5;
}
r_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
code = (2.0d0 / (r_m * r_m)) - 1.5d0
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
return (2.0 / (r_m * r_m)) - 1.5;
}
r_m = math.fabs(r) def code(v, w, r_m): return (2.0 / (r_m * r_m)) - 1.5
r_m = abs(r) function code(v, w, r_m) return Float64(Float64(2.0 / Float64(r_m * r_m)) - 1.5) end
r_m = abs(r); function tmp = code(v, w, r_m) tmp = (2.0 / (r_m * r_m)) - 1.5; end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := N[(N[(2.0 / N[(r$95$m * r$95$m), $MachinePrecision]), $MachinePrecision] - 1.5), $MachinePrecision]
\begin{array}{l}
r_m = \left|r\right|
\\
\frac{2}{r\_m \cdot r\_m} - 1.5
\end{array}
Initial program 83.9%
Taylor expanded in w around 0
Applied rewrites53.9%
r_m = (fabs.f64 r) (FPCore (v w r_m) :precision binary64 (- 3.0 4.5))
r_m = fabs(r);
double code(double v, double w, double r_m) {
return 3.0 - 4.5;
}
r_m = private
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(v, w, r_m)
use fmin_fmax_functions
real(8), intent (in) :: v
real(8), intent (in) :: w
real(8), intent (in) :: r_m
code = 3.0d0 - 4.5d0
end function
r_m = Math.abs(r);
public static double code(double v, double w, double r_m) {
return 3.0 - 4.5;
}
r_m = math.fabs(r) def code(v, w, r_m): return 3.0 - 4.5
r_m = abs(r) function code(v, w, r_m) return Float64(3.0 - 4.5) end
r_m = abs(r); function tmp = code(v, w, r_m) tmp = 3.0 - 4.5; end
r_m = N[Abs[r], $MachinePrecision] code[v_, w_, r$95$m_] := N[(3.0 - 4.5), $MachinePrecision]
\begin{array}{l}
r_m = \left|r\right|
\\
3 - 4.5
\end{array}
Initial program 83.9%
Taylor expanded in r around 0
Applied rewrites51.0%
Taylor expanded in r around inf
Applied rewrites13.0%
herbie shell --seed 2025018
(FPCore (v w r)
:name "Rosa's TurbineBenchmark"
:precision binary64
(- (- (+ 3.0 (/ 2.0 (* r r))) (/ (* (* 0.125 (- 3.0 (* 2.0 v))) (* (* (* w w) r) r)) (- 1.0 v))) 4.5))