III. Instructions Develop a function pseval implementing a Maclaurin's Series calculator and visualizer. It must have the following features: 1. Calculator Mode • It must take in a function handle f, in terms of x and n, containing the power series representation of a function, the number of terms in to be included in the computations, and a scalar value x that will be used to evaluate the function. The program must automatically execute this mode if there are exactly 3 input arguments. . The output will be a scalar value y which is the value of the evaluated function. 2. Visualizer Mode • It must take in a function handle f, in terms of x and n, containing the power series representation of a function, the number of terms n to be included in the computations, and the left and right boundaries x_1 and x_r that will be used in plotting the function. The program must automatically execute this mode if there are exactly 4 input arguments. . Using the left boundary, the right boundary, and an increment of 0.01, generate the vector x. • The output will be a vector y obtained when the function is evaluated using the vector x. Also, plot the resulting power series curve using the specified boundaries and number of terms. Take note to include the zeroth term when counting the number of terms • Label the x-axis as x and the y-axis as f(x). Also, provide a title indicating the number of terms used. . Set the limit of the horizontal axis: x_1 to x_r. Toggle the grid on. IV. Sample Output 1. Calculator Mode f = @(x,n) (-1)^n. *x.^(2*n+1)./factorial(2*n+1); y - pseval(f,5,-5) y. -0.0896 2. Visualizer Mode f@(x,n) (-1)^n. *x.^(2*n+1)./factorial (2*n+1); pseval(f, 2, -3,3);

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question
III. Instructions
Develop a function pseval implementing a Maclaurin's Series calculator and visualizer. It must have the following features:
1. Calculator Mode
▪ It must take in a function handle f, in terms of x and n, containing the power series representation of a function, the number of terms n to be included in the computations, and a scalar value x that will be used to evaluate the function. The
program must automatically execute this mode if there are exactly 3 input arguments.
▪ The output will be a scalar value y which is the value of the evaluated function.
2. Visualizer Mode
▪ It must take in a function handle f, in terms of x and n, containing the power series representation of a function, the number of terms n to be included in the computations, and the left and right boundaries x_1 and x_r that will be used in
plotting the function. The program must automatically execute this mode if there are exactly 4 input arguments.
▪ Using the left boundary, the right boundary, and an increment of 0.01, generate the vector x.
▪ The output will be a vector y obtained when the function is evaluated using the vector x. Also, plot the resulting power series curve using the specified boundaries and number of terms. Take note to include the zeroth term when counting the
number of terms.
▪ Label the x-axis as x and the y-axis as f(x). Also, provide a title indicating the number of terms used.
▪ Set the limit of the horizontal axis: x_1 to x_r. Toggle the grid on.
IV. Sample Output
1. Calculator Mode
f = @(x,n) (-1)^n.*x.^(2*n+1)./factorial (2*n+1);
y = pseval(f,5,-5)
y =
-0.0896
2. Visualizer Mode
f = @(x,n) (-1)^n.*x.^(2*n+1)./factorial (2*n+1);
pseval(f, 2, -3,3);
Function >
1.5
1
0.5
0
-0.5
Maclaurin's approximation of f(x) using 2 terms.
function y = pseval(f,n, varargin)
Code to call your function >
== @(x,n) (-1)^n.*x.^(2*n+1)./factorial (2*n+1);
= pseval(f,5,-5)
pseval(f, 2, -3,3);
C Reset
MATLAB Documentation
C Reset
Transcribed Image Text:III. Instructions Develop a function pseval implementing a Maclaurin's Series calculator and visualizer. It must have the following features: 1. Calculator Mode ▪ It must take in a function handle f, in terms of x and n, containing the power series representation of a function, the number of terms n to be included in the computations, and a scalar value x that will be used to evaluate the function. The program must automatically execute this mode if there are exactly 3 input arguments. ▪ The output will be a scalar value y which is the value of the evaluated function. 2. Visualizer Mode ▪ It must take in a function handle f, in terms of x and n, containing the power series representation of a function, the number of terms n to be included in the computations, and the left and right boundaries x_1 and x_r that will be used in plotting the function. The program must automatically execute this mode if there are exactly 4 input arguments. ▪ Using the left boundary, the right boundary, and an increment of 0.01, generate the vector x. ▪ The output will be a vector y obtained when the function is evaluated using the vector x. Also, plot the resulting power series curve using the specified boundaries and number of terms. Take note to include the zeroth term when counting the number of terms. ▪ Label the x-axis as x and the y-axis as f(x). Also, provide a title indicating the number of terms used. ▪ Set the limit of the horizontal axis: x_1 to x_r. Toggle the grid on. IV. Sample Output 1. Calculator Mode f = @(x,n) (-1)^n.*x.^(2*n+1)./factorial (2*n+1); y = pseval(f,5,-5) y = -0.0896 2. Visualizer Mode f = @(x,n) (-1)^n.*x.^(2*n+1)./factorial (2*n+1); pseval(f, 2, -3,3); Function > 1.5 1 0.5 0 -0.5 Maclaurin's approximation of f(x) using 2 terms. function y = pseval(f,n, varargin) Code to call your function > == @(x,n) (-1)^n.*x.^(2*n+1)./factorial (2*n+1); = pseval(f,5,-5) pseval(f, 2, -3,3); C Reset MATLAB Documentation C Reset
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning