| Alternative 1 | |
|---|---|
| Accuracy | 42.8% |
| Cost | 1372 |
(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 -4e-293)
t_1
(if (<= t_1 0.0)
(+ y (/ (* (- y x) (- a z)) t))
(if (<= t_1 2e+302) t_1 (- x (* (/ (- y x) (- a t)) (- t z)))))))))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 <= -4e-293) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = y + (((y - x) * (a - z)) / t);
} else if (t_1 <= 2e+302) {
tmp = t_1;
} else {
tmp = x - (((y - x) / (a - t)) * (t - z));
}
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 <= -4e-293) {
tmp = t_1;
} else if (t_1 <= 0.0) {
tmp = y + (((y - x) * (a - z)) / t);
} else if (t_1 <= 2e+302) {
tmp = t_1;
} else {
tmp = x - (((y - x) / (a - t)) * (t - z));
}
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 <= -4e-293: tmp = t_1 elif t_1 <= 0.0: tmp = y + (((y - x) * (a - z)) / t) elif t_1 <= 2e+302: tmp = t_1 else: tmp = x - (((y - x) / (a - t)) * (t - z)) 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 <= -4e-293) tmp = t_1; elseif (t_1 <= 0.0) tmp = Float64(y + Float64(Float64(Float64(y - x) * Float64(a - z)) / t)); elseif (t_1 <= 2e+302) tmp = t_1; else tmp = Float64(x - Float64(Float64(Float64(y - x) / Float64(a - t)) * Float64(t - z))); 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 <= -4e-293) tmp = t_1; elseif (t_1 <= 0.0) tmp = y + (((y - x) * (a - z)) / t); elseif (t_1 <= 2e+302) tmp = t_1; else tmp = x - (((y - x) / (a - t)) * (t - z)); 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, -4e-293], t$95$1, If[LessEqual[t$95$1, 0.0], N[(y + N[(N[(N[(y - x), $MachinePrecision] * N[(a - z), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+302], t$95$1, N[(x - N[(N[(N[(y - x), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(t - z), $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 -4 \cdot 10^{-293}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;y + \frac{\left(y - x\right) \cdot \left(a - z\right)}{t}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+302}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x - \frac{y - x}{a - t} \cdot \left(t - z\right)\\
\end{array}
Results
| Original | 62.2% |
|---|---|
| Target | 85.7% |
| Herbie | 89.5% |
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -inf.0Initial program 0.0%
Simplified73.3%
[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.3 | \[ \color{blue}{\left(y - x\right) \cdot \frac{z - t}{a - t}} + x
\] |
*-commutative [<=]73.3 | \[ \color{blue}{\frac{z - t}{a - t} \cdot \left(y - x\right)} + x
\] |
fma-def [=>]73.3 | \[ \color{blue}{\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)}
\] |
Taylor expanded in t around inf 36.8%
Simplified69.3%
[Start]36.8 | \[ y + \frac{\left(-1 \cdot z - -1 \cdot a\right) \cdot \left(y - x\right)}{t}
\] |
|---|---|
distribute-lft-out-- [=>]36.8 | \[ y + \frac{\color{blue}{\left(-1 \cdot \left(z - a\right)\right)} \cdot \left(y - x\right)}{t}
\] |
associate-*r* [<=]36.8 | \[ y + \frac{\color{blue}{-1 \cdot \left(\left(z - a\right) \cdot \left(y - x\right)\right)}}{t}
\] |
*-commutative [<=]36.8 | \[ y + \frac{-1 \cdot \color{blue}{\left(\left(y - x\right) \cdot \left(z - a\right)\right)}}{t}
\] |
associate-*r/ [<=]36.8 | \[ y + \color{blue}{-1 \cdot \frac{\left(y - x\right) \cdot \left(z - a\right)}{t}}
\] |
mul-1-neg [=>]36.8 | \[ y + \color{blue}{\left(-\frac{\left(y - x\right) \cdot \left(z - a\right)}{t}\right)}
\] |
unsub-neg [=>]36.8 | \[ \color{blue}{y - \frac{\left(y - x\right) \cdot \left(z - a\right)}{t}}
\] |
associate-/l* [=>]68.4 | \[ y - \color{blue}{\frac{y - x}{\frac{t}{z - a}}}
\] |
associate-/r/ [=>]69.3 | \[ 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))) < -4.0000000000000002e-293 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 2.0000000000000002e302Initial program 97.2%
if -4.0000000000000002e-293 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 6.5%
Simplified6.5%
[Start]6.5 | \[ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\] |
|---|---|
+-commutative [=>]6.5 | \[ \color{blue}{\frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t} + x}
\] |
associate-*r/ [<=]6.5 | \[ \color{blue}{\left(y - x\right) \cdot \frac{z - t}{a - t}} + x
\] |
*-commutative [<=]6.5 | \[ \color{blue}{\frac{z - t}{a - t} \cdot \left(y - x\right)} + x
\] |
fma-def [=>]6.5 | \[ \color{blue}{\mathsf{fma}\left(\frac{z - t}{a - t}, y - x, x\right)}
\] |
Taylor expanded in t around inf 97.6%
Simplified90.5%
[Start]97.6 | \[ y + \frac{\left(-1 \cdot z - -1 \cdot a\right) \cdot \left(y - x\right)}{t}
\] |
|---|---|
distribute-lft-out-- [=>]97.6 | \[ y + \frac{\color{blue}{\left(-1 \cdot \left(z - a\right)\right)} \cdot \left(y - x\right)}{t}
\] |
associate-*r* [<=]97.6 | \[ y + \frac{\color{blue}{-1 \cdot \left(\left(z - a\right) \cdot \left(y - x\right)\right)}}{t}
\] |
*-commutative [<=]97.6 | \[ y + \frac{-1 \cdot \color{blue}{\left(\left(y - x\right) \cdot \left(z - a\right)\right)}}{t}
\] |
associate-*r/ [<=]97.6 | \[ y + \color{blue}{-1 \cdot \frac{\left(y - x\right) \cdot \left(z - a\right)}{t}}
\] |
mul-1-neg [=>]97.6 | \[ y + \color{blue}{\left(-\frac{\left(y - x\right) \cdot \left(z - a\right)}{t}\right)}
\] |
unsub-neg [=>]97.6 | \[ \color{blue}{y - \frac{\left(y - x\right) \cdot \left(z - a\right)}{t}}
\] |
associate-/l* [=>]97.7 | \[ y - \color{blue}{\frac{y - x}{\frac{t}{z - a}}}
\] |
associate-/r/ [=>]90.5 | \[ y - \color{blue}{\frac{y - x}{t} \cdot \left(z - a\right)}
\] |
Taylor expanded in t around 0 97.6%
if 2.0000000000000002e302 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 2.0%
Simplified71.8%
[Start]2.0 | \[ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\] |
|---|---|
associate-*l/ [<=]71.8 | \[ x + \color{blue}{\frac{y - x}{a - t} \cdot \left(z - t\right)}
\] |
Final simplification89.5%
| Alternative 1 | |
|---|---|
| Accuracy | 42.8% |
| Cost | 1372 |
| Alternative 2 | |
|---|---|
| Accuracy | 53.8% |
| Cost | 1368 |
| Alternative 3 | |
|---|---|
| Accuracy | 53.6% |
| Cost | 1368 |
| Alternative 4 | |
|---|---|
| Accuracy | 45.0% |
| Cost | 1240 |
| Alternative 5 | |
|---|---|
| Accuracy | 43.1% |
| Cost | 1108 |
| Alternative 6 | |
|---|---|
| Accuracy | 42.3% |
| Cost | 1108 |
| Alternative 7 | |
|---|---|
| Accuracy | 62.7% |
| Cost | 1104 |
| Alternative 8 | |
|---|---|
| Accuracy | 83.7% |
| Cost | 1097 |
| Alternative 9 | |
|---|---|
| Accuracy | 87.9% |
| Cost | 1097 |
| Alternative 10 | |
|---|---|
| Accuracy | 50.6% |
| Cost | 1041 |
| Alternative 11 | |
|---|---|
| Accuracy | 50.1% |
| Cost | 977 |
| Alternative 12 | |
|---|---|
| Accuracy | 50.0% |
| Cost | 977 |
| Alternative 13 | |
|---|---|
| Accuracy | 68.1% |
| Cost | 969 |
| Alternative 14 | |
|---|---|
| Accuracy | 74.5% |
| Cost | 969 |
| Alternative 15 | |
|---|---|
| Accuracy | 75.1% |
| Cost | 969 |
| Alternative 16 | |
|---|---|
| Accuracy | 57.4% |
| Cost | 841 |
| Alternative 17 | |
|---|---|
| Accuracy | 66.0% |
| Cost | 841 |
| Alternative 18 | |
|---|---|
| Accuracy | 66.0% |
| Cost | 841 |
| Alternative 19 | |
|---|---|
| Accuracy | 42.5% |
| Cost | 716 |
| Alternative 20 | |
|---|---|
| Accuracy | 42.5% |
| Cost | 716 |
| Alternative 21 | |
|---|---|
| Accuracy | 42.0% |
| Cost | 592 |
| Alternative 22 | |
|---|---|
| Accuracy | 43.2% |
| Cost | 328 |
| Alternative 23 | |
|---|---|
| Accuracy | 28.7% |
| Cost | 64 |
herbie shell --seed 2023141
(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))))