
(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 10 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 (fma x x (* (- (* z z) t) (* y -4.0))))
double code(double x, double y, double z, double t) {
return fma(x, x, (((z * z) - t) * (y * -4.0)));
}
function code(x, y, z, t) return fma(x, x, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0))) end
code[x_, y_, z_, t_] := N[(x * x + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)
\end{array}
Initial program 93.8%
fma-neg96.2%
distribute-lft-neg-in96.2%
*-commutative96.2%
distribute-rgt-neg-in96.2%
metadata-eval96.2%
Simplified96.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ (* x x) (* (* y 4.0) (- t (* z z)))))) (if (<= t_1 INFINITY) t_1 (fma x x (* 4.0 (* t y))))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) + ((y * 4.0) * (t - (z * z)));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = fma(x, x, (4.0 * (t * y)));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = fma(x, x, Float64(4.0 * Float64(t * y))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(x * x + N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 4 \cdot \left(t \cdot y\right)\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < +inf.0Initial program 97.6%
if +inf.0 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) Initial program 0.0%
Taylor expanded in z around 0 40.0%
*-commutative40.0%
*-commutative40.0%
associate-*l*40.0%
Simplified40.0%
fma-neg60.0%
*-commutative60.0%
distribute-lft-neg-in60.0%
*-commutative60.0%
distribute-lft-neg-in60.0%
metadata-eval60.0%
associate-*r*60.0%
Applied egg-rr60.0%
Final simplification96.2%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ (* x x) (* (* y 4.0) (- t (* z z)))))) (if (<= t_1 INFINITY) t_1 (* (* z z) (* y -4.0)))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) + ((y * 4.0) * (t - (z * z)));
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = t_1;
} else {
tmp = (z * z) * (y * -4.0);
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (x * x) + ((y * 4.0) * (t - (z * z)));
double tmp;
if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = t_1;
} else {
tmp = (z * z) * (y * -4.0);
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * x) + ((y * 4.0) * (t - (z * z))) tmp = 0 if t_1 <= math.inf: tmp = t_1 else: tmp = (z * z) * (y * -4.0) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))) tmp = 0.0 if (t_1 <= Inf) tmp = t_1; else tmp = Float64(Float64(z * z) * Float64(y * -4.0)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * x) + ((y * 4.0) * (t - (z * z))); tmp = 0.0; if (t_1 <= Inf) tmp = t_1; else tmp = (z * z) * (y * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(N[(z * z), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) < +inf.0Initial program 97.6%
if +inf.0 < (-.f64 (*.f64 x x) (*.f64 (*.f64 y #s(literal 4 binary64)) (-.f64 (*.f64 z z) t))) Initial program 0.0%
fma-neg60.0%
distribute-lft-neg-in60.0%
*-commutative60.0%
distribute-rgt-neg-in60.0%
metadata-eval60.0%
Simplified60.0%
Taylor expanded in z around inf 40.1%
associate-*r*40.1%
*-commutative40.1%
Simplified40.1%
unpow240.1%
Applied egg-rr40.1%
Final simplification95.4%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+282) (+ (* x x) (* (* y 4.0) (- t (* z z)))) (+ (* x x) (* t (* 4.0 (- y (/ (* z (* z y)) t)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+282) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = (x * x) + (t * (4.0 * (y - ((z * (z * y)) / t))));
}
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) <= 2d+282) then
tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
else
tmp = (x * x) + (t * (4.0d0 * (y - ((z * (z * y)) / t))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+282) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = (x * x) + (t * (4.0 * (y - ((z * (z * y)) / t))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 2e+282: tmp = (x * x) + ((y * 4.0) * (t - (z * z))) else: tmp = (x * x) + (t * (4.0 * (y - ((z * (z * y)) / t)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+282) tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))); else tmp = Float64(Float64(x * x) + Float64(t * Float64(4.0 * Float64(y - Float64(Float64(z * Float64(z * y)) / t))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 2e+282) tmp = (x * x) + ((y * 4.0) * (t - (z * z))); else tmp = (x * x) + (t * (4.0 * (y - ((z * (z * y)) / t)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+282], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(t * N[(4.0 * N[(y - N[(N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+282}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + t \cdot \left(4 \cdot \left(y - \frac{z \cdot \left(z \cdot y\right)}{t}\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2.00000000000000007e282Initial program 98.3%
if 2.00000000000000007e282 < (*.f64 z z) Initial program 82.3%
Taylor expanded in t around inf 82.3%
+-commutative82.3%
*-commutative82.3%
*-commutative82.3%
metadata-eval82.3%
distribute-rgt-neg-in82.3%
distribute-lft-neg-in82.3%
distribute-rgt-out82.3%
unsub-neg82.3%
associate-/l*81.0%
Simplified81.0%
unpow281.0%
*-un-lft-identity81.0%
times-frac83.6%
Applied egg-rr83.6%
/-rgt-identity83.6%
associate-*r*87.7%
associate-*r/90.4%
*-commutative90.4%
Applied egg-rr90.4%
Final simplification96.1%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 5e+287) (+ (* x x) (* (* y 4.0) (- t (* z z)))) (+ (* x x) (* t (* 4.0 (- y (/ (* z y) (/ t z))))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+287) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = (x * x) + (t * (4.0 * (y - ((z * y) / (t / 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) <= 5d+287) then
tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
else
tmp = (x * x) + (t * (4.0d0 * (y - ((z * y) / (t / z)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+287) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = (x * x) + (t * (4.0 * (y - ((z * y) / (t / z)))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 5e+287: tmp = (x * x) + ((y * 4.0) * (t - (z * z))) else: tmp = (x * x) + (t * (4.0 * (y - ((z * y) / (t / z))))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e+287) tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))); else tmp = Float64(Float64(x * x) + Float64(t * Float64(4.0 * Float64(y - Float64(Float64(z * y) / Float64(t / z)))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 5e+287) tmp = (x * x) + ((y * 4.0) * (t - (z * z))); else tmp = (x * x) + (t * (4.0 * (y - ((z * y) / (t / z))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+287], N[(N[(x * x), $MachinePrecision] + N[(N[(y * 4.0), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] + N[(t * N[(4.0 * N[(y - N[(N[(z * y), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+287}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x + t \cdot \left(4 \cdot \left(y - \frac{z \cdot y}{\frac{t}{z}}\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 5e287Initial program 98.3%
if 5e287 < (*.f64 z z) Initial program 82.1%
Taylor expanded in t around inf 82.1%
+-commutative82.1%
*-commutative82.1%
*-commutative82.1%
metadata-eval82.1%
distribute-rgt-neg-in82.1%
distribute-lft-neg-in82.1%
distribute-rgt-out82.1%
unsub-neg82.1%
associate-/l*82.1%
Simplified82.1%
unpow282.1%
*-un-lft-identity82.1%
times-frac84.7%
Applied egg-rr84.7%
/-rgt-identity84.7%
associate-*r*87.5%
clear-num87.5%
un-div-inv90.0%
*-commutative90.0%
Applied egg-rr90.0%
Final simplification96.0%
(FPCore (x y z t)
:precision binary64
(if (<= z 3.1e-200)
(* y (* t 4.0))
(if (<= z 1.8e-57)
(* x x)
(if (<= z 3.5e+18) (* 4.0 (* t y)) (* (* z z) (* y -4.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.1e-200) {
tmp = y * (t * 4.0);
} else if (z <= 1.8e-57) {
tmp = x * x;
} else if (z <= 3.5e+18) {
tmp = 4.0 * (t * y);
} else {
tmp = (z * z) * (y * -4.0);
}
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 <= 3.1d-200) then
tmp = y * (t * 4.0d0)
else if (z <= 1.8d-57) then
tmp = x * x
else if (z <= 3.5d+18) then
tmp = 4.0d0 * (t * y)
else
tmp = (z * z) * (y * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.1e-200) {
tmp = y * (t * 4.0);
} else if (z <= 1.8e-57) {
tmp = x * x;
} else if (z <= 3.5e+18) {
tmp = 4.0 * (t * y);
} else {
tmp = (z * z) * (y * -4.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 3.1e-200: tmp = y * (t * 4.0) elif z <= 1.8e-57: tmp = x * x elif z <= 3.5e+18: tmp = 4.0 * (t * y) else: tmp = (z * z) * (y * -4.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 3.1e-200) tmp = Float64(y * Float64(t * 4.0)); elseif (z <= 1.8e-57) tmp = Float64(x * x); elseif (z <= 3.5e+18) tmp = Float64(4.0 * Float64(t * y)); else tmp = Float64(Float64(z * z) * Float64(y * -4.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 3.1e-200) tmp = y * (t * 4.0); elseif (z <= 1.8e-57) tmp = x * x; elseif (z <= 3.5e+18) tmp = 4.0 * (t * y); else tmp = (z * z) * (y * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 3.1e-200], N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.8e-57], N[(x * x), $MachinePrecision], If[LessEqual[z, 3.5e+18], N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision], N[(N[(z * z), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.1 \cdot 10^{-200}:\\
\;\;\;\;y \cdot \left(t \cdot 4\right)\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-57}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{+18}:\\
\;\;\;\;4 \cdot \left(t \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\
\end{array}
\end{array}
if z < 3.0999999999999999e-200Initial program 94.8%
Taylor expanded in y around inf 92.4%
Taylor expanded in t around inf 37.1%
if 3.0999999999999999e-200 < z < 1.8000000000000001e-57Initial program 100.0%
Taylor expanded in y around 0 100.0%
Simplified55.0%
--rgt-identity55.0%
Applied egg-rr55.0%
if 1.8000000000000001e-57 < z < 3.5e18Initial program 100.0%
fma-neg100.0%
distribute-lft-neg-in100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in t around inf 47.5%
*-commutative47.5%
Simplified47.5%
if 3.5e18 < z Initial program 86.5%
fma-neg88.2%
distribute-lft-neg-in88.2%
*-commutative88.2%
distribute-rgt-neg-in88.2%
metadata-eval88.2%
Simplified88.2%
Taylor expanded in z around inf 66.2%
associate-*r*66.2%
*-commutative66.2%
Simplified66.2%
unpow266.2%
Applied egg-rr66.2%
Final simplification46.3%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 5e+120) (- (* x x) (* y (* t -4.0))) (* (* z z) (* y -4.0))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+120) {
tmp = (x * x) - (y * (t * -4.0));
} else {
tmp = (z * z) * (y * -4.0);
}
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) <= 5d+120) then
tmp = (x * x) - (y * (t * (-4.0d0)))
else
tmp = (z * z) * (y * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 5e+120) {
tmp = (x * x) - (y * (t * -4.0));
} else {
tmp = (z * z) * (y * -4.0);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 5e+120: tmp = (x * x) - (y * (t * -4.0)) else: tmp = (z * z) * (y * -4.0) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 5e+120) tmp = Float64(Float64(x * x) - Float64(y * Float64(t * -4.0))); else tmp = Float64(Float64(z * z) * Float64(y * -4.0)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 5e+120) tmp = (x * x) - (y * (t * -4.0)); else tmp = (z * z) * (y * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+120], N[(N[(x * x), $MachinePrecision] - N[(y * N[(t * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * z), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+120}:\\
\;\;\;\;x \cdot x - y \cdot \left(t \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot z\right) \cdot \left(y \cdot -4\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 5.00000000000000019e120Initial program 99.3%
Taylor expanded in z around 0 90.9%
*-commutative90.9%
*-commutative90.9%
associate-*l*91.0%
Simplified91.0%
if 5.00000000000000019e120 < (*.f64 z z) Initial program 84.8%
fma-neg89.9%
distribute-lft-neg-in89.9%
*-commutative89.9%
distribute-rgt-neg-in89.9%
metadata-eval89.9%
Simplified89.9%
Taylor expanded in z around inf 81.5%
associate-*r*81.5%
*-commutative81.5%
Simplified81.5%
unpow281.5%
Applied egg-rr81.5%
Final simplification87.4%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 0.00295) (* y (* t 4.0)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 0.00295) {
tmp = y * (t * 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) <= 0.00295d0) then
tmp = y * (t * 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) <= 0.00295) {
tmp = y * (t * 4.0);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 0.00295: tmp = y * (t * 4.0) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 0.00295) tmp = Float64(y * Float64(t * 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) <= 0.00295) tmp = y * (t * 4.0); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.00295], N[(y * N[(t * 4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.00295:\\
\;\;\;\;y \cdot \left(t \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 0.00294999999999999993Initial program 96.8%
Taylor expanded in y around inf 96.8%
Taylor expanded in t around inf 49.4%
if 0.00294999999999999993 < (*.f64 x x) Initial program 91.2%
Taylor expanded in y around 0 91.2%
Simplified66.8%
--rgt-identity66.8%
Applied egg-rr66.8%
Final simplification58.6%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 0.001) (* 4.0 (* t y)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 0.001) {
tmp = 4.0 * (t * y);
} 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) <= 0.001d0) then
tmp = 4.0d0 * (t * y)
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) <= 0.001) {
tmp = 4.0 * (t * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 0.001: tmp = 4.0 * (t * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 0.001) tmp = Float64(4.0 * Float64(t * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 0.001) tmp = 4.0 * (t * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 0.001], N[(4.0 * N[(t * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 0.001:\\
\;\;\;\;4 \cdot \left(t \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 1e-3Initial program 96.8%
fma-neg96.8%
distribute-lft-neg-in96.8%
*-commutative96.8%
distribute-rgt-neg-in96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in t around inf 49.3%
*-commutative49.3%
Simplified49.3%
if 1e-3 < (*.f64 x x) Initial program 91.2%
Taylor expanded in y around 0 91.2%
Simplified66.8%
--rgt-identity66.8%
Applied egg-rr66.8%
Final simplification58.6%
(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 93.8%
Taylor expanded in y around 0 93.8%
Simplified41.8%
--rgt-identity41.8%
Applied egg-rr41.8%
(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 2024132
(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))))