Question
What's wrong with this code? function [ y ] = MyExp( x,n ) % % Function: y = MyExp( x, n ) % Uses the
%
% Function: y = MyExp( x, n )
% Uses the Taylor series expansion for exp(x), with n terms,
% to compute an approximation to exp(x).
%
% Input: x = vector containing values at which the exponential is
% to be computed
% n = number of terms in the Taylor series
%
% Output: y = vector, having same length as x, containing exp(x)
% values
%
term = ones(size(x));
y = ones(size(x));
for k = 1:n
term = term .* (x/n);
y = y + term;
end
end
Step by Step Solution
3.42 Rating (165 Votes )
There are 3 Steps involved in it
Step: 1
There are a few issues with this code The calculation of the Taylor series is incorrect The term var...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get StartedRecommended Textbook for
Elementary Linear Algebra with Applications
Authors: Howard Anton, Chris Rorres
9th edition
471669598, 978-0471669593
Students also viewed these Accounting questions
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
Question
Answered: 1 week ago
View Answer in SolutionInn App