and angular formula

Source: Internet
Author: User
Tags printf sin

Today do SICP exercise 1.15, need to use and angle formula, although will write, but forgot how to prove, in MathWorld found a very wonderful proof:

Euler's formula has been used here, and it has been documented before, but it is very ingenious to find the points to prove it.

; SICP ex1.15

; In radians X is very small, the sine of the sinx can be replaced by X.

; and has identities Sinx = 3sin (X/3)-4sin3 (X/3)

; Execute with DrScheme

;

; ;
;
; ;;; ; ; ;; ;;;
; ; ; ; ;; ; ; ;
; ; ; ; ; ; ;
; ;;; ; ; ; ;;;;;
; ; ; ; ; ;
; ; ; ; ; ; ; ;
; ;;; ; ; ; ;;;
;
;

(define (Cube x) (* x x x))
(define (P x) (-(* 3 x) (* 4 (Cube x)))
(Define (sine angle)
(if (Not (> (ABS angle) 0.01))
Angle
(P (sine (/angle 3.0))))

; Comparison with standard functions

> (sine 0.5)

0.4794283252628956

> (Sin 0.5)
0.479425538604203

=====================c program ========================

#include <stdio.h>
#include <math.h>
#define EPS 0.01

Double sine (double x)
{
if (Fabs (x) < EPS) return x;
Double sine3th = sine (x/3.0);
Return 3 * sine3th-4 * sine3th * sine3th * sine3th;
}

int main ()
{
printf ("%.6f/n", sine (0.5));
printf ("%.6f/n", sin (0.5));
return 0;
}

====================================================

The algorithm has a time complexity of LOG3 (x/eps).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.