36 |
36 |
37 lemma Maclaurin_lemma: |
37 lemma Maclaurin_lemma: |
38 "0 < h ==> |
38 "0 < h ==> |
39 \<exists>B. f h = sumr 0 n (%m. (j m / real (fact m)) * (h^m)) + |
39 \<exists>B. f h = sumr 0 n (%m. (j m / real (fact m)) * (h^m)) + |
40 (B * ((h^n) / real(fact n)))" |
40 (B * ((h^n) / real(fact n)))" |
41 by (rule_tac x = "(f h - sumr 0 n (%m. (j m / real (fact m)) * h^m)) * |
41 apply (rule_tac x = "(f h - sumr 0 n (%m. (j m / real (fact m)) * h^m)) * |
42 real(fact n) / (h^n)" |
42 real(fact n) / (h^n)" |
43 in exI, auto) |
43 in exI) |
44 |
44 apply (simp add: times_divide_eq) |
|
45 done |
45 |
46 |
46 lemma eq_diff_eq': "(x = y - z) = (y = x + (z::real))" |
47 lemma eq_diff_eq': "(x = y - z) = (y = x + (z::real))" |
47 by arith |
48 by arith |
48 |
49 |
49 text{*A crude tactic to differentiate by proof.*} |
50 text{*A crude tactic to differentiate by proof.*} |
157 apply (erule exE) |
158 apply (erule exE) |
158 apply (subgoal_tac "difg 0 = g") |
159 apply (subgoal_tac "difg 0 = g") |
159 prefer 2 apply simp |
160 prefer 2 apply simp |
160 apply (frule Maclaurin_lemma2, assumption+) |
161 apply (frule Maclaurin_lemma2, assumption+) |
161 apply (subgoal_tac "\<forall>ma. ma < n --> (\<exists>t. 0 < t & t < h & difg (Suc ma) t = 0) ") |
162 apply (subgoal_tac "\<forall>ma. ma < n --> (\<exists>t. 0 < t & t < h & difg (Suc ma) t = 0) ") |
162 apply (drule_tac x = m and P="%m. m<n --> (\<exists>t. ?QQ m t)" in spec) |
163 apply (drule_tac x = m and P="%m. m<n --> (\<exists>t. ?QQ m t)" in spec) |
163 apply (erule impE) |
164 apply (erule impE) |
164 apply (simp (no_asm_simp)) |
165 apply (simp (no_asm_simp)) |
165 apply (erule exE) |
166 apply (erule exE) |
166 apply (rule_tac x = t in exI) |
167 apply (rule_tac x = t in exI) |
167 apply (simp del: realpow_Suc fact_Suc) |
168 apply (simp add: times_divide_eq del: realpow_Suc fact_Suc) |
168 apply (subgoal_tac "\<forall>m. m < n --> difg m 0 = 0") |
169 apply (subgoal_tac "\<forall>m. m < n --> difg m 0 = 0") |
169 prefer 2 |
170 prefer 2 |
170 apply clarify |
171 apply clarify |
171 apply simp |
172 apply simp |
172 apply (frule_tac m = ma in less_add_one, clarify) |
173 apply (frule_tac m = ma in less_add_one, clarify) |
252 sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + |
253 sumr 0 n (%m. diff m 0 / real (fact m) * h ^ m) + |
253 diff n t / real (fact n) * h ^ n" |
254 diff n t / real (fact n) * h ^ n" |
254 apply (cut_tac f = "%x. f (-x)" |
255 apply (cut_tac f = "%x. f (-x)" |
255 and diff = "%n x. ((- 1) ^ n) * diff n (-x)" |
256 and diff = "%n x. ((- 1) ^ n) * diff n (-x)" |
256 and h = "-h" and n = n in Maclaurin_objl) |
257 and h = "-h" and n = n in Maclaurin_objl) |
257 apply simp |
258 apply (simp add: times_divide_eq) |
258 apply safe |
259 apply safe |
259 apply (subst minus_mult_right) |
260 apply (subst minus_mult_right) |
260 apply (rule DERIV_cmult) |
261 apply (rule DERIV_cmult) |
261 apply (rule lemma_DERIV_subst) |
262 apply (rule lemma_DERIV_subst) |
262 apply (rule DERIV_chain2 [where g=uminus]) |
263 apply (rule DERIV_chain2 [where g=uminus]) |
301 sumr 0 n (%m. diff m 0 / real (fact m) * x ^ m) + |
302 sumr 0 n (%m. diff m 0 / real (fact m) * x ^ m) + |
302 diff n t / real (fact n) * x ^ n" |
303 diff n t / real (fact n) * x ^ n" |
303 apply (case_tac "n = 0", force) |
304 apply (case_tac "n = 0", force) |
304 apply (case_tac "x = 0") |
305 apply (case_tac "x = 0") |
305 apply (rule_tac x = 0 in exI) |
306 apply (rule_tac x = 0 in exI) |
306 apply (force simp add: Maclaurin_bi_le_lemma) |
307 apply (force simp add: Maclaurin_bi_le_lemma times_divide_eq) |
307 apply (cut_tac x = x and y = 0 in linorder_less_linear, auto) |
308 apply (cut_tac x = x and y = 0 in linorder_less_linear, auto) |
308 txt{*Case 1, where @{term "x < 0"}*} |
309 txt{*Case 1, where @{term "x < 0"}*} |
309 apply (cut_tac f = "diff 0" and diff = diff and h = x and n = n in Maclaurin_minus_objl, safe) |
310 apply (cut_tac f = "diff 0" and diff = diff and h = x and n = n in Maclaurin_minus_objl, safe) |
310 apply (simp add: abs_if) |
311 apply (simp add: abs_if) |
311 apply (rule_tac x = t in exI) |
312 apply (rule_tac x = t in exI) |
412 |
413 |
413 lemma Suc_mult_two_diff_one [rule_format, simp]: |
414 lemma Suc_mult_two_diff_one [rule_format, simp]: |
414 "0 < n --> Suc (2 * n - 1) = 2*n" |
415 "0 < n --> Suc (2 * n - 1) = 2*n" |
415 by (induct_tac "n", auto) |
416 by (induct_tac "n", auto) |
416 |
417 |
417 lemma Maclaurin_sin_expansion: |
418 |
418 "\<exists>t. sin x = |
419 text{*It is unclear why so many variant results are needed.*} |
419 (sumr 0 n (%m. (if even m then 0 |
|
420 else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) * |
|
421 x ^ m)) |
|
422 + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
|
423 apply (cut_tac f = sin and n = n and x = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin_all_lt_objl) |
|
424 apply safe |
|
425 apply (simp (no_asm)) |
|
426 apply (simp (no_asm)) |
|
427 apply (case_tac "n", clarify, simp) |
|
428 apply (drule_tac x = 0 in spec, simp, simp) |
|
429 apply (rule ccontr, simp) |
|
430 apply (drule_tac x = x in spec, simp) |
|
431 apply (erule ssubst) |
|
432 apply (rule_tac x = t in exI, simp) |
|
433 apply (rule sumr_fun_eq) |
|
434 apply (auto simp add: odd_Suc_mult_two_ex) |
|
435 apply (auto simp add: even_mult_two_ex simp del: fact_Suc realpow_Suc) |
|
436 (*Could sin_zero_iff help?*) |
|
437 done |
|
438 |
420 |
439 lemma Maclaurin_sin_expansion2: |
421 lemma Maclaurin_sin_expansion2: |
440 "\<exists>t. abs t \<le> abs x & |
422 "\<exists>t. abs t \<le> abs x & |
441 sin x = |
423 sin x = |
442 (sumr 0 n (%m. (if even m then 0 |
424 (sumr 0 n (%m. (if even m then 0 |
445 + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
427 + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
446 apply (cut_tac f = sin and n = n and x = x |
428 apply (cut_tac f = sin and n = n and x = x |
447 and diff = "%n x. sin (x + 1/2*real n * pi)" in Maclaurin_all_lt_objl) |
429 and diff = "%n x. sin (x + 1/2*real n * pi)" in Maclaurin_all_lt_objl) |
448 apply safe |
430 apply safe |
449 apply (simp (no_asm)) |
431 apply (simp (no_asm)) |
450 apply (simp (no_asm)) |
432 apply (simp (no_asm) add: times_divide_eq) |
451 apply (case_tac "n", clarify, simp, simp) |
433 apply (case_tac "n", clarify, simp, simp) |
452 apply (rule ccontr, simp) |
434 apply (rule ccontr, simp) |
453 apply (drule_tac x = x in spec, simp) |
435 apply (drule_tac x = x in spec, simp) |
454 apply (erule ssubst) |
436 apply (erule ssubst) |
455 apply (rule_tac x = t in exI, simp) |
437 apply (rule_tac x = t in exI, simp) |
456 apply (rule sumr_fun_eq) |
438 apply (rule sumr_fun_eq) |
457 apply (auto simp add: odd_Suc_mult_two_ex) |
439 apply (auto simp add: sin_zero_iff odd_Suc_mult_two_ex times_divide_eq) |
458 apply (auto simp add: even_mult_two_ex simp del: fact_Suc realpow_Suc) |
440 done |
459 done |
441 |
|
442 lemma Maclaurin_sin_expansion: |
|
443 "\<exists>t. sin x = |
|
444 (sumr 0 n (%m. (if even m then 0 |
|
445 else ((- 1) ^ ((m - (Suc 0)) div 2)) / real (fact m)) * |
|
446 x ^ m)) |
|
447 + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
|
448 apply (insert Maclaurin_sin_expansion2 [of x n]) |
|
449 apply (blast intro: elim:); |
|
450 done |
|
451 |
|
452 |
460 |
453 |
461 lemma Maclaurin_sin_expansion3: |
454 lemma Maclaurin_sin_expansion3: |
462 "[| 0 < n; 0 < x |] ==> |
455 "[| 0 < n; 0 < x |] ==> |
463 \<exists>t. 0 < t & t < x & |
456 \<exists>t. 0 < t & t < x & |
464 sin x = |
457 sin x = |
467 x ^ m)) |
460 x ^ m)) |
468 + ((sin(t + 1/2 * real(n) *pi) / real (fact n)) * x ^ n)" |
461 + ((sin(t + 1/2 * real(n) *pi) / real (fact n)) * x ^ n)" |
469 apply (cut_tac f = sin and n = n and h = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin_objl) |
462 apply (cut_tac f = sin and n = n and h = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin_objl) |
470 apply safe |
463 apply safe |
471 apply simp |
464 apply simp |
472 apply (simp (no_asm)) |
465 apply (simp (no_asm) add: times_divide_eq) |
473 apply (erule ssubst) |
466 apply (erule ssubst) |
474 apply (rule_tac x = t in exI, simp) |
467 apply (rule_tac x = t in exI, simp) |
475 apply (rule sumr_fun_eq) |
468 apply (rule sumr_fun_eq) |
476 apply (auto simp add: odd_Suc_mult_two_ex) |
469 apply (auto simp add: sin_zero_iff odd_Suc_mult_two_ex times_divide_eq) |
477 apply (auto simp add: even_mult_two_ex simp del: fact_Suc realpow_Suc) |
|
478 done |
470 done |
479 |
471 |
480 lemma Maclaurin_sin_expansion4: |
472 lemma Maclaurin_sin_expansion4: |
481 "0 < x ==> |
473 "0 < x ==> |
482 \<exists>t. 0 < t & t \<le> x & |
474 \<exists>t. 0 < t & t \<le> x & |
486 x ^ m)) |
478 x ^ m)) |
487 + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
479 + ((sin(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
488 apply (cut_tac f = sin and n = n and h = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin2_objl) |
480 apply (cut_tac f = sin and n = n and h = x and diff = "%n x. sin (x + 1/2*real (n) *pi)" in Maclaurin2_objl) |
489 apply safe |
481 apply safe |
490 apply simp |
482 apply simp |
491 apply (simp (no_asm)) |
483 apply (simp (no_asm) add: times_divide_eq) |
492 apply (erule ssubst) |
484 apply (erule ssubst) |
493 apply (rule_tac x = t in exI, simp) |
485 apply (rule_tac x = t in exI, simp) |
494 apply (rule sumr_fun_eq) |
486 apply (rule sumr_fun_eq) |
495 apply (auto simp add: odd_Suc_mult_two_ex) |
487 apply (auto simp add: sin_zero_iff odd_Suc_mult_two_ex times_divide_eq) |
496 apply (auto simp add: even_mult_two_ex simp del: fact_Suc realpow_Suc) |
|
497 done |
488 done |
498 |
489 |
499 |
490 |
500 subsection{*Maclaurin Expansion for Cosine Function*} |
491 subsection{*Maclaurin Expansion for Cosine Function*} |
501 |
492 |
516 x ^ m)) |
507 x ^ m)) |
517 + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
508 + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
518 apply (cut_tac f = cos and n = n and x = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_all_lt_objl) |
509 apply (cut_tac f = cos and n = n and x = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_all_lt_objl) |
519 apply safe |
510 apply safe |
520 apply (simp (no_asm)) |
511 apply (simp (no_asm)) |
521 apply (simp (no_asm)) |
512 apply (simp (no_asm) add: times_divide_eq) |
522 apply (case_tac "n", simp) |
513 apply (case_tac "n", simp) |
523 apply (simp del: sumr_Suc) |
514 apply (simp del: sumr_Suc) |
524 apply (rule ccontr, simp) |
515 apply (rule ccontr, simp) |
525 apply (drule_tac x = x in spec, simp) |
516 apply (drule_tac x = x in spec, simp) |
526 apply (erule ssubst) |
517 apply (erule ssubst) |
527 apply (rule_tac x = t in exI, simp) |
518 apply (rule_tac x = t in exI, simp) |
528 apply (rule sumr_fun_eq) |
519 apply (rule sumr_fun_eq) |
529 apply (auto simp add: odd_Suc_mult_two_ex) |
520 apply (auto simp add: cos_zero_iff even_mult_two_ex) |
530 apply (auto simp add: even_mult_two_ex left_distrib cos_add simp del: fact_Suc realpow_Suc) |
|
531 apply (simp add: mult_commute [of _ pi]) |
|
532 done |
521 done |
533 |
522 |
534 lemma Maclaurin_cos_expansion2: |
523 lemma Maclaurin_cos_expansion2: |
535 "[| 0 < x; 0 < n |] ==> |
524 "[| 0 < x; 0 < n |] ==> |
536 \<exists>t. 0 < t & t < x & |
525 \<exists>t. 0 < t & t < x & |
541 x ^ m)) |
530 x ^ m)) |
542 + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
531 + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
543 apply (cut_tac f = cos and n = n and h = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_objl) |
532 apply (cut_tac f = cos and n = n and h = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_objl) |
544 apply safe |
533 apply safe |
545 apply simp |
534 apply simp |
546 apply (simp (no_asm)) |
535 apply (simp (no_asm) add: times_divide_eq) |
547 apply (erule ssubst) |
536 apply (erule ssubst) |
548 apply (rule_tac x = t in exI, simp) |
537 apply (rule_tac x = t in exI, simp) |
549 apply (rule sumr_fun_eq) |
538 apply (rule sumr_fun_eq) |
550 apply (auto simp add: odd_Suc_mult_two_ex) |
539 apply (auto simp add: cos_zero_iff even_mult_two_ex) |
551 apply (auto simp add: even_mult_two_ex left_distrib cos_add simp del: fact_Suc realpow_Suc) |
540 done |
552 apply (simp add: mult_commute [of _ pi]) |
541 |
553 done |
542 lemma Maclaurin_minus_cos_expansion: |
554 |
543 "[| x < 0; 0 < n |] ==> |
555 lemma Maclaurin_minus_cos_expansion: "[| x < 0; 0 < n |] ==> |
|
556 \<exists>t. x < t & t < 0 & |
544 \<exists>t. x < t & t < 0 & |
557 cos x = |
545 cos x = |
558 (sumr 0 n (%m. (if even m |
546 (sumr 0 n (%m. (if even m |
559 then (- 1) ^ (m div 2)/(real (fact m)) |
547 then (- 1) ^ (m div 2)/(real (fact m)) |
560 else 0) * |
548 else 0) * |
561 x ^ m)) |
549 x ^ m)) |
562 + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
550 + ((cos(t + 1/2 * real (n) *pi) / real (fact n)) * x ^ n)" |
563 apply (cut_tac f = cos and n = n and h = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_minus_objl) |
551 apply (cut_tac f = cos and n = n and h = x and diff = "%n x. cos (x + 1/2*real (n) *pi)" in Maclaurin_minus_objl) |
564 apply safe |
552 apply safe |
565 apply simp |
553 apply simp |
566 apply (simp (no_asm)) |
554 apply (simp (no_asm) add: times_divide_eq) |
567 apply (erule ssubst) |
555 apply (erule ssubst) |
568 apply (rule_tac x = t in exI, simp) |
556 apply (rule_tac x = t in exI, simp) |
569 apply (rule sumr_fun_eq) |
557 apply (rule sumr_fun_eq) |
570 apply (auto simp add: odd_Suc_mult_two_ex) |
558 apply (auto simp add: cos_zero_iff even_mult_two_ex) |
571 apply (auto simp add: even_mult_two_ex left_distrib cos_add simp del: fact_Suc realpow_Suc) |
|
572 apply (simp add: mult_commute [of _ pi]) |
|
573 done |
559 done |
574 |
560 |
575 (* ------------------------------------------------------------------------- *) |
561 (* ------------------------------------------------------------------------- *) |
576 (* Version for ln(1 +/- x). Where is it?? *) |
562 (* Version for ln(1 +/- x). Where is it?? *) |
577 (* ------------------------------------------------------------------------- *) |
563 (* ------------------------------------------------------------------------- *) |