Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LAB 17 - Numerical Differentiation MATLAB Problem 1: Use finite difference approximations, as derived from Taylor series, to estimate the first derivative of the

imageimageimageimage

LAB 17 - Numerical Differentiation MATLAB Problem 1: Use finite difference approximations, as derived from Taylor series, to estimate the first derivative of the non-linear function plotted below at x=0.6. Tabulated values of the function are provided in the table to the right of the plot. Use a finite difference stepsize of h = 0.2, and estimate the first derivative using forward, backward, and central differencing methods. Record your answers in the spaces provided below. 0.6 0.5 > 0.4- 0.3 0.2 0.2 0.4 x x f(x) 0 0.2500 0.2 0.3487 0.4 0.4394 0.6 0.5146 0.6 0.8 0.8 0.5674 1.0 0.5915 I. Anonymous and Functions User-defined functions written in function files can be used for simple mathematical functions, for large and complicated math functions that require extensive programing, and as subprograms in large computer programs. In cases when the value of relatively simple mathematical expression has to be determined many times within a program, MATLAB provides the option of using anonymous functions. An anonymous function is a user-defined function that is defined and written within the computer code (not in a separate function file) and is then used in the code. An anonymous function is created by typing the following command: name = (arglist) expr where arglist is a list of input arguments (independent variables), and expr are mathematical expressions. Anonymous functions can be constructed in the Command Window, within a script file, or inside a regular user-defined function. Example 1: The following function can be defined as an anonymous function for x f(x) FA (x) exp (x.^2)./ sqrt(x.^2 + 5) FA ([10.5 2]) eta Example 2: The following function can be defined as an anonymous function for x and y f(x,y) = 2x-4xy + y HA (x, y) 2*x^2-4*x*y + y^2 HA (2,3) II. Inline Functions Similar to an anonymous function, an inline function is a simple user-defined function that is defined without creating a separate function file (M-file). Inline functions are created with the inline command as follows: name inline ('math expression typed as a string') Example 1: The following function can be defined as an anonymous function for x f(x) x+5 FA inline ("exp (x.^2)./sqrt(x. ^2+5)') FA (2) An inline function that has two or more independent variables can be written by using the following format: name inline ('math expression typed as a string', argl', 'arg2','arg3') Example 2: The following function can be defined as an anonymous function for x and y f(x,y) = 2x-4xy + y HA inline ('2x^2-4*x*y + y^2') HA (2,3)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Numerical Methods For Engineers

Authors: Steven C. Chapra, Raymond P. Canale

5th Edition

978-0071244299, 0071244298

More Books

Students also viewed these Mechanical Engineering questions

Question

What are the 5 Cs of marketing channel structure?

Answered: 1 week ago