| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 712 |
\[\begin{array}{l}
t_0 := \left(1 - \frac{x}{z}\right) \cdot y\\
\mathbf{if}\;y \leq -3200:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;\frac{x}{z} + y\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z) :precision binary64 (let* ((t_0 (- y (/ x (/ z (+ y -1.0)))))) (if (<= z -1e+88) t_0 (if (<= z 1.8e-88) (+ y (/ (- x (* x y)) z)) t_0))))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
double code(double x, double y, double z) {
double t_0 = y - (x / (z / (y + -1.0)));
double tmp;
if (z <= -1e+88) {
tmp = t_0;
} else if (z <= 1.8e-88) {
tmp = y + ((x - (x * y)) / z);
} else {
tmp = t_0;
}
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 + (y * (z - x))) / 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) :: t_0
real(8) :: tmp
t_0 = y - (x / (z / (y + (-1.0d0))))
if (z <= (-1d+88)) then
tmp = t_0
else if (z <= 1.8d-88) then
tmp = y + ((x - (x * y)) / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
public static double code(double x, double y, double z) {
double t_0 = y - (x / (z / (y + -1.0)));
double tmp;
if (z <= -1e+88) {
tmp = t_0;
} else if (z <= 1.8e-88) {
tmp = y + ((x - (x * y)) / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): return (x + (y * (z - x))) / z
def code(x, y, z): t_0 = y - (x / (z / (y + -1.0))) tmp = 0 if z <= -1e+88: tmp = t_0 elif z <= 1.8e-88: tmp = y + ((x - (x * y)) / z) else: tmp = t_0 return tmp
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function code(x, y, z) t_0 = Float64(y - Float64(x / Float64(z / Float64(y + -1.0)))) tmp = 0.0 if (z <= -1e+88) tmp = t_0; elseif (z <= 1.8e-88) tmp = Float64(y + Float64(Float64(x - Float64(x * y)) / z)); else tmp = t_0; end return tmp end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
function tmp_2 = code(x, y, z) t_0 = y - (x / (z / (y + -1.0))); tmp = 0.0; if (z <= -1e+88) tmp = t_0; elseif (z <= 1.8e-88) tmp = y + ((x - (x * y)) / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(y - N[(x / N[(z / N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1e+88], t$95$0, If[LessEqual[z, 1.8e-88], N[(y + N[(N[(x - N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\frac{x + y \cdot \left(z - x\right)}{z}
\begin{array}{l}
t_0 := y - \frac{x}{\frac{z}{y + -1}}\\
\mathbf{if}\;z \leq -1 \cdot 10^{+88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-88}:\\
\;\;\;\;y + \frac{x - x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
Results
| Original | 10.5 |
|---|---|
| Target | 0.0 |
| Herbie | 0.5 |
if z < -9.99999999999999959e87 or 1.8e-88 < z Initial program 16.7
Taylor expanded in y around 0 0.0
Taylor expanded in z around -inf 5.6
Simplified0.3
if -9.99999999999999959e87 < z < 1.8e-88Initial program 1.3
Taylor expanded in y around 0 0.1
Taylor expanded in x around 0 8.7
Simplified0.8
Final simplification0.5
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 712 |
| Alternative 2 | |
|---|---|
| Error | 2.1 |
| Cost | 708 |
| Alternative 3 | |
|---|---|
| Error | 0.1 |
| Cost | 704 |
| Alternative 4 | |
|---|---|
| Error | 10.3 |
| Cost | 648 |
| Alternative 5 | |
|---|---|
| Error | 20.3 |
| Cost | 456 |
| Alternative 6 | |
|---|---|
| Error | 8.9 |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Error | 31.5 |
| Cost | 64 |
herbie shell --seed 2022325
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:herbie-target
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))