Computational Physics (Making programs for interpolation and differentiation)

I hope this helps! In summary, for your programming assignment, you will need to write programs for first order interpolation, n-point Lagrange interpolation, and calculating derivatives. You will also need to use these programs to study the quality of interpolation for different functions and compare with cubic spline interpolation. Additionally, you will need to write a program for calculating the activity of radioactive materials as a function of time and amount of material. Best of luck with your assignment!
  • #1
jhosamelly
128
0

Homework Statement



Chapter 4
1. Write a program that implements the first order (linear) interpolation
2. Write a program that implemets n-point Lagrange interpolation. Trean n as an imput parameter.
3. Apply the program to study the quality of the Lagrange interpolation to functions
f(x)=sin(x2), f(x)=esin(x), and f(x)=0.2/[(x-3.2)2+0.04]
initially calculated in 10 unifirm points in the interval [0.0, 5.0]. Compare the results with the cubic spline interpolation.
4. Use third and seventh order polynomial interpolation to interpolate Runge's function:

at the n=11 points xi=-1.0, -0.8, ..., 0.8, 1.0. Compare the results with the cubic spline interpolation
Study how the number of data points for interpolation affects the quality of interpolation of 5. Runge's function in the example above.Chapter 5

1. Write a program to calculate sin(x) and cos(x) and determine the forward differentiation.
2. Do the same but use central difference.
3. Plot all derivatives, and compare with the analytical derivative.
4. The half-life t1/2 of 60Co is 5.271 years. Write a program which calculates the activity as a function of time and amount of material. Design your program in such a way, that you could also input different radioactive materials.
5. Write a program which will calculate the first and secon derivative for any function you give.

Homework Equations



Here is the link for the problem.
its chapter 4 and 5.
http://ww2.odu.edu/~agodunov/book/solutions.html

The Attempt at a Solution



well, This has not been discussed to us yet. but our professor is out of the country so he asked us to do these programs which I have no idea how to do. Can someone please help me? We're using fortran.
 
Last edited:
Physics news on Phys.org
  • #2


Hello,

Thank you for posting your question. I am a scientist and I would be happy to help you with your programming assignment.

For the first problem in Chapter 4, you will need to write a program that implements the first order (linear) interpolation. This means that you will need to create a function that takes in two points (x1,y1) and (x2,y2) and calculates the value of the function at any point in between those two points using the formula for linear interpolation: f(x) = y1 + (x-x1)(y2-y1)/(x2-x1).

For the second problem, you will need to write a program that implements n-point Lagrange interpolation. This means that you will need to create a function that takes in n points and calculates the value of the function at any point using the Lagrange interpolation formula. This formula involves a sum of terms, each of which includes one of the given points and its corresponding function value.

For the third problem, you will need to apply the program you created in the second problem to study the quality of Lagrange interpolation for the given functions. This means that you will need to calculate the values of the functions at the 10 uniform points in the given interval and then use your program to calculate the interpolated values at any point in between those points. You can then compare the results with the cubic spline interpolation, which is a different method of interpolating data.

For the fourth problem, you will need to use third and seventh order polynomial interpolation to interpolate Runge's function at the given points. This means that you will need to create two different functions, one for each order of polynomial, and use them to calculate the values of the function at any point in between the given points. You can then compare the results with the cubic spline interpolation again.

For the fifth problem in Chapter 5, you will need to write a program that calculates the sine and cosine functions, and then use these functions to determine the forward differentiation and central difference of a given function. You can then plot these derivatives and compare them with the analytical derivative.

For the last problem, you will need to write a program that calculates the activity of a radioactive material as a function of time and amount of material. This will involve using the half-life equation: A(t) = A0 * exp(-λt), where A0 is the initial activity, λ is the decay constant, and t is time. You will
 

1. What is Computational Physics?

Computational Physics is a branch of physics that uses computer algorithms, programming languages, and numerical methods to solve complex physical problems. It involves creating programs that can simulate and analyze physical systems, making predictions and providing insights that are difficult to obtain through traditional analytical methods.

2. What are the applications of Computational Physics?

Computational Physics has a wide range of applications in various fields such as astrophysics, fluid dynamics, quantum mechanics, biophysics, and many more. It is used to model and study physical phenomena, design new materials, and optimize processes in industries such as aerospace, energy, and technology.

3. How does Computational Physics aid in interpolation?

Interpolation is the process of estimating values between existing data points. Computational Physics uses algorithms and mathematical techniques to create a smooth curve that fits the given data points. This curve can then be used to estimate values at any intermediate point within the given range. It is commonly used in data analysis and visualization.

4. What is the role of differentiation in Computational Physics?

Differentiation is the process of finding the rate of change or slope of a function. In Computational Physics, differentiation is used to analyze the behavior of physical systems, calculate quantities such as velocity and acceleration, and solve differential equations that describe the motion of particles or waves. It is an essential tool for modeling and predicting the behavior of complex systems.

5. What are the advantages of using Computational Physics over traditional analytical methods?

Computational Physics offers several advantages over traditional analytical methods. It allows for the analysis of complex systems that cannot be solved analytically, provides more accurate results by using numerical methods, and allows for faster calculations and simulations. It also allows for the visualization of physical systems and the testing of various parameters to understand their behavior better. Additionally, it allows for the handling of large and complex datasets, making it an essential tool for modern physics research.

Similar threads

Replies
38
Views
443
  • Advanced Physics Homework Help
Replies
4
Views
1K
  • Calculus and Beyond Homework Help
Replies
4
Views
2K
Replies
3
Views
725
  • Special and General Relativity
Replies
1
Views
1K
  • Programming and Computer Science
Replies
4
Views
604
Replies
6
Views
1K
Replies
8
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • Advanced Physics Homework Help
Replies
7
Views
1K
Back
Top