Metamath Proof Explorer


Theorem lawcos

Description: Law of cosines (also known as the Al-Kashi theorem or the generalized Pythagorean theorem, or the cosine formula or cosine rule). Given three distinct points A, B, and C, prove a relationship between their segment lengths. This theorem is expressed using the complex number plane as a plane, where F is the signed angle construct (as used in ang180 ), X is the distance of line segment BC, Y is the distance of line segment AC, Z is the distance of line segment AB, and O is the signed angle m/__ BCA on the complex plane. We translate triangle ABC to move C to the origin (C-C), B to U=(B-C), and A to V=(A-C), then use lemma lawcoslem1 to prove this algebraically simpler case. The Metamath convention is to use a signed angle; in this case the sign doesn't matter because we use the cosine of the angle (see cosneg ). The Pythagorean theorem pythag is a special case of the law of cosines. The theorem's expression and approach were suggested by Mario Carneiro. This is Metamath 100 proof #94. (Contributed by David A. Wheeler, 12-Jun-2015)

Ref Expression
Hypotheses lawcos.1 F=x0,y0logyx
lawcos.2 X=BC
lawcos.3 Y=AC
lawcos.4 Z=AB
lawcos.5 O=BCFAC
Assertion lawcos ABCACBCZ2=X2+Y2-2XYcosO

Proof

Step Hyp Ref Expression
1 lawcos.1 F=x0,y0logyx
2 lawcos.2 X=BC
3 lawcos.3 Y=AC
4 lawcos.4 Z=AB
5 lawcos.5 O=BCFAC
6 subcl ACAC
7 6 3adant2 ABCAC
8 7 adantr ABCACBCAC
9 subcl BCBC
10 9 3adant1 ABCBC
11 10 adantr ABCACBCBC
12 subeq0 ACAC=0A=C
13 12 necon3bid ACAC0AC
14 13 bicomd ACACAC0
15 14 3adant2 ABCACAC0
16 15 biimpa ABCACAC0
17 16 adantrr ABCACBCAC0
18 subeq0 BCBC=0B=C
19 18 necon3bid BCBC0BC
20 19 bicomd BCBCBC0
21 20 3adant1 ABCBCBC0
22 21 biimpa ABCBCBC0
23 22 adantrl ABCACBCBC0
24 8 11 17 23 lawcoslem1 ABCACBCA-C-BC2=AC2+BC2-2ACBCACBCACBC
25 nnncan2 ABCA-C-BC=AB
26 25 fveq2d ABCA-C-BC=AB
27 4 26 eqtr4id ABCZ=A-C-BC
28 27 oveq1d ABCZ2=A-C-BC2
29 28 adantr ABCACBCZ2=A-C-BC2
30 2 oveq1i X2=BC2
31 3 oveq1i Y2=AC2
32 30 31 oveq12i X2+Y2=BC2+AC2
33 8 abscld ABCACBCAC
34 33 recnd ABCACBCAC
35 34 sqcld ABCACBCAC2
36 11 abscld ABCACBCBC
37 36 recnd ABCACBCBC
38 37 sqcld ABCACBCBC2
39 35 38 addcomd ABCACBCAC2+BC2=BC2+AC2
40 32 39 eqtr4id ABCACBCX2+Y2=AC2+BC2
41 2 3 oveq12i XY=BCAC
42 34 37 mulcomd ABCACBCACBC=BCAC
43 41 42 eqtr4id ABCACBCXY=ACBC
44 5 fveq2i cosO=cosBCFAC
45 1 11 23 8 17 angvald ABCACBCBCFAC=logACBC
46 45 fveq2d ABCACBCcosBCFAC=coslogACBC
47 44 46 eqtrid ABCACBCcosO=coslogACBC
48 8 11 23 divcld ABCACBCACBC
49 8 11 17 23 divne0d ABCACBCACBC0
50 48 49 logcld ABCACBClogACBC
51 50 imcld ABCACBClogACBC
52 recosval logACBCcoslogACBC=eilogACBC
53 51 52 syl ABCACBCcoslogACBC=eilogACBC
54 47 53 eqtrd ABCACBCcosO=eilogACBC
55 efiarg ACBCACBC0eilogACBC=ACBCACBC
56 48 49 55 syl2anc ABCACBCeilogACBC=ACBCACBC
57 56 fveq2d ABCACBCeilogACBC=ACBCACBC
58 48 abscld ABCACBCACBC
59 48 49 absne0d ABCACBCACBC0
60 58 48 59 redivd ABCACBCACBCACBC=ACBCACBC
61 54 57 60 3eqtrd ABCACBCcosO=ACBCACBC
62 43 61 oveq12d ABCACBCXYcosO=ACBCACBCACBC
63 62 oveq2d ABCACBC2XYcosO=2ACBCACBCACBC
64 40 63 oveq12d ABCACBCX2+Y2-2XYcosO=AC2+BC2-2ACBCACBCACBC
65 24 29 64 3eqtr4d ABCACBCZ2=X2+Y2-2XYcosO