src/HOL/Analysis/Gamma_Function.thy
changeset 73928 3b76524f5a85
parent 73005 83b114a6545f
child 74362 0135a0c77b64
equal deleted inserted replaced
73927:5b5e015189a4 73928:3b76524f5a85
  1012 lemma deriv_ln_Gamma_complex:
  1012 lemma deriv_ln_Gamma_complex:
  1013   assumes "z \<notin> \<real>\<^sub>\<le>\<^sub>0"
  1013   assumes "z \<notin> \<real>\<^sub>\<le>\<^sub>0"
  1014   shows   "deriv ln_Gamma z = Digamma (z :: complex)"
  1014   shows   "deriv ln_Gamma z = Digamma (z :: complex)"
  1015   by (intro DERIV_imp_deriv has_field_derivative_ln_Gamma_complex assms)
  1015   by (intro DERIV_imp_deriv has_field_derivative_ln_Gamma_complex assms)
  1016 
  1016 
       
  1017 
       
  1018 lemma higher_deriv_ln_Gamma_complex:
       
  1019   assumes "(x::complex) \<notin> \<real>\<^sub>\<le>\<^sub>0"
       
  1020   shows   "(deriv ^^ j) ln_Gamma x = (if j = 0 then ln_Gamma x else Polygamma (j - 1) x)"
       
  1021 proof (cases j)
       
  1022   case (Suc j')
       
  1023   have "(deriv ^^ j') (deriv ln_Gamma) x = (deriv ^^ j') Digamma x"
       
  1024     using eventually_nhds_in_open[of "UNIV - \<real>\<^sub>\<le>\<^sub>0" x] assms
       
  1025     by (intro higher_deriv_cong_ev refl)
       
  1026        (auto elim!: eventually_mono simp: open_Diff deriv_ln_Gamma_complex)
       
  1027   also have "\<dots> = Polygamma j' x" using assms
       
  1028     by (subst higher_deriv_Polygamma)
       
  1029        (auto elim!: nonpos_Ints_cases simp: complex_nonpos_Reals_iff)
       
  1030   finally show ?thesis using Suc by (simp del: funpow.simps add: funpow_Suc_right)
       
  1031 qed simp_all
  1017 
  1032 
  1018 
  1033 
  1019 text \<open>
  1034 text \<open>
  1020   We define a type class that captures all the fundamental properties of the inverse of the Gamma function
  1035   We define a type class that captures all the fundamental properties of the inverse of the Gamma function
  1021   and defines the Gamma function upon that. This allows us to instantiate the type class both for
  1036   and defines the Gamma function upon that. This allows us to instantiate the type class both for
  1693 lemma deriv_ln_Gamma_real:
  1708 lemma deriv_ln_Gamma_real:
  1694   assumes "z > 0"
  1709   assumes "z > 0"
  1695   shows   "deriv ln_Gamma z = Digamma (z :: real)"
  1710   shows   "deriv ln_Gamma z = Digamma (z :: real)"
  1696   by (intro DERIV_imp_deriv has_field_derivative_ln_Gamma_real assms)
  1711   by (intro DERIV_imp_deriv has_field_derivative_ln_Gamma_real assms)
  1697 
  1712 
       
  1713 lemma higher_deriv_ln_Gamma_real:
       
  1714   assumes "(x::real) > 0"
       
  1715   shows   "(deriv ^^ j) ln_Gamma x = (if j = 0 then ln_Gamma x else Polygamma (j - 1) x)"
       
  1716 proof (cases j)
       
  1717   case (Suc j')
       
  1718   have "(deriv ^^ j') (deriv ln_Gamma) x = (deriv ^^ j') Digamma x"
       
  1719     using eventually_nhds_in_open[of "{0<..}" x] assms
       
  1720     by (intro higher_deriv_cong_ev refl)
       
  1721        (auto elim!: eventually_mono simp: open_Diff deriv_ln_Gamma_real)
       
  1722   also have "\<dots> = Polygamma j' x" using assms
       
  1723     by (subst higher_deriv_Polygamma)
       
  1724        (auto elim!: nonpos_Ints_cases simp: complex_nonpos_Reals_iff)
       
  1725   finally show ?thesis using Suc by (simp del: funpow.simps add: funpow_Suc_right)
       
  1726 qed simp_all
       
  1727   
       
  1728 lemma higher_deriv_ln_Gamma_complex_of_real:
       
  1729   assumes "(x :: real) > 0"
       
  1730   shows   "(deriv ^^ j) ln_Gamma (complex_of_real x) = of_real ((deriv ^^ j) ln_Gamma x)"
       
  1731     using assms
       
  1732     by (auto simp: higher_deriv_ln_Gamma_real higher_deriv_ln_Gamma_complex
       
  1733                    ln_Gamma_complex_of_real Polygamma_of_real)
  1698 
  1734 
  1699 lemma has_field_derivative_rGamma_real' [derivative_intros]:
  1735 lemma has_field_derivative_rGamma_real' [derivative_intros]:
  1700   "(rGamma has_field_derivative (if x \<in> \<int>\<^sub>\<le>\<^sub>0 then (-1)^(nat \<lfloor>-x\<rfloor>) * fact (nat \<lfloor>-x\<rfloor>) else
  1736   "(rGamma has_field_derivative (if x \<in> \<int>\<^sub>\<le>\<^sub>0 then (-1)^(nat \<lfloor>-x\<rfloor>) * fact (nat \<lfloor>-x\<rfloor>) else
  1701         -rGamma x * Digamma x)) (at x within A)"
  1737         -rGamma x * Digamma x)) (at x within A)"
  1702   using has_field_derivative_rGamma[of x] by (force elim!: nonpos_Ints_cases')
  1738   using has_field_derivative_rGamma[of x] by (force elim!: nonpos_Ints_cases')