| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 1360 |
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (/ x z))))
(if (<= (/ y z) -5e+149)
t_1
(if (<= (/ y z) -1e-303)
(* x (/ y z))
(if (<= (/ y z) 2e-188)
t_1
(if (<= (/ y z) 1e+169) (/ x (/ z y)) (/ y (/ z x))))))))double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
double code(double x, double y, double z, double t) {
double t_1 = y * (x / z);
double tmp;
if ((y / z) <= -5e+149) {
tmp = t_1;
} else if ((y / z) <= -1e-303) {
tmp = x * (y / z);
} else if ((y / z) <= 2e-188) {
tmp = t_1;
} else if ((y / z) <= 1e+169) {
tmp = x / (z / y);
} else {
tmp = y / (z / 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
code = x * (((y / z) * t) / t)
end function
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) :: tmp
t_1 = y * (x / z)
if ((y / z) <= (-5d+149)) then
tmp = t_1
else if ((y / z) <= (-1d-303)) then
tmp = x * (y / z)
else if ((y / z) <= 2d-188) then
tmp = t_1
else if ((y / z) <= 1d+169) then
tmp = x / (z / y)
else
tmp = y / (z / x)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
public static double code(double x, double y, double z, double t) {
double t_1 = y * (x / z);
double tmp;
if ((y / z) <= -5e+149) {
tmp = t_1;
} else if ((y / z) <= -1e-303) {
tmp = x * (y / z);
} else if ((y / z) <= 2e-188) {
tmp = t_1;
} else if ((y / z) <= 1e+169) {
tmp = x / (z / y);
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
def code(x, y, z, t): t_1 = y * (x / z) tmp = 0 if (y / z) <= -5e+149: tmp = t_1 elif (y / z) <= -1e-303: tmp = x * (y / z) elif (y / z) <= 2e-188: tmp = t_1 elif (y / z) <= 1e+169: tmp = x / (z / y) else: tmp = y / (z / x) return tmp
function code(x, y, z, t) return Float64(x * Float64(Float64(Float64(y / z) * t) / t)) end
function code(x, y, z, t) t_1 = Float64(y * Float64(x / z)) tmp = 0.0 if (Float64(y / z) <= -5e+149) tmp = t_1; elseif (Float64(y / z) <= -1e-303) tmp = Float64(x * Float64(y / z)); elseif (Float64(y / z) <= 2e-188) tmp = t_1; elseif (Float64(y / z) <= 1e+169) tmp = Float64(x / Float64(z / y)); else tmp = Float64(y / Float64(z / x)); end return tmp end
function tmp = code(x, y, z, t) tmp = x * (((y / z) * t) / t); end
function tmp_2 = code(x, y, z, t) t_1 = y * (x / z); tmp = 0.0; if ((y / z) <= -5e+149) tmp = t_1; elseif ((y / z) <= -1e-303) tmp = x * (y / z); elseif ((y / z) <= 2e-188) tmp = t_1; elseif ((y / z) <= 1e+169) tmp = x / (z / y); else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], -5e+149], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], -1e-303], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 2e-188], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], 1e+169], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := y \cdot \frac{x}{z}\\
\mathbf{if}\;\frac{y}{z} \leq -5 \cdot 10^{+149}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq -1 \cdot 10^{-303}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{-188}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq 10^{+169}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
Results
| Original | 14.5 |
|---|---|
| Target | 1.4 |
| Herbie | 0.6 |
if (/.f64 y z) < -4.9999999999999999e149 or -9.99999999999999931e-304 < (/.f64 y z) < 1.9999999999999999e-188Initial program 22.4
Simplified14.3
[Start]22.4 | \[ x \cdot \frac{\frac{y}{z} \cdot t}{t}
\] |
|---|---|
rational.json-simplify-2 [=>]22.4 | \[ x \cdot \frac{\color{blue}{t \cdot \frac{y}{z}}}{t}
\] |
rational.json-simplify-49 [=>]14.3 | \[ x \cdot \color{blue}{\left(\frac{y}{z} \cdot \frac{t}{t}\right)}
\] |
rational.json-simplify-2 [=>]14.3 | \[ x \cdot \color{blue}{\left(\frac{t}{t} \cdot \frac{y}{z}\right)}
\] |
rational.json-simplify-54 [=>]23.7 | \[ x \cdot \color{blue}{\frac{\frac{y}{t}}{\frac{z}{t}}}
\] |
rational.json-simplify-61 [=>]23.5 | \[ x \cdot \color{blue}{\frac{t}{\frac{z}{\frac{y}{t}}}}
\] |
rational.json-simplify-61 [=>]22.9 | \[ x \cdot \frac{t}{\color{blue}{\frac{t}{\frac{y}{z}}}}
\] |
rational.json-simplify-61 [=>]14.3 | \[ x \cdot \color{blue}{\frac{\frac{y}{z}}{\frac{t}{t}}}
\] |
rational.json-simplify-60 [=>]14.3 | \[ x \cdot \color{blue}{\frac{y}{z}}
\] |
Taylor expanded in x around 0 1.1
Simplified1.1
[Start]1.1 | \[ \frac{y \cdot x}{z}
\] |
|---|---|
rational.json-simplify-2 [<=]1.1 | \[ \frac{\color{blue}{x \cdot y}}{z}
\] |
rational.json-simplify-49 [=>]1.1 | \[ \color{blue}{y \cdot \frac{x}{z}}
\] |
if -4.9999999999999999e149 < (/.f64 y z) < -9.99999999999999931e-304Initial program 8.6
Simplified0.2
[Start]8.6 | \[ x \cdot \frac{\frac{y}{z} \cdot t}{t}
\] |
|---|---|
rational.json-simplify-2 [=>]8.6 | \[ x \cdot \frac{\color{blue}{t \cdot \frac{y}{z}}}{t}
\] |
rational.json-simplify-49 [=>]0.2 | \[ x \cdot \color{blue}{\left(\frac{y}{z} \cdot \frac{t}{t}\right)}
\] |
rational.json-simplify-2 [=>]0.2 | \[ x \cdot \color{blue}{\left(\frac{t}{t} \cdot \frac{y}{z}\right)}
\] |
rational.json-simplify-54 [=>]16.5 | \[ x \cdot \color{blue}{\frac{\frac{y}{t}}{\frac{z}{t}}}
\] |
rational.json-simplify-61 [=>]16.0 | \[ x \cdot \color{blue}{\frac{t}{\frac{z}{\frac{y}{t}}}}
\] |
rational.json-simplify-61 [=>]8.1 | \[ x \cdot \frac{t}{\color{blue}{\frac{t}{\frac{y}{z}}}}
\] |
rational.json-simplify-61 [=>]0.2 | \[ x \cdot \color{blue}{\frac{\frac{y}{z}}{\frac{t}{t}}}
\] |
rational.json-simplify-60 [=>]0.2 | \[ x \cdot \color{blue}{\frac{y}{z}}
\] |
if 1.9999999999999999e-188 < (/.f64 y z) < 9.99999999999999934e168Initial program 6.8
Simplified16.8
[Start]6.8 | \[ x \cdot \frac{\frac{y}{z} \cdot t}{t}
\] |
|---|---|
rational.json-simplify-2 [=>]6.8 | \[ x \cdot \frac{\color{blue}{t \cdot \frac{y}{z}}}{t}
\] |
rational.json-simplify-49 [=>]0.2 | \[ x \cdot \color{blue}{\left(\frac{y}{z} \cdot \frac{t}{t}\right)}
\] |
rational.json-simplify-49 [<=]6.8 | \[ x \cdot \color{blue}{\frac{t \cdot \frac{y}{z}}{t}}
\] |
rational.json-simplify-2 [<=]6.8 | \[ x \cdot \frac{\color{blue}{\frac{y}{z} \cdot t}}{t}
\] |
rational.json-simplify-49 [=>]7.2 | \[ x \cdot \color{blue}{\left(t \cdot \frac{\frac{y}{z}}{t}\right)}
\] |
rational.json-simplify-47 [=>]16.8 | \[ x \cdot \left(t \cdot \color{blue}{\frac{y}{z \cdot t}}\right)
\] |
Taylor expanded in x around 0 9.9
Simplified0.2
[Start]9.9 | \[ \frac{y \cdot x}{z}
\] |
|---|---|
rational.json-simplify-7 [<=]9.9 | \[ \frac{y \cdot x}{\color{blue}{\frac{z}{1}}}
\] |
rational.json-simplify-61 [<=]10.1 | \[ \color{blue}{\frac{1}{\frac{z}{y \cdot x}}}
\] |
rational.json-simplify-47 [<=]0.6 | \[ \frac{1}{\color{blue}{\frac{\frac{z}{y}}{x}}}
\] |
rational.json-simplify-61 [=>]0.2 | \[ \color{blue}{\frac{x}{\frac{\frac{z}{y}}{1}}}
\] |
rational.json-simplify-7 [=>]0.2 | \[ \frac{x}{\color{blue}{\frac{z}{y}}}
\] |
if 9.99999999999999934e168 < (/.f64 y z) Initial program 36.5
Simplified20.9
[Start]36.5 | \[ x \cdot \frac{\frac{y}{z} \cdot t}{t}
\] |
|---|---|
rational.json-simplify-2 [=>]36.5 | \[ x \cdot \frac{\color{blue}{t \cdot \frac{y}{z}}}{t}
\] |
rational.json-simplify-49 [=>]20.9 | \[ x \cdot \color{blue}{\left(\frac{y}{z} \cdot \frac{t}{t}\right)}
\] |
rational.json-simplify-2 [=>]20.9 | \[ x \cdot \color{blue}{\left(\frac{t}{t} \cdot \frac{y}{z}\right)}
\] |
rational.json-simplify-54 [=>]36.2 | \[ x \cdot \color{blue}{\frac{\frac{y}{t}}{\frac{z}{t}}}
\] |
rational.json-simplify-61 [=>]38.2 | \[ x \cdot \color{blue}{\frac{t}{\frac{z}{\frac{y}{t}}}}
\] |
rational.json-simplify-61 [=>]36.8 | \[ x \cdot \frac{t}{\color{blue}{\frac{t}{\frac{y}{z}}}}
\] |
rational.json-simplify-61 [=>]20.9 | \[ x \cdot \color{blue}{\frac{\frac{y}{z}}{\frac{t}{t}}}
\] |
rational.json-simplify-60 [=>]20.9 | \[ x \cdot \color{blue}{\frac{y}{z}}
\] |
Applied egg-rr2.0
Final simplification0.6
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 1360 |
| Alternative 2 | |
|---|---|
| Error | 0.6 |
| Cost | 1360 |
| Alternative 3 | |
|---|---|
| Error | 6.2 |
| Cost | 320 |
herbie shell --seed 2023068
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
:precision binary64
:herbie-target
(if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))
(* x (/ (* (/ y z) t) t)))