 # Bounding box fitting looks failing due to numerical accuracy

I try plot straight lines inside the bounding box:

But it seems that at the bottom side the lines are exceeding the bounding box slightly.
plot_parabola.m (2.6 KB)
It can be checked that the lines are not larger than the bounding box as below:

``````  # Check that the segment endings are not larger than the bounding box, reduce segment size if required.
#v=real(fl)<real(bb(1)); fl(v)=complex(real(bb(1)),imag(fl(v)));
#v=real(fl)>real(bb(2)); fl(v)=complex(real(bb(2)),imag(fl(v)));
#v=imag(fl)<imag(bb(1)); fl(v)=complex(real(fl(v)),imag(bb(1)));
#v=imag(fl)>imag(bb(2)); fl(v)=complex(real(fl(v)),imag(bb(2)));
``````

But how to check that they end EXACTLY at the edge (where edge is integer coordinate).

It looks solution is to calculate ‘fl’ in regards of ‘t’ and ‘v’ (instead of s)
` fl=v(cs).*t(cs)+n(cs)+c;`
Harder question though is to find the points where the parabola crosses the bounding box…
(as parabola is calculated with the polar coordinates, and bounding box is cartesian, etc.).
I tried to find derivation for different function inaccuracies, but it looks not necessarily easily made:
FPACC.pdf (61.2 KB)

I try find the equation in this excel sheet, but it doesn’t seem to match to the result in columns I and J:
FPACC1.xls (12 KB)
It looks hard to be found by google and also hard to be derived …

Some elements do have y-values that are smaller than -2 (exact). I ran this code

``````plot_parabola
format long
h = get (gca, "children");
ydata = get (h(2), "ydata");
ymin = ydata(2)

ymin = -2.000000000000000

ymin + 2

ans = -4.440892098500626e-16
``````

Octave is doing the right thing here because the y-values do exceed -2 so it uses the next reasonable limit of -4 for the lower bound. In cases like this it is easiest just to set bounds of the plot to the value that you think looks prettiest. For example,

``````ylim ([-2, 6])
``````

Octave calculation looks correct.
So I had to fix it by changing the equation(s).

Anyway, the x^y case error seems to be possible to be formulated with limit theory:
FPACC1.xls (16.5 KB)
FPACC.pdf (65.9 KB)
But all in all it looks becoming quite complicated.