jagomaniak wrote:
> Could you please be more specific? They told us we needed to convert
> the Taylor series into recursion formula, like this:
> 
> http://tinyurl.com/58anen
> 
> and then it's supposed to be easy from there. Also, I have this
> example guide:
> 
>   double k = 0.0;
>   double item = 1.0; 
>   double sum = item;
> 
>   while(fabs(item) >= eps)
>   {
> 
>     k = k + 2.0;
>     item = (-item*x*x)/(k*(k-1.0));
>     sum = sum + item;
>   }
> 
> The program is run like program -tan epsilon, where epsilon is the
> chosen approximation. Then it waits for the user input in radians.

sin x = x + (-1 * (x^3/3!)) + (1 * (x^5/5!)) + (-1 * (x^7/7!))...

Okay - let's start simple.

1)  Write a program that calculates a factorial.
2)  Then write another program that calculates powers of x.  Basically, 
a lightweight pow() implementation.

When you've written code for both, show us and we can move on.  Although 
I suspect you'll have a pretty good idea of what the next step is at 
that point.

I have no idea why you were told to look for a recursive solution.  A 
linear solution seems much more feasible to me.

BTW, if you are having this much trouble getting started with the first 
line of code, you should be asking your teachers for help/resources. 
Many educational institutions also provide a support infrastructure 
typically comprising of the student body.  Their (typically poorly paid) 
job is to help people like you who are struggling.  I'm saying this so 
that you don't feel like c-prog is your only resource.  It isn't 
shameful to ask for help from the official resources provided by your 
institution.  It does take a bit of bravery and pride-swallowing though.


(And for you nitpickers, I realize my suggested approach to this problem 
is highly inefficient/error-prone with large values/etc.  But the only 
other solution is to provide a solution.  My hope is that through 
actually implementing little pieces of this problem the OP will gain a 
little confidence in themselves to finish it off - and maybe even 
realize a more optimal solution on their own).

-- 
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197

*NEW* MyTaskFocus 1.1
Get on task.  Stay on task.

http://www.CubicleSoft.com/MyTaskFocus/

Reply via email to