MATLAB Integrals Homework: Approximating with Cubic Polynomials

  • Thread starter Thread starter fredrick08
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

This discussion focuses on approximating integrals using cubic polynomials in MATLAB, specifically for the Bessel functions J0(x), J1(x), and J2(x). The integral I is approximated by subdividing the interval [a, b] into N intervals and calculating weights w0, w1, w2, and w3 for the function f(x). The provided MATLAB function BJ(x, n) is designed to compute the integral representation of Jn using 100 subdivisions, while a second piece of code generates plots with 2000 subdivisions over the interval [0, 20]. The user seeks assistance in implementing this approach effectively.

PREREQUISITES
  • Understanding of numerical integration techniques
  • Familiarity with MATLAB programming
  • Knowledge of Bessel functions and their properties
  • Basic concepts of polynomial interpolation
NEXT STEPS
  • Research "Cubic Polynomial Interpolation in MATLAB"
  • Learn about "Numerical Integration Techniques" such as Simpson's Rule
  • Explore "Bessel Functions and Their Applications" in MATLAB
  • Investigate "MATLAB Plotting Functions" for visualizing data
USEFUL FOR

This discussion is beneficial for students and professionals in mathematics, engineering, and computer science who are working with numerical methods in MATLAB, particularly those interested in integral approximations and Bessel functions.

fredrick08
Messages
374
Reaction score
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
anyone?
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K