| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 712 |
\[\begin{array}{l}
t_0 := y \cdot \frac{z - x}{z}\\
\mathbf{if}\;y \leq -1:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z) :precision binary64 (+ y (* (- 1.0 y) (/ x z))))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
double code(double x, double y, double z) {
return y + ((1.0 - y) * (x / z));
}
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
code = y + ((1.0d0 - y) * (x / z))
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) {
return y + ((1.0 - y) * (x / z));
}
def code(x, y, z): return (x + (y * (z - x))) / z
def code(x, y, z): return y + ((1.0 - y) * (x / z))
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function code(x, y, z) return Float64(y + Float64(Float64(1.0 - y) * Float64(x / z))) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
function tmp = code(x, y, z) tmp = y + ((1.0 - y) * (x / z)); end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := N[(y + N[(N[(1.0 - y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x + y \cdot \left(z - x\right)}{z}
y + \left(1 - y\right) \cdot \frac{x}{z}
Results
| Original | 10.2 |
|---|---|
| Target | 0.0 |
| Herbie | 0.0 |
Initial program 10.2
Taylor expanded in x around inf 3.5
Simplified0.0
[Start]3.5 | \[ y + \frac{\left(1 + -1 \cdot y\right) \cdot x}{z}
\] |
|---|---|
rational.json-simplify-2 [=>]3.5 | \[ y + \frac{\color{blue}{x \cdot \left(1 + -1 \cdot y\right)}}{z}
\] |
rational.json-simplify-49 [=>]0.0 | \[ y + \color{blue}{\left(1 + -1 \cdot y\right) \cdot \frac{x}{z}}
\] |
rational.json-simplify-17 [=>]0.0 | \[ y + \color{blue}{\left(-1 \cdot y - -1\right)} \cdot \frac{x}{z}
\] |
rational.json-simplify-2 [=>]0.0 | \[ y + \left(\color{blue}{y \cdot -1} - -1\right) \cdot \frac{x}{z}
\] |
rational.json-simplify-9 [=>]0.0 | \[ y + \left(\color{blue}{\left(-y\right)} - -1\right) \cdot \frac{x}{z}
\] |
rational.json-simplify-12 [=>]0.0 | \[ y + \left(\color{blue}{\left(0 - y\right)} - -1\right) \cdot \frac{x}{z}
\] |
rational.json-simplify-42 [=>]0.0 | \[ y + \color{blue}{\left(\left(0 - -1\right) - y\right)} \cdot \frac{x}{z}
\] |
metadata-eval [=>]0.0 | \[ y + \left(\color{blue}{1} - y\right) \cdot \frac{x}{z}
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 712 |
| Alternative 2 | |
|---|---|
| Error | 0.7 |
| Cost | 712 |
| Alternative 3 | |
|---|---|
| Error | 20.6 |
| Cost | 456 |
| Alternative 4 | |
|---|---|
| Error | 9.0 |
| Cost | 320 |
| Alternative 5 | |
|---|---|
| Error | 31.1 |
| Cost | 64 |
herbie shell --seed 2023075
(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))