I'm trying to approximate the value that a function `w`

has in a point `x_target`

(that is constant) in between two other points (also constant), using linear interpolation. To compute `w`

I use an initial solution given by the vector `max(exp(x(i))-K , 0)`

where `x`

is constant increasing vector and `K`

is a value picked from an increasing vector made of 10 values. So I build 10 `w`

, one for every value of `K`

.

Before doing this I find the first index in `x`

such that "x(index)" is bigger than `x_target`

, i.e.,

```
for index = 1:n
if x(index) > x_target
break;
end
end
```

After every `w`

calculation (`w`

is a matrix: every column is a different time step, every line corresponds to a component of the initial solution vector), I compute the approximation of the value that the function has in `x_target`

by linear interpolation (since I have only 2 points I cannot use polynomial interpolation or spline, can I ?) i.e.,

```
p = polyfit([x(index-1),x(index)],[w(index-1,j),w(index,j)],1); % j is the last time step
y = polyval(p,x_target);
```

Here is the error graph (I compare the numerical solution with the analytical one)

And these are the x-axis points (the values of `K`

). At each point, you can see there is a peak, a sort of oscillation. Is it possible to obtain a smoother error graph?

```
1.0000
1.1006
1.2114
1.3332
1.4674
1.6150
1.7775
1.9564
2.1533
2.3699
```