| Alternative 1 | |
|---|---|
| Error | 9.2 |
| Cost | 1300 |
(FPCore (x y z t a) :precision binary64 (- x (/ (- y z) (/ (+ (- t z) 1.0) a))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ t (- 1.0 z)))
(t_2 (- x (* (- y z) (/ a t_1))))
(t_3 (/ (- y z) (/ (+ (- t z) 1.0) a))))
(if (<= t_3 -1e+37)
t_2
(if (<= t_3 4e-150) (- x (/ 1.0 (/ t_1 (* (- y z) a)))) t_2))))double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = t + (1.0 - z);
double t_2 = x - ((y - z) * (a / t_1));
double t_3 = (y - z) / (((t - z) + 1.0) / a);
double tmp;
if (t_3 <= -1e+37) {
tmp = t_2;
} else if (t_3 <= 4e-150) {
tmp = x - (1.0 / (t_1 / ((y - z) * a)));
} else {
tmp = t_2;
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = x - ((y - z) / (((t - z) + 1.0d0) / a))
end function
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = t + (1.0d0 - z)
t_2 = x - ((y - z) * (a / t_1))
t_3 = (y - z) / (((t - z) + 1.0d0) / a)
if (t_3 <= (-1d+37)) then
tmp = t_2
else if (t_3 <= 4d-150) then
tmp = x - (1.0d0 / (t_1 / ((y - z) * a)))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
return x - ((y - z) / (((t - z) + 1.0) / a));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t + (1.0 - z);
double t_2 = x - ((y - z) * (a / t_1));
double t_3 = (y - z) / (((t - z) + 1.0) / a);
double tmp;
if (t_3 <= -1e+37) {
tmp = t_2;
} else if (t_3 <= 4e-150) {
tmp = x - (1.0 / (t_1 / ((y - z) * a)));
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t, a): return x - ((y - z) / (((t - z) + 1.0) / a))
def code(x, y, z, t, a): t_1 = t + (1.0 - z) t_2 = x - ((y - z) * (a / t_1)) t_3 = (y - z) / (((t - z) + 1.0) / a) tmp = 0 if t_3 <= -1e+37: tmp = t_2 elif t_3 <= 4e-150: tmp = x - (1.0 / (t_1 / ((y - z) * a))) else: tmp = t_2 return tmp
function code(x, y, z, t, a) return Float64(x - Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a))) end
function code(x, y, z, t, a) t_1 = Float64(t + Float64(1.0 - z)) t_2 = Float64(x - Float64(Float64(y - z) * Float64(a / t_1))) t_3 = Float64(Float64(y - z) / Float64(Float64(Float64(t - z) + 1.0) / a)) tmp = 0.0 if (t_3 <= -1e+37) tmp = t_2; elseif (t_3 <= 4e-150) tmp = Float64(x - Float64(1.0 / Float64(t_1 / Float64(Float64(y - z) * a)))); else tmp = t_2; end return tmp end
function tmp = code(x, y, z, t, a) tmp = x - ((y - z) / (((t - z) + 1.0) / a)); end
function tmp_2 = code(x, y, z, t, a) t_1 = t + (1.0 - z); t_2 = x - ((y - z) * (a / t_1)); t_3 = (y - z) / (((t - z) + 1.0) / a); tmp = 0.0; if (t_3 <= -1e+37) tmp = t_2; elseif (t_3 <= 4e-150) tmp = x - (1.0 / (t_1 / ((y - z) * a))); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(x - N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(t + N[(1.0 - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x - N[(N[(y - z), $MachinePrecision] * N[(a / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y - z), $MachinePrecision] / N[(N[(N[(t - z), $MachinePrecision] + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -1e+37], t$95$2, If[LessEqual[t$95$3, 4e-150], N[(x - N[(1.0 / N[(t$95$1 / N[(N[(y - z), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]
x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\begin{array}{l}
t_1 := t + \left(1 - z\right)\\
t_2 := x - \left(y - z\right) \cdot \frac{a}{t_1}\\
t_3 := \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}\\
\mathbf{if}\;t_3 \leq -1 \cdot 10^{+37}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_3 \leq 4 \cdot 10^{-150}:\\
\;\;\;\;x - \frac{1}{\frac{t_1}{\left(y - z\right) \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
Results
| Original | 2.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) 1) a)) < -9.99999999999999954e36 or 4.00000000000000003e-150 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) 1) a)) Initial program 0.2
Simplified0.1
[Start]0.2 | \[ x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\] |
|---|---|
rational.json-simplify-61 [=>]0.3 | \[ x - \color{blue}{\frac{a}{\frac{\left(t - z\right) + 1}{y - z}}}
\] |
rational.json-simplify-50 [=>]0.3 | \[ x - \frac{a}{\color{blue}{\frac{-\left(\left(t - z\right) + 1\right)}{z - y}}}
\] |
rational.json-simplify-50 [=>]0.3 | \[ x - \frac{a}{\color{blue}{\frac{-\left(-\left(\left(t - z\right) + 1\right)\right)}{y - z}}}
\] |
rational.json-simplify-10 [=>]0.3 | \[ x - \frac{a}{\frac{\color{blue}{\frac{-\left(\left(t - z\right) + 1\right)}{-1}}}{y - z}}
\] |
rational.json-simplify-47 [=>]0.3 | \[ x - \frac{a}{\color{blue}{\frac{-\left(\left(t - z\right) + 1\right)}{-1 \cdot \left(y - z\right)}}}
\] |
rational.json-simplify-61 [=>]0.2 | \[ x - \color{blue}{\frac{-1 \cdot \left(y - z\right)}{\frac{-\left(\left(t - z\right) + 1\right)}{a}}}
\] |
rational.json-simplify-49 [=>]0.2 | \[ x - \color{blue}{\left(y - z\right) \cdot \frac{-1}{\frac{-\left(\left(t - z\right) + 1\right)}{a}}}
\] |
rational.json-simplify-61 [<=]0.1 | \[ x - \left(y - z\right) \cdot \color{blue}{\frac{a}{\frac{-\left(\left(t - z\right) + 1\right)}{-1}}}
\] |
rational.json-simplify-8 [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\frac{\color{blue}{\left(\left(t - z\right) + 1\right) \cdot -1}}{-1}}
\] |
rational.json-simplify-2 [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\frac{\color{blue}{-1 \cdot \left(\left(t - z\right) + 1\right)}}{-1}}
\] |
rational.json-simplify-49 [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{\left(\left(t - z\right) + 1\right) \cdot \frac{-1}{-1}}}
\] |
metadata-eval [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\left(\left(t - z\right) + 1\right) \cdot \color{blue}{1}}
\] |
rational.json-simplify-46 [=>]0.1 | \[ x - \left(y - z\right) \cdot \color{blue}{\frac{\frac{a}{\left(t - z\right) + 1}}{1}}
\] |
rational.json-simplify-7 [=>]0.1 | \[ x - \left(y - z\right) \cdot \color{blue}{\frac{a}{\left(t - z\right) + 1}}
\] |
rational.json-simplify-1 [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{1 + \left(t - z\right)}}
\] |
rational.json-simplify-17 [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{\left(t - z\right) - -1}}
\] |
rational.json-simplify-42 [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{\left(t - -1\right) - z}}
\] |
rational.json-simplify-18 [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{\left(1 + t\right)} - z}
\] |
rational.json-simplify-48 [=>]0.1 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{t + \left(1 - z\right)}}
\] |
if -9.99999999999999954e36 < (/.f64 (-.f64 y z) (/.f64 (+.f64 (-.f64 t z) 1) a)) < 4.00000000000000003e-150Initial program 3.8
Simplified3.5
[Start]3.8 | \[ x - \frac{y - z}{\frac{\left(t - z\right) + 1}{a}}
\] |
|---|---|
rational.json-simplify-61 [=>]0.3 | \[ x - \color{blue}{\frac{a}{\frac{\left(t - z\right) + 1}{y - z}}}
\] |
rational.json-simplify-50 [=>]0.3 | \[ x - \frac{a}{\color{blue}{\frac{-\left(\left(t - z\right) + 1\right)}{z - y}}}
\] |
rational.json-simplify-50 [=>]0.3 | \[ x - \frac{a}{\color{blue}{\frac{-\left(-\left(\left(t - z\right) + 1\right)\right)}{y - z}}}
\] |
rational.json-simplify-10 [=>]0.3 | \[ x - \frac{a}{\frac{\color{blue}{\frac{-\left(\left(t - z\right) + 1\right)}{-1}}}{y - z}}
\] |
rational.json-simplify-47 [=>]0.3 | \[ x - \frac{a}{\color{blue}{\frac{-\left(\left(t - z\right) + 1\right)}{-1 \cdot \left(y - z\right)}}}
\] |
rational.json-simplify-61 [=>]3.8 | \[ x - \color{blue}{\frac{-1 \cdot \left(y - z\right)}{\frac{-\left(\left(t - z\right) + 1\right)}{a}}}
\] |
rational.json-simplify-49 [=>]3.8 | \[ x - \color{blue}{\left(y - z\right) \cdot \frac{-1}{\frac{-\left(\left(t - z\right) + 1\right)}{a}}}
\] |
rational.json-simplify-61 [<=]3.5 | \[ x - \left(y - z\right) \cdot \color{blue}{\frac{a}{\frac{-\left(\left(t - z\right) + 1\right)}{-1}}}
\] |
rational.json-simplify-8 [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\frac{\color{blue}{\left(\left(t - z\right) + 1\right) \cdot -1}}{-1}}
\] |
rational.json-simplify-2 [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\frac{\color{blue}{-1 \cdot \left(\left(t - z\right) + 1\right)}}{-1}}
\] |
rational.json-simplify-49 [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{\left(\left(t - z\right) + 1\right) \cdot \frac{-1}{-1}}}
\] |
metadata-eval [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\left(\left(t - z\right) + 1\right) \cdot \color{blue}{1}}
\] |
rational.json-simplify-46 [=>]3.5 | \[ x - \left(y - z\right) \cdot \color{blue}{\frac{\frac{a}{\left(t - z\right) + 1}}{1}}
\] |
rational.json-simplify-7 [=>]3.5 | \[ x - \left(y - z\right) \cdot \color{blue}{\frac{a}{\left(t - z\right) + 1}}
\] |
rational.json-simplify-1 [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{1 + \left(t - z\right)}}
\] |
rational.json-simplify-17 [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{\left(t - z\right) - -1}}
\] |
rational.json-simplify-42 [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{\left(t - -1\right) - z}}
\] |
rational.json-simplify-18 [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{\left(1 + t\right)} - z}
\] |
rational.json-simplify-48 [=>]3.5 | \[ x - \left(y - z\right) \cdot \frac{a}{\color{blue}{t + \left(1 - z\right)}}
\] |
Applied egg-rr0.3
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 9.2 |
| Cost | 1300 |
| Alternative 2 | |
|---|---|
| Error | 17.3 |
| Cost | 1240 |
| Alternative 3 | |
|---|---|
| Error | 10.2 |
| Cost | 1236 |
| Alternative 4 | |
|---|---|
| Error | 10.2 |
| Cost | 1236 |
| Alternative 5 | |
|---|---|
| Error | 17.7 |
| Cost | 1112 |
| Alternative 6 | |
|---|---|
| Error | 18.1 |
| Cost | 1108 |
| Alternative 7 | |
|---|---|
| Error | 0.3 |
| Cost | 1024 |
| Alternative 8 | |
|---|---|
| Error | 9.5 |
| Cost | 972 |
| Alternative 9 | |
|---|---|
| Error | 6.4 |
| Cost | 968 |
| Alternative 10 | |
|---|---|
| Error | 0.3 |
| Cost | 960 |
| Alternative 11 | |
|---|---|
| Error | 9.3 |
| Cost | 840 |
| Alternative 12 | |
|---|---|
| Error | 1.8 |
| Cost | 832 |
| Alternative 13 | |
|---|---|
| Error | 16.3 |
| Cost | 584 |
| Alternative 14 | |
|---|---|
| Error | 18.4 |
| Cost | 456 |
| Alternative 15 | |
|---|---|
| Error | 27.1 |
| Cost | 64 |
herbie shell --seed 2023074
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.SparkLine:renderSparkLine from Chart-1.5.3"
:precision binary64
:herbie-target
(- x (* (/ (- y z) (+ (- t z) 1.0)) a))
(- x (/ (- y z) (/ (+ (- t z) 1.0) a))))