Maxima 5.31.3 http://maxima.sourceforge.net using Lisp CLISP 2.49 (2010-07-07) Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. (%i1) batch("to4.max") read and interpret file: /home/dennis/mastersource/mine/taylorode/to4.max (%i2) keepfloat:true (%i3) load("stringproc") (%i4) exact_soln_y(x):=block([],(1.0+2.0*x)^sin(x)) (%i5) solvediffeq(f,y,xl,x0,y0,n,xf,h):=block( [yy,xx,true_y,t0,tf,est_time,iter,adj,series,series2], x:first(xl),iter:0,xx:x0,yy:y0,t0:elapsed_real_time(), series:taylor(first(f),first(xl),x0,n), series2:integrate(series,x),adj:yy-subst(xx,x,series2), while xx < xf and iter < 100 do (true_y:exact_soln_y(xx), print(iter," Iterations x = ",xx," y = ",yy, " true y = ",true_y),xx:h+xx, series:taylor(first(f),first(xl),xx,n), series2:integrate(series,x), yy:adj+subst(xx,x,series2),true_y:exact_soln_y(xx), iter:1+iter),tf:elapsed_real_time(), if xx-x0 > 0.0 then (est_time:(tf-t0)*(xf-x0)/(xx-x0)/60.0/60.0, printf(true,"Estimated Time = ~f Hours ~%", est_time)) else printf(true,"Zero time")) (%o5) solvediffeq(f, y, xl, x0, y0, n, xf, h) := block([yy, xx, true_y, t0, tf, est_time, iter, adj, series, series2], x : first(xl), iter : 0, xx : x0, yy : y0, t0 : elapsed_real_time(), series : taylor(first(f), first(xl), x0, n), series2 : integrate(series, x), adj : yy - subst(xx, x, series2), while (xx < xf) and (iter < 100) do (true_y : exact_soln_y(xx), print(iter, " Iterations x = ", xx, " y = ", yy, " true y = ", true_y), xx : h + xx, series : taylor(first(f), first(xl), xx, n), series2 : integrate(series, x), yy : adj + subst(xx, x, series2), true_y : exact_soln_y(xx), iter : 1 + iter), tf : elapsed_real_time(), (tf - t0) (xf - x0) ------------------- xx - x0 ------------------- 60.0 if xx - x0 > 0.0 then (est_time : -------------------, 60.0 printf(true, "Estimated Time = ~f Hours ~%", est_time)) else printf(true, "Zero time")) (%i6) solvediffeq([(1.0+2.0*x)^sin(x)*(2.0*sin(x)/(1.0+2.0*x) +cos(x)*log(1.0+2.0*x))],[y],[x],0.1, exact_soln_y(0.1),30,1.0,1.0E-5) 0 Iterations x = 0.1 y = 1.01836844605944 true y = 1.01836844605944 1 Iterations x = 0.10001 y = 1.01837198856965 true y = 1.0183719881022 2 Iterations x = 0.10002 y = 1.018375531400061 true y = 1.01837553046494 3 Iterations x = 0.10003 y = 1.018379074550669 true y = 1.018379073147654 4 Iterations x = 0.10004 y = 1.018382618021469 true y = 1.018382616150338 5 Iterations x = 0.10005 y = 1.018386161812457 true y = 1.018386159472986 6 Iterations x = 0.10006 y = 1.018389705923628 true y = 1.018389703115594 7 Iterations x = 0.10007 y = 1.018393250354976 true y = 1.018393247078157 8 Iterations x = 0.10008 y = 1.018396795106496 true y = 1.01839679136067 9 Iterations x = 0.10009 y = 1.018400340178185 true y = 1.018400335963128 10 Iterations x = 0.1001 y = 1.018403885570037 true y = 1.018403880885526 11 Iterations x = 0.10011 y = 1.018407431282047 true y = 1.018407426127858 12 Iterations x = 0.10012 y = 1.018410977314211 true y = 1.018410971690121 13 Iterations x = 0.10013 y = 1.018414523666523 true y = 1.018414517572309 14 Iterations x = 0.10014 y = 1.018418070338979 true y = 1.018418063774417 15 Iterations x = 0.10015 y = 1.018421617331573 true y = 1.018421610296441 16 Iterations x = .1001599999999999 y = 1.018425164644301 true y = 1.018425157138374 17 Iterations x = .1001699999999999 y = 1.018428712277159 true y = 1.018428704300214 18 Iterations x = .1001799999999999 y = 1.018432260230141 true y = 1.018432251781954 19 Iterations x = .1001899999999999 y = 1.018435808503242 true y = 1.018435799583589 20 Iterations x = .1001999999999999 y = 1.018439357096458 true y = 1.018439347705115 21 Iterations x = .1002099999999999 y = 1.018442906009783 true y = 1.018442896146526 22 Iterations x = .1002199999999999 y = 1.018446455243213 true y = 1.018446444907819 23 Iterations x = .1002299999999999 y = 1.018450004796743 true y = 1.018449993988987 24 Iterations x = .1002399999999999 y = 1.018453554670368 true y = 1.018453543390026 25 Iterations x = .1002499999999999 y = 1.018457104864084 true y = 1.018457093110931 26 Iterations x = .1002599999999999 y = 1.018460655377885 true y = 1.018460643151696 27 Iterations x = .1002699999999999 y = 1.018464206211766 true y = 1.018464193512319 28 Iterations x = .1002799999999999 y = 1.018467757365723 true y = 1.018467744192792 29 Iterations x = .1002899999999999 y = 1.018471308839751 true y = 1.018471295193111 30 Iterations x = .1002999999999999 y = 1.018474860633845 true y = 1.018474846513272 31 Iterations x = .1003099999999999 y = 1.018478412748 true y = 1.018478398153269 32 Iterations x = .1003199999999999 y = 1.018481965182212 true y = 1.018481950113098 33 Iterations x = .1003299999999999 y = 1.018485517936474 true y = 1.018485502392753 34 Iterations x = .1003399999999999 y = 1.018489071010784 true y = 1.018489054992229 35 Iterations x = .1003499999999999 y = 1.018492624405135 true y = 1.018492607911523 36 Iterations x = .1003599999999999 y = 1.018496178119523 true y = 1.018496161150628 37 Iterations x = .1003699999999999 y = 1.018499732153944 true y = 1.018499714709539 38 Iterations x = .1003799999999999 y = 1.018503286508391 true y = 1.018503268588253 39 Iterations x = .1003899999999999 y = 1.018506841182861 true y = 1.018506822786764 40 Iterations x = .1003999999999999 y = 1.018510396177348 true y = 1.018510377305067 41 Iterations x = .1004099999999998 y = 1.018513951491848 true y = 1.018513932143156 42 Iterations x = .1004199999999998 y = 1.018517507126356 true y = 1.018517487301028 43 Iterations x = .1004299999999998 y = 1.018521063080867 true y = 1.018521042778677 44 Iterations x = .1004399999999998 y = 1.018524619355375 true y = 1.018524598576099 45 Iterations x = .1004499999999998 y = 1.018528175949878 true y = 1.018528154693288 46 Iterations x = .1004599999999998 y = 1.018531732864368 true y = 1.018531711130239 47 Iterations x = .1004699999999998 y = 1.018535290098843 true y = 1.018535267886948 48 Iterations x = .1004799999999998 y = 1.018538847653296 true y = 1.01853882496341 49 Iterations x = .1004899999999998 y = 1.018542405527723 true y = 1.01854238235962 50 Iterations x = .1004999999999998 y = 1.018545963722119 true y = 1.018545940075572 51 Iterations x = .1005099999999998 y = 1.018549522236479 true y = 1.018549498111262 52 Iterations x = .1005199999999998 y = 1.018553081070799 true y = 1.018553056466685 53 Iterations x = .1005299999999998 y = 1.018556640225073 true y = 1.018556615141836 54 Iterations x = .1005399999999998 y = 1.018560199699297 true y = 1.01856017413671 55 Iterations x = .1005499999999998 y = 1.018563759493466 true y = 1.018563733451302 56 Iterations x = .1005599999999998 y = 1.018567319607576 true y = 1.018567293085608 57 Iterations x = .1005699999999998 y = 1.01857088004162 true y = 1.018570853039622 58 Iterations x = .1005799999999998 y = 1.018574440795595 true y = 1.01857441331334 59 Iterations x = .1005899999999998 y = 1.018578001869495 true y = 1.018577973906756 60 Iterations x = .1005999999999998 y = 1.018581563263316 true y = 1.018581534819866 61 Iterations x = .1006099999999998 y = 1.018585124977053 true y = 1.018585096052664 62 Iterations x = .1006199999999998 y = 1.0185886870107 true y = 1.018588657605146 63 Iterations x = .1006299999999998 y = 1.018592249364255 true y = 1.018592219477308 64 Iterations x = .1006399999999998 y = 1.01859581203771 true y = 1.018595781669143 65 Iterations x = .1006499999999998 y = 1.018599375031062 true y = 1.018599344180647 66 Iterations x = .1006599999999997 y = 1.018602938344306 true y = 1.018602907011815 67 Iterations x = .1006699999999997 y = 1.018606501977436 true y = 1.018606470162643 68 Iterations x = .1006799999999997 y = 1.018610065930449 true y = 1.018610033633125 69 Iterations x = .1006899999999997 y = 1.018613630203339 true y = 1.018613597423256 70 Iterations x = .1006999999999997 y = 1.018617194796101 true y = 1.018617161533032 71 Iterations x = .1007099999999997 y = 1.018620759708731 true y = 1.018620725962447 72 Iterations x = .1007199999999997 y = 1.018624324941223 true y = 1.018624290711497 73 Iterations x = .1007299999999997 y = 1.018627890493574 true y = 1.018627855780177 74 Iterations x = .1007399999999997 y = 1.018631456365777 true y = 1.018631421168481 75 Iterations x = .1007499999999997 y = 1.018635022557829 true y = 1.018634986876406 76 Iterations x = .1007599999999997 y = 1.018638589069724 true y = 1.018638552903946 77 Iterations x = .1007699999999997 y = 1.018642155901458 true y = 1.018642119251095 78 Iterations x = .1007799999999997 y = 1.018645723053026 true y = 1.01864568591785 79 Iterations x = .1007899999999997 y = 1.018649290524422 true y = 1.018649252904206 80 Iterations x = .1007999999999997 y = 1.018652858315643 true y = 1.018652820210157 81 Iterations x = .1008099999999997 y = 1.018656426426682 true y = 1.018656387835698 82 Iterations x = .1008199999999997 y = 1.018659994857537 true y = 1.018659955780825 83 Iterations x = .1008299999999997 y = 1.0186635636082 true y = 1.018663524045532 84 Iterations x = .1008399999999997 y = 1.018667132678669 true y = 1.018667092629816 85 Iterations x = .1008499999999997 y = 1.018670702068938 true y = 1.01867066153367 86 Iterations x = .1008599999999997 y = 1.018674271779002 true y = 1.01867423075709 87 Iterations x = .1008699999999997 y = 1.018677841808856 true y = 1.018677800300071 88 Iterations x = .1008799999999997 y = 1.018681412158496 true y = 1.018681370162609 89 Iterations x = .1008899999999997 y = 1.018684982827916 true y = 1.018684940344698 90 Iterations x = .1008999999999997 y = 1.018688553817112 true y = 1.018688510846333 91 Iterations x = .1009099999999997 y = 1.018692125126079 true y = 1.01869208166751 92 Iterations x = .1009199999999996 y = 1.018695696754813 true y = 1.018695652808223 93 Iterations x = .1009299999999996 y = 1.018699268703308 true y = 1.018699224268468 94 Iterations x = .1009399999999996 y = 1.018702840971559 true y = 1.018702796048239 95 Iterations x = .1009499999999996 y = 1.018706413559563 true y = 1.018706368147533 96 Iterations x = .1009599999999996 y = 1.018709986467313 true y = 1.018709940566343 97 Iterations x = .1009699999999996 y = 1.018713559694805 true y = 1.018713513304666 98 Iterations x = .1009799999999996 y = 1.018717133242035 true y = 1.018717086362496 99 Iterations x = .1009899999999996 y = 1.018720707108997 true y = 1.018720659739828 Estimated Time = 4.920501250001908 Hours (%o6) to4.max