
(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));
}
real(8) function code(x, y, z, t)
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));
}
real(8) function code(x, y, z, t)
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}
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 1e+238) (- (* x x) (* (* y 4.0) (- (* z z) t))) (- (* x x) (* z (* 4.0 (* y z))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+238) {
tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
} else {
tmp = (x * x) - (z * (4.0 * (y * z)));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z * z) <= 1d+238) then
tmp = (x * x) - ((y * 4.0d0) * ((z * z) - t))
else
tmp = (x * x) - (z * (4.0d0 * (y * z)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+238) {
tmp = (x * x) - ((y * 4.0) * ((z * z) - t));
} else {
tmp = (x * x) - (z * (4.0 * (y * z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 1e+238: tmp = (x * x) - ((y * 4.0) * ((z * z) - t)) else: tmp = (x * x) - (z * (4.0 * (y * z))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 1e+238) tmp = Float64(Float64(x * x) - Float64(Float64(y * 4.0) * Float64(Float64(z * z) - t))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(4.0 * Float64(y * z)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 1e+238) tmp = (x * x) - ((y * 4.0) * ((z * z) - t)); else tmp = (x * x) - (z * (4.0 * (y * z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+238], N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(4.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+238}:\\
\;\;\;\;x \cdot x - \left(y \cdot 4\right) \cdot \left(z \cdot z - t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(4 \cdot \left(y \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1e238Initial program 98.3%
if 1e238 < (*.f64 z z) Initial program 74.9%
Taylor expanded in z around inf 0
Simplified0
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* z (* -4.0 (* y z)))))
(if (<= x 4.9e-188)
t_1
(if (<= x 6.4e-118) (* (* 4.0 y) t) (if (<= x 3.8e+79) t_1 (* x x))))))
double code(double x, double y, double z, double t) {
double t_1 = z * (-4.0 * (y * z));
double tmp;
if (x <= 4.9e-188) {
tmp = t_1;
} else if (x <= 6.4e-118) {
tmp = (4.0 * y) * t;
} else if (x <= 3.8e+79) {
tmp = t_1;
} else {
tmp = x * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = z * ((-4.0d0) * (y * z))
if (x <= 4.9d-188) then
tmp = t_1
else if (x <= 6.4d-118) then
tmp = (4.0d0 * y) * t
else if (x <= 3.8d+79) then
tmp = t_1
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = z * (-4.0 * (y * z));
double tmp;
if (x <= 4.9e-188) {
tmp = t_1;
} else if (x <= 6.4e-118) {
tmp = (4.0 * y) * t;
} else if (x <= 3.8e+79) {
tmp = t_1;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): t_1 = z * (-4.0 * (y * z)) tmp = 0 if x <= 4.9e-188: tmp = t_1 elif x <= 6.4e-118: tmp = (4.0 * y) * t elif x <= 3.8e+79: tmp = t_1 else: tmp = x * x return tmp
function code(x, y, z, t) t_1 = Float64(z * Float64(-4.0 * Float64(y * z))) tmp = 0.0 if (x <= 4.9e-188) tmp = t_1; elseif (x <= 6.4e-118) tmp = Float64(Float64(4.0 * y) * t); elseif (x <= 3.8e+79) tmp = t_1; else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = z * (-4.0 * (y * z)); tmp = 0.0; if (x <= 4.9e-188) tmp = t_1; elseif (x <= 6.4e-118) tmp = (4.0 * y) * t; elseif (x <= 3.8e+79) tmp = t_1; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(-4.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 4.9e-188], t$95$1, If[LessEqual[x, 6.4e-118], N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision], If[LessEqual[x, 3.8e+79], t$95$1, N[(x * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(-4 \cdot \left(y \cdot z\right)\right)\\
\mathbf{if}\;x \leq 4.9 \cdot 10^{-188}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.4 \cdot 10^{-118}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 4.90000000000000004e-188 or 6.40000000000000008e-118 < x < 3.8000000000000002e79Initial program 92.2%
Taylor expanded in z around inf 0
Simplified0
if 4.90000000000000004e-188 < x < 6.40000000000000008e-118Initial program 100.0%
Taylor expanded in t around inf 0
Simplified0
Applied egg-rr0
if 3.8000000000000002e79 < x Initial program 87.1%
Taylor expanded in x around inf 0
Simplified0
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 1.12e-16) (* (- (* z z) t) (* y -4.0)) (- (* x x) (* z (* 4.0 (* y z))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1.12e-16) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = (x * x) - (z * (4.0 * (y * z)));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x * x) <= 1.12d-16) then
tmp = ((z * z) - t) * (y * (-4.0d0))
else
tmp = (x * x) - (z * (4.0d0 * (y * z)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 1.12e-16) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = (x * x) - (z * (4.0 * (y * z)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 1.12e-16: tmp = ((z * z) - t) * (y * -4.0) else: tmp = (x * x) - (z * (4.0 * (y * z))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 1.12e-16) tmp = Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)); else tmp = Float64(Float64(x * x) - Float64(z * Float64(4.0 * Float64(y * z)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 1.12e-16) tmp = ((z * z) - t) * (y * -4.0); else tmp = (x * x) - (z * (4.0 * (y * z))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 1.12e-16], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(4.0 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 1.12 \cdot 10^{-16}:\\
\;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(4 \cdot \left(y \cdot z\right)\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.12e-16Initial program 95.8%
Taylor expanded in x around 0 0
Simplified0
if 1.12e-16 < (*.f64 x x) Initial program 87.8%
Taylor expanded in z around inf 0
Simplified0
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 3.6e+159) (* (- (* z z) t) (* y -4.0)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 3.6e+159) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = x * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x * x) <= 3.6d+159) then
tmp = ((z * z) - t) * (y * (-4.0d0))
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 3.6e+159) {
tmp = ((z * z) - t) * (y * -4.0);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 3.6e+159: tmp = ((z * z) - t) * (y * -4.0) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 3.6e+159) tmp = Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 3.6e+159) tmp = ((z * z) - t) * (y * -4.0); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 3.6e+159], N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 3.6 \cdot 10^{+159}:\\
\;\;\;\;\left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 3.60000000000000037e159Initial program 93.2%
Taylor expanded in x around 0 0
Simplified0
if 3.60000000000000037e159 < (*.f64 x x) Initial program 88.6%
Taylor expanded in x around inf 0
Simplified0
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 9e+30) (* 4.0 (* y t)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 9e+30) {
tmp = 4.0 * (y * t);
} else {
tmp = x * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x * x) <= 9d+30) then
tmp = 4.0d0 * (y * t)
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 9e+30) {
tmp = 4.0 * (y * t);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 9e+30: tmp = 4.0 * (y * t) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 9e+30) tmp = Float64(4.0 * Float64(y * t)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 9e+30) tmp = 4.0 * (y * t); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 9e+30], N[(4.0 * N[(y * t), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 9 \cdot 10^{+30}:\\
\;\;\;\;4 \cdot \left(y \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 8.9999999999999999e30Initial program 93.0%
Taylor expanded in t around inf 0
Simplified0
if 8.9999999999999999e30 < (*.f64 x x) Initial program 89.8%
Taylor expanded in x around inf 0
Simplified0
(FPCore (x y z t) :precision binary64 (if (<= x 1.5e+17) (* (* 4.0 y) t) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.5e+17) {
tmp = (4.0 * y) * t;
} else {
tmp = x * x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= 1.5d+17) then
tmp = (4.0d0 * y) * t
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= 1.5e+17) {
tmp = (4.0 * y) * t;
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 1.5e+17: tmp = (4.0 * y) * t else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 1.5e+17) tmp = Float64(Float64(4.0 * y) * t); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 1.5e+17) tmp = (4.0 * y) * t; else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 1.5e+17], N[(N[(4.0 * y), $MachinePrecision] * t), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.5 \cdot 10^{+17}:\\
\;\;\;\;\left(4 \cdot y\right) \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 1.5e17Initial program 92.9%
Taylor expanded in t around inf 0
Simplified0
Applied egg-rr0
if 1.5e17 < x Initial program 88.0%
Taylor expanded in x around inf 0
Simplified0
(FPCore (x y z t) :precision binary64 (* x x))
double code(double x, double y, double z, double t) {
return x * x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * x
end function
public static double code(double x, double y, double z, double t) {
return x * x;
}
def code(x, y, z, t): return x * x
function code(x, y, z, t) return Float64(x * x) end
function tmp = code(x, y, z, t) tmp = x * x; end
code[x_, y_, z_, t_] := N[(x * x), $MachinePrecision]
\begin{array}{l}
\\
x \cdot x
\end{array}
Initial program 91.3%
Taylor expanded in x around inf 0
Simplified0
(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)));
}
real(8) function code(x, y, z, t)
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 2024110
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
:alt
(- (* x x) (* 4.0 (* y (- (* z z) t))))
(- (* x x) (* (* y 4.0) (- (* z z) t))))