MATLAB Integrals Homework: Approximating with Cubic Polynomials

  • Thread starter fredrick08
  • Start date
  • Tags
    Matlab
In summary, the conversation discusses finding an approximation for an integral using subintervals and weights. It also includes instructions for plotting Bessel functions using MATLAB. The function BJ(x, n) is given as an example for implementing the method and producing the required plots. The conversation also mentions the lack of experience in programming and requests for assistance.
  • #1
fredrick08
376
0

Homework Statement


Let us consider an approximation to an integral. Let f(x) be some continuous function on
[a, b]. We wish to find an approximation for the integral
I = int from a to b of f(x)dx
in the following manner:
Subdivide the interval into N intervals of length h = (b−a)/N. Let xi = ih for i = 0, . . . ,N.
Let
Ij = int from 0 to h of f(xj+t)dt

Find a cubic polynomial Pj (x) that goes through (xj , f(xj)), (xj + h/3,f(xj + h/3)),(xj+2h/3, f(xj+2h/3) and (xj+1,f(xj+1))
We form an approximation for the integral by letting
I=sum(j=0 to N-1) of w0*f(xj)+w1*f(xj+h/3)+w2*f(xj+2h/3)+w3*f(xj+1)
Find these weights, wi.
In 2 peices of code, plot the first three Bessel functions, J0(x), J1(x) and J2(x), on the
interval [0, 20]. The first piece of code should be a MATLAB function BJ(x, n) outputing
the approximation for the integral representation of Jn, given by
Jn(x) =(1/pi)int from 0 to pi of cos(nt − x sin t)dt
using the above method for 100 subdivisions of [0, pi]. The second piece of code should call
the function an produce the required plots with 2000 subdivisions of [0, 20].

Im just gobsmacked with this qn.. as i only started using MATLAB a couple of days, ago and have no programming experience.

what i have done so far is really no good, but i have no idea.

function [Jn]=BJ(x,n)
N=100;
b=pi;
a=0
h=(b-a)/N;
x=a:h:b;
xj=i*h;
Ij=0;
J0=cos(n*xj-x*sin(xj));
J1=cos(n*(xj+h/3)-x*sin(xj+h/3));
J2=cos(n*(xj+(2*h/3))-x*sin(xj+(2*h/3)));
J3=cos(n*(xj+1)-x*sin(xj+1));
for i=0:N;
Ij=Ij+w0*J0+w1*J1+w2*J2+w3*J3;
J=(1/pi)*Ij;
end

can someone please help me
 
Physics news on Phys.org
  • #2
anyone?
 

FAQ: MATLAB Integrals Homework: Approximating with Cubic Polynomials

What is MATLAB Integrals Homework?

MATLAB Integrals Homework is a programming assignment that involves using MATLAB software to approximate integrals with cubic polynomials. It is commonly assigned to students in math and science courses.

Why do we approximate integrals with cubic polynomials?

Cubic polynomials are used to approximate integrals because they can closely mimic the behavior of more complicated functions. This allows us to get a good estimate of the integral without having to solve it exactly.

How do I complete the MATLAB Integrals Homework?

To complete the homework, you will need to have a basic understanding of MATLAB programming and the use of cubic polynomials. You will also need to follow the instructions given by your instructor and carefully input and run the code provided in the assignment.

What are some tips for successfully completing the MATLAB Integrals Homework?

Some tips for successfully completing the homework include carefully reading and understanding the instructions, checking your code for errors, and testing your results with different functions to ensure accuracy. It is also helpful to reach out to your instructor or classmates for assistance if needed.

What is the purpose of the MATLAB Integrals Homework?

The purpose of the homework is to help students practice and apply their knowledge of MATLAB and approximation techniques to solve integrals. It also helps students develop problem-solving and critical thinking skills, which are important in the field of science.

Similar threads

Back
Top