| Alternative 1 | |
|---|---|
| Error | 6.6 |
| Cost | 2760 |
(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 (+ (* y (/ (- t z) (- t a))) (+ x (- (* (- t z) (/ x (- t a)))))))
(t_2 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (<= t_2 -5e-308)
t_1
(if (<= t_2 0.0) (+ y (* -1.0 (* (- y x) (- (/ z t) (/ a t))))) t_1))))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 = (y * ((t - z) / (t - a))) + (x + -((t - z) * (x / (t - a))));
double t_2 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_2 <= -5e-308) {
tmp = t_1;
} else if (t_2 <= 0.0) {
tmp = y + (-1.0 * ((y - x) * ((z / t) - (a / t))));
} else {
tmp = t_1;
}
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 - x) * (z - t)) / (a - t))
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) :: tmp
t_1 = (y * ((t - z) / (t - a))) + (x + -((t - z) * (x / (t - a))))
t_2 = x + (((y - x) * (z - t)) / (a - t))
if (t_2 <= (-5d-308)) then
tmp = t_1
else if (t_2 <= 0.0d0) then
tmp = y + ((-1.0d0) * ((y - x) * ((z / t) - (a / t))))
else
tmp = t_1
end if
code = tmp
end function
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 = (y * ((t - z) / (t - a))) + (x + -((t - z) * (x / (t - a))));
double t_2 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_2 <= -5e-308) {
tmp = t_1;
} else if (t_2 <= 0.0) {
tmp = y + (-1.0 * ((y - x) * ((z / t) - (a / t))));
} else {
tmp = t_1;
}
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 = (y * ((t - z) / (t - a))) + (x + -((t - z) * (x / (t - a)))) t_2 = x + (((y - x) * (z - t)) / (a - t)) tmp = 0 if t_2 <= -5e-308: tmp = t_1 elif t_2 <= 0.0: tmp = y + (-1.0 * ((y - x) * ((z / t) - (a / t)))) else: tmp = t_1 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(y * Float64(Float64(t - z) / Float64(t - a))) + Float64(x + Float64(-Float64(Float64(t - z) * Float64(x / Float64(t - a)))))) t_2 = Float64(x + Float64(Float64(Float64(y - x) * Float64(z - t)) / Float64(a - t))) tmp = 0.0 if (t_2 <= -5e-308) tmp = t_1; elseif (t_2 <= 0.0) tmp = Float64(y + Float64(-1.0 * Float64(Float64(y - x) * Float64(Float64(z / t) - Float64(a / t))))); else tmp = t_1; 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 = (y * ((t - z) / (t - a))) + (x + -((t - z) * (x / (t - a)))); t_2 = x + (((y - x) * (z - t)) / (a - t)); tmp = 0.0; if (t_2 <= -5e-308) tmp = t_1; elseif (t_2 <= 0.0) tmp = y + (-1.0 * ((y - x) * ((z / t) - (a / t)))); else tmp = t_1; 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[(y * N[(N[(t - z), $MachinePrecision] / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x + (-N[(N[(t - z), $MachinePrecision] * N[(x / N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $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, -5e-308], t$95$1, If[LessEqual[t$95$2, 0.0], N[(y + N[(-1.0 * N[(N[(y - x), $MachinePrecision] * N[(N[(z / t), $MachinePrecision] - N[(a / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := y \cdot \frac{t - z}{t - a} + \left(x + \left(-\left(t - z\right) \cdot \frac{x}{t - a}\right)\right)\\
t_2 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_2 \leq -5 \cdot 10^{-308}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;y + -1 \cdot \left(\left(y - x\right) \cdot \left(\frac{z}{t} - \frac{a}{t}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 24.9 |
|---|---|
| Target | 9.2 |
| Herbie | 6.2 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -4.99999999999999955e-308 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 21.6
Simplified10.3
[Start]21.6 | \[ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\] |
|---|---|
rational.json-simplify-49 [=>]10.3 | \[ x + \color{blue}{\left(z - t\right) \cdot \frac{y - x}{a - t}}
\] |
Applied egg-rr7.2
Taylor expanded in y around -inf 21.6
Simplified6.7
[Start]21.6 | \[ -1 \cdot \frac{\left(t - z\right) \cdot x}{t - a} + \left(\frac{y \cdot \left(t - z\right)}{t - a} + x\right)
\] |
|---|---|
rational.json-simplify-41 [=>]21.4 | \[ \color{blue}{\frac{y \cdot \left(t - z\right)}{t - a} + \left(x + -1 \cdot \frac{\left(t - z\right) \cdot x}{t - a}\right)}
\] |
rational.json-simplify-2 [=>]21.4 | \[ \frac{\color{blue}{\left(t - z\right) \cdot y}}{t - a} + \left(x + -1 \cdot \frac{\left(t - z\right) \cdot x}{t - a}\right)
\] |
rational.json-simplify-49 [=>]13.9 | \[ \color{blue}{y \cdot \frac{t - z}{t - a}} + \left(x + -1 \cdot \frac{\left(t - z\right) \cdot x}{t - a}\right)
\] |
rational.json-simplify-2 [=>]13.9 | \[ y \cdot \frac{t - z}{t - a} + \left(x + \color{blue}{\frac{\left(t - z\right) \cdot x}{t - a} \cdot -1}\right)
\] |
rational.json-simplify-9 [=>]13.9 | \[ y \cdot \frac{t - z}{t - a} + \left(x + \color{blue}{\left(-\frac{\left(t - z\right) \cdot x}{t - a}\right)}\right)
\] |
rational.json-simplify-2 [=>]13.9 | \[ y \cdot \frac{t - z}{t - a} + \left(x + \left(-\frac{\color{blue}{x \cdot \left(t - z\right)}}{t - a}\right)\right)
\] |
rational.json-simplify-49 [=>]6.7 | \[ y \cdot \frac{t - z}{t - a} + \left(x + \left(-\color{blue}{\left(t - z\right) \cdot \frac{x}{t - a}}\right)\right)
\] |
if -4.99999999999999955e-308 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 61.2
Simplified61.2
[Start]61.2 | \[ x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\] |
|---|---|
rational.json-simplify-2 [=>]61.2 | \[ x + \frac{\color{blue}{\left(z - t\right) \cdot \left(y - x\right)}}{a - t}
\] |
rational.json-simplify-49 [=>]61.2 | \[ x + \color{blue}{\left(y - x\right) \cdot \frac{z - t}{a - t}}
\] |
Taylor expanded in t around inf 0.4
Simplified0.4
[Start]0.4 | \[ \left(-1 \cdot \frac{z \cdot \left(y - x\right)}{t} + y\right) - -1 \cdot \frac{a \cdot \left(y - x\right)}{t}
\] |
|---|---|
rational.json-simplify-48 [=>]0.4 | \[ \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)}
\] |
rational.json-simplify-2 [=>]0.4 | \[ y + \left(-1 \cdot \frac{z \cdot \left(y - x\right)}{t} - \color{blue}{\frac{a \cdot \left(y - x\right)}{t} \cdot -1}\right)
\] |
rational.json-simplify-52 [=>]0.4 | \[ y + \color{blue}{-1 \cdot \left(\frac{z \cdot \left(y - x\right)}{t} - \frac{a \cdot \left(y - x\right)}{t}\right)}
\] |
rational.json-simplify-49 [=>]0.3 | \[ y + -1 \cdot \left(\color{blue}{\left(y - x\right) \cdot \frac{z}{t}} - \frac{a \cdot \left(y - x\right)}{t}\right)
\] |
rational.json-simplify-49 [=>]0.4 | \[ y + -1 \cdot \left(\left(y - x\right) \cdot \frac{z}{t} - \color{blue}{\left(y - x\right) \cdot \frac{a}{t}}\right)
\] |
rational.json-simplify-2 [=>]0.4 | \[ y + -1 \cdot \left(\left(y - x\right) \cdot \frac{z}{t} - \color{blue}{\frac{a}{t} \cdot \left(y - x\right)}\right)
\] |
rational.json-simplify-52 [=>]0.4 | \[ y + -1 \cdot \color{blue}{\left(\left(y - x\right) \cdot \left(\frac{z}{t} - \frac{a}{t}\right)\right)}
\] |
Final simplification6.2
| Alternative 1 | |
|---|---|
| Error | 6.6 |
| Cost | 2760 |
| Alternative 2 | |
|---|---|
| Error | 7.1 |
| Cost | 2632 |
| Alternative 3 | |
|---|---|
| Error | 7.1 |
| Cost | 2632 |
| Alternative 4 | |
|---|---|
| Error | 6.6 |
| Cost | 2632 |
| Alternative 5 | |
|---|---|
| Error | 20.2 |
| Cost | 1760 |
| Alternative 6 | |
|---|---|
| Error | 20.8 |
| Cost | 1760 |
| Alternative 7 | |
|---|---|
| Error | 25.1 |
| Cost | 1628 |
| Alternative 8 | |
|---|---|
| Error | 34.8 |
| Cost | 1240 |
| Alternative 9 | |
|---|---|
| Error | 26.6 |
| Cost | 1236 |
| Alternative 10 | |
|---|---|
| Error | 17.7 |
| Cost | 1232 |
| Alternative 11 | |
|---|---|
| Error | 17.1 |
| Cost | 1228 |
| Alternative 12 | |
|---|---|
| Error | 34.5 |
| Cost | 1172 |
| Alternative 13 | |
|---|---|
| Error | 34.4 |
| Cost | 1108 |
| Alternative 14 | |
|---|---|
| Error | 34.4 |
| Cost | 1108 |
| Alternative 15 | |
|---|---|
| Error | 34.5 |
| Cost | 1108 |
| Alternative 16 | |
|---|---|
| Error | 26.2 |
| Cost | 972 |
| Alternative 17 | |
|---|---|
| Error | 26.2 |
| Cost | 972 |
| Alternative 18 | |
|---|---|
| Error | 26.2 |
| Cost | 972 |
| Alternative 19 | |
|---|---|
| Error | 36.5 |
| Cost | 844 |
| Alternative 20 | |
|---|---|
| Error | 28.8 |
| Cost | 840 |
| Alternative 21 | |
|---|---|
| Error | 30.9 |
| Cost | 776 |
| Alternative 22 | |
|---|---|
| Error | 30.9 |
| Cost | 776 |
| Alternative 23 | |
|---|---|
| Error | 33.4 |
| Cost | 712 |
| Alternative 24 | |
|---|---|
| Error | 36.0 |
| Cost | 328 |
| Alternative 25 | |
|---|---|
| Error | 45.9 |
| Cost | 64 |
herbie shell --seed 2023074
(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))))