Intersection of Parametric Curves Using vpasolve

17 次查看(过去 30 天)
I'm trying to find the intersections of two parametric curves. I thought it was solved until i zoomed in to see a significant error.
I'm not sure what's going on.
Any help would be appreciated. Thank you.
Problem: Graph the cycloid
and the trochoid
together on the interval [0, 4π]. Find the coordinates of the four points of intersection. (Hint: Solve the equation r(t) = s(u). Note the different independent variables for r and s—the points of intersection need not correspond to the same “time” on each curve. Also, since the coordinate functions are transcendental, you may need to use vpasolve rather than solve.) Use MATLAB to mark the four points on your graph.
From Multivariable Calculus with MATLAB: With Applications to Geometry and Physics 1st ed. 2017 (Lispman, Rosenberg). This is Problem 2.21. Page 29.
Define curves
syms ind t u;
rx(ind)=2*(ind)-2*sin(ind);
ry(ind)=2*(1-cos(ind));
sx(ind)=2*(ind)-sin(ind);
sy(ind)=2-cos(ind);
figure;hold on;xlim([0 25]);
fplot(rx(t),ry(t),[0 4*pi],'b');
fplot(sx(u),sy(u),[0 4*pi],'r');
xlabel('r_x(t) ~ s_x(u)');
ylabel('r_y(t) ~ s_x(u)');
From inspection (see see first plot below), intersections ocurr where r(t) is approximately {1, 12 13 24}. The x component of r(t) is approximately double t. So approximations for t are t=1/2{1,12,13,24}. Also note that and remain approximately close in value as t and u vary.
guesses=[1, 12 13 24]/2;
Setup the system to solve: (eq)
eq=[rx(t) ry(t)]-[sx(u) sy(u)]==0;
For each guess, solve eq for t and u (using vpasolve).
for guess=guesses
solution=vpasolve(eq,[t u],guess);
Plot the intersection point Pn. Plot r(t) with a large blue dot and s(u) as a small yellow dot.
plot(rx(solution.t),ry(solution.t),'b.','markersize',20); % plot R(t) at t_x = Pn_x
plot(sx(solution.u),sy(solution.u),'y.','markersize',5); % plot S(u) at u_x = Pn_x
Print intersection values of t and u at Pn.
fprintf('R(t) and S(u) intersect at P%d when',find(guesses==guess));
tn=double(solution.t)
un=double(solution.u)
end
R(t) and S(u) intersect at P1 when
tn = 1.0918
un = 0.3983
R(t) and S(u) intersect at P2 when
tn = 5.1914
un = 5.8849
R(t) and S(u) intersect at P3 when
tn = 7.3750
un = 6.6814
R(t) and S(u) intersect at P4 when
tn = 11.4745
un = 12.1681
hold off;
Zoom-In to see the error
figure; hold on;
fplot(rx(t),ry(t),[0 4*pi],'b');
fplot(sx(u),sy(u),[0 4*pi],'r');
for guess=guesses
solution=vpasolve(eq,[t u],guess);
plot(rx(solution.t),ry(solution.t),'k.','markersize',20); % plot R(t) at Pn
plot(sx(solution.u),sy(solution.u),'g.','markersize',15); % plot S(u) at Pn
end
xlabel('r_x(t) ~ s_x(u)');
ylabel('r_y(t) ~ s_x(u)');
xlim([12.15603 12.15897])
ylim([1.078214 1.078684])
  2 个评论
Simon Chan
Simon Chan 2021-8-14
Just wondering why the marker colors are not black and green on the plot for the following code?
plot(rx(solution.t),ry(solution.t),'k.','markersize',20); % plot R(t) at Pn
plot(sx(solution.u),sy(solution.u),'g.','markersize',15); % plot S(u) at Pn
Simon Le Serve
Simon Le Serve 2021-8-14
编辑:Simon Le Serve 2021-8-14
hey Simon, thanks you're right!
Not sure though, must have not executed on last edit.
you have a sharp eye!

请先登录,再进行评论。

采纳的回答

John D'Errico
John D'Errico 2021-8-14
编辑:John D'Errico 2021-8-14
Your probem is when you zoomed in. The mathematics seems fine.
>> tn
tn =
11.4745470305524
>> un
un =
12.1681063167797
>> vpa(rx(tn))
ans =
24.724031702281097750999349300293
>> vpa(sx(un))
ans =
24.72403170228109712971250329995
>> vpa(ry(tn))
ans =
1.0782644793999382387376598972632
>> vpa(sy(un))
ans =
1.0782644793999394359320615865557
The MATLAB zoom is not very accurate, not when you zoom in that deeply. It does not re-evaluate those curves, and then give you a hyper-accurate picture. Instead, it gives you a literally microscopic view of the pixels that were plotted.
The numbers are correct. Just that the zoom has confused you.
  3 个评论
John D'Errico
John D'Errico 2021-8-14
No. You are mistaken. You set the limits AFTER you created the plot. The very last thing you did was:
xlim([12.15603 12.15897])
ylim([1.078214 1.078684])
Let me be more careful in how the plots are created.
tn
tn =
11.4745470305524
un
un =
12.1681063167797
fplot(rx(t),ry(t),[11.474 11.475],'b');
hold on
fplot(sx(u),sy(u),[12.168 12.169],'r');
plot(rx(solution.t),ry(solution.t),'k.','markersize',20); % plot R(t) at Pn
plot(sx(solution.u),sy(solution.u),'g.','markersize',15); % plot S(u) at Pn
The intersection of the curves is now seen to be accurately placed.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by