Solving Collocation Problems with Cubic Polynomial Approximations

  • Thread starter squenshl
  • Start date
  • Tags
    Matlab
In summary, Matlab is a high-level programming language and interactive environment used for scientific and technical computing. It can be used to solve problems by writing scripts or using built-in functions and toolboxes. It is also suitable for data analysis and visualization, as well as machine learning and deep learning. To improve skills in using Matlab, there are various resources available such as online tutorials, official documentation, and courses or workshops.
  • #1
squenshl
479
4

Homework Statement


Approximate y by a cubic polynomial on each of the sub-intervals [0,1/2] & [1/2,1] and then solve the collocation problem.
Approximate y by a cubic polynomial on each of the sub-intervals [0,1/4], [1/4,1/2], [1/2,3/4], [3/4,1] and then solve the collocation problem.


Homework Equations





The Attempt at a Solution


I have written the files below. Also:

function yp = f(x,y)
yp = 3/2*y.^2;

The fd_jac(x) file as in my other example.

I have an example of a function y = r(a)

function y = r(a)
x = [0.2 0.4 0.6 0.8]';
x0 = 0; xf = 1;
y0 = 4; yf = 1;

length(a)
y(1) = y0 - p(a,x0);
y(2:5) = ppp(a,x) - f(x,p(a,x));
y(6) = yf - p(a,xf);

y = y';

Please help.
 

Attachments

  • Collocation.m
    812 bytes · Views: 358
  • p.m
    116 bytes · Views: 360
  • ppp.m
    89 bytes · Views: 347
Physics news on Phys.org
  • #2


Hi there,

Thank you for your forum post. It seems like you are working on solving a collocation problem using a cubic polynomial approximation. In order to solve this problem, you will need to follow a few steps:

1. Divide the interval [0,1] into smaller sub-intervals. In your first attempt, you have divided it into two sub-intervals [0,1/2] and [1/2,1]. In your second attempt, you have divided it into four sub-intervals [0,1/4], [1/4,1/2], [1/2,3/4], [3/4,1].

2. Approximate y by a cubic polynomial on each sub-interval. This means that for each sub-interval, you will have to find the coefficients of a cubic polynomial that best fits the data points.

3. Solve the collocation problem. This involves using the cubic polynomial approximation to solve a system of equations. The equations will be based on the boundary conditions and the continuity of the polynomial at the points where the sub-intervals meet.

I see that you have already written the files for the function and the fd_jac(x). Now, you will need to write a function for the cubic polynomial approximation. You can use the polyfit function in MATLAB to find the coefficients of the polynomial that best fits the data points.

Once you have the coefficients, you can use them to solve the system of equations in the collocation problem. This will give you the values of y at the points where the sub-intervals meet, which will then allow you to plot the cubic polynomial approximation for the entire interval [0,1].

I hope this helps. Good luck with your work!
 

FAQ: Solving Collocation Problems with Cubic Polynomial Approximations

1. What is Matlab and what is it used for?

Matlab is a high-level programming language and interactive environment used for scientific and technical computing. It allows users to manipulate, visualize, and analyze data, as well as create and run complex algorithms and models.

2. How do I solve a problem using Matlab?

To solve a problem using Matlab, you can write a script or function that contains the necessary commands and algorithms. You can also use the built-in functions and toolboxes to assist with your problem-solving.

3. Can Matlab be used for data analysis and visualization?

Yes, Matlab has powerful data analysis and visualization capabilities. It allows users to import, clean, and manipulate large datasets, as well as create various types of plots and charts to visualize the data.

4. Is Matlab suitable for machine learning and deep learning?

Yes, Matlab has a dedicated Machine Learning and Deep Learning Toolbox that provides tools and functions for developing and implementing machine learning and deep learning algorithms. It also offers prebuilt models and algorithms for various applications.

5. How can I learn Matlab and improve my skills?

There are many resources available for learning Matlab, including online tutorials, official documentation, and community forums. You can also enroll in courses or workshops to further develop your skills and knowledge in using Matlab for scientific and technical computing.

Back
Top