
(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 (if (<= (* x x) 2e+286) (+ (* x x) (* 4.0 (- (* y t) (* z (* z y))))) (fma x x (* y (* 4.0 t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 2e+286) {
tmp = (x * x) + (4.0 * ((y * t) - (z * (z * y))));
} else {
tmp = fma(x, x, (y * (4.0 * t)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 2e+286) tmp = Float64(Float64(x * x) + Float64(4.0 * Float64(Float64(y * t) - Float64(z * Float64(z * y))))); else tmp = fma(x, x, Float64(y * Float64(4.0 * t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+286], N[(N[(x * x), $MachinePrecision] + N[(4.0 * N[(N[(y * t), $MachinePrecision] - N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x + N[(y * N[(4.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+286}:\\
\;\;\;\;x \cdot x + 4 \cdot \left(y \cdot t - z \cdot \left(z \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, x, y \cdot \left(4 \cdot t\right)\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 2.00000000000000007e286Initial program 93.8%
sub-neg93.8%
distribute-rgt-in92.2%
Applied egg-rr92.2%
distribute-rgt-out93.8%
unsub-neg93.8%
add-sqr-sqrt39.5%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod35.8%
add-sqr-sqrt57.9%
distribute-rgt-out--55.7%
associate-*r*55.7%
associate-*r*55.7%
*-commutative55.7%
distribute-rgt-out--55.7%
*-commutative55.7%
associate-*l*61.8%
*-commutative61.8%
add-sqr-sqrt35.1%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-unprod42.5%
add-sqr-sqrt98.3%
Applied egg-rr98.3%
if 2.00000000000000007e286 < (*.f64 x x) Initial program 80.8%
sub-neg80.8%
distribute-rgt-in79.5%
Applied egg-rr79.5%
Taylor expanded in z around 0 87.7%
cancel-sign-sub-inv87.7%
metadata-eval87.7%
unpow287.7%
associate-*r*87.7%
*-commutative87.7%
associate-*r*87.7%
fma-def93.2%
Simplified93.2%
Final simplification96.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* -4.0 (* y (* z z)))) (t_2 (* t (* 4.0 y))))
(if (<= (* x x) 1.58e-164)
t_2
(if (<= (* x x) 1.65e-82)
t_1
(if (<= (* x x) 33000000.0)
t_2
(if (or (<= (* x x) 9.6e+50) (not (<= (* x x) 1.3e+132)))
(* x x)
t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = -4.0 * (y * (z * z));
double t_2 = t * (4.0 * y);
double tmp;
if ((x * x) <= 1.58e-164) {
tmp = t_2;
} else if ((x * x) <= 1.65e-82) {
tmp = t_1;
} else if ((x * x) <= 33000000.0) {
tmp = t_2;
} else if (((x * x) <= 9.6e+50) || !((x * x) <= 1.3e+132)) {
tmp = x * x;
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_1 = (-4.0d0) * (y * (z * z))
t_2 = t * (4.0d0 * y)
if ((x * x) <= 1.58d-164) then
tmp = t_2
else if ((x * x) <= 1.65d-82) then
tmp = t_1
else if ((x * x) <= 33000000.0d0) then
tmp = t_2
else if (((x * x) <= 9.6d+50) .or. (.not. ((x * x) <= 1.3d+132))) then
tmp = x * x
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -4.0 * (y * (z * z));
double t_2 = t * (4.0 * y);
double tmp;
if ((x * x) <= 1.58e-164) {
tmp = t_2;
} else if ((x * x) <= 1.65e-82) {
tmp = t_1;
} else if ((x * x) <= 33000000.0) {
tmp = t_2;
} else if (((x * x) <= 9.6e+50) || !((x * x) <= 1.3e+132)) {
tmp = x * x;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -4.0 * (y * (z * z)) t_2 = t * (4.0 * y) tmp = 0 if (x * x) <= 1.58e-164: tmp = t_2 elif (x * x) <= 1.65e-82: tmp = t_1 elif (x * x) <= 33000000.0: tmp = t_2 elif ((x * x) <= 9.6e+50) or not ((x * x) <= 1.3e+132): tmp = x * x else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(-4.0 * Float64(y * Float64(z * z))) t_2 = Float64(t * Float64(4.0 * y)) tmp = 0.0 if (Float64(x * x) <= 1.58e-164) tmp = t_2; elseif (Float64(x * x) <= 1.65e-82) tmp = t_1; elseif (Float64(x * x) <= 33000000.0) tmp = t_2; elseif ((Float64(x * x) <= 9.6e+50) || !(Float64(x * x) <= 1.3e+132)) tmp = Float64(x * x); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -4.0 * (y * (z * z)); t_2 = t * (4.0 * y); tmp = 0.0; if ((x * x) <= 1.58e-164) tmp = t_2; elseif ((x * x) <= 1.65e-82) tmp = t_1; elseif ((x * x) <= 33000000.0) tmp = t_2; elseif (((x * x) <= 9.6e+50) || ~(((x * x) <= 1.3e+132))) tmp = x * x; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-4.0 * N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 1.58e-164], t$95$2, If[LessEqual[N[(x * x), $MachinePrecision], 1.65e-82], t$95$1, If[LessEqual[N[(x * x), $MachinePrecision], 33000000.0], t$95$2, If[Or[LessEqual[N[(x * x), $MachinePrecision], 9.6e+50], N[Not[LessEqual[N[(x * x), $MachinePrecision], 1.3e+132]], $MachinePrecision]], N[(x * x), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := -4 \cdot \left(y \cdot \left(z \cdot z\right)\right)\\
t_2 := t \cdot \left(4 \cdot y\right)\\
\mathbf{if}\;x \cdot x \leq 1.58 \cdot 10^{-164}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 1.65 \cdot 10^{-82}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \cdot x \leq 33000000:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \cdot x \leq 9.6 \cdot 10^{+50} \lor \neg \left(x \cdot x \leq 1.3 \cdot 10^{+132}\right):\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (*.f64 x x) < 1.57999999999999998e-164 or 1.65000000000000011e-82 < (*.f64 x x) < 3.3e7Initial program 91.5%
Taylor expanded in t around inf 57.5%
associate-*r*57.6%
Simplified57.6%
if 1.57999999999999998e-164 < (*.f64 x x) < 1.65000000000000011e-82 or 9.6000000000000007e50 < (*.f64 x x) < 1.3e132Initial program 94.3%
Taylor expanded in z around inf 53.9%
unpow253.9%
Simplified53.9%
if 3.3e7 < (*.f64 x x) < 9.6000000000000007e50 or 1.3e132 < (*.f64 x x) Initial program 87.9%
Taylor expanded in x around inf 81.1%
unpow281.1%
Simplified81.1%
Final simplification68.5%
(FPCore (x y z t)
:precision binary64
(if (<= (* x x) 7.2e-163)
(* t (* 4.0 y))
(if (<= (* x x) 44000000.0)
(* z (* z (* y -4.0)))
(if (<= (* x x) 2.4e+56)
(* x x)
(if (<= (* x x) 3.35e+127) (* -4.0 (* y (* z z))) (* x x))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 7.2e-163) {
tmp = t * (4.0 * y);
} else if ((x * x) <= 44000000.0) {
tmp = z * (z * (y * -4.0));
} else if ((x * x) <= 2.4e+56) {
tmp = x * x;
} else if ((x * x) <= 3.35e+127) {
tmp = -4.0 * (y * (z * z));
} 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) <= 7.2d-163) then
tmp = t * (4.0d0 * y)
else if ((x * x) <= 44000000.0d0) then
tmp = z * (z * (y * (-4.0d0)))
else if ((x * x) <= 2.4d+56) then
tmp = x * x
else if ((x * x) <= 3.35d+127) then
tmp = (-4.0d0) * (y * (z * z))
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) <= 7.2e-163) {
tmp = t * (4.0 * y);
} else if ((x * x) <= 44000000.0) {
tmp = z * (z * (y * -4.0));
} else if ((x * x) <= 2.4e+56) {
tmp = x * x;
} else if ((x * x) <= 3.35e+127) {
tmp = -4.0 * (y * (z * z));
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 7.2e-163: tmp = t * (4.0 * y) elif (x * x) <= 44000000.0: tmp = z * (z * (y * -4.0)) elif (x * x) <= 2.4e+56: tmp = x * x elif (x * x) <= 3.35e+127: tmp = -4.0 * (y * (z * z)) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 7.2e-163) tmp = Float64(t * Float64(4.0 * y)); elseif (Float64(x * x) <= 44000000.0) tmp = Float64(z * Float64(z * Float64(y * -4.0))); elseif (Float64(x * x) <= 2.4e+56) tmp = Float64(x * x); elseif (Float64(x * x) <= 3.35e+127) tmp = Float64(-4.0 * Float64(y * Float64(z * z))); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 7.2e-163) tmp = t * (4.0 * y); elseif ((x * x) <= 44000000.0) tmp = z * (z * (y * -4.0)); elseif ((x * x) <= 2.4e+56) tmp = x * x; elseif ((x * x) <= 3.35e+127) tmp = -4.0 * (y * (z * z)); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 7.2e-163], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 44000000.0], N[(z * N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 2.4e+56], N[(x * x), $MachinePrecision], If[LessEqual[N[(x * x), $MachinePrecision], 3.35e+127], N[(-4.0 * N[(y * N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 7.2 \cdot 10^{-163}:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{elif}\;x \cdot x \leq 44000000:\\
\;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\
\mathbf{elif}\;x \cdot x \leq 2.4 \cdot 10^{+56}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;x \cdot x \leq 3.35 \cdot 10^{+127}:\\
\;\;\;\;-4 \cdot \left(y \cdot \left(z \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 7.1999999999999996e-163Initial program 94.5%
Taylor expanded in t around inf 60.6%
associate-*r*60.6%
Simplified60.6%
if 7.1999999999999996e-163 < (*.f64 x x) < 4.4e7Initial program 84.2%
Taylor expanded in z around inf 39.0%
metadata-eval39.0%
distribute-lft-neg-in39.0%
*-commutative39.0%
unpow239.0%
*-commutative39.0%
associate-*r*39.0%
associate-*l*54.7%
distribute-rgt-neg-in54.7%
distribute-rgt-neg-in54.7%
distribute-rgt-neg-in54.7%
metadata-eval54.7%
Simplified54.7%
if 4.4e7 < (*.f64 x x) < 2.40000000000000013e56 or 3.3499999999999998e127 < (*.f64 x x) Initial program 87.9%
Taylor expanded in x around inf 81.1%
unpow281.1%
Simplified81.1%
if 2.40000000000000013e56 < (*.f64 x x) < 3.3499999999999998e127Initial program 100.0%
Taylor expanded in z around inf 65.1%
unpow265.1%
Simplified65.1%
Final simplification69.9%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 5.5e+289) (+ (* x x) (* 4.0 (- (* y t) (* z (* z y))))) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 5.5e+289) {
tmp = (x * x) + (4.0 * ((y * t) - (z * (z * 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) <= 5.5d+289) then
tmp = (x * x) + (4.0d0 * ((y * t) - (z * (z * 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) <= 5.5e+289) {
tmp = (x * x) + (4.0 * ((y * t) - (z * (z * y))));
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 5.5e+289: tmp = (x * x) + (4.0 * ((y * t) - (z * (z * y)))) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 5.5e+289) tmp = Float64(Float64(x * x) + Float64(4.0 * Float64(Float64(y * t) - Float64(z * Float64(z * y))))); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 5.5e+289) tmp = (x * x) + (4.0 * ((y * t) - (z * (z * y)))); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 5.5e+289], N[(N[(x * x), $MachinePrecision] + N[(4.0 * N[(N[(y * t), $MachinePrecision] - N[(z * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5.5 \cdot 10^{+289}:\\
\;\;\;\;x \cdot x + 4 \cdot \left(y \cdot t - z \cdot \left(z \cdot y\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 5.4999999999999999e289Initial program 93.8%
sub-neg93.8%
distribute-rgt-in92.2%
Applied egg-rr92.2%
distribute-rgt-out93.8%
unsub-neg93.8%
add-sqr-sqrt39.5%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod35.8%
add-sqr-sqrt57.9%
distribute-rgt-out--55.7%
associate-*r*55.7%
associate-*r*55.7%
*-commutative55.7%
distribute-rgt-out--55.7%
*-commutative55.7%
associate-*l*61.8%
*-commutative61.8%
add-sqr-sqrt35.1%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-unprod42.5%
add-sqr-sqrt98.3%
Applied egg-rr98.3%
if 5.4999999999999999e289 < (*.f64 x x) Initial program 80.8%
Taylor expanded in x around inf 91.8%
unpow291.8%
Simplified91.8%
Final simplification96.4%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 1e+129) (+ (* x x) (* (* 4.0 y) (- t (* z z)))) (- (* x x) (* z (* z (* 4.0 y))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+129) {
tmp = (x * x) + ((4.0 * y) * (t - (z * z)));
} else {
tmp = (x * x) - (z * (z * (4.0 * 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) <= 1d+129) then
tmp = (x * x) + ((4.0d0 * y) * (t - (z * z)))
else
tmp = (x * x) - (z * (z * (4.0d0 * y)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 1e+129) {
tmp = (x * x) + ((4.0 * y) * (t - (z * z)));
} else {
tmp = (x * x) - (z * (z * (4.0 * y)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 1e+129: tmp = (x * x) + ((4.0 * y) * (t - (z * z))) else: tmp = (x * x) - (z * (z * (4.0 * y))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 1e+129) tmp = Float64(Float64(x * x) + Float64(Float64(4.0 * y) * Float64(t - Float64(z * z)))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(4.0 * y)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 1e+129) tmp = (x * x) + ((4.0 * y) * (t - (z * z))); else tmp = (x * x) - (z * (z * (4.0 * y))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+129], N[(N[(x * x), $MachinePrecision] + N[(N[(4.0 * y), $MachinePrecision] * N[(t - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+129}:\\
\;\;\;\;x \cdot x + \left(4 \cdot y\right) \cdot \left(t - z \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(4 \cdot y\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1e129Initial program 98.0%
if 1e129 < (*.f64 z z) Initial program 78.3%
Taylor expanded in z around inf 78.4%
unpow278.4%
associate-*r*78.4%
*-commutative78.4%
associate-*r*91.2%
*-commutative91.2%
Simplified91.2%
Final simplification95.3%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 2e+110) (- (* x x) (* t (* y -4.0))) (- (* x x) (* z (* z (* 4.0 y))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 2e+110) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = (x * x) - (z * (z * (4.0 * 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+110) then
tmp = (x * x) - (t * (y * (-4.0d0)))
else
tmp = (x * x) - (z * (z * (4.0d0 * 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+110) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = (x * x) - (z * (z * (4.0 * y)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 2e+110: tmp = (x * x) - (t * (y * -4.0)) else: tmp = (x * x) - (z * (z * (4.0 * y))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 2e+110) tmp = Float64(Float64(x * x) - Float64(t * Float64(y * -4.0))); else tmp = Float64(Float64(x * x) - Float64(z * Float64(z * Float64(4.0 * y)))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z * z) <= 2e+110) tmp = (x * x) - (t * (y * -4.0)); else tmp = (x * x) - (z * (z * (4.0 * y))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+110], N[(N[(x * x), $MachinePrecision] - N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] - N[(z * N[(z * N[(4.0 * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+110}:\\
\;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x - z \cdot \left(z \cdot \left(4 \cdot y\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2e110Initial program 97.9%
Taylor expanded in z around 0 93.9%
*-commutative93.9%
*-commutative93.9%
associate-*l*93.9%
Simplified93.9%
if 2e110 < (*.f64 z z) Initial program 79.5%
Taylor expanded in z around inf 78.9%
unpow278.9%
associate-*r*78.9%
*-commutative78.9%
associate-*r*91.0%
*-commutative91.0%
Simplified91.0%
Final simplification92.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -3.05e+68) (not (<= x 5.6e+94))) (* x x) (* (* y -4.0) (- (* z z) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.05e+68) || !(x <= 5.6e+94)) {
tmp = x * x;
} else {
tmp = (y * -4.0) * ((z * z) - 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 ((x <= (-3.05d+68)) .or. (.not. (x <= 5.6d+94))) then
tmp = x * x
else
tmp = (y * (-4.0d0)) * ((z * z) - t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.05e+68) || !(x <= 5.6e+94)) {
tmp = x * x;
} else {
tmp = (y * -4.0) * ((z * z) - t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -3.05e+68) or not (x <= 5.6e+94): tmp = x * x else: tmp = (y * -4.0) * ((z * z) - t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -3.05e+68) || !(x <= 5.6e+94)) tmp = Float64(x * x); else tmp = Float64(Float64(y * -4.0) * Float64(Float64(z * z) - t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -3.05e+68) || ~((x <= 5.6e+94))) tmp = x * x; else tmp = (y * -4.0) * ((z * z) - t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -3.05e+68], N[Not[LessEqual[x, 5.6e+94]], $MachinePrecision]], N[(x * x), $MachinePrecision], N[(N[(y * -4.0), $MachinePrecision] * N[(N[(z * z), $MachinePrecision] - t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.05 \cdot 10^{+68} \lor \neg \left(x \leq 5.6 \cdot 10^{+94}\right):\\
\;\;\;\;x \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(y \cdot -4\right) \cdot \left(z \cdot z - t\right)\\
\end{array}
\end{array}
if x < -3.05e68 or 5.59999999999999997e94 < x Initial program 86.3%
Taylor expanded in x around inf 83.1%
unpow283.1%
Simplified83.1%
if -3.05e68 < x < 5.59999999999999997e94Initial program 92.9%
Taylor expanded in x around 0 81.0%
*-commutative81.0%
*-commutative81.0%
unpow281.0%
*-commutative81.0%
associate-*l*81.0%
Simplified81.0%
Final simplification81.9%
(FPCore (x y z t) :precision binary64 (if (<= (* z z) 4e+197) (- (* x x) (* t (* y -4.0))) (* z (* z (* y -4.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z * z) <= 4e+197) {
tmp = (x * x) - (t * (y * -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) <= 4d+197) then
tmp = (x * x) - (t * (y * (-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) <= 4e+197) {
tmp = (x * x) - (t * (y * -4.0));
} else {
tmp = z * (z * (y * -4.0));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z * z) <= 4e+197: tmp = (x * x) - (t * (y * -4.0)) else: tmp = z * (z * (y * -4.0)) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(z * z) <= 4e+197) tmp = Float64(Float64(x * x) - Float64(t * Float64(y * -4.0))); else tmp = 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+197) tmp = (x * x) - (t * (y * -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], 4e+197], N[(N[(x * x), $MachinePrecision] - N[(t * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(z * N[(y * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 4 \cdot 10^{+197}:\\
\;\;\;\;x \cdot x - t \cdot \left(y \cdot -4\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \left(y \cdot -4\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 3.9999999999999998e197Initial program 97.5%
Taylor expanded in z around 0 90.4%
*-commutative90.4%
*-commutative90.4%
associate-*l*90.4%
Simplified90.4%
if 3.9999999999999998e197 < (*.f64 z z) Initial program 76.6%
Taylor expanded in z around inf 74.6%
metadata-eval74.6%
distribute-lft-neg-in74.6%
*-commutative74.6%
unpow274.6%
*-commutative74.6%
associate-*r*74.6%
associate-*l*83.8%
distribute-rgt-neg-in83.8%
distribute-rgt-neg-in83.8%
distribute-rgt-neg-in83.8%
metadata-eval83.8%
Simplified83.8%
Final simplification88.1%
(FPCore (x y z t) :precision binary64 (if (<= (* x x) 44000000.0) (* t (* 4.0 y)) (* x x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x * x) <= 44000000.0) {
tmp = t * (4.0 * 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) <= 44000000.0d0) then
tmp = t * (4.0d0 * 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) <= 44000000.0) {
tmp = t * (4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x * x) <= 44000000.0: tmp = t * (4.0 * y) else: tmp = x * x return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(x * x) <= 44000000.0) tmp = Float64(t * Float64(4.0 * y)); else tmp = Float64(x * x); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x * x) <= 44000000.0) tmp = t * (4.0 * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(x * x), $MachinePrecision], 44000000.0], N[(t * N[(4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 44000000:\\
\;\;\;\;t \cdot \left(4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if (*.f64 x x) < 4.4e7Initial program 91.5%
Taylor expanded in t around inf 51.7%
associate-*r*51.7%
Simplified51.7%
if 4.4e7 < (*.f64 x x) Initial program 88.9%
Taylor expanded in x around inf 76.0%
unpow276.0%
Simplified76.0%
Final simplification64.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 90.1%
Taylor expanded in x around inf 45.3%
unpow245.3%
Simplified45.3%
Final simplification45.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)));
}
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 2023171
(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))))