For Programmers: Free Programming Magazines  


Home > Archive > Matlab > January 2008 > How to solve cosine function









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to solve cosine function
Melvin

2008-01-31, 8:28 pm

The cosine function can be evaluated by the following
infinite series:

cos x = 1 – [x^2 / 2!] + [x^4 / 4!] – [x^6 / 6!] ……

I need to write a Matlab function to implement this formula
so that it computes and prints out the values of cos(x) as
each term in the series is added. In other words, compute
and print in sequence the values for:

cos x = 1
cos x = 1 - [x^2 / 2!]
cos x = 1 - [x^2 / 2!] + [x^4 / 4!]


Walter Roberson

2008-01-31, 8:28 pm

In article <fnt7af$fuj$1@fred.mathworks.com>,
Melvin <melvin1974@mathwoks.com> wrote:
>The cosine function can be evaluated by the following
>infinite series:


>cos x = 1 – [x^2 / 2!] + [x^4 / 4!] – [x^6 / 6!] ……


Well, at least you are getting closer to the right formula,
though I still don't know what ampersand numbersign 8 2 1 1 semi-colon
is. You should use plain text in postings, not Unicode characters.


>I need to write a Matlab function to implement this formula
>so that it computes and prints out the values of cos(x) as
>each term in the series is added. In other words, compute
>and print in sequence the values for:


>cos x = 1
>cos x = 1 - [x^2 / 2!]
>cos x = 1 - [x^2 / 2!] + [x^4 / 4!]


Okay, so what have you got so far? The only difference between
your posting now and your original posting is that you have fixed
up the ! (factorial indicator). What have you tried in the
meantime, and what problems have you had?

It seems clear that you are working on an assignment, and
the complete program is quite short (61 characters excluding
the function heading) so if we say much at all we would have
given away too much for you to have learned how to do the
assignment for yourself.
--
This is a Usenet signature block. Please do not quote it when replying
to one of my postings.
http://en.wikipedia.org/wiki/Signature_block
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com