
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * x) - ((y * 4.0d0) * ((z * z) - t))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t): return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))) end
function tmp = code(x, y, z, t) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (- (* x x) (* (* y 4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
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(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * x) - ((y * 4.0d0) * ((z * z) - t))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - ((y * 4.0) * ((z * z) - t));
}
def code(x, y, z, t): return (x * x) - ((y * 4.0) * ((z * z) - t))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))) end
function tmp = code(x, y, z, t) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)
\end{array}
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= x_m 1.35e+154) (- (* x_m x_m) (fma z (* z (* 4.0 y)) (* -4.0 (* t y)))) (* x_m x_m)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 1.35e+154) {
tmp = (x_m * x_m) - fma(z, (z * (4.0 * y)), (-4.0 * (t * y)));
} else {
tmp = x_m * x_m;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (x_m <= 1.35e+154) tmp = Float64(Float64(x_m * x_m) - fma(z, Float64(z * Float64(4.0 * y)), Float64(-4.0 * Float64(t * y)))); else tmp = Float64(x_m * x_m); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 1.35e+154], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(z * N[(z * N[(4.0 * y), $MachinePrecision]), $MachinePrecision] + N[(-4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * x$95$m), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;x\_m \cdot x\_m - \mathsf{fma}\left(z, z \cdot \left(4 \cdot y\right), -4 \cdot \left(t \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot x\_m\\
\end{array}
\end{array}
if x < 1.35000000000000003e154Initial program 94.1%
Taylor expanded in z around 0
Applied rewrites91.8%
Applied rewrites97.4%
if 1.35000000000000003e154 < x Initial program 79.9%
Taylor expanded in x around inf
Applied rewrites91.4%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1e+147) (- (* x_m x_m) (* (* y 4.0) (- (* z z) t))) (fma x_m x_m (* -4.0 (* z (* z y))))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1e+147) {
tmp = (x_m * x_m) - ((y * 4.0) * ((z * z) - t));
} else {
tmp = fma(x_m, x_m, (-4.0 * (z * (z * y))));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1e+147) tmp = Float64(Float64(x_m * x_m) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))); else tmp = fma(x_m, x_m, Float64(-4.0 * Float64(z * Float64(z * y)))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1e+147], N[(N[(x$95$m * x$95$m), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * x$95$m + N[(-4.0 * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 10^{+147}:\\
\;\;\;\;x\_m \cdot x\_m - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, -4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\right)\\
\end{array}
\end{array}
if z < 9.9999999999999998e146Initial program 93.6%
if 9.9999999999999998e146 < z Initial program 71.1%
Taylor expanded in z around 0
Applied rewrites66.2%
Taylor expanded in t around 0
Applied rewrites76.7%
Applied rewrites96.6%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 2.3e-28) (fma x_m x_m (* 4.0 (* t y))) (fma x_m x_m (* -4.0 (* z (* z y))))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 2.3e-28) {
tmp = fma(x_m, x_m, (4.0 * (t * y)));
} else {
tmp = fma(x_m, x_m, (-4.0 * (z * (z * y))));
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 2.3e-28) tmp = fma(x_m, x_m, Float64(4.0 * Float64(t * y))); else tmp = fma(x_m, x_m, Float64(-4.0 * Float64(z * Float64(z * y)))); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 2.3e-28], N[(x$95$m * x$95$m + N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x$95$m * x$95$m + N[(-4.0 * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.3 \cdot 10^{-28}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, 4 \cdot \left(t \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, -4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\right)\\
\end{array}
\end{array}
if z < 2.29999999999999986e-28Initial program 93.2%
Taylor expanded in z around 0
Applied rewrites91.7%
Taylor expanded in z around 0
Applied rewrites75.3%
if 2.29999999999999986e-28 < z Initial program 83.8%
Taylor expanded in z around 0
Applied rewrites81.0%
Taylor expanded in t around 0
Applied rewrites77.4%
Applied rewrites87.0%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1260000000.0) (fma x_m x_m (* 4.0 (* t y))) (if (<= z 1.75e+190) (* (* (- (* z z) t) y) -4.0) (* (* z (* z y)) -4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1260000000.0) {
tmp = fma(x_m, x_m, (4.0 * (t * y)));
} else if (z <= 1.75e+190) {
tmp = (((z * z) - t) * y) * -4.0;
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1260000000.0) tmp = fma(x_m, x_m, Float64(4.0 * Float64(t * y))); elseif (z <= 1.75e+190) tmp = Float64(Float64(Float64(Float64(z * z) - t) * y) * -4.0); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1260000000.0], N[(x$95$m * x$95$m + N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.75e+190], N[(N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1260000000:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, 4 \cdot \left(t \cdot y\right)\right)\\
\mathbf{elif}\;z \leq 1.75 \cdot 10^{+190}:\\
\;\;\;\;\left(\left(z \cdot z - t\right) \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.26e9Initial program 93.4%
Taylor expanded in z around 0
Applied rewrites92.0%
Taylor expanded in z around 0
Applied rewrites75.4%
if 1.26e9 < z < 1.7499999999999999e190Initial program 88.2%
Taylor expanded in x around 0
Applied rewrites66.2%
if 1.7499999999999999e190 < z Initial program 73.4%
Taylor expanded in z around inf
Applied rewrites79.8%
Applied rewrites89.6%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 4.7e+61) (fma x_m x_m (* 4.0 (* t y))) (* (* z (* z y)) -4.0)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 4.7e+61) {
tmp = fma(x_m, x_m, (4.0 * (t * y)));
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 4.7e+61) tmp = fma(x_m, x_m, Float64(4.0 * Float64(t * y))); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 4.7e+61], N[(x$95$m * x$95$m + N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 4.7 \cdot 10^{+61}:\\
\;\;\;\;\mathsf{fma}\left(x\_m, x\_m, 4 \cdot \left(t \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 4.6999999999999998e61Initial program 93.6%
Taylor expanded in z around 0
Applied rewrites92.3%
Taylor expanded in z around 0
Applied rewrites75.2%
if 4.6999999999999998e61 < z Initial program 78.8%
Taylor expanded in z around inf
Applied rewrites71.4%
Applied rewrites79.2%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= z 1.96e-140) (* (* 4.0 t) y) (if (<= z 1260000000.0) (* x_m x_m) (* (* z (* z y)) -4.0))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1.96e-140) {
tmp = (4.0 * t) * y;
} else if (z <= 1260000000.0) {
tmp = x_m * x_m;
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_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(x_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 1.96d-140) then
tmp = (4.0d0 * t) * y
else if (z <= 1260000000.0d0) then
tmp = x_m * x_m
else
tmp = (z * (z * y)) * (-4.0d0)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
double tmp;
if (z <= 1.96e-140) {
tmp = (4.0 * t) * y;
} else if (z <= 1260000000.0) {
tmp = x_m * x_m;
} else {
tmp = (z * (z * y)) * -4.0;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z, t): tmp = 0 if z <= 1.96e-140: tmp = (4.0 * t) * y elif z <= 1260000000.0: tmp = x_m * x_m else: tmp = (z * (z * y)) * -4.0 return tmp
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (z <= 1.96e-140) tmp = Float64(Float64(4.0 * t) * y); elseif (z <= 1260000000.0) tmp = Float64(x_m * x_m); else tmp = Float64(Float64(z * Float64(z * y)) * -4.0); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z, t) tmp = 0.0; if (z <= 1.96e-140) tmp = (4.0 * t) * y; elseif (z <= 1260000000.0) tmp = x_m * x_m; else tmp = (z * (z * y)) * -4.0; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1.96e-140], N[(N[(4.0 * t), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[z, 1260000000.0], N[(x$95$m * x$95$m), $MachinePrecision], N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.96 \cdot 10^{-140}:\\
\;\;\;\;\left(4 \cdot t\right) \cdot y\\
\mathbf{elif}\;z \leq 1260000000:\\
\;\;\;\;x\_m \cdot x\_m\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \left(z \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 1.96000000000000002e-140Initial program 92.6%
Taylor expanded in t around inf
Applied rewrites36.1%
Applied rewrites36.1%
if 1.96000000000000002e-140 < z < 1.26e9Initial program 98.0%
Taylor expanded in x around inf
Applied rewrites52.0%
if 1.26e9 < z Initial program 82.1%
Taylor expanded in z around inf
Applied rewrites64.8%
Applied rewrites71.2%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (if (<= x_m 0.195) (* (* 4.0 t) y) (* x_m x_m)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 0.195) {
tmp = (4.0 * t) * y;
} else {
tmp = x_m * x_m;
}
return tmp;
}
x_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(x_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x_m <= 0.195d0) then
tmp = (4.0d0 * t) * y
else
tmp = x_m * x_m
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
double tmp;
if (x_m <= 0.195) {
tmp = (4.0 * t) * y;
} else {
tmp = x_m * x_m;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z, t): tmp = 0 if x_m <= 0.195: tmp = (4.0 * t) * y else: tmp = x_m * x_m return tmp
x_m = abs(x) function code(x_m, y, z, t) tmp = 0.0 if (x_m <= 0.195) tmp = Float64(Float64(4.0 * t) * y); else tmp = Float64(x_m * x_m); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z, t) tmp = 0.0; if (x_m <= 0.195) tmp = (4.0 * t) * y; else tmp = x_m * x_m; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := If[LessEqual[x$95$m, 0.195], N[(N[(4.0 * t), $MachinePrecision] * y), $MachinePrecision], N[(x$95$m * x$95$m), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 0.195:\\
\;\;\;\;\left(4 \cdot t\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;x\_m \cdot x\_m\\
\end{array}
\end{array}
if x < 0.19500000000000001Initial program 93.8%
Taylor expanded in t around inf
Applied rewrites47.8%
Applied rewrites47.8%
if 0.19500000000000001 < x Initial program 87.3%
Taylor expanded in x around inf
Applied rewrites69.3%
x_m = (fabs.f64 x) (FPCore (x_m y z t) :precision binary64 (* x_m x_m))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
return x_m * x_m;
}
x_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(x_m, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_m * x_m
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
return x_m * x_m;
}
x_m = math.fabs(x) def code(x_m, y, z, t): return x_m * x_m
x_m = abs(x) function code(x_m, y, z, t) return Float64(x_m * x_m) end
x_m = abs(x); function tmp = code(x_m, y, z, t) tmp = x_m * x_m; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_, t_] := N[(x$95$m * x$95$m), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x\_m \cdot x\_m
\end{array}
Initial program 90.6%
Taylor expanded in x around inf
Applied rewrites40.8%
herbie shell --seed 2025132
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
(- (* x x) (* (* y 4.0) (- (* z z) t))))