?
Solved

FORTRAN - Neville's algorithm

Posted on 2004-11-07
7
Medium Priority
?
2,380 Views
Last Modified: 2013-11-08
Hello! Don't see a Fortran Language topic so I'm posting here! Soo
I'm Having a lil' problem here ... Trying to write a good Interpolation module using Neville's algorithm and it just seems like I can't  get a good interpolation for the function 1/sin(x).
Anyone have any ideas how to make an alternative subroutine or maybe what's wrong with mine? I'm posting here mine.
I know that interpolation 1/sin(x) is tricky beacuse the function has breaks around 0, pi, and 2 pi, but nevertheles
the numbers I'm getting have no sense
I'm trying to interpolate with 10th order polinomial and trying to interpolate 30 equidistant points in interval (0, 2*pi)
and all I'm getting out are really wierd numbers ... am I doing something wrong?
Please Help ...

======================================
   SUBROUTINE Neville(A, B, xm, xt, res, err)
       REAL, dimension(:), intent( in ) :: A, B
     REAL, intent( in ) :: xt
     REAL, intent( out ) :: res, err
       INTEGER, intent ( in ) :: xm
     REAL, dimension(xm) :: P
       INTEGER j,k
     P(:) = B(:)
       DO j=1, xm
          DO k=1, xm - j
               P(k)=((xt - A(k+j)) * P(k) + (A(k)-xt) * P(k+1))/(A(k)-A(k+j))
            END DO
       END DO
       res=P(1)
       err=P(1)-P(2)
       return

   END SUBROUTINE Neville
0
Comment
Question by:Physicistm
  • 4
  • 2
7 Comments
 
LVL 3

Author Comment

by:Physicistm
ID: 12519636
Ohh yes by the way ... It's Fortran 90!!
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 12519818
Have a look to this page:
http://www.haoli.org/nr/bookfpdf/f3-1.pdf
0
 
LVL 3

Author Comment

by:Physicistm
ID: 12520265
Numerical Recipes is actually a book from where I study numerical methods..
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 31

Expert Comment

by:moorhouselondon
ID: 12521427
I note that you are starting your counters at 1.  According to the following link, the algorithm was intended to be started from index 0, and suggests that if one wishes to start from 1, then of course adjustment to the boundary conditions at the top needs to be made.

http://www.cs.uaf.edu/~bueler/nevM.htm

If that's not the issue (I've only glanced at the coding), then let us know
0
 
LVL 31

Assisted Solution

by:moorhouselondon
moorhouselondon earned 500 total points
ID: 12521448
The link cited by jaime_olivares uses 1-based indexing, so I think my initial thought is wrong.
0
 
LVL 3

Author Comment

by:Physicistm
ID: 12526395
Basicly with my Subroutine I get the same results as with the one written in Numerical Recipes F77, but I0m curious can someone test my subroutine with the function 1/sin(x) and others ... I mean write a main program and tell me their experience?... Have I really done something wrong or do the results really look that odd as mines.

moorhouselondon:
Unlike C or C++, Fortran starts it's counters(indexes) for Arrays with number 1 not 0. for example Array[1] is actually the first member of the array, not the second like in C or C++ .. like I said
0
 
LVL 3

Author Comment

by:Physicistm
ID: 12599267
Figuered thatone out ... the main problem was the function that I was trying to interpolate ... soo the algorithm is basicly ok! But the function is not! :((

Thanx for trying guys!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Loops Section Overview
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question