{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

ASE 311 Extra Credit - >> yit =-10*exp-2*xi*xi...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ASE 311 Extra Credit 1.) function yia = implementation(xp,yp,xi) n = length(xp)-1; yia = 0; for i = 1 : n + 1 dk1 = yp(i); for k = 1 : n + 1 if (k~=i) dk1 = dk1./(xp(i) - xp(k)); end end yja = 0; for j = 1 : n + 1 if (j~=i) dk2 = 1; for k = 1 : n + 1 if (k~=i && k~=j) dk2 = dk2.*(xi - xp(k)); end end yja = yja + dk2; end end yia = yia + ((dk1).* yja); end >> xp = [ 0.6 1.5 1.6 2.5 3.5 ]; >> yp = [ 0.9036 0.3734 0.3261 0.08422 0.01596 ]; >> xi = linspace(-0.6,3.5,291); >> yia = implementation(xp,yp,xi);
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: >> yit = -10*exp(-2*xi).*xi + 5*exp(-2*xi); >> plot(xi, yia, xi, yit) 0.5 1 1.5 2 2.5 3 3.5-0.7-0.6-0.5-0.4-0.3-0.2-0.1 Lagrange Interpolation Derivative Exact Solution Derivative 2.) >> xp = [ 0.6 1.5 1.6 2.5 3.5 ]; >> yp = [ 0.9036 0.3734 0.3261 0.08422 0.01596 ]; >> xi = linspace(0.6,3.5,291); >> yia = implementation(xp,yp,xi); >> yit= -10*exp(-2*xi).*xi + 5*exp(-2*xi); >> sqrt(trapz(xi, (yia-yit).^2)) ans = 0.0978...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern