Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

what is wrong with my matlab code clc; function approx = cosineApprox(x,t) approx = 1 for i=1:1:t-1 nextTerms = (-1)^i*(x^(2*i))/factorial(2*i); approx = approx + nextTerm;

image text in transcribedimage text in transcribedimage text in transcribedwhat is wrong with my matlab code

clc;

function approx = cosineApprox(x,t)

approx = 1

for i=1:1:t-1

nextTerms = (-1)^i*(x^(2*i))/factorial(2*i);

approx = approx + nextTerm;

end

end

x = 2*pi/3;

actual = cos(x);

disp("original value:");

disp(actual);

t = input("number of terms:");

approx = cosineApprox(x,t);

disp("approximate value:");

disp(approx);

-0.4996 >> approx = approxcosineFunction(x, 10) approX - -0.5000

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

How could assessment be used in an employee development program?

Answered: 1 week ago