| Alternative 1 | |
|---|---|
| Error | 35.9 |
| Cost | 192 |
\[x \cdot x
\]
(FPCore (x y z) :precision binary64 (- (* x x) (* (* y 4.0) z)))
(FPCore (x y z) :precision binary64 (if (<= x -8.825758568846344e+58) (* x x) (if (<= x 123168817.04912652) (* z (* -4.0 y)) (* x x))))
double code(double x, double y, double z) {
return (x * x) - ((y * 4.0) * z);
}
double code(double x, double y, double z) {
double tmp;
if (x <= -8.825758568846344e+58) {
tmp = x * x;
} else if (x <= 123168817.04912652) {
tmp = z * (-4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * x) - ((y * 4.0d0) * z)
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-8.825758568846344d+58)) then
tmp = x * x
else if (x <= 123168817.04912652d0) then
tmp = z * ((-4.0d0) * y)
else
tmp = x * x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (x * x) - ((y * 4.0) * z);
}
public static double code(double x, double y, double z) {
double tmp;
if (x <= -8.825758568846344e+58) {
tmp = x * x;
} else if (x <= 123168817.04912652) {
tmp = z * (-4.0 * y);
} else {
tmp = x * x;
}
return tmp;
}
def code(x, y, z): return (x * x) - ((y * 4.0) * z)
def code(x, y, z): tmp = 0 if x <= -8.825758568846344e+58: tmp = x * x elif x <= 123168817.04912652: tmp = z * (-4.0 * y) else: tmp = x * x return tmp
function code(x, y, z) return Float64(Float64(x * x) - Float64(Float64(y * 4.0) * z)) end
function code(x, y, z) tmp = 0.0 if (x <= -8.825758568846344e+58) tmp = Float64(x * x); elseif (x <= 123168817.04912652) tmp = Float64(z * Float64(-4.0 * y)); else tmp = Float64(x * x); end return tmp end
function tmp = code(x, y, z) tmp = (x * x) - ((y * 4.0) * z); end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -8.825758568846344e+58) tmp = x * x; elseif (x <= 123168817.04912652) tmp = z * (-4.0 * y); else tmp = x * x; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x * x), $MachinePrecision] - N[(N[(y * 4.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[x, -8.825758568846344e+58], N[(x * x), $MachinePrecision], If[LessEqual[x, 123168817.04912652], N[(z * N[(-4.0 * y), $MachinePrecision]), $MachinePrecision], N[(x * x), $MachinePrecision]]]
x \cdot x - \left(y \cdot 4\right) \cdot z
\begin{array}{l}
\mathbf{if}\;x \leq -8.825758568846344 \cdot 10^{+58}:\\
\;\;\;\;x \cdot x\\
\mathbf{elif}\;x \leq 123168817.04912652:\\
\;\;\;\;z \cdot \left(-4 \cdot y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
Results
if x < -8.82575856884634358e58 or 123168817.049126521 < x Initial program 0.0
Taylor expanded in x around inf 10.0
Simplified10.0
if -8.82575856884634358e58 < x < 123168817.049126521Initial program 0.0
Taylor expanded in x around 0 13.5
Simplified13.5
Final simplification12.6
| Alternative 1 | |
|---|---|
| Error | 35.9 |
| Cost | 192 |

herbie shell --seed 2022325
(FPCore (x y z)
:name "Graphics.Rasterific.QuadraticFormula:discriminant from Rasterific-0.6.1"
:precision binary64
(- (* x x) (* (* y 4.0) z)))