Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Problem in fortran prg

  1. Jan 7, 2010 #1
    hi all,

    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 im getting as
    a = -16.2156696
    b = -1.78127503
    c = 0.496948689

    can somebody plz plz help me to find out the problem

    here i have attached the prg

    thank you,

    Attached Files:

    • fit.txt
      File size:
      3.7 KB
  2. jcsd
  3. Jan 7, 2010 #2


    User Avatar
    Science Advisor

    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.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook