Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

UDF and anonymous function question. Use long format to do this question. You must create two . m files: one is a UDF function file

UDF and anonymous function question. Use long format to do this question. You must create two .m files: one is a UDF function file for step b, and one is a script file that includes all steps from a to e.
Taylor series expansion is an infinite sum of terms that are expressed in terms of the functions derivatives at a single point. The series is often used to simply approximate a function around a point.
In this question, we are going to estimate the errors between the original function and approximate function (Taylor series)
You are given an original function (1-x) and its Taylor series:
(1-x)=1-x/2-x^2/8-x^3/16-(5x^4)/128+O(x^5)
a - Use Matlab command to create a vector x range from -0.5 to 0.5 with step size of 0.05.
b - Create a user-defined function (UDF) for the defined function y(x) that has one input x and one output y. You may name the UDF q1UDF. Call this function with the input x vector created in a, name the output vector as y_UDF. Copy and paste the UDF code.
y(x)=1-x/2-x^2/8-x^3/16-(5x^4)/128
c - Create an anonymous function for the above defined function y(x) that has one input x and one output y. You may name the anonymous function q1AF. Call this function with the input x vector created in a, name the output vector as y_anonymous. Copy and paste the script.
d - Use Matlab command sqrt(1-x) to get a new vector with the input x vector created in a, name the output vector as y_matlab.
e - To compare the difference of two vectors A & B, we can use Matlab command norm to compute norm of (A-B). Compute the following two errors to compare our function calculations:
error1= norm(y_anonymous y_UDF)
error2= norm(y_matlab y_UDF)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions