How to use any function interpolation method to create two functions ...

448 Views Asked by At

I need help desperately on this. I have been working on it for a while.

Use any function interpolation method studied in the course to create two functions $x(t)$ and $y(t)$ on $0 ≤ t ≤ 1$ so that the graph of $(x(t),y(t))$ resembles a handwritten version of the first letter of your name. Show the graph of the curve and provide the coordinates of the data points you interpolated.

Hint: you can make a parametric plot of two expressions in t on the interval [0,1] using plot([x, y, t = 0..1]).

So say the letter is $A$ and my functions are $x(t)=|t|+1$ and $y(t)=0.5$, then which polynomial method will give the best approximation? Lagrange? Hermite? Cubic-Spline?

For Lagrange:

xi := [seq(-abs(x)+1, i = 0 .. 7)];
print(`output redirected...`);
  # input placeholder  [-|x| + 1, -|x| + 1, -|x| + 1, -|x| + 1, -|x| + 1, -|x| + 1, -|x| + 1, -|x| + 1]
yi := [seq(.5, i = 1 .. 7)];
print(`output redirected...`);
  # input placeholder [0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5]
plot(xi, yi);
%; Error, (in plot) two lists or Vectors of numerical values expected P := proc (x) options operator, arrow;
interp(xi, yi, x) end proc;
print(`output redirected...`);
  # input placeholder x -> interp(xi, yi, x) P(x);
%; Error, (in CurveFitting:-PolynomialInterpolation) number of values in first and second arguments must match plot(P(x), x = 0 .. 1);
%; Error, (in CurveFitting:-PolynomialInterpolation) number of values in first and second arguments must match

But I'm getting errors, as you can see above.

1

There are 1 best solutions below

3
On

It seems from the description of the exercise that you should first create the functions $x(t),y(t)$ at some particular, perhaps equally spaced $t$ values, in such a way that if the points were plotted in order, and afterwards one "connected the dots" in that order, the result would be a bare outline of the letter, say the letter A as you suggest.

A very basic such pair of functions could be made by using the values $t=1,2,\cdots,7$ and making the points $x(t),y(t)$ for those values be successively $$(0,0),(1,1),(2,2),(3,1),(4,0),(3,1),(1,1).$$ These points correspond to starting at the lower left of the A as $(0,0)$, going up to the top, then down to the lower right of the A, then retracing up to the right end of the middle bar of the A, and finally ending at the left end of the middle bar of the A at the point $(1,1)$

Then one could insert more points between these, in order to force the interpolation to make the letter seem more curved, and so on. Also it depends on what "handwritten" is taken to mean, maybe it means that the lines should not look straight, and perhaps have some extra hooks like in cursive writing.

It would seem once you started, the more initial points the better the result would look, and I don't know what methods you have available for interpolation, but any of them could be applied separately to the sequence of $x$ coordinates, for the function $x(t)$, and then to the $y$ coordinates for $y(t)$. In other words single variable function interpolations can be used to get the final curves for $x(t)$ and $y(t).$

Your two functions seem like you were trying to have one which did the V shape of the A, and another to do the middle bar, but these can't be thought of as the functions $x(t),y(t)$. It's the points whose pairs are $x(t),y(t)$ which must trace out the curve.