lecture7 - Lecture 7 Symbolic Computations The focus of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Lecture 7 Symbolic Computations The focus of this course is on numerical computations, i.e. calculations, usually approximations, with floating point numbers. However, Matlab can also do symbolic computations which means exact calculations using symbols as in Algebra or Calculus. You should have done some symbolic Matlab computations in your Calculus courses and in this chapter we review what you should already know. Defining functions and basic operations Before doing any symbolic computation, one must declare the variables used to be symbolic: > syms x y A function is defined by simply typing the formula: > f = cos(x) + 3*x^2 Note that coefficients must be multiplied using * . To find specific values, you must use the command subs : > subs(f,pi) This command stands for substitute , it substitutes π for x in the formula for f . If we define another function: > g = exp(-y^2) then we can compose the functions: > h = compose(g,f) i.e. h ( x ) = g ( f ( x )). Since f and g are functions of different variables, their product must be a function of two variables: > k = f*g > subs(k,[x,y],[0,1]) We can do simple calculus operations, like differentiation: > f1 = diff(f) indefinite integrals (antiderivatives): > F = int(f) and definite integrals: > int(f,0,2*pi) To change a symbolic answer into a numerical answer, use the double command which stands for double precision , (not times 2): > double(ans) Note that some antiderivatives cannot be found in terms of elementary functions, for some of these it can be expressed in terms of special functions: > G = int(g) and for others Matlab does the best it can: 20 21-6-4-2 2 4 6-1-0.5 0.5 1 x cos(x 5 ) Figure 7.1: Graph of cos( x 5 ) produced by the ezplot command. It is wrong because cos u should oscillate smoothly between...
View Full Document

This note was uploaded on 02/09/2012 for the course MATH 344 taught by Professor Young,t during the Fall '08 term at Ohio University- Athens.

Page1 / 8

lecture7 - Lecture 7 Symbolic Computations The focus of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online