
(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 9 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) 2e+259) (fma x x (* (- (* z z) t) (* y -4.0))) (- (* x x) (* z (* z (* y 4.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+259) {
tmp = fma(x, x, (((z * z) - t) * (y * -4.0)));
} else {
tmp = (x * x) - (z * (z * (y * 4.0)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+259) tmp = fma(x, x, Float64(Float64(Float64(z * z) - t) * Float64(y * -4.0))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0)))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+259], N[(x * x + N[(N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision] * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+259}:\\
\;\;\;\;\mathsf{fma}\left(x, x, \left(z \cdot z - t\right) \cdot \left(y \cdot -4\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2e259Initial program 98.8%
fma-neg99.9%
*-commutative99.9%
distribute-rgt-neg-in99.9%
distribute-rgt-neg-in99.9%
metadata-eval99.9%
Simplified99.9%
if 2e259 < (*.f64 z z) Initial program 78.6%
Taylor expanded in z around inf 78.6%
*-commutative78.6%
unpow278.6%
*-commutative78.6%
associate-*r*78.6%
associate-*l*94.7%
*-commutative94.7%
Simplified94.7%
Final simplification98.4%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+259) (+ (* x x) (* (* y 4.0) (- t (* z z)))) (- (* x x) (* z (* z (* y 4.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+259) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = (x * x) - (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) <= 2d+259) then
tmp = (x * x) + ((y * 4.0d0) * (t - (z * z)))
else
tmp = (x * x) - (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) <= 2e+259) {
tmp = (x * x) + ((y * 4.0) * (t - (z * z)));
} else {
tmp = (x * x) - (z * (z * (y * 4.0)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 2e+259: tmp = (x * x) + ((y * 4.0) * (t - (z * z))) else: tmp = (x * x) - (z * (z * (y * 4.0))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+259) tmp = Float64(Float64(x * x) + Float64(Float64(y * 4.0) * Float64(t - Float64(z * z)))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 2e+259) tmp = (x * x) + ((y * 4.0) * (t - (z * z))); else tmp = (x * x) - (z * (z * (y * 4.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+259], 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[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+259}:\\
\;\;\;\;x \cdot x + \left(y \cdot 4\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2e259Initial program 98.8%
if 2e259 < (*.f64 z z) Initial program 78.6%
Taylor expanded in z around inf 78.6%
*-commutative78.6%
unpow278.6%
*-commutative78.6%
associate-*r*78.6%
associate-*l*94.7%
*-commutative94.7%
Simplified94.7%
Final simplification97.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (* y 4.0))))
(if (<= z 1.6e-286)
t_1
(if (<= z 3e-252)
(* x x)
(if (<= z 5.6e-104)
t_1
(if (<= z 2.45e+104) (* x x) (* -4.0 (* (* z z) y))))))))
double code(double x, double y, double z, double t) {
double t_1 = t * (y * 4.0);
double tmp;
if (z <= 1.6e-286) {
tmp = t_1;
} else if (z <= 3e-252) {
tmp = x * x;
} else if (z <= 5.6e-104) {
tmp = t_1;
} else if (z <= 2.45e+104) {
tmp = x * x;
} else {
tmp = -4.0 * ((z * z) * y);
}
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 = t * (y * 4.0d0)
if (z <= 1.6d-286) then
tmp = t_1
else if (z <= 3d-252) then
tmp = x * x
else if (z <= 5.6d-104) then
tmp = t_1
else if (z <= 2.45d+104) then
tmp = x * x
else
tmp = (-4.0d0) * ((z * z) * y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = t * (y * 4.0);
double tmp;
if (z <= 1.6e-286) {
tmp = t_1;
} else if (z <= 3e-252) {
tmp = x * x;
} else if (z <= 5.6e-104) {
tmp = t_1;
} else if (z <= 2.45e+104) {
tmp = x * x;
} else {
tmp = -4.0 * ((z * z) * y);
}
return tmp;
}
def code(x, y, z, t): t_1 = t * (y * 4.0) tmp = 0 if z <= 1.6e-286: tmp = t_1 elif z <= 3e-252: tmp = x * x elif z <= 5.6e-104: tmp = t_1 elif z <= 2.45e+104: tmp = x * x else: tmp = -4.0 * ((z * z) * y) return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(y * 4.0)) tmp = 0.0 if (z <= 1.6e-286) tmp = t_1; elseif (z <= 3e-252) tmp = Float64(x * x); elseif (z <= 5.6e-104) tmp = t_1; elseif (z <= 2.45e+104) tmp = Float64(x * x); else tmp = Float64(-4.0 * Float64(Float64(z * z) * y)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * (y * 4.0); tmp = 0.0; if (z <= 1.6e-286) tmp = t_1; elseif (z <= 3e-252) tmp = x * x; elseif (z <= 5.6e-104) tmp = t_1; elseif (z <= 2.45e+104) tmp = x * x; else tmp = -4.0 * ((z * z) * y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 1.6e-286], t$95$1, If[LessEqual[z, 3e-252], N[(x * x), $MachinePrecision], If[LessEqual[z, 5.6e-104], t$95$1, If[LessEqual[z, 2.45e+104], N[(x * x), $MachinePrecision], N[(-4.0 * N[(N[(z * z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;z \leq 1.6 \cdot 10^{-286}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 3 \cdot 10^{-252}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{-104}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 2.45 \cdot 10^{+104}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(\left(z \cdot z\right) \cdot y\right)\\
\end{array}
\end{array}
if z < 1.60000000000000003e-286 or 2.99999999999999995e-252 < z < 5.6e-104Initial program 93.6%
Taylor expanded in t around inf 39.1%
associate-*r*39.1%
Simplified39.1%
if 1.60000000000000003e-286 < z < 2.99999999999999995e-252 or 5.6e-104 < z < 2.44999999999999993e104Initial program 100.0%
Taylor expanded in x around inf 59.7%
unpow259.7%
Simplified59.7%
if 2.44999999999999993e104 < z Initial program 81.2%
Taylor expanded in z around inf 81.3%
unpow281.3%
Simplified81.3%
Final simplification49.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* t (* y 4.0))))
(if (<= z 4.3e-284)
t_1
(if (<= z 9.2e-252)
(* x x)
(if (<= z 1.45e-103)
t_1
(if (<= z 4.1e+105) (* x x) (* -4.0 (* z (* z y)))))))))
double code(double x, double y, double z, double t) {
double t_1 = t * (y * 4.0);
double tmp;
if (z <= 4.3e-284) {
tmp = t_1;
} else if (z <= 9.2e-252) {
tmp = x * x;
} else if (z <= 1.45e-103) {
tmp = t_1;
} else if (z <= 4.1e+105) {
tmp = x * x;
} else {
tmp = -4.0 * (z * (z * y));
}
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 = t * (y * 4.0d0)
if (z <= 4.3d-284) then
tmp = t_1
else if (z <= 9.2d-252) then
tmp = x * x
else if (z <= 1.45d-103) then
tmp = t_1
else if (z <= 4.1d+105) then
tmp = x * x
else
tmp = (-4.0d0) * (z * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = t * (y * 4.0);
double tmp;
if (z <= 4.3e-284) {
tmp = t_1;
} else if (z <= 9.2e-252) {
tmp = x * x;
} else if (z <= 1.45e-103) {
tmp = t_1;
} else if (z <= 4.1e+105) {
tmp = x * x;
} else {
tmp = -4.0 * (z * (z * y));
}
return tmp;
}
def code(x, y, z, t): t_1 = t * (y * 4.0) tmp = 0 if z <= 4.3e-284: tmp = t_1 elif z <= 9.2e-252: tmp = x * x elif z <= 1.45e-103: tmp = t_1 elif z <= 4.1e+105: tmp = x * x else: tmp = -4.0 * (z * (z * y)) return tmp
function code(x, y, z, t) t_1 = Float64(t * Float64(y * 4.0)) tmp = 0.0 if (z <= 4.3e-284) tmp = t_1; elseif (z <= 9.2e-252) tmp = Float64(x * x); elseif (z <= 1.45e-103) tmp = t_1; elseif (z <= 4.1e+105) tmp = Float64(x * x); else tmp = Float64(-4.0 * Float64(z * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = t * (y * 4.0); tmp = 0.0; if (z <= 4.3e-284) tmp = t_1; elseif (z <= 9.2e-252) tmp = x * x; elseif (z <= 1.45e-103) tmp = t_1; elseif (z <= 4.1e+105) tmp = x * x; else tmp = -4.0 * (z * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(t * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 4.3e-284], t$95$1, If[LessEqual[z, 9.2e-252], N[(x * x), $MachinePrecision], If[LessEqual[z, 1.45e-103], t$95$1, If[LessEqual[z, 4.1e+105], N[(x * x), $MachinePrecision], N[(-4.0 * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := t \cdot \left(y \cdot 4\right)\\
\mathbf{if}\;z \leq 4.3 \cdot 10^{-284}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 9.2 \cdot 10^{-252}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{-103}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4.1 \cdot 10^{+105}:\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\
\end{array}
\end{array}
if z < 4.3000000000000003e-284 or 9.1999999999999991e-252 < z < 1.4499999999999999e-103Initial program 93.6%
Taylor expanded in t around inf 39.1%
associate-*r*39.1%
Simplified39.1%
if 4.3000000000000003e-284 < z < 9.1999999999999991e-252 or 1.4499999999999999e-103 < z < 4.1000000000000002e105Initial program 100.0%
Taylor expanded in x around inf 59.7%
unpow259.7%
Simplified59.7%
if 4.1000000000000002e105 < z Initial program 81.2%
Taylor expanded in z around inf 81.3%
unpow281.3%
*-commutative81.3%
associate-*l*88.0%
Simplified88.0%
Final simplification50.8%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 4e+129) (- (* x x) (* t (* y -4.0))) (- (* x x) (* z (* z (* y 4.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 4e+129) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = (x * x) - (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) <= 4d+129) then
tmp = (x * x) - (t * (y * (-4.0d0)))
else
tmp = (x * x) - (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) <= 4e+129) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = (x * x) - (z * (z * (y * 4.0)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 4e+129: tmp = (x * x) - (t * (y * -4.0)) else: tmp = (x * x) - (z * (z * (y * 4.0))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 4e+129) tmp = Float64(Float64(x * x) - Float64(t * Float64(y * -4.0))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(y * 4.0)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 4e+129) tmp = (x * x) - (t * (y * -4.0)); else tmp = (x * x) - (z * (z * (y * 4.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 4e+129], N[(N[(x * x), $MachinePrecision] - N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(y * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+129}:\\
\;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(y \cdot 4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 4e129Initial program 100.0%
Taylor expanded in z around 0 93.4%
associate-*r*93.4%
Simplified93.4%
if 4e129 < (*.f64 z z) Initial program 81.9%
Taylor expanded in z around inf 79.0%
*-commutative79.0%
unpow279.0%
*-commutative79.0%
associate-*r*79.0%
associate-*l*91.1%
*-commutative91.1%
Simplified91.1%
Final simplification92.5%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 3.5e+76) (* (- (* z z) t) (* y -4.0)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 3.5e+76) {
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.5d+76) 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.5e+76) {
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.5e+76: 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.5e+76) 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.5e+76) 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.5e+76], 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.5 \cdot 10^{+76}:\\
\;\;\;\;\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.5e76Initial program 93.4%
Taylor expanded in x around 0 84.4%
*-commutative84.4%
*-commutative84.4%
unpow284.4%
*-commutative84.4%
associate-*l*84.4%
Simplified84.4%
if 3.5e76 < (*.f64 x x) Initial program 92.1%
Taylor expanded in x around inf 77.4%
unpow277.4%
Simplified77.4%
Final simplification81.3%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+230) (- (* x x) (* t (* y -4.0))) (* -4.0 (* z (* z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+230) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = -4.0 * (z * (z * y));
}
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+230) then
tmp = (x * x) - (t * (y * (-4.0d0)))
else
tmp = (-4.0d0) * (z * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+230) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = -4.0 * (z * (z * y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 2e+230: tmp = (x * x) - (t * (y * -4.0)) else: tmp = -4.0 * (z * (z * y)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+230) tmp = Float64(Float64(x * x) - Float64(t * Float64(y * -4.0))); else tmp = Float64(-4.0 * Float64(z * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 2e+230) tmp = (x * x) - (t * (y * -4.0)); else tmp = -4.0 * (z * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+230], N[(N[(x * x), $MachinePrecision] - N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+230}:\\
\;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(z \cdot \left(z \cdot y\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2.0000000000000002e230Initial program 99.4%
Taylor expanded in z around 0 90.3%
associate-*r*90.3%
Simplified90.3%
if 2.0000000000000002e230 < (*.f64 z z) Initial program 79.0%
Taylor expanded in z around inf 81.4%
unpow281.4%
*-commutative81.4%
associate-*l*91.3%
Simplified91.3%
Final simplification90.6%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 3.5e+66) (* t (* y 4.0)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 3.5e+66) {
tmp = 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.5d+66) then
tmp = 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.5e+66) {
tmp = t * (y * 4.0);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 3.5e+66: tmp = t * (y * 4.0) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 3.5e+66) tmp = Float64(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.5e+66) tmp = 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.5e+66], N[(t * N[(y * 4.0), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 3.5 \cdot 10^{+66}:\\
\;\;\;\;t \cdot \left(y \cdot 4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 3.4999999999999997e66Initial program 93.4%
Taylor expanded in t around inf 48.7%
associate-*r*48.7%
Simplified48.7%
if 3.4999999999999997e66 < (*.f64 x x) Initial program 92.1%
Taylor expanded in x around inf 77.4%
unpow277.4%
Simplified77.4%
Final simplification61.5%
(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 92.8%
Taylor expanded in x around inf 41.8%
unpow241.8%
Simplified41.8%
Final simplification41.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 2023199
(FPCore (x y z t)
:name "Graphics.Rasterific.Shading:$sradialGradientWithFocusShader from Rasterific-0.6.1, B"
:precision binary64
:herbie-target
(- (* x x) (* 4.0 (* y (- (* z z) t))))
(- (* x x) (* (* y 4.0) (- (* z z) t))))