CSE 123 Symbolic Processing. Declaring Symbolic Variables and Constants To enable symbolic processing, the variables and constants involved must first.

Slides:



Advertisements
Similar presentations
Beginning Programming for Engineers
Advertisements

More type systems. Physical units A unit expression is defined by following grammar u, v := b | 1 | u * v | u -1 where u, v are unit expressions themselves.
Eng Ship Structures 1 Hull Girder Response Analysis
Chapter 11: Symbolic Computing for Calculus
Solving Linear Equations  Many applications require solving systems of linear equations.  One method for solving linear equations is to write a matrix.
Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. D. Cinpinski E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Taylor’s Series.
Unit 7 Symbolic Processing 中華技術學院電子系 副教授 蔡樸生 副教授 林盈灝.
MATLAB FUNDAMENTALS: USER DEFINED FUNCTIONS THE SYMBOLIC TOOLBOX HP 100 – MATLAB Wednesday, 10/29/2014
Integrals 5.
Lecture 16 Symbolic Mathematics Symbolic mathematics: algebraezplotcalculus © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
7 INVERSE FUNCTIONS.
Matlab Matlab is a powerful mathematical tool and this tutorial is intended to be an introduction to some of the functions that you might find useful.
3 DERIVATIVES. In this section, we will learn: How functions are defined implicitly. 3.6 Implicit Differentiation DERIVATIVES.
8 Indefinite Integrals Case Study 8.1 Concepts of Indefinite Integrals
Logarithmic Functions  In this section, another type of function will be studied called the logarithmic function. There is a close connection between.
Full Year Review MTH 251/252/253 – Calculus. MTH251 – Differential Calculus Limits Continuity Derivatives Applications.
Preview of Calculus.
Algebra Review. Polynomial Manipulation Combine like terms, multiply, FOIL, factor, etc.
1 1.0 Students solve equations and inequalities involving absolute value. Algebra 2 Standards.
+ FE Mathematics Review Dr. Omar Meza Assistant Professor Department of Mechanical Engineering.
3 DIFFERENTIATION RULES.
7.2The Natural Logarithmic and Exponential Function Math 6B Calculus II.
3.6 Derivatives of Logarithmic Functions 1Section 3.6 Derivatives of Log Functions.
Techniques of Integration
S C alculu. 1. Preliminaries 2. Functions and Limits 3. The Derivative 4. Applications of the Derivative 5. The Integral 6. Applications of the Integral.
Differential calculation of function many the variables. Derivate of part. Part and complete differentials. Application complete a differential.
Formal Definition of Antiderivative and Indefinite Integral Lesson 5-3.
Math 15 Lecture 7 University of California, Merced Scilab A “Very” Short Introduction.
 The functions that we have met so far can be described by expressing one variable explicitly in terms of another variable.  For example,, or y = x sin.
ENGR-25_Prob_10-25_Catenary_Solution.ppt.ppt 1 Bruce Mayer, PE ENGR/MTH/PHYS25: Computational Methods Bruce Mayer, PE Registered.
4.4 Solving Exponential and Logarithmic Equations.
Chapter 12 Review: Symbolic Mathematics
1 Section 5.5 Solving Recurrences Any recursively defined function ƒ with domain N that computes numbers is called a recurrence or recurrence relation.
3 DIFFERENTIATION RULES. The functions that we have met so far can be described by expressing one variable explicitly in terms of another variable. 
MATLAB Basics. The following screen will appear when you start up Matlab. All of the commands that will be discussed should be typed at the >> prompt.
Chapter 2: First Steps in MuPAD MATLAB for Scientist and Engineers Using Symbolic Toolbox.
An Introduction to MathCAD Finding Solutions and Symbolic Maths.
Copyright © Cengage Learning. All rights reserved. 7 Techniques of Integration.
Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB.
3.6 Derivatives of Logarithmic Functions In this section, we: use implicit differentiation to find the derivatives of the logarithmic functions and, in.
Chapter 5-The Integral Calculus, 2ed, by Blank & Krantz, Copyright 2011 by John Wiley & Sons, Inc, All Rights Reserved.
Introduction to Matlab
Chapter 8 Integration Techniques. 8.1 Integration by Parts.
THE WORK OF A FORCE, THE PRINCIPLE OF WORK AND ENERGY & SYSTEMS OF PARTICLES Today’s Objectives: Students will be able to: 1.Calculate the work of a force.
APPLICATIONS A roller coaster makes use of gravitational forces to assist the cars in reaching high speeds in the “valleys” of the track. How can we design.
The previous mathematics courses your have studied dealt with finite solutions to a given problem or problems. Calculus deals more with continuous mathematics.
Calculus, 8/E by Howard Anton, Irl Bivens, and Stephen Davis Copyright © 2005 by John Wiley & Sons, Inc. All rights reserved. Chapter Integration.
Antiderivatives Indefinite Integrals. Definition  A function F is an antiderivative of f on an interval I if F’(x) = f(x) for all x in I.  Example:
A) b) c) d) Solving LOG Equations and Inequalities **SIMPLIFY all LOG Expressions** CASE #1: LOG on one side and VALUE on other Side Apply Exponential.
Chapter 11 Calculus. Symbolic Expressions Required: > Symbolic Math Toolbox > Use Symbolic Variables.
Tangents.
7.2* Natural Logarithmic Function In this section, we will learn about: The natural logarithmic function and its derivatives. INVERSE FUNCTIONS.
EEE 242 Computer Tools for Electrical Engineering Lecture IV Mustafa KARABULUT.
MATLAB (Matrix Algebra laboratory), distributed by The MathWorks, is a technical computing environment for high performance numeric computation and.
Algebra II (H) FINAL EXAM REVIEW CHAPTERS 6, 7, 8, 9, 10, 12.
Kerimbekova M.S. MF-12 Equation. Equation is In mathematics, an equation is an equality containing one or more variables. The first use of an equals sign,
Trigonometric Identities
Modeling and Simulation Dr. Mohammad Kilani
Ch. 8.5 Exponential and Logarithmic Equations
DIFFERENTIATION & INTEGRATION
MTH1170 Differential Equations
MATLAB DENC 2533 ECADD LAB 9.
Symbolic mathematics: algebra ezplot calculus
Trigonometric Identities
Warm Up – 1/2 - Thursday.
Copyright © Cengage Learning. All rights reserved.
Limits, continuity, and differentiability computing derivatives
Arab Open University Faculty of Computer Studies Dr
More Properties of Logarithms
Presentation transcript:

CSE 123 Symbolic Processing

Declaring Symbolic Variables and Constants To enable symbolic processing, the variables and constants involved must first be declared as symbolic objects. For example, to create the symbolic variables with names x and y: >> syms x y To declare symbolic constants, the sym function is used. >> pi = sym(’pi’); >> delta = sym(’1/10’); >> sqroot2 = sym(’sqrt(2)’); The advantage of using symbolic constants is that they maintain full accuracy until a numeric evaluation is required. >>a = 3 *sqrt(2) a = >>b = 3 *sqroot2 b= 3*2^(1/2)

Symbolic Expressions Symbolic variables can be used in expressions and as arguments of functions in much the same way as numeric variables have been used. >> syms s t A >> f = s^2 + 4*s + 5 f = s^2+4*s+5 >> g = s + 2 g = s+2 >> h = f*g h = (s^2+4*s+5)*(s+2) >> z= exp(-s*t) z = exp(-s*t) >> y = A*exp(-s*t) y = A*exp(-s*t) >>n = 3 ; >>syms x ; >>A = x.^((0:n)'*( 0:n))

Manipulating Polynomial Expressions The Matlab commands for this purpose include: expand(S)Expands each element of a symbolic expression S as a product of its factors. expand is most often used on polynomials, but also expands trigonometric, exponential and logarithmic functions. factor(S)Factors each element of the symbolic matrix S. simplify(S)Simplifies each element of the symbolic matrix S. [n,d] = numden(S)Returns two symbolic expressions that represent the numerator expression num and the denominator expression den for the rational representation of the symbolic expression S. subs(S,old,new)Symbolic substitution, replacing symbolic variable old with symbolic variable new in the symbolic expression S.

Manipulating Polynomial Expressions >> syms s >> A = s^4 -3*s^3 -s +2; >> B = 4*s^3 -2*s^2 +5*s -16; >> C = A + B C = s^4+s^3+4*s-14-2*s^2 >> syms s >> A = s^4 -3*s^3 -s +2; >> C = 3*A C = 3*s^4-9*s^3-3*s+6 >> syms s >> A = s+2; >> B = s+3; >> C = A*B C = (s+2)*(s+3) >> C = expand(C) C = s^2+5*s+6 >> syms s >> D = s^2 + 6*s + 9; >> D = factor(D) D = (s+3)^2 >> P = s^3 - 2*s^2 -3*s + 10; >> P = factor(P) P = (s+2)*(s^2-4*s+5)

Manipulating Polynomial Expressions >> syms s >> H = -(1/6)/(s+3) -(1/2)/(s+1)+(2/3)/s; >> [N,D] = numden(H) N = s+2 D = (s+3)*(s+1)*s >> D = expand(D) D = s^3+4*s^2+3*s Consider the expressions >> syms s >> G = s+4 + 2/(s+4) + 3/(s+2); >> [N,D] = numden(G) N = s^3+10*s^2+37*s+48 D = (s+4)*(s+2) >> D = expand(D) D = s^2+6*s+8

Manipulating Polynomial Expressions >> syms s >> H = (s^3 +2*s^2 +5*s +10)/(s^2 + 5); >> H = simplify(H) H = s+2 Cancellation of terms: >> factor(s^3 +2*s^2 +5*s +10) ans = (s+2)*(s^2+5)

Manipulating Polynomial Expressions >> syms s >> H = (s+3)/(s^2 +6*s + 8); >> G = subs(H,s,s+2) G = (s+5)/((s+2)^2+6*s+20) >> G = collect(G) G = (s+5)/(s^2+10*s+24) Variable substitution: >>syms x >>f = 2*x^2 - 3*x + 1 >>subs(f,2) >>ans = 3 >>syms x y >>f = x^2*y + 5*x*sqrt(y) >>subs(f, x, 3) >>ans = 9*y+15*y^(1/2) >>subs(f, y, 3) >>ans = 3*x^2+5*x*3^(1/2)

Manipulating Polynomial Expressions >>poly2sym ( [2, 6, 4] ) ans = 2 *x^2+6 *x+4 >> poly2sym( [5, -3, 7), ' y ' ) ans= 5*y^2 - 3 *y+7 The function poly2 sym (p) converts a coefficient vector p to a symbolic polynomial. The form poly2sym (p, ' v ' ) generates the polynomial in terms of the variable v. For example, >>syms x >>sym2poly(9 *x^2+4 *x+ 6) The function sym2poly (E) converts the expression E to a polynomial coefficient vector.

Manipulating Trigonometric Expressions >> syms theta phi >> A = sin(theta + phi) A = sin(theta+phi) >> A = expand(A) A = sin(theta)*cos(phi)+cos(theta)*sin(phi) >> B = cos(2*theta) B = cos(2*theta) >> B = expand(B) B = 2*cos(theta)^2-1 Trigonometric expressions can also be manipulated symbolically in Matlab, primarily with the use of the expand function.

Solving Algebraic and Transcendental Equations The symbolic math toolbox can be used to solve algebraic and transcendental equations, as well as systems of such equations. The function used in solving these equations is solve. There are several forms of solve, solve(E1, E2,...,EN) solve(E1, E2,...,EN, var1, var2,...,varN) where E1, E2,...,EN are the names of symbolic expressions and var1, var2,..., varN are variables in the expressions that have been declared to be symbolic. The solutions obtained are the roots of the expressions; that is, symbolic expressions for the variables under the conditions E1=0, E2 = 0,... EN = 0.

Solving Algebraic and Transcendental Equations >> syms s >> E = s+2; >> s = solve(E) s = -2 >> syms s >> D = s^2 +6*s +9; >> s = solve(D) s = [ -3] >> syms theta x z >> E = z*cos(theta) - x; >> theta = solve(E,theta) theta = acos(x/z)

Calculus Limits The Symbolic Math Toolbox enables you to calculate the limits of functions directly. >>syms h n x >>limit( (cos(x+h) - cos(x))/h,h,0 ) >>ans = -sin(x)

Calculus Limits >>limit(x/abs(x),x,0,'left') >>ans = >>limit(x/abs(x),x,0,'right') >>ans = 1 >>limit(x/abs(x),x,0) >>ans = NaN

Calculus Differentiation The diff function, when applied to a symbolic expression, provides a symbolic derivative. diff(E) Differentiates a symbolic expression E with respect to its free variable as determined by findsym. diff(E,v) Differentiates E with respect to symbolic variable v. diff(E,n) Differentiates E n times for positive integer n.

Calculus Differentiation >> syms s n >> p = s^3 + 4*s^2 -7*s -10; >> d = diff(p) d = 3*s^2+8*s-7 >> e = diff(p,2) e = 6*s+8 >> f = diff(p,3) f = 6 >> g = s^n; >> h = diff(g) h = s^n*n/s >> h = simplify(h) h = s^(n-1)*n

Calculus Integration The int function, when applied to a symbolic expression, provides a symbolic integration. int(E) Indefinite integral of symbolic expression E with respect to its symbolic variable as defined by findsym. If E is a constant, the integral is with respect to x. int(E,v) Indefinite integral of E with respect to scalar symbolic variable v. int(E,a,b) Definite integral of E with respect to its symbolic variable from a to b, where a and b are each double or symbolic scalars.

Calculus >> syms x n a b t >> int(x^n) ans = x^(n+1)/(n+1) >> int(x^3 +4*x^2 + 7*x + 10) ans = 1/4*x^4+4/3*x^3+7/2*x^2+10*x >> int(x,1,t) ans = 1/2*t^2-1/2 >> int(x^3,a,b) ans = 1/4*b^4-1/4*a^4 Integration >> syms x >> int(1/x) ans = log(x) >> int(cos(x)) ans = sin(x) >> int(1/(1+x^2)) ans = atan(x) >> int(exp(-x^2)) ans = 1/2*pi^(1/2)*erf(x)

Calculus >>syms x k >> s1 = symsum(1/k^2,1,inf) >> s2 = symsum(x^k,k,0,inf) s1 = 1/6*pi^2 s2 = -1/(x-1) Symbolic summation: symsum()

Example 1 >>p1 = poly2sym([6, 2, 7, -3]); >> p2 = poly2sym([10, -5, 8]); >> p3 = p1*p2; >> expand(p3) ans = 60*x^5-10*x^4+108*x^3-49*x^2+71*x-24 >>syms x >>subs(ans,x,2) ans = 2546 Two polynomials in the variable x are represented by the coefficient vectors p1= [6, 2, 7, -3] and p2 = [10, -5, 8). a. Use MATLAB to calculate product of these two polynomials; express the product In Its simplest form. b. Use MATLAB to find the numeric value of the product if x = 2.

Example 2 >>syms a x >>E = x^3+8*x^2+a*x+10 >>solve(E,x); >>subs(ans, a, 17); ans = i i i Use MATLAB to solve the polynomial equation x 3 + 8x 2 + ax + 10 = 0, for x in terms of the parameter a, and evaluate your solution for the case a = 17. Use MATLAB to check the answer.

Example 3 syms b x y E = x^2+y^2/b^2-1; F = x^2/100+4*y^2-1; S = solve(E,F); In terms of the parameter b, use MATLAB to find the points of intersection of the two ellipses described by Evaluate the solution obtained in part a for the case b = 2. >>subs(S.x,b,2) ans = >>subs(S.y,b,2) ans =

Example 4 >>syms x >>y = x^4- (16/3)*x^3+8*x^2-4; >>dydx = diff(y); >>solve(dydx) ans = 0 2 Use MATLAB to determine all the local minima and local maxima and all the inflection points of the following function: >>d2ydx2 = diff(y,2); >>solve(d2ydx2) ans = [2/3] [2] >>p1 = subs(d2ydx2,0) p1 = 16 >>p2 = subs(d2ydx2,2) p2 = 0 >>p3 = subs(d2ydx2,2/3) p3 = 0

Example 5 A certain object has a mass m = 100 kg and is acted on by a force f(t) = 500[2 - e -t sin(5 π t)] N. The mass is at rest at t=0. Use MATLAB to compute the object's velocity at t = 5 s. The equation of motion is f=ma. syms t f = exp(-t)*sin(5*pi*t); v = double(50-5*int(f,0,5)) v =

Example 6 Use MATLAB to compute the following limits:

Example 6 Find the expression for the sum of the geometric series syms r k n symsum(r^k,k,0,n-1); simplify(ans) ans = (r^n-1)/(r-1)

Example 7 Given the expressions: E1 = x x x and E2= (x + 5) x, use MATLAB to a. Find the product E1 E2 and express it in its simplest form. b. Find the quotient E 1/ E2 and express it in its simplest form. c. Evaluate the sum E 1 + E2 at x = 7.1 in symbolic form and in numeric form. >>syms x >>E1 = x^3-15*x^2+75*x-125; >>E2 = (x+5)^2-20*x; >>S1 = E1*E2; >>factor(S1) ans = (x-5)^5 >>S2 = E1/E2; >>simplify(S2) ans = x-5 >>S3 = E1+E2; >>G = sym(subs(S3,x,7.1)) G = *2^(-49) >>G = simplify(G) G = / >>H = double(G) H =

Example 8 Use MATLAB to solve the equation syms x solve(sqrt(1-x^2)-x) ans = 1/2*2^(1/2) >>S = solve(‘x+6*y=a’,’2*x-3*y=9’); >>S.x ans = 18/5+1/5*a >>S.y ans = -3/5+2/15*a Use MATLAB to solve the equation set x + 6y = a, 2x - 3y = 9 for x and y in terms of the parameter a.

Example 9 Given that y = x sin(3x), use MATLAB to find. syms x int(x*sin(3*x)) ans = 1/9*sin(3*x)-1/3*x*cos(3*x) syms x y int(6*y^2*tan(8*x),y) ans = 2*y^3*tan(8*x) Given that z = 6y 2 tan(8x), use MATLAB to find

Example 10 The shape of a cable hanging with no load other than its own weight is a catenary curve. A particular bridge cable is described by the catenary y(x) =10 cosh(x - 20)/ 10 for 0 ≤ x ≤ 50, where x and y are the horizontal and vertical coordinates measured in feet. The length L of a curve described by y(x) for a ≤ x ≤ b can be found from the following integral: syms x y = 10*cosh((x-20)/10); dydx = diff(y); L = double(int(sqrt(1+dydx^2),0,50)) L =