1587 apply (drule (1) LIM_fun_less_zero, force) |
1587 apply (drule (1) LIM_fun_less_zero, force) |
1588 apply simp |
1588 apply simp |
1589 apply (drule (1) LIM_fun_gt_zero, force) |
1589 apply (drule (1) LIM_fun_gt_zero, force) |
1590 done |
1590 done |
1591 |
1591 |
|
1592 lemma GMVT': |
|
1593 fixes f g :: "real \<Rightarrow> real" |
|
1594 assumes "a < b" |
|
1595 assumes isCont_f: "\<And>z. a \<le> z \<Longrightarrow> z \<le> b \<Longrightarrow> isCont f z" |
|
1596 assumes isCont_g: "\<And>z. a \<le> z \<Longrightarrow> z \<le> b \<Longrightarrow> isCont g z" |
|
1597 assumes DERIV_g: "\<And>z. a < z \<Longrightarrow> z < b \<Longrightarrow> DERIV g z :> (g' z)" |
|
1598 assumes DERIV_f: "\<And>z. a < z \<Longrightarrow> z < b \<Longrightarrow> DERIV f z :> (f' z)" |
|
1599 shows "\<exists>c. a < c \<and> c < b \<and> (f b - f a) * g' c = (g b - g a) * f' c" |
|
1600 proof - |
|
1601 have "\<exists>g'c f'c c. DERIV g c :> g'c \<and> DERIV f c :> f'c \<and> |
|
1602 a < c \<and> c < b \<and> (f b - f a) * g'c = (g b - g a) * f'c" |
|
1603 using assms by (intro GMVT) (force simp: differentiable_def)+ |
|
1604 then obtain c where "a < c" "c < b" "(f b - f a) * g' c = (g b - g a) * f' c" |
|
1605 using DERIV_f DERIV_g by (force dest: DERIV_unique) |
|
1606 then show ?thesis |
|
1607 by auto |
|
1608 qed |
|
1609 |
|
1610 lemma lhopital_right_0: |
|
1611 fixes f g :: "real \<Rightarrow> real" |
|
1612 assumes f_0: "isCont f 0" "f 0 = 0" |
|
1613 assumes g_0: "isCont g 0" "g 0 = 0" |
|
1614 assumes ev: |
|
1615 "eventually (\<lambda>x. g x \<noteq> 0) (at_right 0)" |
|
1616 "eventually (\<lambda>x. g' x \<noteq> 0) (at_right 0)" |
|
1617 "eventually (\<lambda>x. DERIV f x :> f' x) (at_right 0)" |
|
1618 "eventually (\<lambda>x. DERIV g x :> g' x) (at_right 0)" |
|
1619 assumes lim: "((\<lambda> x. (f' x / g' x)) ---> x) (at_right 0)" |
|
1620 shows "((\<lambda> x. f x / g x) ---> x) (at_right 0)" |
|
1621 proof - |
|
1622 from eventually_conj[OF eventually_conj[OF ev(1) ev(2)] eventually_conj[OF ev(3) ev(4)]] |
|
1623 obtain a where [arith]: "0 < a" |
|
1624 and g_neq_0: "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> g x \<noteq> 0" |
|
1625 and g'_neq_0: "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> g' x \<noteq> 0" |
|
1626 and f: "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> DERIV f x :> (f' x)" |
|
1627 and g: "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> DERIV g x :> (g' x)" |
|
1628 unfolding eventually_within eventually_at by (auto simp: dist_real_def) |
|
1629 |
|
1630 { fix x assume x: "0 \<le> x" "x < a" |
|
1631 from `0 \<le> x` have "isCont f x" |
|
1632 unfolding le_less |
|
1633 proof |
|
1634 assume "0 = x" with `isCont f 0` show "isCont f x" by simp |
|
1635 next |
|
1636 assume "0 < x" with f x show ?thesis by (auto intro!: DERIV_isCont) |
|
1637 qed } |
|
1638 note isCont_f = this |
|
1639 |
|
1640 { fix x assume x: "0 \<le> x" "x < a" |
|
1641 from `0 \<le> x` have "isCont g x" |
|
1642 unfolding le_less |
|
1643 proof |
|
1644 assume "0 = x" with `isCont g 0` show "isCont g x" by simp |
|
1645 next |
|
1646 assume "0 < x" with g x show ?thesis by (auto intro!: DERIV_isCont) |
|
1647 qed } |
|
1648 note isCont_g = this |
|
1649 |
|
1650 have "\<exists>\<zeta>. \<forall>x\<in>{0 <..< a}. 0 < \<zeta> x \<and> \<zeta> x < x \<and> f x / g x = f' (\<zeta> x) / g' (\<zeta> x)" |
|
1651 proof (rule bchoice, rule) |
|
1652 fix x assume "x \<in> {0 <..< a}" |
|
1653 then have x[arith]: "0 < x" "x < a" by auto |
|
1654 with g'_neq_0 g_neq_0 `g 0 = 0` have g': "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> 0 \<noteq> g' x" "g 0 \<noteq> g x" |
|
1655 by auto |
|
1656 |
|
1657 have "\<exists>c. 0 < c \<and> c < x \<and> (f x - f 0) * g' c = (g x - g 0) * f' c" |
|
1658 using isCont_f isCont_g f g `x < a` by (intro GMVT') auto |
|
1659 then guess c .. |
|
1660 moreover |
|
1661 with g'(1)[of c] g'(2) have "(f x - f 0) / (g x - g 0) = f' c / g' c" |
|
1662 by (simp add: field_simps) |
|
1663 ultimately show "\<exists>y. 0 < y \<and> y < x \<and> f x / g x = f' y / g' y" |
|
1664 using `f 0 = 0` `g 0 = 0` by (auto intro!: exI[of _ c]) |
|
1665 qed |
|
1666 then guess \<zeta> .. |
|
1667 then have \<zeta>: "eventually (\<lambda>x. 0 < \<zeta> x \<and> \<zeta> x < x \<and> f x / g x = f' (\<zeta> x) / g' (\<zeta> x)) (at_right 0)" |
|
1668 unfolding eventually_within eventually_at by (intro exI[of _ a]) (auto simp: dist_real_def) |
|
1669 moreover |
|
1670 from \<zeta> have "eventually (\<lambda>x. norm (\<zeta> x) \<le> x) (at_right 0)" |
|
1671 by eventually_elim auto |
|
1672 then have "((\<lambda>x. norm (\<zeta> x)) ---> 0) (at_right 0)" |
|
1673 by (rule_tac real_tendsto_sandwich[where f="\<lambda>x. 0" and h="\<lambda>x. x"]) |
|
1674 (auto intro: tendsto_const tendsto_ident_at_within) |
|
1675 then have "(\<zeta> ---> 0) (at_right 0)" |
|
1676 by (rule tendsto_norm_zero_cancel) |
|
1677 with \<zeta> have "filterlim \<zeta> (at_right 0) (at_right 0)" |
|
1678 by (auto elim!: eventually_elim1 simp: filterlim_within filterlim_at) |
|
1679 from this lim have "((\<lambda>t. f' (\<zeta> t) / g' (\<zeta> t)) ---> x) (at_right 0)" |
|
1680 by (rule_tac filterlim_compose[of _ _ _ \<zeta>]) |
|
1681 ultimately show "((\<lambda>t. f t / g t) ---> x) (at_right 0)" |
|
1682 apply (rule_tac filterlim_cong[THEN iffD1, OF refl refl]) |
|
1683 apply (erule_tac eventually_elim1) |
|
1684 apply simp_all |
|
1685 done |
|
1686 qed |
|
1687 |
|
1688 lemma lhopital_right_0_at_top: |
|
1689 fixes f g :: "real \<Rightarrow> real" |
|
1690 assumes g_0: "LIM x at_right 0. g x :> at_top" |
|
1691 assumes ev: |
|
1692 "eventually (\<lambda>x. g' x \<noteq> 0) (at_right 0)" |
|
1693 "eventually (\<lambda>x. DERIV f x :> f' x) (at_right 0)" |
|
1694 "eventually (\<lambda>x. DERIV g x :> g' x) (at_right 0)" |
|
1695 assumes lim: "((\<lambda> x. (f' x / g' x)) ---> x) (at_right 0)" |
|
1696 shows "((\<lambda> x. f x / g x) ---> x) (at_right 0)" |
|
1697 unfolding tendsto_iff |
|
1698 proof safe |
|
1699 fix e :: real assume "0 < e" |
|
1700 |
|
1701 with lim[unfolded tendsto_iff, rule_format, of "e / 4"] |
|
1702 have "eventually (\<lambda>t. dist (f' t / g' t) x < e / 4) (at_right 0)" by simp |
|
1703 from eventually_conj[OF eventually_conj[OF ev(1) ev(2)] eventually_conj[OF ev(3) this]] |
|
1704 obtain a where [arith]: "0 < a" |
|
1705 and g'_neq_0: "\<And>x. 0 < x \<Longrightarrow> x < a \<Longrightarrow> g' x \<noteq> 0" |
|
1706 and f0: "\<And>x. 0 < x \<Longrightarrow> x \<le> a \<Longrightarrow> DERIV f x :> (f' x)" |
|
1707 and g0: "\<And>x. 0 < x \<Longrightarrow> x \<le> a \<Longrightarrow> DERIV g x :> (g' x)" |
|
1708 and Df: "\<And>t. 0 < t \<Longrightarrow> t < a \<Longrightarrow> dist (f' t / g' t) x < e / 4" |
|
1709 unfolding eventually_within_le by (auto simp: dist_real_def) |
|
1710 |
|
1711 from Df have |
|
1712 "eventually (\<lambda>t. t < a) (at_right 0)" |
|
1713 "eventually (\<lambda>t::real. 0 < t) (at_right 0)" |
|
1714 unfolding eventually_within eventually_at by (auto intro!: exI[of _ a] simp: dist_real_def) |
|
1715 moreover |
|
1716 |
|
1717 have "eventually (\<lambda>t. 0 < g t) (at_right 0)" |
|
1718 using g_0[unfolded filterlim_at_top, rule_format, of "1"] by eventually_elim auto |
|
1719 |
|
1720 moreover |
|
1721 |
|
1722 have "eventually (\<lambda>t. g a < g t) (at_right 0)" |
|
1723 using g_0[unfolded filterlim_at_top, rule_format, of "g a + 1"] by eventually_elim auto |
|
1724 moreover |
|
1725 have inv_g: "((\<lambda>x. inverse (g x)) ---> 0) (at_right 0)" |
|
1726 using tendsto_inverse_0 filterlim_mono[OF g_0 at_top_le_at_infinity order_refl] |
|
1727 by (rule filterlim_compose) |
|
1728 then have "((\<lambda>x. norm (1 - g a * inverse (g x))) ---> norm (1 - g a * 0)) (at_right 0)" |
|
1729 by (intro tendsto_intros) |
|
1730 then have "((\<lambda>x. norm (1 - g a / g x)) ---> 1) (at_right 0)" |
|
1731 by (simp add: inverse_eq_divide) |
|
1732 from this[unfolded tendsto_iff, rule_format, of 1] |
|
1733 have "eventually (\<lambda>x. norm (1 - g a / g x) < 2) (at_right 0)" |
|
1734 by (auto elim!: eventually_elim1 simp: dist_real_def) |
|
1735 |
|
1736 moreover |
|
1737 from inv_g have "((\<lambda>t. norm ((f a - x * g a) * inverse (g t))) ---> norm ((f a - x * g a) * 0)) (at_right 0)" |
|
1738 by (intro tendsto_intros) |
|
1739 then have "((\<lambda>t. norm (f a - x * g a) / norm (g t)) ---> 0) (at_right 0)" |
|
1740 by (simp add: inverse_eq_divide) |
|
1741 from this[unfolded tendsto_iff, rule_format, of "e / 2"] `0 < e` |
|
1742 have "eventually (\<lambda>t. norm (f a - x * g a) / norm (g t) < e / 2) (at_right 0)" |
|
1743 by (auto simp: dist_real_def) |
|
1744 |
|
1745 ultimately show "eventually (\<lambda>t. dist (f t / g t) x < e) (at_right 0)" |
|
1746 proof eventually_elim |
|
1747 fix t assume t[arith]: "0 < t" "t < a" "g a < g t" "0 < g t" |
|
1748 assume ineq: "norm (1 - g a / g t) < 2" "norm (f a - x * g a) / norm (g t) < e / 2" |
|
1749 |
|
1750 have "\<exists>y. t < y \<and> y < a \<and> (g a - g t) * f' y = (f a - f t) * g' y" |
|
1751 using f0 g0 t(1,2) by (intro GMVT') (force intro!: DERIV_isCont)+ |
|
1752 then guess y .. |
|
1753 from this |
|
1754 have [arith]: "t < y" "y < a" and D_eq: "(f t - f a) / (g t - g a) = f' y / g' y" |
|
1755 using `g a < g t` g'_neq_0[of y] by (auto simp add: field_simps) |
|
1756 |
|
1757 have *: "f t / g t - x = ((f t - f a) / (g t - g a) - x) * (1 - g a / g t) + (f a - x * g a) / g t" |
|
1758 by (simp add: field_simps) |
|
1759 have "norm (f t / g t - x) \<le> |
|
1760 norm (((f t - f a) / (g t - g a) - x) * (1 - g a / g t)) + norm ((f a - x * g a) / g t)" |
|
1761 unfolding * by (rule norm_triangle_ineq) |
|
1762 also have "\<dots> = dist (f' y / g' y) x * norm (1 - g a / g t) + norm (f a - x * g a) / norm (g t)" |
|
1763 by (simp add: abs_mult D_eq dist_real_def) |
|
1764 also have "\<dots> < (e / 4) * 2 + e / 2" |
|
1765 using ineq Df[of y] `0 < e` by (intro add_le_less_mono mult_mono) auto |
|
1766 finally show "dist (f t / g t) x < e" |
|
1767 by (simp add: dist_real_def) |
|
1768 qed |
|
1769 qed |
|
1770 |
1592 end |
1771 end |