![]() |
|
#1
|
|||
|
|||
Computing infinite series on pythonPlease I have problem writing a function that returns the cosine of a number with the aid of an infinite series, cos x = 1 − x2⁄2! + x4⁄4! − x6⁄6! + …
The program is meant to collect two arguments; n, number of terms and x, the number. writing the factorial function wasn't a problem for me. The infinite series one, is just slapping me |
|||
|
#2
|
|||
|
|||
Re: Computing ininite series on pythonQuote:
I would not actually use the factorial function. My method would be build the terms as you go. Note that only even-numbered terms of the Taylor series are non-zero So, for example the sum of first few terms looks like Code:
After the first term, here's the ticket:
Here's an approach Code:
Typical result (for 0.5 radians): Code:
Regards, Dave |
Recent GIDBlog
Once again, no time for hobbies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Python - Need help with time card script/wage calculator | sigkill9 | Python Forum | 5 | 12-Mar-2008 22:01 |
| Neutral Python book - the Quest for the Impossible? | Kimmo | Python Forum | 1 | 04-Aug-2007 13:56 |
| Looking for opinions | crystalattice | Miscellaneous Programming Forum | 6 | 27-Sep-2006 22:02 |
| Re: Beginning Python Tutorial (Part 5) | crystalattice | Python Forum | 0 | 04-Oct-2005 05:27 |
| Re: Beginning Python Tutorial (Part 2) | crystalattice | Python Forum | 2 | 31-Jul-2005 13:25 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The