Want to show your appreciation?
Please a cup of tea.

Sunday, July 17, 2011

Proof of Trigonometric Formulas

Having a lot of fun working with my kid to proof the trigonometric formulas in the camp textbook.

Sum and Difference Formulas

(1) cos(u-v) = cos(u)cos(v) + sin(u)sin(v)

Let A, B, C and D are points on unit circle O. A is [1,0], B is [cos(u-v), sin(u-v)], C is [cos(v), sin(v)] and D is [cos(u), sin(u)]. Then angle AOB is equals to angle COD, hence, segment AB = CD.

AB2 = [cos(u-v)-1]2 + [sin(u-v)-0]2 = CD2 =[(cos(u)-cos(v)]2 + [sin(u) – sin(v)]2 ------ Distance formula.

=> [cos(u-v)]2 – 2cos(u-v) + 1 + [sin(u-v)]2 = [(cos(u)]2 – 2cos(u)cos(v) + [cos(v)]2 + [sin(u)]2 – 2sin(u)sin(v) +  [sin(v)]2

=> – 2cos(u-v) + 2 = 2 – 2cos(u)cos(v) – 2sin(u)sin(v) ----- Using [(cos(x)]2 +[sin(x)]2  = 1

=> cos(u-v) = cos(u)cos(v) + sin(u)sin(v)

(2) cos(u+v) = cos(u)cos(v) - sin(u)sin(v)

cos(u+v) = cos(u-(-v)) = cos(u)cos(-v) + sin(u)sin(-v) ------ Using (1)

=> cos(u+v) = cos(u)cos(v) – sin(u)(sin(v) ------- Using cos(-x) = cos(x) and sin(-x) = –sin(x)

(3) sin(u+v) = sin(u)cos(v) + cos(u)sin(v)

sin(u+v) = cos(pi/2 – (u+v)) = cos((pi/2-u) – v) = cos(pi/2-u)cos(v) + sin(pi/2-u)sin(v) ------- Using (1)

=> sin(u+v) = sin(u)cos(v) + cos(u)sin(v) ------ Using cos(pi/2-x) = sin(x) and sin(pi/2-x) = cos(x)

(4) sin(u-v) = sin(u)cos(v) - cos(u)sin(v)

sin(u-v) = sin(u+(-v)) = sin(u)cos(-v) + cos(u)sin(-v) ------ Using (3)

=> sin(u-v) = sin(u)cos(v) – cos(u)(sin(v) ------- Using cos(-x) = cos(x) and sin(-x) = –sin(x)

Product-to-Sum Formulas

(5) cos(u)cos(v) = [cos(u+v) + cos(u-v)] / 2

Add formula (1) and (2):

cos(u+v) + cos(u-v) = cos(u)cos(v) - sin(u)sin(v) + cos(u)cos(v) + sin(u)sin(v)

=> cos(u+v) + cos(u-v) = 2cos(u)cos(v)

=> cos(u)cos(v) = [cos(u+v) + cos(u-v)] / 2

(6) sin(u)sin(v) = [cos(u-v) - cos(u+v)] / 2

Subtract formula (1) by (2):

cos(u-v) - cos(u+v) = cos(u)cos(v) + sin(u)sin(v) – [cos(u)cos(v) - sin(u)sin(v)]

=> cos(u-v) - cos(u+v) = 2sin(u)sin(v)

=> sin(u)sin(v) = [cos(u-v) - cos(u+v)] / 2

(7) sin(u)cos(v) = [sin(u+v) + sin(u-v)] / 2

Add formula (3) and (4):

sin(u+v) + sin(u-v) = sin(u)cos(v) + cos(u)sin(v) + sin(u)cos(v) - cos(u)sin(v)

=> sin(u+v) + sin(u-v) = 2sin(u)cos(v)

=> sin(u)cons(v) = [sin(u+v) + sin(u-v)] / 2

(8) cos(u)sin(v) = [sin(u+v) - sin(u-v)] / 2

There are two simple methods to prove this.

Method 1

Subtract formula (3) by (4)

sin(u+v) - sin(u-v) = sin(u)cos(v) + cos(u)sin(v) – [sin(u)cos(v) - cos(u)sin(v)]

=> sin(u+v) + sin(u-v) = cos(u)sin(v)

=> cos(u)sin(v) =  [sin(u+v) - sin(u-v)] / 2

Method 2

cos(u)sin(v) = sin(v)cos(u) = [sin(v+u) + sin(v-u)] / 2 ------ Using (7)

=> cos(u)sin(v) = sin(v)cos(u) = [sin(u+v) + sin(-(u-v))] / 2

=> cos(u)sin(v) =  [sin(u+v) - sin(u-v)] / 2 ------ Using sin(-x) = -sin(x)

Sum-to-Product Formulas

(9) cos(u) + cos(v) = 2cos[(u+v)/2]cos[(u-v)/2]

cos(x)cos(y) = [cos(x+y) + cos(x-y)] / 2 ------ Using (5)

Let u=x+y and v=x-y, we can have x=(u+v)/2 and y=(u-v)/2

=> cos[(u+v)/2]cos[(u-v)/2] = [cos(u) + cos(v)] / 2 ------ Replacing x, y with u, v

=> cos(u) + cos(v) = 2cos[(u+v)/2]cos[(u-v)/2]

(10) cos(u) - cos(v) = -2sin[(u+v)/2]sin[(u-v)/2]

Similarly to the proof of (9), we can arrive (10) from (6)

(11) sin(u) + sin(v) = 2sin[(u+v)/2]cos[(u-v)/2]

Similarly to the proof of (9), we can arrive (11) from (7)

(12) sin(u) - sin(v) = 2cos[(u+v)/2]sin[(u-v)/2]

There are two methods to do this.

Method 1

Similarly to the proof of (9), we can arrive (12) from (8)

Method 2

sin(u) – sin(v) = sin(u) + sin(-v) ------ Using sin(-x) = -sin(x)

= 2sin[(u+(-v))/2]cos[(u-(-v))/2] ------ Using (12)

=> sin(u) - sin(v) = 2cos[(u+v)/2]sin[(u-v)/2]

Double Angle Formulas

(13.1) cos(2u) = cos2(u) – sin2(u)

cos(2u) = cos(u+u) = cos(u)cos(u) – sin(u)sin(u) ------ Using (2)

=> cos(2u) = cos2(u) – sin2(u)

(13.2) cos(2u) = 2cos2(u) – 1

cos(2u) = cos2(u) – sin2(u) ------ Using (13.1)

= cos2(u) – [sin2(u) + cos2(u) - cos2(u)]

= cos2(u) – [1-cos2(u)] ------ Using cos2(u) + sin2(u) = 1

= 2cos2(u) – 1

(13.3) cos(2u) = 1 – 2sin2(u)

cos(2u) = cos2(u) – sin2(u) ------ Using (13.1)

= [cos2(u) + sin2(u) - sin2(u)] – sin2(u)

=  [1 – sin2(u)] – sin2(u) ------ Using cos2(u) + sin2(u) = 1

= 1 - 2sin2(u)

(14) sin(2u) = sin(u)cos(u)

sin(2u) = sin(u+u) = sin(u)cos(u) + cos(u)sin(u) ------ Using (3)

=> sin(2u) = 2sin(u)cos(u)

(15) tan(2u) = 2tan(u) / (1 - tan2(u))

Divide formula (14) by (13.1)

sin(2u)/cos(2u) = 2sin(u)cos(u)/[cos2(u) – sin2(u)]

=> tan(2u) = 2sin(u)cos(u)/[cos2(u) – sin2(u)]

= {2sin(u)cos(u)/cos2(u)} / {[cos2(u) – sin2(u)]/cos2(u)}

= {2sin(u)/cos(u)} / {1 - sin2(u)/cos2(u)}

= 2tan(u) / (1 - tan2(u))

Power Reducing Formulas

(16) sin2(u) = [1-cos(2u)]/2

We can easily arrive to this from (13.3)

(17) cos2(u) = [1+cos(2u)]/2

We can easily arrive to this from (13.2)

(18) tan2(u) = [1-cos(2u)]/[1+cos(2u)]

We can easily arrive to this by dividing (17) by (18)

Half Angle Formulas

(19) sin(u/2) = +/-[1-cos(u))/2]1/2

sin2(x) = [1-cos(2x)]/2 ------ Using (16)

=> sin2(u/2) = [1-cos(u)]/2 ------ let x = u/2

=> sin(u/2) = +/-[1-cos(u))/2]1/2

(20) cos(u/2) = +/-[1+cos(u))/2]1/2

Similar to (19), we can arrive this from (17)

(21.1) tan(u/2) = [1-cos(u)] / sin(u)

tan2(x) = [1-cos(2x)]/[1+cos(2x)] ------ Using (18)

=> tan2(u/2) = [1-cos(u)]/[1+cos(u)] ------ let x = u/2

=> tan2(u/2) = {[1-cos(u)]*[1-cos(u)]} / {[1+cos(u)]*[1-cos(u)]}

=> tan2(u/2) = [1-cos(u)]2 / [1-cos2(u)]

=> tan2(u/2) = [1-cos(u)]2 / sin2(u) ------ Using cos2(u) + sin2(u) = 1

=> tan(u/2) = [1-cos(u)] / sin(u)

(21.2) tan(u/2) = sin(u) / [1+cos(u)]

tan2(x) = [1-cos(2x)]/[1+cos(2x)] ------ Using (18)

=> tan2(u/2) = [1-cos(u)]/[1+cos(u)] ------ let x = u/2

=> tan2(u/2) = {[1-cos(u)]*[1+cos(u)]} / {[1+cos(u)]*[1+cos(u)]}

=> tan2(u/2) = [1-cos2(u)] / [1+cos(u)]2

=> tan2(u/2) = sin2(u) / [1+cos(u)]2 ------ Using cos2(u) + sin2(u) = 1

=> tan(u/2) = sin(u) / [1+cos(u)]

Thursday, July 07, 2011

Java Collection Framework (1.5) Interface Diagram

Here is an interface level class diagram to show the relationship between Java Collection Framework (1.5) interfaces.

java-collection-interface-1.5

 

More detail class level diagrams can be found in links below

http://www.falkhausen.de/en/diagram/spec/java.util.Collections.html

http://www.jroller.com/VelkaVrana/entry/java_1_6_collections_class