Making a program to convert K(1+cos(nQ-phi)) to a power series

Click For Summary

Discussion Overview

The discussion revolves around converting the equation K(1+cos(nQ-phi)) into a power series for use in a Fortran program designed to calculate torsional potential. Participants explore the mathematical foundations of power series, specifically Taylor and Maclaurin series, and the implications of truncating these series for practical applications.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant seeks guidance on how to convert three parameters (K, n, phi) into seven parameters required by their program for the torsional potential equation.
  • Another participant explains that the choice of expansion point in Taylor series affects convergence properties and suggests that expanding around a = 0 simplifies calculations.
  • A participant expresses confusion regarding the number of terms to consider in a power series, noting their professor's comment that many cases have finite terms, yet they are obtaining an infinite series when expanding around Q=0.
  • There is a suggestion that the correlation between "n" and the number of non-zero terms in the power series may be relevant, and a question about whether Maclaurin series and power series are equivalent.
  • One participant indicates that an infinite power series expansion is expected for the nQ term, and suggests that a finite approximation could be achieved by truncating the series to a seventh-degree polynomial.
  • Discussion includes the mention of using numerical techniques, such as the Newton-Raphson method, for solving the polynomial approximation derived from the Taylor series.

Areas of Agreement / Disagreement

Participants express differing views on the nature of the power series expansion, particularly regarding the number of terms and the conditions under which the series can be truncated. There is no consensus on how to approach the conversion of parameters or the specifics of the series expansion.

Contextual Notes

Participants highlight the importance of the choice of expansion point and the implications for convergence and truncation, but there are unresolved questions about the relationship between the parameters and the resulting series.

shitij
Messages
19
Reaction score
0
Hi all !

I am a summer trainee and am currently making (modifying: I am changing the way the program takes input) a program in Fortran, and my math is a little shaky.
What I have is an input file with 3 parameters in it for the equation (which is the equation for calculating torsional potential):

K (1+cos(nQ-phi))

The parameters given to me are: K, n and phi.

Now the program takes 7 parameters for this equation which are the prefactors for the corresponding power series (it does it that way because calculating double differential is easier then).
So, I have to convert the given 3 parameters to the 7 parameters that the programs wants.
How do I do that?

I looked at the taylor series expansion on wikipedia, but I am not sure what I should expand this against. Is power series = maclaurin series? So I have to expand this around a=0?

Thanks !
 
Physics news on Phys.org
Hey garbageij and welcome to the forums.

The major use for having different points to expand around in taylor series relates to having convergence properties in some neighborhood of the point you are expanding around.

If you know the function is defined everywhere, converges everywhere and is differentiable everywhere, then you can use any point you want.

In terms of the neighbourhood, the reason why people might want to use different points of expansion is because you may want to get an approximation to a point 'close' to the one you are expanding around and because it's close, a lot of the derivative terms (especially the higher ones) can be ignored to give a good approximation.

Since the cos function is defined everywhere, converges everywhere, and is differentiable everywhere, you can use whatever point of expansion you wish including a = 0. In fact, using a = 0 makes things a lot easier in terms of the algebra and calculation (i.e. you have x^n instead of something like (x-a)^n for some non-zero a).
 
Thank you for your reply chiro !

Hmm...actually I asked my prof that "From what I understand, power series have infinite terms, so how many terms shall I consider?" (where should I truncate it)
He replied "Not necessarily. In many cases (like this one) it has finite terms and rest of the terms are just 0" Then he gave me an example of cos(2x)=2cos^2(x)-1. (I don't remember exactly, but I think this is somewhat what he said)

The thing is, that when I am expanding it around Q=0, I am not getting finite terms (like he said I should). Like I am getting terms like:
0 + n*K*sin(phi)*Q/1! - n2*K*cos(-phi)*Q2/2!-n3*K*sin(phi)*Q3/3! + ...

This will go on forever, right? Am I doing something wrong? I feel there should be some correlation between "n" and the number of non-zero terms in the power series. Also he always mentioned the term power series, is mclaurin series=power series?

Thanks !
 
garbageij said:
Thank you for your reply chiro !

Hmm...actually I asked my prof that "From what I understand, power series have infinite terms, so how many terms shall I consider?" (where should I truncate it)
He replied "Not necessarily. In many cases (like this one) it has finite terms and rest of the terms are just 0" Then he gave me an example of cos(2x)=2cos^2(x)-1. (I don't remember exactly, but I think this is somewhat what he said)

The thing is, that when I am expanding it around Q=0, I am not getting finite terms (like he said I should). Like I am getting terms like:
0 + n*K*sin(phi)*Q/1! - n2*K*cos(-phi)*Q2/2!-n3*K*sin(phi)*Q3/3! + ...

This will go on forever, right? Am I doing something wrong? I feel there should be some correlation between "n" and the number of non-zero terms in the power series. Also he always mentioned the term power series, is mclaurin series=power series?

Thanks !

You should get an infinite power series expansion for your nQ term (I'm assuming you are expanding the series around -phi, so this is OK because the trig functions are infinite-power series and in general, can not be reduced down to polynomials.

I'm guessing (and you would have to check this) is that you want n terms (in your case possibly seven) which is a good enough approximation to work with so that you will get a seventh degree polynomial for Q which you can solve using numerical techniques. You can then take this Q and simply apply it your application (i.e. torsion).

The equation to find f(Q) (i.e the taylor series approximation you calculated) = 0 can be solved using what is known as a root finding algorithm like Newton-Rhapson, which requires the derivative. Given that you have a polynomial approximation, the derivative is easy to find using term by term differentiation.
 

Similar threads

Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 17 ·
Replies
17
Views
5K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K