Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What's wrong with this code? function [ y ] = MyExp( x,n ) % % Function: y = MyExp( x, n ) % Uses the

What's wrong with this code?

function [ y ] = MyExp( x,n )
%
% 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... 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_2

Step: 3

blur-text-image_3

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

Elementary Linear Algebra with Applications

Authors: Howard Anton, Chris Rorres

9th edition

471669598, 978-0471669593

More Books

Students also viewed these Accounting questions

Question

Find the currents in the circuits. 1. 3. 512 8 13 512 6 + 2 V 2

Answered: 1 week ago