370 using odd_pos [OF n] x by simp |
370 using odd_pos [OF n] x by simp |
371 show "isCont (root n) x" |
371 show "isCont (root n) x" |
372 using odd_pos [OF n] by (rule isCont_real_root) |
372 using odd_pos [OF n] by (rule isCont_real_root) |
373 qed |
373 qed |
374 |
374 |
|
375 lemma DERIV_even_real_root: |
|
376 assumes n: "0 < n" and "even n" |
|
377 assumes x: "x < 0" |
|
378 shows "DERIV (root n) x :> inverse (- real n * root n x ^ (n - Suc 0))" |
|
379 proof (rule DERIV_inverse_function) |
|
380 show "x - 1 < x" by simp |
|
381 show "x < 0" using x . |
|
382 next |
|
383 show "\<forall>y. x - 1 < y \<and> y < 0 \<longrightarrow> - (root n y ^ n) = y" |
|
384 proof (rule allI, rule impI, erule conjE) |
|
385 fix y assume "x - 1 < y" and "y < 0" |
|
386 hence "root n (-y) ^ n = -y" using `0 < n` by simp |
|
387 with real_root_minus[OF `0 < n`] and `even n` |
|
388 show "- (root n y ^ n) = y" by simp |
|
389 qed |
|
390 next |
|
391 show "DERIV (\<lambda>x. - (x ^ n)) (root n x) :> - real n * root n x ^ (n - Suc 0)" |
|
392 by (auto intro!: DERIV_intros) |
|
393 show "- real n * root n x ^ (n - Suc 0) \<noteq> 0" |
|
394 using n x by simp |
|
395 show "isCont (root n) x" |
|
396 using n by (rule isCont_real_root) |
|
397 qed |
|
398 |
|
399 lemma DERIV_real_root_generic: |
|
400 assumes "0 < n" and "x \<noteq> 0" |
|
401 and even: "\<lbrakk> even n ; 0 < x \<rbrakk> \<Longrightarrow> D = inverse (real n * root n x ^ (n - Suc 0))" |
|
402 and even: "\<lbrakk> even n ; x < 0 \<rbrakk> \<Longrightarrow> D = - inverse (real n * root n x ^ (n - Suc 0))" |
|
403 and odd: "odd n \<Longrightarrow> D = inverse (real n * root n x ^ (n - Suc 0))" |
|
404 shows "DERIV (root n) x :> D" |
|
405 using assms by (cases "even n", cases "0 < x", |
|
406 auto intro: DERIV_real_root[THEN DERIV_cong] |
|
407 DERIV_odd_real_root[THEN DERIV_cong] |
|
408 DERIV_even_real_root[THEN DERIV_cong]) |
|
409 |
375 subsection {* Square Root *} |
410 subsection {* Square Root *} |
376 |
411 |
377 definition |
412 definition |
378 sqrt :: "real \<Rightarrow> real" where |
413 sqrt :: "real \<Rightarrow> real" where |
379 "sqrt = root 2" |
414 "sqrt = root 2" |
454 lemmas real_sqrt_eq_1_iff [simp] = real_sqrt_eq_iff [where y=1, simplified] |
489 lemmas real_sqrt_eq_1_iff [simp] = real_sqrt_eq_iff [where y=1, simplified] |
455 |
490 |
456 lemma isCont_real_sqrt: "isCont sqrt x" |
491 lemma isCont_real_sqrt: "isCont sqrt x" |
457 unfolding sqrt_def by (rule isCont_real_root [OF pos2]) |
492 unfolding sqrt_def by (rule isCont_real_root [OF pos2]) |
458 |
493 |
|
494 lemma DERIV_real_sqrt_generic: |
|
495 assumes "x \<noteq> 0" |
|
496 assumes "x > 0 \<Longrightarrow> D = inverse (sqrt x) / 2" |
|
497 assumes "x < 0 \<Longrightarrow> D = - inverse (sqrt x) / 2" |
|
498 shows "DERIV sqrt x :> D" |
|
499 using assms unfolding sqrt_def |
|
500 by (auto intro!: DERIV_real_root_generic) |
|
501 |
459 lemma DERIV_real_sqrt: |
502 lemma DERIV_real_sqrt: |
460 "0 < x \<Longrightarrow> DERIV sqrt x :> inverse (sqrt x) / 2" |
503 "0 < x \<Longrightarrow> DERIV sqrt x :> inverse (sqrt x) / 2" |
461 unfolding sqrt_def by (rule DERIV_real_root [OF pos2, simplified]) |
504 using DERIV_real_sqrt_generic by simp |
|
505 |
|
506 declare |
|
507 DERIV_real_sqrt_generic[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] |
|
508 DERIV_real_root_generic[THEN DERIV_chain2, THEN DERIV_cong, DERIV_intros] |
462 |
509 |
463 lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)" |
510 lemma not_real_square_gt_zero [simp]: "(~ (0::real) < x*x) = (x = 0)" |
464 apply auto |
511 apply auto |
465 apply (cut_tac x = x and y = 0 in linorder_less_linear) |
512 apply (cut_tac x = x and y = 0 in linorder_less_linear) |
466 apply (simp add: zero_less_mult_iff) |
513 apply (simp add: zero_less_mult_iff) |