-
Notifications
You must be signed in to change notification settings - Fork 1
/
Ejercicio_desigualdades_absolutas.lean
65 lines (60 loc) · 2.39 KB
/
Ejercicio_desigualdades_absolutas.lean
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
-- ---------------------------------------------------------------------
-- Ejercicio. Sean a y b números reales. Demostrar que
-- abs (a*b) ≤ (a^2 + b^2) / 2
-- ----------------------------------------------------------------------
import data.real.basic
import tactic
variables a b : ℝ
-- 1ª demostración
example : abs (a*b) ≤ (a^2 + b^2) / 2 :=
begin
apply abs_le.mpr,
split,
{ have h1 : 0 ≤ a^2 + 2*a*b + b^2,
calc 0 ≤ (a+b)^2 : by exact pow_two_nonneg (a + b)
... = a^2+2*a*b+b^2 : by ring,
have h2 : -2*(a*b) ≤ a^2 + b^2,
calc -2*(a*b)
≤ -2*(a*b)+(a^2+2*a*b+b^2) : by exact le_add_of_nonneg_right h1
... = a^2 + b^2 : by ring,
show -((a^2 + b^2) / 2) ≤ a*b, by linarith [h2] },
{ have h3 : 0 ≤ a^2 - 2*a*b + b^2,
calc 0 ≤ (a-b)^2 : by exact pow_two_nonneg (a - b)
... = a^2-2*a*b+b^2 : by ring,
have h4 : 2*(a*b) ≤ a^2 + b^2,
calc 2*(a*b)
≤ 2*(a*b)+(a^2-2*a*b+b^2) : by exact le_add_of_nonneg_right h3
... = a^2 + b^2 : by ring,
show a * b ≤ (a^2 + b^2)/2, by linarith [h4] },
end
-- 2ª demostración
example : abs (a*b) ≤ (a^2 + b^2) / 2 :=
begin
apply abs_le.mpr,
split,
{ have h1 : 0 ≤ a^2 + 2*a*b + b^2,
calc 0 ≤ (a+b)^2 : by exact pow_two_nonneg (a + b)
... = a^2+2*a*b+b^2 : by ring,
have h2 : -2*(a*b) ≤ a^2 + b^2,
calc -2*(a*b)
≤ -2*(a*b)+(a^2+2*a*b+b^2) : by exact le_add_of_nonneg_right h1
... = a^2 + b^2 : by ring,
show -((a^2 + b^2) / 2) ≤ a*b, by linarith [h2] },
{ have h4 : 2*a*b ≤ a^2 + b^2 := two_mul_le_add_sq a b,
show a * b ≤ (a^2 + b^2)/2, by linarith [h4] },
end
-- 3ª demostración
example : abs (a*b) ≤ (a^2 + b^2) / 2 :=
begin
apply abs_le.mpr,
split,
{ have h1 : 0 ≤ a^2 + 2*a*b + b^2,
calc 0 ≤ (a+b)^2 : by exact pow_two_nonneg (a + b)
... = a^2+2*a*b+b^2 : by ring,
have h2 : -2*(a*b) ≤ a^2 + b^2,
calc -2*(a*b)
≤ -2*(a*b)+(a^2+2*a*b+b^2) : by exact le_add_of_nonneg_right h1
... = a^2 + b^2 : by ring,
show -((a^2 + b^2) / 2) ≤ a*b, by linarith [h2] },
{ show a * b ≤ (a^2 + b^2)/2, by linarith [two_mul_le_add_sq a b] },
end