c언어 푸는 것 문의합니다.

dudehdznddl의 이미지

#include "stdafx.h"
#define PI 3.141592

void main(void)
{
long int factorial=1;
float y=0.0,y1=1.0,x;
int n,i, sign=1;

printf("x.\n");
scanf("%f",&x);
x *= PI/180.0;
printf("n.\n");
scanf("%d",&n);

for(i=1;i<=n;i++) {
factorial *= i;
y1 *= x;
if(i%2==0) continue;
y += sign*y1/factorial;
sign = -sign;
}
printf("y = %f \n",y);
}

sin x 푸는 것을 cos x로 바꿔서 풀어야 하는데 위의 형식 유지하면서 무엇을 바꾸면 될까요???

shint의 이미지

정확한건 구현하시는분이 아실거 같습니다. ㅇ_ㅇ;; sin x 를 설명하실 수 있다면. cos x 도 설명이 될겁니다.

cos() sin() 정리
http://cfile226.uf.daum.net/media/260BEC3F5517CDA3108D50

값도 확인해보시고. 줄도 맞춰 보십시요. ㅇ_ㅇ;;
http://codepad.org/

#include <stdio.h>
#define PI 3.141592
 
void main(void)
{
    long int factorial=1;
    float y=0.0,y1=1.0,x;
    int n,i, sign=1;
 
    x = 1;
    n = 100;
 
    x *= PI/180.0;
 
    for(i=1;i<=n;i++)
    {
        factorial *= i;
        y1 *= x;
        if(i%2==0) continue;
        y += sign*y1/factorial;
        sign = -sign;
        printf("factorial = %15ld \t", factorial);
        printf("y1 = %15f \t", y1);
        printf("x = %f \t", x);
        printf("sign = %3d \t", sign);
        printf("y = %f \n", y);
    }
 
}
 
factorial =               1 	y1 =        0.017453 	x = 0.017453 	sign =  -1 	y = 0.017453 
factorial =               6 	y1 =        0.000005 	x = 0.017453 	sign =   1 	y = 0.017452 
factorial =             120 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = 0.017452 
factorial =            5040 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = 0.017452 
factorial =          362880 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = 0.017452 
factorial =        39916800 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = 0.017452 
factorial =      1932053504 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = 0.017452 
factorial =      2004310016 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = 0.017452 
factorial =      -288522240 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = 0.017452 
factorial =       109641728 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = 0.017452 
factorial =     -1195114496 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = 0.017452 
factorial =       862453760 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = 0.017452 
factorial =      2076180480 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = 0.017452 
factorial =      1484783616 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = 0.017452 
factorial =     -1241513984 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = 0.017452 
factorial =       738197504 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = 0.017452 
factorial =     -2147483648 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = 0.017452 
factorial =               0 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = nan 
factorial =               0 	y1 =        0.000000 	x = 0.017453 	sign =  -1 	y = nan 
factorial =               0 	y1 =        0.000000 	x = 0.017453 	sign =   1 	y = nan 

이거 cos 무한급수 구현한 소스 같은데. 한번 확인 해보세요.
비쥬얼 C 질문입니다.
http://tip.daum.net/question/3300200

개발자 분에 동의가 필요하지만. 확인용으로 먼저 올려봅니다.

C++ 컴파일러로 확인 가능합니다.
http://codepad.org/

#include <math.h>
 
#ifndef PI
#define PI 3.1415927
#endif
 
/*Cosine 함수 시작*/
double cosine(int degree)
{
    double x=0, term, r;    /* x는 0로 지정해두고 r은 입력받은 정수를 라디안으로 바꾼값을 저장할 변수*/
    int i;                  /*for문을 사용하기위한 변수*/
 
    degree = degree%360;
    degree = (degree<180)?(degree):(degree - 360); // r의 절대값을 1/2 이하로 해 주면 더 빠르게 수렴.
 
    r=degree*2*PI/360;      /*입력받은 정수를 라디안으로 변환*/
 
    /* r*r (r*r)*r*r (r*r*r*r)*r*r
 * cos r = 1 - --- + --------- - ------------- ...
 * 1*2 (1*2)*3*4 (1*2*3*4)*5*6
 */
 
    term = 1;
 
    for(i=0; i<=7; i++)     /* i를 1부터 5까지 1씩 증가시켜 for문 사용 */
    {
        x += term;
        term *= (-1.0)*(r*r)/((2*i+1)*(2*i+2));
    }
    return x;
}
 
int main()
{
    int degree;
    for(degree = 0; degree< 540; degree+=7)
    {
        printf("ncos(%3d) = %f, %f, %f\n"
                , degree
                , cosine(degree)
                , cos(((degree%360)*2*PI/360))
                , cosine(degree)- cos(((degree%360)*2*PI/360)));
    }
 
    return 0;
}
 
ncos(  0) = 1.000000, 1.000000, 0.000000
ncos(  7) = 0.992546, 0.992546, 0.000000
ncos( 14) = 0.970296, 0.970296, 0.000000
ncos( 21) = 0.933580, 0.933580, 0.000000
ncos( 28) = 0.882948, 0.882948, 0.000000
ncos( 35) = 0.819152, 0.819152, 0.000000
ncos( 42) = 0.743145, 0.743145, -0.000000
ncos( 49) = 0.656059, 0.656059, -0.000000
ncos( 56) = 0.559193, 0.559193, -0.000000
ncos( 63) = 0.453990, 0.453990, -0.000000
ncos( 70) = 0.342020, 0.342020, -0.000000
ncos( 77) = 0.224951, 0.224951, -0.000000
ncos( 84) = 0.104528, 0.104528, -0.000000
ncos( 91) = -0.017452, -0.017452, -0.000000
ncos( 98) = -0.139173, -0.139173, -0.000000
ncos(105) = -0.258819, -0.258819, -0.000000
ncos(112) = -0.374607, -0.374607, -0.000000
ncos(119) = -0.484810, -0.484810, -0.000000
ncos(126) = -0.587785, -0.587785, -0.000000
ncos(133) = -0.681998, -0.681998, -0.000000
ncos(140) = -0.766045, -0.766044, -0.000000
ncos(147) = -0.838671, -0.838671, -0.000000
ncos(154) = -0.898794, -0.898794, -0.000000
ncos(161) = -0.945519, -0.945519, -0.000001
ncos(168) = -0.978149, -0.978148, -0.000001
ncos(175) = -0.996197, -0.996195, -0.000003
ncos(182) = -0.999394, -0.999391, -0.000003
ncos(189) = -0.987690, -0.987688, -0.000002
ncos(196) = -0.961263, -0.961262, -0.000001
ncos(203) = -0.920505, -0.920505, -0.000001
ncos(210) = -0.866026, -0.866025, -0.000000
ncos(217) = -0.798636, -0.798635, -0.000000
ncos(224) = -0.719340, -0.719340, -0.000000
ncos(231) = -0.629320, -0.629320, -0.000000
ncos(238) = -0.529919, -0.529919, -0.000000
ncos(245) = -0.422618, -0.422618, -0.000000
ncos(252) = -0.309017, -0.309017, -0.000000
ncos(259) = -0.190809, -0.190809, -0.000000
ncos(266) = -0.069756, -0.069756, -0.000000
ncos(273) = 0.052336, 0.052336, -0.000000
ncos(280) = 0.173648, 0.173648, -0.000000
ncos(287) = 0.292372, 0.292372, -0.000000
ncos(294) = 0.406737, 0.406737, -0.000000
ncos(301) = 0.515038, 0.515038, -0.000000
ncos(308) = 0.615661, 0.615662, -0.000000
ncos(315) = 0.707107, 0.707107, -0.000000
ncos(322) = 0.788011, 0.788011, -0.000000
ncos(329) = 0.857167, 0.857167, -0.000000
ncos(336) = 0.913545, 0.913545, -0.000000
ncos(343) = 0.956305, 0.956305, -0.000000
ncos(350) = 0.984808, 0.984808, -0.000000
ncos(357) = 0.998630, 0.998630, -0.000000
ncos(364) = 0.997564, 0.997564, 0.000000
ncos(371) = 0.981627, 0.981627, 0.000000
ncos(378) = 0.951057, 0.951057, 0.000000
ncos(385) = 0.906308, 0.906308, 0.000000
ncos(392) = 0.848048, 0.848048, 0.000000
ncos(399) = 0.777146, 0.777146, -0.000000
ncos(406) = 0.694658, 0.694658, -0.000000
ncos(413) = 0.601815, 0.601815, -0.000000
ncos(420) = 0.500000, 0.500000, -0.000000
ncos(427) = 0.390731, 0.390731, -0.000000
ncos(434) = 0.275637, 0.275637, -0.000000
ncos(441) = 0.156434, 0.156434, -0.000000
ncos(448) = 0.034899, 0.034899, -0.000000
ncos(455) = -0.087156, -0.087156, -0.000000
ncos(462) = -0.207912, -0.207912, -0.000000
ncos(469) = -0.325568, -0.325568, -0.000000
ncos(476) = -0.438371, -0.438371, -0.000000
ncos(483) = -0.544639, -0.544639, -0.000000
ncos(490) = -0.642788, -0.642788, -0.000000
ncos(497) = -0.731354, -0.731354, -0.000000
ncos(504) = -0.809017, -0.809017, -0.000000
ncos(511) = -0.874620, -0.874620, -0.000000
ncos(518) = -0.927184, -0.927184, -0.000001
ncos(525) = -0.965927, -0.965926, -0.000001
ncos(532) = -0.990270, -0.990268, -0.000002
ncos(539) = -0.999852, -0.999848, -0.000004

sin(PI/4)를 테일러 무한급수를 이용해서 푸는 문제 C++[출처] sin(PI/4)를 테일러 무한급수를 이용해서 푸는 문제|작성자 xtElite
http://blog.naver.com/xtelite/50022553426

Cosine
http://mathworld.wolfram.com/Cosine.html
http://www.wolframalpha.com/input/?i=N[Sqrt[Sum[6*%281%2Fn^2%29%2C+{n%2C+1%2C+Infinity}]]%2C+31]

무한등비 급수
http://www.mathteacher.pe.kr/mt_11/mt_16_06.htm

조화 급수(harmonic series)와 오일러-마스케로니 상수(Euler-Mascheroni constant)
http://ghebook.blogspot.kr/2010/11/harmonic-series-euler-mascheroni.html

Random Attractors
Found using Lyapunov Exponents
http://paulbourke.net/fractals/lyapunov/

Taylor Series
http://www.mathsisfun.com/algebra/taylor-series.html

Trigonometric functions
http://en.wikipedia.org/wiki/Trigonometric_functions

Sine
http://en.wikipedia.org/wiki/Sine

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.