| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 840 |
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z) :precision binary64 (if (<= y -1.6e+61) (* (- 1.0 (/ x z)) y) (if (<= y 1.6e+16) (+ y (/ (+ x (* y (- x))) z)) (- y (* 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) {
double tmp;
if (y <= -1.6e+61) {
tmp = (1.0 - (x / z)) * y;
} else if (y <= 1.6e+16) {
tmp = y + ((x + (y * -x)) / z);
} else {
tmp = y - (y * (x / z));
}
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) :: tmp
if (y <= (-1.6d+61)) then
tmp = (1.0d0 - (x / z)) * y
else if (y <= 1.6d+16) then
tmp = y + ((x + (y * -x)) / z)
else
tmp = y - (y * (x / z))
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 tmp;
if (y <= -1.6e+61) {
tmp = (1.0 - (x / z)) * y;
} else if (y <= 1.6e+16) {
tmp = y + ((x + (y * -x)) / z);
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
def code(x, y, z): return (x + (y * (z - x))) / z
def code(x, y, z): tmp = 0 if y <= -1.6e+61: tmp = (1.0 - (x / z)) * y elif y <= 1.6e+16: tmp = y + ((x + (y * -x)) / z) else: tmp = y - (y * (x / z)) return tmp
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function code(x, y, z) tmp = 0.0 if (y <= -1.6e+61) tmp = Float64(Float64(1.0 - Float64(x / z)) * y); elseif (y <= 1.6e+16) tmp = Float64(y + Float64(Float64(x + Float64(y * Float64(-x))) / z)); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.6e+61) tmp = (1.0 - (x / z)) * y; elseif (y <= 1.6e+16) tmp = y + ((x + (y * -x)) / z); else tmp = y - (y * (x / z)); 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_] := If[LessEqual[y, -1.6e+61], N[(N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], If[LessEqual[y, 1.6e+16], N[(y + N[(N[(x + N[(y * (-x)), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x + y \cdot \left(z - x\right)}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -1.6 \cdot 10^{+61}:\\
\;\;\;\;\left(1 - \frac{x}{z}\right) \cdot y\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+16}:\\
\;\;\;\;y + \frac{x + y \cdot \left(-x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}
Results
| Original | 10.4 |
|---|---|
| Target | 0.0 |
| Herbie | 0.1 |
if y < -1.5999999999999999e61Initial program 28.8
Taylor expanded in x around inf 9.2
Simplified9.2
[Start]9.2 | \[ y + \frac{\left(1 + -1 \cdot y\right) \cdot x}{z}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]9.2 | \[ y + \frac{\color{blue}{x \cdot \left(1 + -1 \cdot y\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-37 [=>]9.2 | \[ y + \frac{\color{blue}{1 \cdot x + x \cdot \left(-1 \cdot y\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]9.2 | \[ y + \frac{\color{blue}{x \cdot 1} + x \cdot \left(-1 \cdot y\right)}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]9.2 | \[ y + \frac{\color{blue}{x} + x \cdot \left(-1 \cdot y\right)}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]9.2 | \[ y + \frac{x + x \cdot \color{blue}{\left(y \cdot -1\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [<=]9.2 | \[ y + \frac{x + \color{blue}{y \cdot \left(x \cdot -1\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]9.2 | \[ y + \frac{x + y \cdot \color{blue}{\left(-x\right)}}{z}
\] |
Taylor expanded in y around inf 0.1
Simplified0.1
[Start]0.1 | \[ y \cdot \left(1 + -1 \cdot \frac{x}{z}\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-37 [=>]0.1 | \[ \color{blue}{1 \cdot y + y \cdot \left(-1 \cdot \frac{x}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]0.1 | \[ \color{blue}{y \cdot 1} + y \cdot \left(-1 \cdot \frac{x}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]0.1 | \[ \color{blue}{y} + y \cdot \left(-1 \cdot \frac{x}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ y + y \cdot \color{blue}{\left(\frac{x}{z} \cdot -1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]0.1 | \[ y + y \cdot \color{blue}{\left(-\frac{x}{z}\right)}
\] |
Applied egg-rr0.1
if -1.5999999999999999e61 < y < 1.6e16Initial program 0.5
Taylor expanded in x around inf 0.1
Simplified0.1
[Start]0.1 | \[ y + \frac{\left(1 + -1 \cdot y\right) \cdot x}{z}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ y + \frac{\color{blue}{x \cdot \left(1 + -1 \cdot y\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-37 [=>]0.1 | \[ y + \frac{\color{blue}{1 \cdot x + x \cdot \left(-1 \cdot y\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]0.1 | \[ y + \frac{\color{blue}{x \cdot 1} + x \cdot \left(-1 \cdot y\right)}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]0.1 | \[ y + \frac{\color{blue}{x} + x \cdot \left(-1 \cdot y\right)}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ y + \frac{x + x \cdot \color{blue}{\left(y \cdot -1\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [<=]0.1 | \[ y + \frac{x + \color{blue}{y \cdot \left(x \cdot -1\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]0.1 | \[ y + \frac{x + y \cdot \color{blue}{\left(-x\right)}}{z}
\] |
if 1.6e16 < y Initial program 24.5
Taylor expanded in x around inf 8.0
Simplified8.0
[Start]8.0 | \[ y + \frac{\left(1 + -1 \cdot y\right) \cdot x}{z}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]8.0 | \[ y + \frac{\color{blue}{x \cdot \left(1 + -1 \cdot y\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-37 [=>]8.0 | \[ y + \frac{\color{blue}{1 \cdot x + x \cdot \left(-1 \cdot y\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]8.0 | \[ y + \frac{\color{blue}{x \cdot 1} + x \cdot \left(-1 \cdot y\right)}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]8.0 | \[ y + \frac{\color{blue}{x} + x \cdot \left(-1 \cdot y\right)}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]8.0 | \[ y + \frac{x + x \cdot \color{blue}{\left(y \cdot -1\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-7 [<=]8.0 | \[ y + \frac{x + \color{blue}{y \cdot \left(x \cdot -1\right)}}{z}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]8.0 | \[ y + \frac{x + y \cdot \color{blue}{\left(-x\right)}}{z}
\] |
Taylor expanded in y around inf 0.1
Simplified0.1
[Start]0.1 | \[ y \cdot \left(1 + -1 \cdot \frac{x}{z}\right)
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-37 [=>]0.1 | \[ \color{blue}{1 \cdot y + y \cdot \left(-1 \cdot \frac{x}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]0.1 | \[ \color{blue}{y \cdot 1} + y \cdot \left(-1 \cdot \frac{x}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]0.1 | \[ \color{blue}{y} + y \cdot \left(-1 \cdot \frac{x}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]0.1 | \[ y + y \cdot \color{blue}{\left(\frac{x}{z} \cdot -1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]0.1 | \[ y + y \cdot \color{blue}{\left(-\frac{x}{z}\right)}
\] |
Applied egg-rr0.1
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 840 |
| Alternative 2 | |
|---|---|
| Error | 1.4 |
| Cost | 712 |
| Alternative 3 | |
|---|---|
| Error | 1.4 |
| Cost | 712 |
| Alternative 4 | |
|---|---|
| Error | 0.0 |
| Cost | 704 |
| Alternative 5 | |
|---|---|
| Error | 20.3 |
| Cost | 456 |
| Alternative 6 | |
|---|---|
| Error | 9.0 |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Error | 31.5 |
| Cost | 64 |
herbie shell --seed 2023090
(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))