Engr 0012 (04-1) LecNotes 14-01 Declaring/using a function for evaluation String Function Declaration sfname = '2*x+2'; Calculating “y-values” x = linspace(-5,5,8);

Slides:



Advertisements
Similar presentations
Mathematics Roots, Differentiation and Integration Prof. Muhammad Saeed.
Advertisements

Is the shape below a function? Explain. Find the domain and range.
Engr 0012 (04-1) LecNotes Engr 0012 (04-1) LecNotes Functional analysis y = f(x) things to do 1. sketch graph 2. find roots (zeros) 3. find.
Relations and Functions 9.2 Relations 9.5 Functions.
Evaluating Quadratic Functions (5.5) Figuring out values for y given x Figuring out values for x given y.
Engineering H192 - Computer Programming The Ohio State University Gateway Engineering Education Coalition Lect 19P. 1Winter Quarter MATLAB: Script and.
Properties of Functions
Unit 11 – Derivative Graphs Section 11.1 – First Derivative Graphs First Derivative Slope of the Tangent Line.
Graph 8 a. Graph b. Domain _________ c. Range __________
Setting Up Clear any equations or lists from your calculator to start! Clear any equations or lists from your calculator to start! ~From the Y= list ~From.
Rational Parent Function Rational Standard Form Example:Example: Transformations: VA: HA: Domain: Range: Y-intercepts: Roots (x-int): VA: HA: Domain: Range:
Increasing / Decreasing Test
What is the domain of the following relation? (use correct notation) { (1, 3), (4, 5.5), (6, 9), (10, 0) }
Chapter 2 Section 3. Introduction to Functions Goal:Find domain and range, determine if it’s a function, use function notation and evaluate. Definition.
Q Exponential functions f (x) = a x are one-to-one functions. Q (from section 3.7) This means they each have an inverse function. Q We denote the inverse.
Numerical Computation Lecture 2: Introduction to Matlab Programming United International College.
What is the symmetry? f(x)= x 3 –x.
7.5 – Graphing Square Roots and Cube Roots
Recap Sum and Product Functions Matrix Size Function Variance and Standard Deviation Random Numbers Complex Numbers.
Scientific Computing Introduction to Matlab Programming.
13-5 The cosine Function Today’s Objective: I can graph the cosine function.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Analyzing Functions (4.16) y=f(x) MATLAB. Functional Analysis includes: Plotting and evaluating a function Finding extreme points Finding the roots (zeros.
Functions and Models 1. Graphing Calculators and Computers 1.4.
Graph Square Root and Cube Root Functions
Evaluating Functions Domain and Range
Domain and Range of a Graph. Domain The domain of a graph is displayed by the set of all possible x-values or abscissas. In this example, the domain continues.
13-4 The Sine Function Today’s Objective: I can graph the sine function.
1-d Arrays & Plotting.
Inverse Functions.
POLYNOMIALS REVIEW The DEGREE of a polynomial is the largest degree of any single term in the polynomial (Polynomials are often written in descending order.
POLYNOMIALS REVIEW The DEGREE of a polynomial is the largest degree of any single term in the polynomial (Polynomials are often written in descending order.
Unit 1: Functions Review Determining if a relation is a function or not a function (NOT a function if it fails the vertical line test; NOT a function if.
Objective: Identify intervals on which functions increase, decrease or is constant. Locate relative maxima or minima. Use piecewise functions. Warm up.
Ch : Which Values Are Possible? Domain & Range.
Engr 0012 (04-1) LecNotes loading data from files >> file_name = input( 'Enter data file name ==> ','s') Enter data file name ==> c:\temp\speed_mpg.dat.
Domain and Range: Graph Domain- Look horizontally: What x-values are contained in the graph? That’s your domain! Range- Look vertically: What y-values.
EXAM REVIEW #1. Copy the chart below and place the numbers into the appropriate categories. -10, 0, ½, √225, π, 1 / 3, 9, 500, 12 / 3, -1 Natural Whole.
Chapter 16B.5 Graphing Derivatives The derivative is the slope of the original function. The derivative is defined at the end points of a function on.
Math – Exponential Functions
Objective – Students will be able to investigate graphs with different viewing windows or viewing screens. Therefore learning how important it is to choose.
POLYNOMIALS REVIEW The DEGREE of a polynomial is the largest degree of any single term in the polynomial (Polynomials are often written in descending order.
What do these situations have in common? Explain..
Bell Ringer 1. What is a function? 2. What “test” can you use to determine if a graph is a function? 3. What is domain? 4. What is range?
4.3 – Derivatives and the shapes of curves
Introduction to Programming for Mechanical Engineers
4.3a Increasing and Decreasing Functions And the First Derivative Test
MTH1170 Function Extrema.
Section 3.3 – Rates of Change and Behavior of Graphs
Piecewise Functions At least 2 equations, each of which applies to a different part of the functions domain. It is like having 3 equations for 3 different.
Chapter 1: Lesson 1.5 Analyzing Graphs of Functions
Precalculus Day 36.
Chapter 4: Lesson 4.5 Graphs of Sine and Cosine Functions
Notes Over 2.1 Function {- 3, - 1, 1, 2 } { 0, 2, 5 }
Objective 1A f(x) = 2x + 3 What is the Range of the function
Piecewise Functions At least 2 equations, each of which applies to a different part of the functions domain. It is like having 3 equations for 3 different.
Relations and Function
A graphing calculator is required for some problems or parts of problems 2000.
Inverse Functions.
Graphing and Evaluating The Piecewise Function A Series of Examples
Students, Take out your calendar and your homework
58 – First Derivative Graphs Calculator Required
Bell Ringer What is a function?
Notes Over 8.3 Simplifying Natural Base Expressions
2. What “test” can you use to determine if a graph is a function?
(3, 2) 2 -3 (-4, -3) -2 (5, -2) 1. a) Find: f(3) = ______
Unit 3 Functions.
Students, Take out your calendar and your homework
Domain-Range Graphing f(x) Notation Calculating Slope
2.1(b) Notes: Graphing Quadratic Functions
Presentation transcript:

Engr 0012 (04-1) LecNotes Declaring/using a function for evaluation String Function Declaration sfname = '2*x+2'; Calculating “y-values” x = linspace(-5,5,8); y = eval(sfname,x); Displaying function domain = [-10 10]; fplot(sfname,domain); Finding roots xroot = fzero(sfname,where); Finding minima xmin = fminbnd(sfname,lb,ub); x = xmin; ymin = eval(sfname,x); m-file Function Declaration function [y] = mfname(x); y = 2*x+2; Calculating “y-values” xvec = linspace(-5,5,8); yvec =feval(mfname,xvec); Displaying function domain = [-10 10]; fplot(mfname,domain); Finding roots xroot = fzero(mfname,where); Finding minima xmin = fminbnd(mfname,lb,ub); ymin =feval(mfname,xmin); Inline Function Declaration ifname = inline('2*x+2'); Calculating “y-values” xvec = linspace(-5,5,8); yvec =feval(ifname,xvec); Displaying function domain = [-10 10]; fplot(ifname,domain); Finding roots xroot = fzero(ifname,where); Finding minima xmin = fminbnd(ifname,lb,ub); ymin =feval(ifname,xmin);

Engr 0012 (04-1) LecNotes Finding maxima no fmaxbnd command can define new function string >> negfcn = ['-1*(',sfname,')']; m-file function [y] = neg_f13a(x) y = -( 2*cos(3*x)./exp(x) ); need to create and save in current directory >> negfcn = input('neg fcn name? ==> ','s'); neg fcn name? neg_f13a inline >> negfcn = inline( '-( 2*cos(3*x)./exp(x))' );

Engr 0012 (04-1) LecNotes Finding maxima call fminbnd with negative of function string >> max1 = fminbnd(negfcn,1.5,2.5) max1 = m-file >> max2 = fminbnd(negfcn,1.5,2.5) max2 = inline >> max3 = fminbnd(negfcn,1.5,2.5) max3 =

Engr 0012 (04-1) LecNotes Finding areas neg area pos area easiest: use quad or quadl area = quad(fname,xmin,xmax); or area = quadl(fname,xmin,xmax); >> area1 = quad(sfname,1.5,2.5) area1 = >> area2 = quadl(mfname,1.5,2.5) area2 = can use any declaration form with quad or quadl >> area3 = quadl(ifname,0,pi) area3 =

Engr 0012 (04-1) LecNotes Finding areas more complex and not as accurate!!! use trapz area = trapz(xtrap,ytrap) need to define x & y vectors of points numtraps = 100; xtrap = xlow:(xhigh-xlow)/numtraps:xhigh; if string x = xtrap; ytrap = eval(sfname,x); if m-file ytrap = feval(mfname,xtrap); if inline ytrap = feval(ifname,xtrap); area = trapz(xtrap,ytrap); n = 100 area = n = 300 area = n = 500 area =

Engr 0012 (04-1) LecNotes Finding  f(x) dx over a range objective is to create a vector of cumulative area versus x value and then plot them on the graph (i.e. area(x) vs x % create xpts for plotting; xpts = xmin:(xmax-xmin)/500:xmax; for i = 1:1:length(xpts) cumarea(i) = quad(fname,xpts(1),xpts(i)); end % plot cumulative area hold on plot(xpts,cumarea,'g-')