Solving Problem in Fortran Program - Bevington Polyfit.f

  • Fortran
  • Thread starter akila
  • Start date
  • Tags
    Fortran
In summary, the conversation discusses a problem with fitting a 2nd order polynomial using a FORTRAN program from the library "bevington--- polfit.f". The person is getting incorrect coefficients when using their own data and is seeking help to identify the issue. They also mention using compiler options and the lack of an IMPLICIT NONE statement. The conversation ends with a suggestion to refer to the library's documentation for clarification on variables.
  • #1
akila
1
0
hi all,

greetings,
i have a fortran prg to fit 2nd order polynomial to my data
taken from (bevington--- polfit.f)

i'm making some mistake, and i could not find what is the problem with this.
When i give some other other random data it is fitting properly
but not the data i have :(
for y = a + bx + cx^2 i should get the coefficients to be

a = 1.4558380406304288E+03
b = -3.6779173737460803E+02
c = 2.3247378080674739E+01

but I am getting as
a = -16.2156696
b = -1.78127503
c = 0.496948689


can somebody please please help me to find out the problem

here i have attached the prg

thank you,
regards,
akila
 

Attachments

  • fit.txt
    3.7 KB · Views: 426
Technology news on Phys.org
  • #2
Firstly, you can enclose code directly into the forum by using the CODE tags.

OK, what compiler options have you used? I notice that you don't include an IMPLICIT NONE statement. wt is not defined as an array, how does the implicit declaration work for arrays?

If you got polfit from some sort of library, then your inputs are probably wrong. Also, go back to that library's documentation and make sure you know what all those variables are. For example, the variable MODE in the subroutine isn't crystal clear to me.
 
  • #3


Hello Akila,

Thank you for reaching out for help with your Fortran program. It sounds like you are trying to fit a 2nd order polynomial to your data using the Bevington method. I understand that you are experiencing some difficulties with the program and are not getting the expected results.

Firstly, it is important to make sure that your data is properly formatted and in the correct units for the program to work correctly. Double check that your data is in the same format as the example data in the Bevington method and that the units are consistent. This could be a common mistake that can cause incorrect results.

Another possibility is that there may be a mistake in the code itself. I would recommend going through the program line by line and double checking each step to ensure that it is performing the intended function. It may also be helpful to compare your code to other examples of the Bevington method to see if there are any differences or missing steps.

If you are still having trouble finding the issue, it may be helpful to seek out a colleague or fellow programmer who is familiar with Fortran to review your code and provide some insight. It can also be helpful to take a break and come back to the problem with fresh eyes. Sometimes a new perspective can help identify the problem.

I hope this helps and that you are able to successfully solve the problem with your Fortran program. Best of luck to you.

Sincerely,
 

1. What is Fortran and how is it used in solving problems?

Fortran is a high-level programming language commonly used for scientific and numerical computation. It is particularly well-suited for solving complex mathematical problems and is often used in fields such as physics, engineering, and finance.

2. What is the Bevington Polyfit.f program and how does it work?

The Bevington Polyfit.f program is a Fortran program that performs polynomial curve fitting using the Bevington method. This method uses the least squares approach to fit a polynomial curve to a set of data points, minimizing the sum of squared errors between the curve and the data. The program takes in the data points as input and outputs the coefficients of the best-fit polynomial curve.

3. How accurate is the Bevington Polyfit.f program?

The accuracy of the Bevington Polyfit.f program depends on the quality and quantity of the input data. Generally, the more data points that are used, the more accurate the results will be. However, it is important to note that the program is only as accurate as the data provided, so it is crucial to ensure the data is reliable and representative of the problem being solved.

4. Are there any limitations to the Bevington Polyfit.f program?

Like any program, the Bevington Polyfit.f program has its limitations. One limitation is that it can only fit polynomial curves and may not be suitable for other types of data. Additionally, the program relies on the user to provide accurate and appropriate input data. If the data is not well-suited for polynomial curve fitting, the results may not be accurate.

5. Can the Bevington Polyfit.f program be modified for different purposes?

Yes, the Bevington Polyfit.f program can be modified to fit different types of polynomial curves or to solve other types of problems. The code can be edited to change the number of data points, the degree of the polynomial curve, or other parameters to fit the specific needs of the problem at hand. However, it is important to have a solid understanding of Fortran programming and the Bevington method before attempting to make modifications to the program.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
9
Views
1K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
17
Views
4K
  • Programming and Computer Science
Replies
22
Views
4K
  • Programming and Computer Science
Replies
4
Views
3K
  • Programming and Computer Science
Replies
20
Views
5K
  • Programming and Computer Science
Replies
2
Views
2K
  • Programming and Computer Science
Replies
13
Views
4K
  • Programming and Computer Science
Replies
5
Views
10K
Back
Top