| Alternative 1 | |
|---|---|
| Error | 6.5 |
| Cost | 5008 |
(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 (* (- (/ z (- a t)) (/ t (- a t))) y))
(t_2 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (<= t_2 (- INFINITY))
(+ t_1 (* x (+ (/ z t) (* (- (/ z (pow t 2.0)) (/ 1.0 t)) a))))
(if (<= t_2 -5e-259)
(- (/ (* (- z t) y) (- a t)) (- (/ (* (- z t) x) (- a t)) x))
(if (<= t_2 0.0)
(+ t_1 (* x (- (/ (- a z) t))))
(+ t_1 (* x (- (- 2.0 (/ (- z t) (- a t))) 1.0))))))))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 = ((z / (a - t)) - (t / (a - t))) * y;
double t_2 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1 + (x * ((z / t) + (((z / pow(t, 2.0)) - (1.0 / t)) * a)));
} else if (t_2 <= -5e-259) {
tmp = (((z - t) * y) / (a - t)) - ((((z - t) * x) / (a - t)) - x);
} else if (t_2 <= 0.0) {
tmp = t_1 + (x * -((a - z) / t));
} else {
tmp = t_1 + (x * ((2.0 - ((z - t) / (a - t))) - 1.0));
}
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 = ((z / (a - t)) - (t / (a - t))) * y;
double t_2 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1 + (x * ((z / t) + (((z / Math.pow(t, 2.0)) - (1.0 / t)) * a)));
} else if (t_2 <= -5e-259) {
tmp = (((z - t) * y) / (a - t)) - ((((z - t) * x) / (a - t)) - x);
} else if (t_2 <= 0.0) {
tmp = t_1 + (x * -((a - z) / t));
} else {
tmp = t_1 + (x * ((2.0 - ((z - t) / (a - t))) - 1.0));
}
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 = ((z / (a - t)) - (t / (a - t))) * y t_2 = x + (((y - x) * (z - t)) / (a - t)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 + (x * ((z / t) + (((z / math.pow(t, 2.0)) - (1.0 / t)) * a))) elif t_2 <= -5e-259: tmp = (((z - t) * y) / (a - t)) - ((((z - t) * x) / (a - t)) - x) elif t_2 <= 0.0: tmp = t_1 + (x * -((a - z) / t)) else: tmp = t_1 + (x * ((2.0 - ((z - t) / (a - t))) - 1.0)) 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(Float64(Float64(z / Float64(a - t)) - Float64(t / Float64(a - t))) * y) t_2 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(t_1 + Float64(x * Float64(Float64(z / t) + Float64(Float64(Float64(z / (t ^ 2.0)) - Float64(1.0 / t)) * a)))); elseif (t_2 <= -5e-259) tmp = Float64(Float64(Float64(Float64(z - t) * y) / Float64(a - t)) - Float64(Float64(Float64(Float64(z - t) * x) / Float64(a - t)) - x)); elseif (t_2 <= 0.0) tmp = Float64(t_1 + Float64(x * Float64(-Float64(Float64(a - z) / t)))); else tmp = Float64(t_1 + Float64(x * Float64(Float64(2.0 - Float64(Float64(z - t) / Float64(a - t))) - 1.0))); 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 = ((z / (a - t)) - (t / (a - t))) * y; t_2 = x + (((y - x) * (z - t)) / (a - t)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1 + (x * ((z / t) + (((z / (t ^ 2.0)) - (1.0 / t)) * a))); elseif (t_2 <= -5e-259) tmp = (((z - t) * y) / (a - t)) - ((((z - t) * x) / (a - t)) - x); elseif (t_2 <= 0.0) tmp = t_1 + (x * -((a - z) / t)); else tmp = t_1 + (x * ((2.0 - ((z - t) / (a - t))) - 1.0)); 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[(N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] - N[(t / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[(y - x), $MachinePrecision] * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(t$95$1 + N[(x * N[(N[(z / t), $MachinePrecision] + N[(N[(N[(z / N[Power[t, 2.0], $MachinePrecision]), $MachinePrecision] - N[(1.0 / t), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -5e-259], N[(N[(N[(N[(z - t), $MachinePrecision] * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(N[(z - t), $MachinePrecision] * x), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.0], N[(t$95$1 + N[(x * (-N[(N[(a - z), $MachinePrecision] / t), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(x * N[(N[(2.0 - N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y\\
t_2 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1 + x \cdot \left(\frac{z}{t} + \left(\frac{z}{{t}^{2}} - \frac{1}{t}\right) \cdot a\right)\\
\mathbf{elif}\;t_2 \leq -5 \cdot 10^{-259}:\\
\;\;\;\;\frac{\left(z - t\right) \cdot y}{a - t} - \left(\frac{\left(z - t\right) \cdot x}{a - t} - x\right)\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;t_1 + x \cdot \left(-\frac{a - z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 + x \cdot \left(\left(2 - \frac{z - t}{a - t}\right) - 1\right)\\
\end{array}
Results
| Original | 24.7 |
|---|---|
| Target | 9.9 |
| Herbie | 5.6 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -inf.0Initial program 64.0
Taylor expanded in y around 0 38.9
Taylor expanded in x around 0 11.9
Simplified11.9
[Start]11.9 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + \left(1 + -1 \cdot \frac{z - t}{a - t}\right) \cdot x
\] |
|---|---|
rational.json-simplify-2 [=>]11.9 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + \color{blue}{x \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right)}
\] |
rational.json-simplify-2 [=>]11.9 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \left(1 + \color{blue}{\frac{z - t}{a - t} \cdot -1}\right)
\] |
rational.json-simplify-9 [=>]11.9 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \left(1 + \color{blue}{\left(-\frac{z - t}{a - t}\right)}\right)
\] |
Taylor expanded in a around 0 16.0
if -inf.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -4.99999999999999977e-259Initial program 2.2
Taylor expanded in y around -inf 2.2
Simplified2.2
[Start]2.2 | \[ -1 \cdot \frac{\left(z - t\right) \cdot x}{a - t} + \left(\frac{\left(z - t\right) \cdot y}{a - t} + x\right)
\] |
|---|---|
rational.json-simplify-2 [=>]2.2 | \[ \color{blue}{\frac{\left(z - t\right) \cdot x}{a - t} \cdot -1} + \left(\frac{\left(z - t\right) \cdot y}{a - t} + x\right)
\] |
rational.json-simplify-9 [=>]2.2 | \[ \color{blue}{\left(-\frac{\left(z - t\right) \cdot x}{a - t}\right)} + \left(\frac{\left(z - t\right) \cdot y}{a - t} + x\right)
\] |
rational.json-simplify-1 [=>]2.2 | \[ \left(-\frac{\left(z - t\right) \cdot x}{a - t}\right) + \color{blue}{\left(x + \frac{\left(z - t\right) \cdot y}{a - t}\right)}
\] |
Applied egg-rr2.0
if -4.99999999999999977e-259 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 56.5
Taylor expanded in y around 0 31.7
Taylor expanded in x around 0 31.4
Simplified31.4
[Start]31.4 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + \left(1 + -1 \cdot \frac{z - t}{a - t}\right) \cdot x
\] |
|---|---|
rational.json-simplify-2 [=>]31.4 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + \color{blue}{x \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right)}
\] |
rational.json-simplify-2 [=>]31.4 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \left(1 + \color{blue}{\frac{z - t}{a - t} \cdot -1}\right)
\] |
rational.json-simplify-9 [=>]31.4 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \left(1 + \color{blue}{\left(-\frac{z - t}{a - t}\right)}\right)
\] |
Taylor expanded in t around -inf 4.1
Simplified4.1
[Start]4.1 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \left(-1 \cdot \frac{a - z}{t}\right)
\] |
|---|---|
rational.json-simplify-2 [=>]4.1 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \color{blue}{\left(\frac{a - z}{t} \cdot -1\right)}
\] |
rational.json-simplify-9 [=>]4.1 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \color{blue}{\left(-\frac{a - z}{t}\right)}
\] |
if 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 21.5
Taylor expanded in y around 0 14.0
Taylor expanded in x around 0 5.2
Simplified5.2
[Start]5.2 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + \left(1 + -1 \cdot \frac{z - t}{a - t}\right) \cdot x
\] |
|---|---|
rational.json-simplify-2 [=>]5.2 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + \color{blue}{x \cdot \left(1 + -1 \cdot \frac{z - t}{a - t}\right)}
\] |
rational.json-simplify-2 [=>]5.2 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \left(1 + \color{blue}{\frac{z - t}{a - t} \cdot -1}\right)
\] |
rational.json-simplify-9 [=>]5.2 | \[ \left(\frac{z}{a - t} - \frac{t}{a - t}\right) \cdot y + x \cdot \left(1 + \color{blue}{\left(-\frac{z - t}{a - t}\right)}\right)
\] |
Applied egg-rr5.2
Final simplification5.6
| Alternative 1 | |
|---|---|
| Error | 6.5 |
| Cost | 5008 |
| Alternative 2 | |
|---|---|
| Error | 11.7 |
| Cost | 4944 |
| Alternative 3 | |
|---|---|
| Error | 12.1 |
| Cost | 4432 |
| Alternative 4 | |
|---|---|
| Error | 12.1 |
| Cost | 4432 |
| Alternative 5 | |
|---|---|
| Error | 5.4 |
| Cost | 4428 |
| Alternative 6 | |
|---|---|
| Error | 5.4 |
| Cost | 4364 |
| Alternative 7 | |
|---|---|
| Error | 26.9 |
| Cost | 2020 |
| Alternative 8 | |
|---|---|
| Error | 35.6 |
| Cost | 1768 |
| Alternative 9 | |
|---|---|
| Error | 35.3 |
| Cost | 1768 |
| Alternative 10 | |
|---|---|
| Error | 33.8 |
| Cost | 1768 |
| Alternative 11 | |
|---|---|
| Error | 30.2 |
| Cost | 1764 |
| Alternative 12 | |
|---|---|
| Error | 35.3 |
| Cost | 1504 |
| Alternative 13 | |
|---|---|
| Error | 30.5 |
| Cost | 1504 |
| Alternative 14 | |
|---|---|
| Error | 30.4 |
| Cost | 1504 |
| Alternative 15 | |
|---|---|
| Error | 27.9 |
| Cost | 1504 |
| Alternative 16 | |
|---|---|
| Error | 39.0 |
| Cost | 1372 |
| Alternative 17 | |
|---|---|
| Error | 22.8 |
| Cost | 1296 |
| Alternative 18 | |
|---|---|
| Error | 37.1 |
| Cost | 1044 |
| Alternative 19 | |
|---|---|
| Error | 37.2 |
| Cost | 1044 |
| Alternative 20 | |
|---|---|
| Error | 36.8 |
| Cost | 716 |
| Alternative 21 | |
|---|---|
| Error | 37.8 |
| Cost | 592 |
| Alternative 22 | |
|---|---|
| Error | 35.8 |
| Cost | 328 |
| Alternative 23 | |
|---|---|
| Error | 45.6 |
| Cost | 64 |
herbie shell --seed 2023077
(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))))