Maple Calculations L-3-demo

626
-1

Published on

Maple Calculations Mathematics Module 3 of the course IO2081 Modelling for Industrial Design of the TU Delft.

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
626
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Maple Calculations L-3-demo

  1. 1. Lecture 4 : Some exercises about differential equations, the "for-loop" and the Euler method. classification of differential equations: We have the following categories: the first order separabel deq., the first order linear deq., the homogeneous second order linear deq.(without external forces), the non-homogeneous second order linear deq. For the last two: with constant coefficients: Classify the following differential eq.: (see Stewart chapter 9 and chapter 17) > DEQ1 d diff y x , x = y x 2 Cx$y x ; d DEQ1 := y x = y x 2 Cx y x dx > DEQ2 d diff y x , x = y x Cx$y x ; d DEQ2 := y x = y x Cx y x dx > DEQ3 d diff y x , x = x$ y x (1.1) (1.2) 2 ; DEQ3 := d y x =xy x dx 2 (1.3) > DEQ4 d diff y x , x = y x Cx; DEQ4 := > DEQ5 d diff y x , x, x = y x d y x = y x Cx dx 2 Cx$y x ; d2 2 DEQ5 := 2 y x = y x Cx y x dx > DEQ5 d diff y x , x, x = y x 2 Cx$diff y x , x C2$y x ; d2 d DEQ5 := 2 y x = y x 2 Cx y x C2 y x dx dx diff y x , x, x C2$ y x Cdiff y x , x > DEQ6 d = 1; 2 x Csin x 2 d d y x C2 y x C y x 2 dx dx =1 DEQ6 := x2 Csin x diff v x , x, x M x > DEQ7 d = ; 3 2 E x mI x sqrt 1 C diff v x , x d2 v x dx2 DEQ7 := 1C the answers: (1.4) d v x dx 2 3/2 = M x E x mI x (1.5) (1.6) (1.7) (1.8)
  2. 2. In succession: 1: first order not sep, not lin., 2.first order sep. and lin. 3. first order sep. 4.first order lin. 5. second order, non lin. 6. second order, lin. 7.first order sep. after transformation d v x =u x . dx The last differential equation DEQ7 : This last equation has to do with the deflection of beams. For instance we define M (internal moment) , E modulus of elasticity and mT moment of inertia of a crosssection of the beam at "place" x, as > M d x/1; E d x/1; mI d x/1; M := x/1 E := x/1 mI := x/1 (1.1.1.1) Then DEQ7 is: > DEQ7; d2 v x dx2 1C d v x dx 2 3/2 =1 (1.1.1.2) Solving: > dsolve DEQ7, v x ; 1 C_C2 (1.1.1.3) x C2 x _C1 C_C12 K1 What does this answer mean? _C1 and _C2 are integration constants, and perhaps you see that simplification of the answer gives: v x 2 = 1 K x C_C1 2. How is the beam bending? v x = _C1 Cx C1 _C1 Cx K1 K 2 > Little programming with maple, the "for-loop" and the "procedure": the "for loop": example 1: > value d 0 : n d 5 : for i from 1 by 1 to n do value d valueCi end do: > value; 15 (2.1.1.1) example 2: calculate the product n$ n K1 $ n K2 $...$3$2$1 using a "for-loop" for n = 1000: > n d 10 : produkt d 1 : for k from 2 to n do produkt d produkt$k :od: produkt; 3628800 (2.1.2.1) >
  3. 3. The procedure: example 1: We can define with "proc" a new own command named "sumnaturalnumbers" which calculates the sum of the first n numbers: > sumnaturalnumbers d proc n local value, i : value d 0 : for i from 1 by 1 to n do value d valueCi end do: return value : end proc: > sumnaturalnumbers 100 ; 5050 (2.2.1.1) > example 2: define a new command which calculates the product of the first n natural numbers: > productnaturalnumbers dproc n local produkt, k : produkt d 1 : for k from 2 to n do produkt d produkt$k :od: return produkt : end proc: > productnaturalnumbers 10 ; 3628800 (2.2.2.1) > produkt; (2.2.2.2) 3628800 example 3: define a new command which makes a plot of the function and its derivative in one picture on the interval [a,b]: > Picture dproc a, b, F local Picture1, Picture2; with plots : Picture1 d plot F x , x = a ..b, color = black : Picture2 d plot diff F x , x , x = a ..b, color = red : return display Picture1, Picture2 : end proc: > Picture K 10, x/x2 ; 10, (2.2.3.1) display PLOT ... , PLOT ... > the Euler method (see Stewart section 9.2), a numerical differential equation solver for y'= F x, y x : a simple example: We start with > Deq d diff y x , x = y x ; (3 1 1)
  4. 4. d y x =y x (3.1.1) dx underneath you see the set of Maple commands on differential equation > with DEtools ; AreSimilar, DEnormal, DEplot, DEplot3d, DEplot_polygon, DFactor, DFactorLCLM, (3.1.2) DFactorsols, Dchangevar, FunctionDecomposition, GCRD, Gosper, Heunsols, Homomorphisms, IVPsol, IsHyperexponential, LCLM, MeijerGsols, MultiplicativeDecomposition, ODEInvariants, PDEchangecoords, PolynomialNormalForm, RationalCanonicalForm, ReduceHyperexp, RiemannPsols, Xchange, Xcommutator, Xgauge, Zeilberger, abelsol, adjoint, autonomous, bernoullisol, buildsol, buildsym, canoni, caseplot, casesplit, checkrank, chinisol, clairautsol, constcoeffsols, convertAlg, convertsys, dalembertsol, dcoeffs, de2diffop, dfieldplot, diff_table, diffop2de, dperiodic_sols, dpolyform, dsubs, eigenring, endomorphism_charpoly, equinv, eta_k, eulersols, exactsol, expsols, exterior_power, firint, firtest, formal_sol, gen_exp, generate_ic, genhomosol, gensys, hamilton_eqs, hypergeomsols, hyperode, indicialeq, infgen, initialdata, integrate_sols, intfactor, invariants, kovacicsols, leftdivision, liesol, line_int, linearsol, matrixDE, matrix_riccati, maxdimsystems, moser_reduce, muchange, mult, mutest, newton_polygon, normalG2, ode_int_y, ode_y1, odeadvisor, odepde, parametricsol, particularsol, phaseportrait, poincare, polysols, power_equivalent, rational_equivalent, ratsols, redode, reduceOrder, reduce_order, regular_parts, regularsp, remove_RootOf, riccati_system, riccatisol, rifread, rifsimp, rightdivision, rtaylor, separablesol, singularities, solve_group, super_reduce, symgen, symmetric_power, symmetric_product, symtest, transinv, translate, untranslate, varparam, zoom > ?dfieldplot, With the above commando we can sketch a direction field plot of a ordinary first order differntial equation. > dfieldplot Deq, y x , x =K ..2, y =K ..2, color = black ; 2 2 Deq :=
  5. 5. 2 y(x) K 2 K 1 1 0 1 x 2 K 1 K 2 > ?DEplot > DEplot Deq, y x , x = 0 ..5, y = 0 ..30, y 0 =1 ;
  6. 6. 30 20 y(x) 10 0 1 2 3 4 5 x From this picture you can estimate the course of y(x) starting from a certain point. We just have to follow the arrows! This is the base of the Euler Method. the Euler procedure: Investigate the underneath procedure > EULERMETHODELIJST dproc n, a, b, F, x0, y0 local stapgrootte, X, Y, i, LIJST : b Ka : stapgrootte d n X d x0 : Y d y0 : LIJST d X, Y : for i from 1 to n do Y d Y Cstapgrootte$F X, Y : X d X Cstapgrootte : LIJST d LIJST, X, Y : od: return LIJST : end proc:
  7. 7. Above the procedure EULERMETHODELIJST returns a list of x and y coordinates which are approximations of the solution on a, b of y' x = F x, y with initial condition y x0 = y0. The input n is the number of subintervals of the interval a, b , a, b are the boundaries of the interval, F a function of two variables. Some investigations: > H d EULERMETHODELIJST 10, 0, 1, x, y /y, 0, 1 : > H; 1 11 1 121 3 1331 2 14641 1 161051 3 0, 1 , , , , , , , , , , , , (3.2.1) 10 10 5 100 10 1000 5 10000 2 100000 5 1771561 7 19487171 4 214358881 9 2357947691 , , , , , , , 1, 1000000 10 10000000 5 100000000 10 1000000000 25937424601 10000000000 > with plots : PLOT1 d plot H , color = red, thickness = 3 ; PLOT2 d plot exp x , x = 0 ..1, color = black, thickness = 2 : display PLOT1, PLOT2 ; PLOT1 := PLOT ... 2.6 2.4 2.2 2 1.8 1.6 1.4 1.2 1 0 0.2 0.4 0.6 x a real test > DV d diff y x , x = y x 2 Cx2; 0.8 1
  8. 8. d y x = y x 2 Cx2 dx (3.2.1.1) inc := y 0 = 1 DV := (3.2.1.2) > inc d y 0 = 1; > A d dsolve DV, inc , y x ; 3 4 2 3 1 2 Cπ BesselJ K , x 4 2 3 1 2 x K CBesselY K , x 2 4 2 3 Γ 4 K 2 3 1 1 2 Γ Cπ BesselJ , x 4 4 2 1 1 2 K CBesselY , x 2 4 2 3 Γ 4 Γ A := y x = 1 x K 3 4 A unintelligible answer , a plot: > plot rhs A , x = 0 ..0.5 ; x = 0 (3. 2 3 1 2 Cπ BesselJ K , x 4 2 3 1 2 CBesselY K , x 2 4 2 3 Γ 4 2 3 1 1 2 K Γ Cπ BesselJ , x 4 4 2 1 1 2 CBesselY , x 2 4 2 3 Γ 4 K Γ x !0 0 !x
  9. 9. 2 1.8 1.6 1.4 1.2 1 0 0.1 0.2 0.3 0.4 0.5 x > H1 d EULERMETHODELIJST 20, 0, 0.5, x, y /y2 Cx2, 0, 1 : > plot H1 ;
  10. 10. 1.9 1.8 1.7 1.6 1.5 1.4 1.3 1.2 1.1 1.0 > 0 0.1 0.2 0.3 0.4 0.5

×