| Alternative 1 | |
|---|---|
| Accuracy | 88.7% |
| Cost | 8905 |
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (<= t_1 (- INFINITY))
(+ y (* (- z a) (/ (- x y) t)))
(if (<= t_1 -1e-260)
t_1
(if (<= t_1 0.0)
(+ y (/ (* x (- z a)) t))
(if (<= t_1 1e+291) t_1 (+ x (* (- t z) (/ (- x y) (- a t))))))))))double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = y + ((z - a) * ((x - y) / t));
} else if (t_1 <= -1e-260) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = y + ((x * (z - a)) / t);
} else if (t_1 <= 1e+291) {
tmp = t_1;
} else {
tmp = x + ((t - z) * ((x - y) / (a - t)));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
public static double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = y + ((z - a) * ((x - y) / t));
} else if (t_1 <= -1e-260) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = y + ((x * (z - a)) / t);
} else if (t_1 <= 1e+291) {
tmp = t_1;
} else {
tmp = x + ((t - z) * ((x - y) / (a - t)));
}
return tmp;
}
def code(x, y, z, t, a): return x + (((y - x) * (z - t)) / (a - t))
def code(x, y, z, t, a): t_1 = x + (((y - x) * (z - t)) / (a - t)) tmp = 0 if t_1 <= -math.inf: tmp = y + ((z - a) * ((x - y) / t)) elif t_1 <= -1e-260: tmp = t_1 elif t_1 <= 0.0: tmp = y + ((x * (z - a)) / t) elif t_1 <= 1e+291: tmp = t_1 else: tmp = x + ((t - z) * ((x - y) / (a - t))) return tmp
function code(x, y, z, t, a) return Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) end
function code(x, y, z, t, a) t_1 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(y + Float64(Float64(z - a) * Float64(Float64(x - y) / t))); elseif (t_1 <= -1e-260) tmp = t_1; elseif (t_1 <= 0.0) tmp = Float64(y + Float64(Float64(x * Float64(z - a)) / t)); elseif (t_1 <= 1e+291) tmp = t_1; else tmp = Float64(x + Float64(Float64(t - z) * Float64(Float64(x - y) / Float64(a - t)))); end return tmp end
function tmp = code(x, y, z, t, a) tmp = x + (((y - x) * (z - t)) / (a - t)); end
function tmp_2 = code(x, y, z, t, a) t_1 = x + (((y - x) * (z - t)) / (a - t)); tmp = 0.0; if (t_1 <= -Inf) tmp = y + ((z - a) * ((x - y) / t)); elseif (t_1 <= -1e-260) tmp = t_1; elseif (t_1 <= 0.0) tmp = y + ((x * (z - a)) / t); elseif (t_1 <= 1e+291) tmp = t_1; else tmp = x + ((t - z) * ((x - y) / (a - t))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(y + N[(N[(z - a), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -1e-260], t$95$1, If[LessEqual[t$95$1, 0.0], N[(y + N[(N[(x * N[(z - a), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e+291], t$95$1, N[(x + N[(N[(t - z), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;y + \left(z - a\right) \cdot \frac{x - y}{t}\\
\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-260}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;y + \frac{x \cdot \left(z - a\right)}{t}\\
\mathbf{elif}\;t_1 \leq 10^{+291}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - z\right) \cdot \frac{x - y}{a - t}\\
\end{array}
Results
| Original | 61.7% |
|---|---|
| Target | 85.9% |
| Herbie | 88.3% |
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -inf.0Initial program 0.0%
Simplified73.7%
[Start]0.0 | \[ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\] |
|---|---|
+-commutative [=>]0.0 | \[ \color{blue}{\frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} + x}
\] |
associate-*r/ [<=]73.7 | \[ \color{blue}{\left(y - x\right) \cdot \frac{z - t}{a - t}} + x
\] |
*-commutative [<=]73.7 | \[ \color{blue}{\frac{z - t}{a - t} \cdot \left(y - x\right)} + x
\] |
fma-def [=>]73.7 | \[ \color{blue}{\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)}
\] |
Taylor expanded in t around inf 35.3%
Simplified67.1%
[Start]35.3 | \[ y + \frac{\left(-1 \cdot z - -1 \cdot a\right) \cdot \left(y - x\right)}{t}
\] |
|---|---|
distribute-lft-out-- [=>]35.3 | \[ y + \frac{\color{blue}{\left(-1 \cdot \left(z - a\right)\right)} \cdot \left(y - x\right)}{t}
\] |
associate-*r* [<=]35.3 | \[ y + \frac{\color{blue}{-1 \cdot \left(\left(z - a\right) \cdot \left(y - x\right)\right)}}{t}
\] |
*-commutative [<=]35.3 | \[ y + \frac{-1 \cdot \color{blue}{\left(\left(y - x\right) \cdot \left(z - a\right)\right)}}{t}
\] |
associate-*r/ [<=]35.3 | \[ y + \color{blue}{-1 \cdot \frac{\left(y - x\right) \cdot \left(z - a\right)}{t}}
\] |
mul-1-neg [=>]35.3 | \[ y + \color{blue}{\left(-\frac{\left(y - x\right) \cdot \left(z - a\right)}{t}\right)}
\] |
unsub-neg [=>]35.3 | \[ \color{blue}{y - \frac{\left(y - x\right) \cdot \left(z - a\right)}{t}}
\] |
associate-/l* [=>]66.1 | \[ y - \color{blue}{\frac{y - x}{\frac{t}{z - a}}}
\] |
associate-/r/ [=>]67.1 | \[ y - \color{blue}{\frac{y - x}{t} \cdot \left(z - a\right)}
\] |
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -9.99999999999999961e-261 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 9.9999999999999996e290Initial program 96.7%
if -9.99999999999999961e-261 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 10.7%
Simplified11.3%
[Start]10.7 | \[ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\] |
|---|---|
associate-/l* [=>]11.3 | \[ x + \color{blue}{\frac{y - x}{\frac{a - t}{z - t}}}
\] |
Taylor expanded in t around inf 93.6%
Simplified93.6%
[Start]93.6 | \[ \left(-1 \cdot \frac{z \cdot \left(y - x\right)}{t} + y\right) - -1 \cdot \frac{a \cdot \left(y - x\right)}{t}
\] |
|---|---|
+-commutative [=>]93.6 | \[ \color{blue}{\left(y + -1 \cdot \frac{z \cdot \left(y - x\right)}{t}\right)} - -1 \cdot \frac{a \cdot \left(y - x\right)}{t}
\] |
associate--l+ [=>]93.6 | \[ \color{blue}{y + \left(-1 \cdot \frac{z \cdot \left(y - x\right)}{t} - -1 \cdot \frac{a \cdot \left(y - x\right)}{t}\right)}
\] |
*-commutative [=>]93.6 | \[ y + \left(-1 \cdot \frac{\color{blue}{\left(y - x\right) \cdot z}}{t} - -1 \cdot \frac{a \cdot \left(y - x\right)}{t}\right)
\] |
associate-*r/ [=>]93.6 | \[ y + \left(\color{blue}{\frac{-1 \cdot \left(\left(y - x\right) \cdot z\right)}{t}} - -1 \cdot \frac{a \cdot \left(y - x\right)}{t}\right)
\] |
associate-*r/ [=>]93.6 | \[ y + \left(\frac{-1 \cdot \left(\left(y - x\right) \cdot z\right)}{t} - \color{blue}{\frac{-1 \cdot \left(a \cdot \left(y - x\right)\right)}{t}}\right)
\] |
div-sub [<=]93.6 | \[ y + \color{blue}{\frac{-1 \cdot \left(\left(y - x\right) \cdot z\right) - -1 \cdot \left(a \cdot \left(y - x\right)\right)}{t}}
\] |
distribute-lft-out-- [=>]93.6 | \[ y + \frac{\color{blue}{-1 \cdot \left(\left(y - x\right) \cdot z - a \cdot \left(y - x\right)\right)}}{t}
\] |
Taylor expanded in x around inf 93.7%
if 9.9999999999999996e290 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 4.8%
Simplified71.5%
[Start]4.8 | \[ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\] |
|---|---|
associate-*l/ [<=]71.5 | \[ x + \color{blue}{\frac{y - x}{a - t} \cdot \left(z - t\right)}
\] |
Final simplification88.3%
| Alternative 1 | |
|---|---|
| Accuracy | 88.7% |
| Cost | 8905 |
| Alternative 2 | |
|---|---|
| Accuracy | 88.8% |
| Cost | 2633 |
| Alternative 3 | |
|---|---|
| Accuracy | 85.5% |
| Cost | 1360 |
| Alternative 4 | |
|---|---|
| Accuracy | 69.7% |
| Cost | 1232 |
| Alternative 5 | |
|---|---|
| Accuracy | 73.2% |
| Cost | 1232 |
| Alternative 6 | |
|---|---|
| Accuracy | 73.6% |
| Cost | 1232 |
| Alternative 7 | |
|---|---|
| Accuracy | 50.2% |
| Cost | 844 |
| Alternative 8 | |
|---|---|
| Accuracy | 64.2% |
| Cost | 841 |
| Alternative 9 | |
|---|---|
| Accuracy | 69.0% |
| Cost | 841 |
| Alternative 10 | |
|---|---|
| Accuracy | 60.9% |
| Cost | 713 |
| Alternative 11 | |
|---|---|
| Accuracy | 41.8% |
| Cost | 712 |
| Alternative 12 | |
|---|---|
| Accuracy | 44.5% |
| Cost | 580 |
| Alternative 13 | |
|---|---|
| Accuracy | 44.5% |
| Cost | 328 |
| Alternative 14 | |
|---|---|
| Accuracy | 3.0% |
| Cost | 64 |
| Alternative 15 | |
|---|---|
| Accuracy | 28.9% |
| Cost | 64 |
herbie shell --seed 2023138
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))
(+ x (/ (* (- y x) (- z t)) (- a t))))