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

In summary, You are a summer trainee working on a Fortran program that calculates torsional potential. You need to convert 3 input parameters to 7 parameters for the program using a power series expansion. The cos function can be expanded around any point, including a = 0, and the number of terms in the expansion depends on the desired approximation. Your professor mentioned that power series may have infinite terms, but in some cases, there may be finite terms with the rest being 0. The expansion around -phi will result in an infinite series, but this is acceptable since trig functions cannot be reduced to polynomials. You will need to use root finding algorithms to solve for Q, which will then be applied in the torsion equation
  • #1
shitij
19
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
  • #2
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).
 
  • #3
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 !
 
  • #4
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.
 

1. What is the purpose of converting K(1+cos(nQ-phi)) to a power series?

The purpose of converting K(1+cos(nQ-phi)) to a power series is to simplify the expression and make it easier to work with. Power series are useful in mathematics and science because they allow for more efficient calculations and can provide insight into the behavior of a function.

2. How do you create a program to convert K(1+cos(nQ-phi)) to a power series?

To create a program to convert K(1+cos(nQ-phi)) to a power series, you will need to use a combination of mathematical principles and coding techniques. This may include understanding the properties of power series, utilizing programming languages such as Python or Java, and implementing algorithms to perform the conversion.

3. Can this conversion be done manually without a program?

Yes, it is possible to manually convert K(1+cos(nQ-phi)) to a power series. However, depending on the values of K, n, and phi, it can be a tedious and time-consuming process. Using a program can save time and reduce the possibility of human error.

4. What are some potential applications of this conversion?

This conversion can be useful in various fields such as physics, engineering, and signal processing. It can help in analyzing and understanding the behavior of periodic functions, modeling physical systems, and designing filters for signal processing applications.

5. Are there any limitations to this conversion method?

One limitation of this conversion method is that it may not work for all values of K, n, and phi. There may be certain values that result in infinite or undefined power series. Additionally, the accuracy of the power series approximation may depend on the number of terms used in the series, so it may not always be an exact representation of the original function.

Similar threads

Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
605
  • Engineering and Comp Sci Homework Help
Replies
9
Views
1K
  • Calculus and Beyond Homework Help
Replies
11
Views
2K
Replies
3
Views
546
  • Quantum Physics
Replies
3
Views
989
  • Calculus and Beyond Homework Help
Replies
6
Views
2K
Replies
2
Views
1K
Back
Top