
(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}
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 2.2e+139) (fma x x (* (* -4.0 y) (- (* z_m z_m) t))) (- (* x x) (* (* (* -4.0 (- (* (/ y (* z_m z_m)) t) y)) z_m) z_m))))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.2e+139) {
tmp = fma(x, x, ((-4.0 * y) * ((z_m * z_m) - t)));
} else {
tmp = (x * x) - (((-4.0 * (((y / (z_m * z_m)) * t) - y)) * z_m) * z_m);
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 2.2e+139) tmp = fma(x, x, Float64(Float64(-4.0 * y) * Float64(Float64(z_m * z_m) - t))); else tmp = Float64(Float64(x * x) - Float64(Float64(Float64(-4.0 * Float64(Float64(Float64(y / Float64(z_m * z_m)) * t) - y)) * z_m) * z_m)); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 2.2e+139], N[(x * x + N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(N[(N[(-4.0 * N[(N[(N[(y / N[(z$95$m * z$95$m), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision] * z$95$m), $MachinePrecision] * z$95$m), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 2.2 \cdot 10^{+139}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m - t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - \left(\left(-4 \cdot \left(\frac{y}{z\_m \cdot z\_m} \cdot t - y\right)\right) \cdot z\_m\right) \cdot z\_m\\
\end{array}
\end{array}
if z < 2.1999999999999999e139Initial program 98.0%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6498.8
Applied rewrites98.8%
if 2.1999999999999999e139 < z Initial program 72.7%
Taylor expanded in z around inf
*-commutativeN/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites90.4%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= x 7.2e+170) (fma x x (* (* -4.0 y) (- (* z_m z_m) t))) (* x x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (x <= 7.2e+170) {
tmp = fma(x, x, ((-4.0 * y) * ((z_m * z_m) - t)));
} else {
tmp = x * x;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (x <= 7.2e+170) tmp = fma(x, x, Float64(Float64(-4.0 * y) * Float64(Float64(z_m * z_m) - t))); else tmp = Float64(x * x); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[x, 7.2e+170], N[(x * x + N[(N[(-4.0 * y), $MachinePrecision] * N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.2 \cdot 10^{+170}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(-4 \cdot y\right) \cdot \left(z\_m \cdot z\_m - t\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 7.1999999999999999e170Initial program 92.2%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6493.7
Applied rewrites93.7%
if 7.1999999999999999e170 < x Initial program 80.8%
Taylor expanded in x around inf
pow2N/A
lift-*.f6492.7
Applied rewrites92.7%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(if (<= z_m 5.6e-27)
(fma x x (* (* t y) 4.0))
(if (<= z_m 1.48e+156)
(fma (* (* z_m z_m) y) -4.0 (* x x))
(* (* z_m (* z_m y)) -4.0))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 5.6e-27) {
tmp = fma(x, x, ((t * y) * 4.0));
} else if (z_m <= 1.48e+156) {
tmp = fma(((z_m * z_m) * y), -4.0, (x * x));
} else {
tmp = (z_m * (z_m * y)) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 5.6e-27) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); elseif (z_m <= 1.48e+156) tmp = fma(Float64(Float64(z_m * z_m) * y), -4.0, Float64(x * x)); else tmp = Float64(Float64(z_m * Float64(z_m * y)) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 5.6e-27], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z$95$m, 1.48e+156], N[(N[(N[(z$95$m * z$95$m), $MachinePrecision] * y), $MachinePrecision] * -4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(z$95$m * N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5.6 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{elif}\;z\_m \leq 1.48 \cdot 10^{+156}:\\
\;\;\;\;\mathsf{fma}\left(\left(z\_m \cdot z\_m\right) \cdot y, -4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z\_m \cdot \left(z\_m \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 5.5999999999999999e-27Initial program 98.6%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6499.2
Applied rewrites99.2%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6495.6
Applied rewrites95.6%
if 5.5999999999999999e-27 < z < 1.4799999999999999e156Initial program 95.7%
Taylor expanded in t around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6480.3
Applied rewrites80.3%
if 1.4799999999999999e156 < z Initial program 70.9%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6477.3
Applied rewrites77.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6489.2
Applied rewrites89.2%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 5.4e+81) (fma x x (* (* t y) 4.0)) (* (* z_m (* z_m y)) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 5.4e+81) {
tmp = fma(x, x, ((t * y) * 4.0));
} else {
tmp = (z_m * (z_m * y)) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 5.4e+81) tmp = fma(x, x, Float64(Float64(t * y) * 4.0)); else tmp = Float64(Float64(z_m * Float64(z_m * y)) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 5.4e+81], N[(x * x + N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision], N[(N[(z$95$m * N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5.4 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(t \cdot y\right) \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z\_m \cdot \left(z\_m \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 5.3999999999999999e81Initial program 98.3%
lift-*.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift--.f64N/A
pow2N/A
*-commutativeN/A
pow2N/A
associate-*r*N/A
fp-cancel-sub-sign-invN/A
pow2N/A
metadata-evalN/A
lower-fma.f64N/A
associate-*r*N/A
pow2N/A
lower-*.f64N/A
lower-*.f64N/A
lift--.f64N/A
lift-*.f6498.9
Applied rewrites98.9%
Taylor expanded in z around 0
*-commutativeN/A
lower-*.f64N/A
lower-*.f6488.0
Applied rewrites88.0%
if 5.3999999999999999e81 < z Initial program 78.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6473.3
Applied rewrites73.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6481.5
Applied rewrites81.5%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= z_m 5.4e+81) (fma (* t y) 4.0 (* x x)) (* (* z_m (* z_m y)) -4.0)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 5.4e+81) {
tmp = fma((t * y), 4.0, (x * x));
} else {
tmp = (z_m * (z_m * y)) * -4.0;
}
return tmp;
}
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (z_m <= 5.4e+81) tmp = fma(Float64(t * y), 4.0, Float64(x * x)); else tmp = Float64(Float64(z_m * Float64(z_m * y)) * -4.0); end return tmp end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[z$95$m, 5.4e+81], N[(N[(t * y), $MachinePrecision] * 4.0 + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(z$95$m * N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;z\_m \leq 5.4 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot y, 4, x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z\_m \cdot \left(z\_m \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if z < 5.3999999999999999e81Initial program 98.3%
Taylor expanded in z around 0
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6487.5
Applied rewrites87.5%
if 5.3999999999999999e81 < z Initial program 78.2%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6473.3
Applied rewrites73.3%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6481.5
Applied rewrites81.5%
z_m = (fabs.f64 z)
(FPCore (x y z_m t)
:precision binary64
(let* ((t_1 (- (* z_m z_m) t)))
(if (<= t_1 -2e+55)
(* (* t y) 4.0)
(if (<= t_1 2e+185) (* x x) (* (* z_m (* z_m y)) -4.0)))))z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double t_1 = (z_m * z_m) - t;
double tmp;
if (t_1 <= -2e+55) {
tmp = (t * y) * 4.0;
} else if (t_1 <= 2e+185) {
tmp = x * x;
} else {
tmp = (z_m * (z_m * y)) * -4.0;
}
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 = (z_m * z_m) - t
if (t_1 <= (-2d+55)) then
tmp = (t * y) * 4.0d0
else if (t_1 <= 2d+185) then
tmp = x * x
else
tmp = (z_m * (z_m * y)) * (-4.0d0)
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 = (z_m * z_m) - t;
double tmp;
if (t_1 <= -2e+55) {
tmp = (t * y) * 4.0;
} else if (t_1 <= 2e+185) {
tmp = x * x;
} else {
tmp = (z_m * (z_m * y)) * -4.0;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): t_1 = (z_m * z_m) - t tmp = 0 if t_1 <= -2e+55: tmp = (t * y) * 4.0 elif t_1 <= 2e+185: tmp = x * x else: tmp = (z_m * (z_m * y)) * -4.0 return tmp
z_m = abs(z) function code(x, y, z_m, t) t_1 = Float64(Float64(z_m * z_m) - t) tmp = 0.0 if (t_1 <= -2e+55) tmp = Float64(Float64(t * y) * 4.0); elseif (t_1 <= 2e+185) tmp = Float64(x * x); else tmp = Float64(Float64(z_m * Float64(z_m * y)) * -4.0); end return tmp end
z_m = abs(z); function tmp_2 = code(x, y, z_m, t) t_1 = (z_m * z_m) - t; tmp = 0.0; if (t_1 <= -2e+55) tmp = (t * y) * 4.0; elseif (t_1 <= 2e+185) tmp = x * x; else tmp = (z_m * (z_m * y)) * -4.0; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision]
code[x_, y_, z$95$m_, t_] := Block[{t$95$1 = N[(N[(z$95$m * z$95$m), $MachinePrecision] - t), $MachinePrecision]}, If[LessEqual[t$95$1, -2e+55], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], If[LessEqual[t$95$1, 2e+185], N[(x * x), $MachinePrecision], N[(N[(z$95$m * N[(z$95$m * y), $MachinePrecision]), $MachinePrecision] * -4.0), $MachinePrecision]]]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
t_1 := z\_m \cdot z\_m - t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+55}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+185}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(z\_m \cdot \left(z\_m \cdot y\right)\right) \cdot -4\\
\end{array}
\end{array}
if (-.f64 (*.f64 z z) t) < -2.00000000000000002e55Initial program 96.6%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6465.9
Applied rewrites65.9%
if -2.00000000000000002e55 < (-.f64 (*.f64 z z) t) < 2e185Initial program 99.1%
Taylor expanded in x around inf
pow2N/A
lift-*.f6456.0
Applied rewrites56.0%
if 2e185 < (-.f64 (*.f64 z z) t) Initial program 80.0%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6463.9
Applied rewrites63.9%
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6471.3
Applied rewrites71.3%
z_m = (fabs.f64 z) (FPCore (x y z_m t) :precision binary64 (if (<= (* x x) 6.5e-85) (* (* t y) 4.0) (* x x)))
z_m = fabs(z);
double code(double x, double y, double z_m, double t) {
double tmp;
if ((x * x) <= 6.5e-85) {
tmp = (t * y) * 4.0;
} 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 * x) <= 6.5d-85) then
tmp = (t * y) * 4.0d0
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 * x) <= 6.5e-85) {
tmp = (t * y) * 4.0;
} else {
tmp = x * x;
}
return tmp;
}
z_m = math.fabs(z) def code(x, y, z_m, t): tmp = 0 if (x * x) <= 6.5e-85: tmp = (t * y) * 4.0 else: tmp = x * x return tmp
z_m = abs(z) function code(x, y, z_m, t) tmp = 0.0 if (Float64(x * x) <= 6.5e-85) tmp = Float64(Float64(t * y) * 4.0); 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 * x) <= 6.5e-85) tmp = (t * y) * 4.0; else tmp = x * x; end tmp_2 = tmp; end
z_m = N[Abs[z], $MachinePrecision] code[x_, y_, z$95$m_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 6.5e-85], N[(N[(t * y), $MachinePrecision] * 4.0), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
z_m = \left|z\right|
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 6.5 \cdot 10^{-85}:\\
\;\;\;\;\left(t \cdot y\right) \cdot 4\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 6.5e-85Initial program 94.4%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
lower-*.f6449.5
Applied rewrites49.5%
if 6.5e-85 < (*.f64 x x) Initial program 88.2%
Taylor expanded in x around inf
pow2N/A
lift-*.f6465.2
Applied rewrites65.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 90.9%
Taylor expanded in x around inf
pow2N/A
lift-*.f6441.3
Applied rewrites41.3%
herbie shell --seed 2025114
(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))))