Question

1. What is the Maclaurin series for the function sin(x)? Please determine the minimum number of terms needed to compute sin(0.1) accurate to 12 decimal places (rounded), using a) Taylor’s theorem and b) alternating series theorem.

Show your work and justify your answers for the above problem.

2. Create two random matrices A and B each of size ? × ?. Write a computer program in Java or Matlab to compute

a) D(i, j) = A(i, j) * B(i, j) for i = 1 … n and j = 1 … n, and

b) D(i, j) = ∑ (A(i,k) ∗ B(k,j)) ? ?=1 for i= 1 … n and j = 1 … n.

Use a timing function to report the execution time for the two computations using single and then double precisions. Report on the execution time of each run. Try n = 100 and 1000.

c) repeat the calculations in (a) and (b) above using Matlab.

1. What is the Maclaurin series for the function sin(x)? Please determine the minimum number of terms needed to compute sin(0

0 0
Add a comment Improve this question Transcribed image text
Answer #1

2)

clc%clears screen
clear all%clears history
close all%closes all files
format long
n=10;
A=rand(n);
B=rand(n);
D=[];
tic;
for i=1:n
for j=1:n
D(i,j)=A(i,j)*B(i,j);
end
end
t1=toc;
D=[];
tic;
for i=1:n
for j=1:n
D(i,j)=0;
for k=1:n
D(i,j)=D(i,j)+A(i,k)*B(k,j);
end
end
end
t2=toc;
disp('part a time for double');
disp(t1)
disp('part b time for double');
disp(t2)
A=single(rand(n));
B=single(rand(n));
D=[];
tic;
for i=1:n
for j=1:n
D(i,j)=A(i,j)*B(i,j);
end
end
t1=toc;
D=[];
tic;
for i=1:n
for j=1:n
D(i,j)=single(0);
for k=1:n
D(i,j)=D(i,j)+A(i,k)*B(k,j);
end
end
end
t2=toc;
disp('part a time for single');
disp(t1)
disp('part b time for single');
disp(t2)

Add a comment
Know the answer?
Add Answer to:
1. What is the Maclaurin series for the function sin(x)? Please determine the minimum number of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT