11
DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS MEKANIKA SOFTWARE SEMINARS

DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

Embed Size (px)

DESCRIPTION

DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS. MEKANIKA SOFTWARE SEMINARS. ODE INITIAL VALUE PROBLEMS. ODE solvers handle the following types of first-order ODE’s: Explicit ODEs Linearly implicit ODEs Fully implicit ODEs ODE IVP solvers include: - PowerPoint PPT Presentation

Citation preview

Page 1: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

DIFFERENTIAL EQUATIONS, INTEGRATION,

POLYNOMIALS, RANDOM NUMBERS

MEKANIKA SOFTWARE SEMINARS

Page 2: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

ODE INITIAL VALUE PROBLEMS

• ODE solvers handle the following types of first-order ODE’s:– Explicit ODEs– Linearly implicit ODEs – Fully implicit ODEs

• ODE IVP solvers include:

– ode45, ode23, ode113 (non-stiff DE’s)– ode23t, ode23tb (moderately stiff DE’s)– ode15s, ode23s (stiff DE’s)– ode15i (fully implicit

DE’s)

• All ODE’s must be reduced to first order DE’s by substitutions before MATLAB can actually solve them.

Page 3: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

ODE IVP SYNTAX

• ODE syntax :

– [t,y] = solver (odefun , tspan , y0)

– [t,y] = ode15i (odefun , tspan, y0, yp0)• The odefun is generally given as a function handle:

e.g. @function, where function defines the ODE.• Another parameter may be included in certain cases in

the syntax, viz. options• For ode15i one must endeavor to use the decic function

in MATLAB to compute consistent initial conditions.

[y0mod,yp0mod] = decic (odefun,t0,y0,fixed_y0,yp0,fixed_yp0)

Page 4: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

ODE BOUNDARY VALUE PROBLEMS

• Just as IVP’s require the initial conditions to be explicitly specified, BVP’s require boundary conditions to be specified.

• While solving BVP’s we must give MATLAB a consistent and continuous initial solution from where to begin its iterations. To do this, we use the bvpinit function as:

solinit = bvpinit( x, yinit, parameters)• This generates an initial mesh from which bvpinit can

form a good starting point for the BVP solver

• The BVP solver is bvp4c, which solves 2-point BVP’s using a 3-stage finite difference Lobatto-Illa formula which is 4th order uniformly accurate.

Page 5: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

ODE BVP SYNTAX

• sol = bvp4c(odefun,bcfun,solinit)• bcfun is a function that computes the residual in the

boundary conditions.– res = bcfun (ya,yb)

• solinit is a structure containing the initial guess for a solution.

Page 6: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

PARTIAL DIFFERENTIAL EQUATIONS

• c * δu/δt = x-m * f + s– c : coupling matrix; diagonal– m : symmetry of the problem– f : flux vector– s : source vector– all of the above are expressed as some function of

(x, t, u, δu/δx)

• The PDE holds for t0<t<tf and a<x<b and must satisfy :

– IC : u(x, t0) = u0(x)

– BC : p(x,t,u) + q(x,t)*f = 0

Page 7: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

PDE SOLVER SYNTAX

• sol = pdepe (m,pdefun,icfun,bcfun,xmesh,tspan) – [c,f,s] = pdefun (x,t,u,dudx)– u = icfun(x)– [pl,ql,pr,qr] = bcfun(xl,ul,xr,ur,t)

– Vector [x0, x1, ..., xn] – Vector [t0, t1, ..., tf]

• sol is a 3-dimensional vector where sol(i , j , k) gives component k of the solution at time tspan(i) and the mesh point xmesh(j)

• [uout ,DuoutDx] = pdeval (m,x,u(j,:),xout)

Page 8: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

NUMERICAL INTEGRATION

• Numerically evaluate with adaptive Simpson quadrature

– q = quad(fun,a,b,tol)• Numerically evaluate with adaptive Lobatto quadrature

– q = quadl(fun,a,b,tol)• Double integration

– q = dblquad(fun,xmin,xmax,ymin,ymax,tol)• Triple Integration

– triplequad(fun,xmin,xmax,ymin,ymax,zmin,zmax)

Page 9: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

IMPORTANT TRANSFORMS

• FOURIER TRANSFORM : F = fourier(f)• LAPLACE TRANSFORM : L = laplace(F) • Z-TRANSFORM : F = ztrans(f)

• INVERSE FOURIER : F = ifourier(f)• INVERSE LAPLACE : L = ilaplace(F) • INVERSE Z-TRANSFORM : F = iztrans(f)

Page 10: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

POLYNOMIAL MANIPULATION

• CONVOLUTION : w = conv(u,v)• DECONVOLUTION : [q,r] = deconv(v,u)• RESIDUE : [r,p,k] = residue(b,a)• DERIVATIVE : k = polyder(p)• INTEGRATION : polyint(p,k)• CURVE FITTING : [p,S,mu] = polyfit(x,y,n)• EVALUATION : [y,delta] = polyval(p,x,S,mu)

Page 11: DIFFERENTIAL EQUATIONS, INTEGRATION, POLYNOMIALS, RANDOM NUMBERS

RANDOM NUMBER GENERATION

• UNIFORM RANDOM NUMBERS : Y = rand(m,n)• NORMAL RANDOM NUMBERS : Y = randn(m,n)• RANDOM PERMUTATION : p = randperm(n)