
(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}
Sampling outcomes in binary64 precision:
Herbie found 7 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}
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 1.85e+152) (fma (- (* z_m z_m) t) (* -4.0 y) (* x x)) (fma (* (* y z_m) z_m) -4.0 (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1.85e+152) {
tmp = fma(((z_m * z_m) - t), (-4.0 * y), (x * x));
} else {
tmp = fma(((y * z_m) * z_m), -4.0, (x * x));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 1.85e+152) tmp = fma(Float64(Float64(z_m * z_m) - t), Float64(-4.0 * y), Float64(x * x)); else tmp = fma(Float64(Float64(y * z_m) * z_m), -4.0, Float64(x * x)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 1.85e+152], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision] * N[(-4.0 * y), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 1.85 \cdot 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(z\_m \cdot z\_m - t, -4 \cdot y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(y \cdot z\_m\right) \cdot z\_m, -4, x \cdot x\right)\\
\end{array}
\end{array}
if z < 1.84999999999999998e152Initial program 94.5%
Applied rewrites95.8%
if 1.84999999999999998e152 < z Initial program 66.2%
Taylor expanded in t around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-rgt-identityN/A
unpow2N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
associate-*l*N/A
unpow2N/A
*-rgt-identityN/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
sqr-neg-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
unpow2N/A
mul-1-negN/A
fp-cancel-sign-subN/A
*-commutativeN/A
mul-1-negN/A
Applied rewrites66.2%
Applied rewrites79.3%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(let* ((t_1 (* (* t 4.0) y)))
(if (<= x 4.5e-248)
t_1
(if (<= x 4.5e-62)
(* (* (* -4.0 z_m) y) z_m)
(if (<= x 0.115) t_1 (* x x))))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = (t * 4.0) * y;
double tmp;
if (x <= 4.5e-248) {
tmp = t_1;
} else if (x <= 4.5e-62) {
tmp = ((-4.0 * z_m) * y) * z_m;
} else if (x <= 0.115) {
tmp = t_1;
} else {
tmp = x * x;
}
return tmp;
}
z_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, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (t * 4.0d0) * y
if (x <= 4.5d-248) then
tmp = t_1
else if (x <= 4.5d-62) then
tmp = (((-4.0d0) * z_m) * y) * z_m
else if (x <= 0.115d0) then
tmp = t_1
else
tmp = x * x
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
double t_1 = (t * 4.0) * y;
double tmp;
if (x <= 4.5e-248) {
tmp = t_1;
} else if (x <= 4.5e-62) {
tmp = ((-4.0 * z_m) * y) * z_m;
} else if (x <= 0.115) {
tmp = t_1;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): t_1 = (t * 4.0) * y tmp = 0 if x <= 4.5e-248: tmp = t_1 elif x <= 4.5e-62: tmp = ((-4.0 * z_m) * y) * z_m elif x <= 0.115: tmp = t_1 else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(Float64(t * 4.0) * y) tmp = 0.0 if (x <= 4.5e-248) tmp = t_1; elseif (x <= 4.5e-62) tmp = Float64(Float64(Float64(-4.0 * z_m) * y) * z_m); elseif (x <= 0.115) tmp = t_1; else tmp = Float64(x * x); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m, t) t_1 = (t * 4.0) * y; tmp = 0.0; if (x <= 4.5e-248) tmp = t_1; elseif (x <= 4.5e-62) tmp = ((-4.0 * z_m) * y) * z_m; elseif (x <= 0.115) tmp = t_1; else tmp = x * x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(t * 4.0), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[x, 4.5e-248], t$95$1, If[LessEqual[x, 4.5e-62], N[(N[(N[(-4.0 * z$95$m), $MachinePrecision] * y), $MachinePrecision] * z$95$m), $MachinePrecision], If[LessEqual[x, 0.115], t$95$1, N[(x * x), $MachinePrecision]]]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
t_1 := \left(t \cdot 4\right) \cdot y\\
\mathbf{if}\;x \leq 4.5 \cdot 10^{-248}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{-62}:\\
\;\;\;\;\left(\left(-4 \cdot z\_m\right) \cdot y\right) \cdot z\_m\\
\mathbf{elif}\;x \leq 0.115:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 4.4999999999999996e-248 or 4.50000000000000018e-62 < x < 0.115000000000000005Initial program 91.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6437.7
Applied rewrites37.7%
Applied rewrites37.7%
if 4.4999999999999996e-248 < x < 4.50000000000000018e-62Initial program 97.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6466.1
Applied rewrites66.1%
Applied rewrites69.0%
if 0.115000000000000005 < x Initial program 88.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
lower-*.f6438.8
Applied rewrites38.8%
Taylor expanded in t around inf
Applied rewrites37.2%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6473.2
Applied rewrites73.2%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 29500000000.0) (fma (* t 4.0) y (* x x)) (fma (* (* y z_m) z_m) -4.0 (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 29500000000.0) {
tmp = fma((t * 4.0), y, (x * x));
} else {
tmp = fma(((y * z_m) * z_m), -4.0, (x * x));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 29500000000.0) tmp = fma(Float64(t * 4.0), y, Float64(x * x)); else tmp = fma(Float64(Float64(y * z_m) * z_m), -4.0, Float64(x * x)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 29500000000.0], N[(N[(t * 4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 29500000000:\\
\;\;\;\;\mathsf{fma}\left(t \cdot 4, y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(y \cdot z\_m\right) \cdot z\_m, -4, x \cdot x\right)\\
\end{array}
\end{array}
if z < 2.95e10Initial program 93.7%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-rgt-identityN/A
unpow2N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
associate-*l*N/A
unpow2N/A
*-rgt-identityN/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
sqr-neg-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
unpow2N/A
mul-1-negN/A
fp-cancel-sign-subN/A
*-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
Applied rewrites81.0%
Applied rewrites82.5%
if 2.95e10 < z Initial program 82.8%
Taylor expanded in t around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-rgt-identityN/A
unpow2N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
associate-*l*N/A
unpow2N/A
*-rgt-identityN/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
sqr-neg-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
unpow2N/A
mul-1-negN/A
fp-cancel-sign-subN/A
*-commutativeN/A
mul-1-negN/A
Applied rewrites73.5%
Applied rewrites80.2%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 1.35e-9) (* (* (- (* z_m z_m) t) y) -4.0) (fma (* t 4.0) y (* x x))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 1.35e-9) {
tmp = (((z_m * z_m) - t) * y) * -4.0;
} else {
tmp = fma((t * 4.0), y, (x * x));
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 1.35e-9) tmp = Float64(Float64(Float64(Float64(z_m * z_m) - t) * y) * -4.0); else tmp = fma(Float64(t * 4.0), y, Float64(x * x)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[x, 1.35e-9], N[(N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision] * y), $MachinePrecision] * -4.0), $MachinePrecision], N[(N[(t * 4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.35 \cdot 10^{-9}:\\
\;\;\;\;\left(\left(z\_m \cdot z\_m - t\right) \cdot y\right) \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot 4, y, x \cdot x\right)\\
\end{array}
\end{array}
if x < 1.3500000000000001e-9Initial program 91.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
lower-*.f6466.9
Applied rewrites66.9%
if 1.3500000000000001e-9 < x Initial program 89.8%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-rgt-identityN/A
unpow2N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
associate-*l*N/A
unpow2N/A
*-rgt-identityN/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
sqr-neg-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
unpow2N/A
mul-1-negN/A
fp-cancel-sign-subN/A
*-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
Applied rewrites85.3%
Applied rewrites85.3%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 5.6e+69) (fma (* t 4.0) y (* x x)) (* (* (* -4.0 z_m) y) z_m)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 5.6e+69) {
tmp = fma((t * 4.0), y, (x * x));
} else {
tmp = ((-4.0 * z_m) * y) * z_m;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 5.6e+69) tmp = fma(Float64(t * 4.0), y, Float64(x * x)); else tmp = Float64(Float64(Float64(-4.0 * z_m) * y) * z_m); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 5.6e+69], N[(N[(t * 4.0), $MachinePrecision] * y + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-4.0 * z$95$m), $MachinePrecision] * y), $MachinePrecision] * z$95$m), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5.6 \cdot 10^{+69}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot 4, y, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(-4 \cdot z\_m\right) \cdot y\right) \cdot z\_m\\
\end{array}
\end{array}
if z < 5.59999999999999964e69Initial program 94.1%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-rgt-identityN/A
unpow2N/A
associate-*l*N/A
fp-cancel-sign-sub-invN/A
distribute-lft-neg-inN/A
associate-*l*N/A
unpow2N/A
*-rgt-identityN/A
mul-1-negN/A
*-commutativeN/A
unpow2N/A
sqr-neg-revN/A
distribute-lft-neg-outN/A
distribute-rgt-neg-inN/A
unpow2N/A
mul-1-negN/A
fp-cancel-sign-subN/A
*-commutativeN/A
mul-1-negN/A
distribute-lft-neg-outN/A
*-commutativeN/A
Applied rewrites79.9%
Applied rewrites81.3%
if 5.59999999999999964e69 < z Initial program 77.7%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6475.0
Applied rewrites75.0%
Applied rewrites77.0%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 0.115) (* (* t 4.0) y) (* x x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 0.115) {
tmp = (t * 4.0) * y;
} else {
tmp = x * x;
}
return tmp;
}
z_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, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (x <= 0.115d0) then
tmp = (t * 4.0d0) * y
else
tmp = x * x
end if
code = tmp
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 0.115) {
tmp = (t * 4.0) * y;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): tmp = 0 if x <= 0.115: tmp = (t * 4.0) * y else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 0.115) tmp = Float64(Float64(t * 4.0) * y); else tmp = Float64(x * x); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m, t) tmp = 0.0; if (x <= 0.115) tmp = (t * 4.0) * y; else tmp = x * x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[x, 0.115], N[(N[(t * 4.0), $MachinePrecision] * y), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.115:\\
\;\;\;\;\left(t \cdot 4\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 0.115000000000000005Initial program 92.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6437.5
Applied rewrites37.5%
Applied rewrites37.5%
if 0.115000000000000005 < x Initial program 88.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
lower-*.f6438.8
Applied rewrites38.8%
Taylor expanded in t around inf
Applied rewrites37.2%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6473.2
Applied rewrites73.2%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (* x x))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
return x * x;
}
z_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, y, z_m, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
code = x * x
end function
z_m = Math.abs(z);
public static double code(double x, double y, double z_m, double t) {
return x * x;
}
z_m = math.fabs(z) def code(x, y, z_m, t): return x * x
z_m = abs(z) function code(x, y, z_m, t) return Float64(x * x) end
z_m = abs(z); function tmp = code(x, y, z_m, t) tmp = x * x; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
z_m = \left|z\right|
\\
x \cdot x
\end{array}
Initial program 91.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower--.f64N/A
unpow2N/A
lower-*.f6460.1
Applied rewrites60.1%
Taylor expanded in t around inf
Applied rewrites56.9%
Taylor expanded in x around inf
unpow2N/A
lower-*.f6448.3
Applied rewrites48.3%
(FPCore (x y z t) :precision binary64 (- (* x x) (* 4.0 (* y (- (* z z) t)))))
double code(double x, double y, double z, double t) {
return (x * x) - (4.0 * (y * ((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) - (4.0d0 * (y * ((z * z) - t)))
end function
public static double code(double x, double y, double z, double t) {
return (x * x) - (4.0 * (y * ((z * z) - t)));
}
def code(x, y, z, t): return (x * x) - (4.0 * (y * ((z * z) - t)))
function code(x, y, z, t) return Float64(Float64(x * x) - Float64(4.0 * Float64(y * Float64(Float64(z * z) - t)))) end
function tmp = code(x, y, z, t) tmp = (x * x) - (4.0 * (y * ((z * z) - t))); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] - N[(4.0 * N[(y * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x - 4 \cdot \left(y \cdot \left(z \cdot z - t\right)\right)
\end{array}
herbie shell --seed 2024360
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
:alt
(! :herbie-platform default (- (* x x) (* 4 (* y (- (* z z) t)))))
(- (* x x) (* (* y 4.0) (- (* z z) t))))