473,405 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Writing C code for sin(x) using taylor series

I am trying to write C code for sin(x) using the first 5 terms of the taylor series. I am new to programming and am not allowed to use loops. I don't have much yet, but what I have so far is:

Expand|Select|Wrap|Line Numbers
  1. /* solution to Taylor Series approximation of sin(x) */
  2. #include <stdio.h>
  3. #define PI 3.1416f
  4.  
  5. int main ()
  6. {
  7. float x_deg;
  8. float x;
  9. float sinx;
  10.  
  11. /*enter the angle "x_deg in degrees"*/
  12. printf ("Enter x_deg:");
  13. scanf ("%f, %x_deg);
  14.  
  15. x=x_deg*PI/180;
  16.  
I am not really sure where to go from here. I am a little confused about how to implement the taylor series to calculate sin(x). Any help would be appreciated, thanks.
Feb 4 '11 #1
1 8940
Banfa
9,065 Expert Mod 8TB
Perhaps you had better explain how the Taylor series is calculated, or rather what it is you want to calculate. We ar code gurus not maths gurus :D

You seem to have used the type float in your program but normally we would advise anyone using floating point types to use double unless they have a good and communicable reason why they need to use float.
Feb 4 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Prashanth Ellina | last post by:
Hi, I need to write some data to an xml file. I have an XML Schema defined. I would like to use some mechanism of writing the data to the xml file and having exceptions thrown back to me when...
0
by: Andrius | last post by:
Hello, having some problems by writing XML file by XML schema. using strongly typed datasets. Schema: <?xml version="1.0" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">...
1
by: Slimo | last post by:
Hello, Can someone post a sample code for ASP.NET using WMI (retrieve harddisk space, network card name,...) no matters I just need an example to see how it works. I prefer code using VB. Thanks
5
by: oz | last post by:
Hi, Where can i find code examples of connecting with MQ from VB.net(not using msmq bridge) BR Oz --- Outgoing mail is certified Virus Free.
5
by: Lyle | last post by:
How do get a line control on the end of a line using the streamwriter.writeline (not carriage line control)? How do you get the following command to print a quote in the file? I have tried using...
1
by: Monty | last post by:
Hi, I am using Access for a back-end database. I can't use the automated updating provided for SQL databases, so I need some assistance in writing the code that does the actual updating, deleting...
2
by: chb1980 | last post by:
this is a question..about Taylor series... 1) Find the Taylor series approximation of order 2 (n=2) for the funtion f(x,y)=sin(xy) about (x。,y。)=(π/4,π/4) using this approximation , compute the...
2
by: chb1980 | last post by:
this is a question..about Taylor series... 1) Find the Taylor series approximation of order 2 (n=2) for the funtion f(x,y)=sin(xy) about (x。,y。)=(π/4,π/4) using this approximation , compute the...
1
by: srivatsa86 | last post by:
HI i am doing a project of voice recognition.can anyone give me an c code for voice recording using microphone.. thanks a lot
1
by: arperidot | last post by:
hey guys, the question asks to Scan the angle in degrees using x=PI*x_deg/180 and calculate Y=sin^2(x). Calculate sin^2(x) approximately by using n terms (n>0) the Taylor series sin(x)=Sum (k...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.