259 Lecture 18 The Symbolic Toolbox. 2  MATLAB has a set of built-in commands that allow us to work with functions in a fashion similar to Mathematica.

Slides:



Advertisements
Similar presentations
Beginning Programming for Engineers
Advertisements

259 Lecture 17 Working with Data in MATLAB. Overview  In this lecture, we’ll look at some commands that are useful for working with data!  fzero  sum,
MATLAB: toolboxes, technical calculations. Numeric integration (1) Evaluating integral: computing a surface below a curve.
Introduction to Matlab
Matlab Graphics S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Introduction to Matlab: 2D Graphics.
Chapter 11: Symbolic Computing for Calculus
Calculus S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn Math Review with Matlab: Differentiation.
Functions in Maple 教授:蔡桂宏 博士 學生:柯建豪 學號: 統資軟體課程講義.
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 中華技術學院電子系 副教授 蔡樸生 副教授 林盈灝.
CSE 123 Symbolic Processing. Declaring Symbolic Variables and Constants To enable symbolic processing, the variables and constants involved must first.
MATLAB FUNDAMENTALS: USER DEFINED FUNCTIONS THE SYMBOLIC TOOLBOX HP 100 – MATLAB Wednesday, 10/29/2014
Lecture 16 Symbolic Mathematics Symbolic mathematics: algebraezplotcalculus © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
MATLAB’s extensive, device-independent plotting capabilities are one of its most powerful features. They make it very easy to plot any data at any time.
MATLAB GRAPHICS 2-D.
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.
Linear system equation Solve the following system of linear equations: 2 x + y – 4 z = 5 x - 2 y - 5 z = y + 2 z = 4 One possible solution is by.
Dr. Jie Zou PHY Welcome to PHY 3320 Computational Methods in Physics and Engineering.
1 Chapter 8 Calculus Operations with MATLAB We are now ready to see how calculus operations can be performed with MATLAB. It should be noted that a digital.
Derivatives and Differential Equations
Introduction to Matlab Jianguo Wang CSSCR September 2009.
259 Lecture 16 Numerical Differentiation and Integration in MATLAB; Function M-files.
259 Lecture 15 Introduction to MATLAB. 2 What is MATLAB?  MATLAB, which stands for “MATrix LABoratory” is a high- performance language for technical.
Chapter 5 Review: Plotting Introduction to MATLAB 7 Engineering 161.
The FTC Part 2, Total Change/Area & U-Sub. Question from Test 1 Liquid drains into a tank at the rate 21e -3t units per minute. If the tank starts empty.
More U-Substitution February 17, Substitution Rule for Indefinite Integrals If u = g(x) is a differentiable function whose range is an interval.
Introduction to MATLAB
Objectives Understand what MATLAB is and why it is widely used in engineering and science Start the MATLAB program and solve simple problems in the command.
ENGR-25_Prob_10-25_Catenary_Solution.ppt.ppt 1 Bruce Mayer, PE ENGR/MTH/PHYS25: Computational Methods Bruce Mayer, PE Registered.
ECE 1304 Introduction to Electrical and Computer Engineering Section 1.1 Introduction to MATLAB.
Chapter 12 Review: Symbolic Mathematics
EECE 360/460 Matlab Tutorial Jan Outline What is Matlab? What is Matlab? Matlab Interface Matlab Interface Basic Syntax Basic Syntax Plotting Graphs.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
5.c – The Fundamental Theorem of Calculus and Definite Integrals.
Section 5.4a FUNDAMENTAL THEOREM OF CALCULUS. Deriving the Theorem Let Apply the definition of the derivative: Rule for Integrals!
MAT 1221 Survey of Calculus Maple
Chapter 2: First Steps in MuPAD MATLAB for Scientist and Engineers Using Symbolic Toolbox.
Introduction To this point MATLAB has been used to answer questions with a numeric value ▫Variables are assigned specific values ▫Answers are numbers MATLAB.
MATHLAB Prepared for: Md. Monzur Ashraf Prepared By: Md. Shafiul Parvez Aakaash.
Scientific Computing Introduction to Matlab Programming.
MAT 213 Brief Calculus Section 5.6 Integration by Substitution or Algebraic Manipulation.
The Indefinite Integral
MULTIPLE INTEGRALS 2.2 Iterated Integrals In this section, we will learn how to: Express double integrals as iterated integrals.
Analyzing Functions (4.16) y=f(x) MATLAB. Functional Analysis includes: Plotting and evaluating a function Finding extreme points Finding the roots (zeros.
MA/CS375 Fall MA/CS 375 Fall 2002 Lecture 8.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
Chapter 11 Calculus. Symbolic Expressions Required: > Symbolic Math Toolbox > Use Symbolic Variables.
Hands-on Introduction to Mathematica. Primarily a computer program to do symbolic algebra and calculus Does Plotting, Numerical and Web stuff too. Very.
NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS ( NET 222: COMMUNICATIONS AND NETWORKS FUNDAMENTALS (PRACTICAL PART) Lab 2 : potting to Matlab Networks.
EEE 242 Computer Tools for Electrical Engineering Lecture IV Mustafa KARABULUT.
259 Lecture 5 Spring 2016 Mathematical Functions in Excel.
Wednesday, April 20, 2016MAT 145. Wednesday, April 20, 2016MAT 145.
6.2 – Antidifferentiation by Substitution. Introduction Our antidifferentiation formulas don’t tell us how to evaluate integrals such as Our strategy.
Mathematical Applications By Matlab 3 rd Day Dr. Wael Khedr CSI Dept.
Numerical Differentiation and Integration in MATLAB; Function M-files
259 Lecture 18 The Symbolic Toolbox.
Introduction to MATLAB
Section 14.2 Computing Partial Derivatives Algebraically
Working with Data in MATLAB
Computer Application in Engineering Design
Introduction to MATLAB
Derivative of an Exponential
Introduction Mathcad is a product of mathSoft inc. The Mathcad can help us to calculate, graph, and communicate technical ideas. It lets us work with.
Symbolic mathematics: algebra ezplot calculus
Use Part 1 of the Fundamental Theorem of Calculus to find the derivative of the function. {image}
Introduction to MATLAB
symbolic math toolbox matlab
Integration by Substitution (4.5)
symbolic math toolbox matlab
Presentation transcript:

259 Lecture 18 The Symbolic Toolbox

2  MATLAB has a set of built-in commands that allow us to work with functions in a fashion similar to Mathematica.  Octave can also perform some of the same functionality via the “symbolic” package – we will look at this after the MATLAB features!  For more on the commands available, type “help Symbolic Toolbox”.  The commands we will look at are:  sym, syms, diff, int, simplify, pretty, subs, double, and ezplot.  For help on these commands, use the help file.  If a symbolic command has the same name as a numerical command, such as “diff”, typing “help sym/commandname” will give help on the symbolic command.  Try “help diff” and “help sym/diff”.

3 sym  To define symbolic variables in MATLAB, use the “sym” command.  Example 1a: Here’s how to define variables x, y, and a, and functions  f(x) = x 3 + 2x 2 +x-1  g(x) = sin(x)  h(y) =  (a 2 - y 2 )/(y+1)  x = sym(‘x’)  y = sym(‘y’)  a = sym(‘a’)  f = x^3+2*x^2+x-1  g = sin(x)  h = sqrt(a^2-y^2)/(y+1)  Typing “pretty(h)” will make h(y) look nicer!  Note that in MATLAB, “syms x y a” also works to define symbolic variables!

4 diff  To find the derivative of a function defined symbolically, we use the “diff” command.  Example 2a: Find the following derivatives of the functions from Example 1a: f’(x), f’’(x), g’(x), h’’’(y).  Also find dy/dx if y = x + x 2 – x 4 or  y = tan(x) sin(x) -ln(x)/e x  diff(f)  fprime = diff(f)  f2prime = diff(f,2)  gprime = diff(g)  h3prime = diff(h,3)  pretty(h3prime)  simplify(h3prime)  pretty(simplify(h3prime))  diff('x + x^2 - x^4')  diff('tan(x)^sin(x) - log(x)/exp(x)')  pretty(ans)

5 subs  To evaluate a symbolic function we use the command “subs”.  Example 3a: For the functions defined in Example 1a, find each of the following:  f(-3)  f(v) where v = [1 2 4]  g’(pi/4)  h(1)  h(1) with a = 2  h(y) with a = 2  subs(f,-3)  v = [1 2 4]  subs(f,v)  subs(gprime,pi/4)  subs(h,1)  b = subs(h,1)  subs(b,2)  subs(h,'a',2)

6 ezplot  We can plot symbolic functions with the command “ezplot”!  Example 4a: Use ezplot to graph the functions f(x), g(x), g’(x), f’(x), and f’’(x) defined in Example 1a.  Note that the default settings for ezplot can be changed with title, xlabel, and ylabel.  The default x-interval of [-2, 2] can also be changed.  ezplot(f)  ezplot(f,[-1,1])  ezplot(g)  ezplot(gprime,[0,2*pi])  One way to plot multiple graphs via ezplot: ezplot(f) hold on ezplot(fprime) ezplot(f2prime) title('Plot of f and it''s derivatives.') hold off

7 int  To find indefinite or definite integrals in MATLAB, we use “int”.  Example 5: Find each integral:  int(f)  int(g,0,pi)  int(h,'y',0.5,1)  pretty(ans)  sym(a,'positive')  int(h,'y',0.5,1)  pretty(ans)  int(h,'a',0.5,1)  int('x + x^2 - x^4')

8 funtool  Finally, here’s a way to work with functions that is more “user friendly”.  Typing “funtool” brings up a function calculator in MATLAB.  funtool is a visual function calculator that manipulates and displays functions of one variable.  At startup, funtool displays graphs of a pair of functions, f(x) = x and g(x) = 1.  The graphs plot the functions over the domain [-2*pi, 2*pi].  funtool also displays a control panel that lets you save, retrieve, redefine, combine, and transform f and g.

Symbolic Package in Octave  To perform symbolic manipulation in Octave, first we need to load the “symbolic” package.  The symbolic package, as well as other add-ons can be found here: Octave downloads from Source Forge (both Windows and Mac OS X installers can be found here: Octave Homepage:  A reference for the “symbolic” package can be found here (choose “Function Reference”): 9

Symbolic Functions in Octave  Once the “symbolic” package is installed, turn on Octave and type “pkg load all” to load all installed packages.  To enable the symbolic features in Octave, type “symbols”. 10

11 sym in Octave  To define symbolic variables in Octave, use the “sym” command.  Example 1b: Here’s how to define variables x, y, and a, and functions  f(x) = x 3 + 2x 2 +x-1  g(x) = sin(x)  h(y) =  (a 2 - y 2 )/(y+1)  x = sym(‘x’)  y = sym(‘y’)  a = sym(‘a’)  f = x^3+2*x^2+x-1  g = Sin(x)  h = Sqrt(a^2-y^2)/(y+1)

12 diff in Octave  To find the derivative of a function defined symbolically in Octave, we use the “differentiate” command.  Example 2b: Find the following derivatives of the functions from Example 1b: f’(x), f’’(x), g’(x), h’’’(y).  Also find dy/dx if y = x + x 2 – x 4 or  y = tan(x) sin(x) -ln(x)/e x  differentiate(f,x)  fprime = differentiate(f,x)  f2prime = differentiate(f,x,2)  gprime = differentiate(g,x)  h3prime = differentiate(h,y,3)  differentiate(x + x^2 - x^4,x)  differentiate(Tan(x)^Sin(x) -Log(x)/Exp(x),x)

13 subs in Octave  To evaluate a symbolic function in Octave, we use the command “subs”.  Example 3b: For the functions defined in Example 1b, find each of the following:  f(-3)  g’(pi/4)  h(1)  h(1) with a = 2  h(y) with a = 2  subs(f,x,-3)  subs(gprime,pi/4)  subs(h,y,1)  b = subs(h,y,1)  subs(b,a,2)  subs(h,a,2)

14 ezplot in Octave  We can plot symbolic functions with the command “ezplot”!  Example 4b: Use ezplot to graph the functions f(x), g(x), g’(x), f’(x), and f’’(x) defined in Example 1b.  Note that the default settings for ezplot can be changed with title, xlabel, and ylabel.  The default x-interval of [-2, 2] can also be changed.  Recall that f = x^3+2*x^2+x-1 g = Sin(x)  ezplot(‘x^3+2*x^2+x-1’)  ezplot(‘x^3+2*x^2+x- 1’,[-1,1])  ezplot(‘sin(x)’)  ezplot(‘cos(x)’,[0,2*pi])  One way to plot multiple graphs via ezplot: ezplot(‘x^3+2*x^2+x-1’) hold on ezplot(‘3*x^2+4*x+1’) ezplot(‘6x+4’) title('Plot of f and it''s derivatives.') hold off

15 References  Using MATLAB in Calculus by Gary Jenson  MATLAB Help File