Question

this is Matlab. Three images are consecutive and connected. I NEED PROBLEM 2

Chapter 6 Programming in Matlab Week 6 THE ALTERNATING HARMONIC SERIES The alternating harmonic series converges to the naturCalculate the first two cumulative totals total)-y(1) total(2) - total(1) +(2) Set the starting index number equal to 3 whilePrint the value of the final element in the sequence the cumulative sum the natural log of 2 Plot the results End

Chapter 6 Programming in Matlab Week 6 THE ALTERNATING HARMONIC SERIES The alternating harmonic series converges to the natural log of 2 +--...-In(2) = 0.6931471806 -1--+ Because of this, we can use the alternating harmonic series to approximate the In(2). But how far out do you have to take the series to get a good approximation of the final answer? We can use a while loop to solve this problem. 1. State the Problem Use a while loop to calculate the members of the alternating harmonic sequence and the value of the series until it converges to values that vary by less than.001. Compare the result to the natural log of 2. 2. Describe the Input and Output Input The description of the alternating harmonic series The value of the truncated series, once the convergence criterion is met Plot the cumulative sum of the series elements, up to the point where the convergence criterion is met. Output Start Define first two members of the sequence (1) 1 and y(2)-12
Calculate the first two cumulative totals total)-y(1) total(2) - total(1) +(2) Set the starting index number equal to 3 while the absolute value of adjacent cumulative sums is ter than 0.001 continue False Calculate the next member of the sequence y(A) = Calculate the next cumulative sum total(k) totalk-1)+y(k) Increment the counter k k+1
Print the value of the final element in the sequence the cumulative sum the natural log of 2 Plot the results End
0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries

clc
clear all
y=[1,-1/2];
total=[1,1/2];
k=3;
while(abs(total(k-1)-total(k-2))>0.001)
y(k)=(-1)^(k+1)/k;
total(k)=total(k-1)+y(k);
k=k+1;
  
end
fprintf('Final element is %f\n',y(end));
disp('Approximation sum is');
total(end)
disp('Natural log(2) is')
log(2)
plot(total)

Figure 1 Eile Edit yiew Insert 1ools Desktop ndow Help 0.95 0.9 0.85 0.8 0.75 0.7 0.65 0.6 0.55 0.5 1000 200 400 600 800 1200​​​​​​​

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
this is Matlab. Three images are consecutive and connected. I NEED PROBLEM 2 Chapter 6 Programming in Matlab Week 6 THE ALTERNATING HARMONIC SERIES The alternating harmonic series converges to the na...
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
  • 11. (10 points) - MATLAB ce of the alternating harmonic series, shown below: 1-2?--+ - 3...

    11. (10 points) - MATLAB ce of the alternating harmonic series, shown below: 1-2?--+ - 3 4 5 Use a loop to determine when the series has converged within a tolerance of 0.001. The animation should show how the value of the series changes as each successive term is added, resulting in a final

  • Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are...

    Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are usually calculated on computers using truncated Taylor series (an infinite series). An infinite series is an infinite set of terms whose sum is a particular function or expression. For example, the infinite series used to evaluate the natural log of a number is (x - 1)2 (x-1)3 (x-1)* (x-1)5 2 4 where x E (0, 2], or 0

  • 4. One interesting property of a Fibonacci sequence is that the ratio of the values of...

    4. One interesting property of a Fibonacci sequence is that the ratio of the values of adjacent members of the sequence approaches a number called "the golden ratio". Create a program that accepts the first two numbers of a Fibonacci sequence as user input and then calculates additional values in the sequence until the ratio of adjacent values converges to within 0.001 You can do this in a while loop by comparing the ratio of element k to element k...

  • Matlab function to solve an inequality that has a summation problem on one side. I have...

    Matlab function to solve an inequality that has a summation problem on one side. I have to write a function that uses a while loop and determines the biggest exponent value(k) in the summation out = symsum(2^i,i,o,k) that exceeds the input n in the inequality out > n so i need it to test the values of k from 1 on until out is the closest over n it can be. this assignment you will write two functions. The first...

  • Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5...

    Solve in MATLAB Problem 3: Given the vector x- [2 1 0 6 2 3 5 3 4 1 3 2 10 12 4 2 7 9 2 4 51 use a for loop to (a) Add up the values of all elements in x (b) Compute the cumulative sum, y, of elements in x You can check your results using the built-in functions sum and cumsum. Q.5 What is the value of the sum of elements in vector x?...

  • 1, write an m file to determine the sum of the infinite series converges to π2 /6. Do this by com...

    please write matlab code for these questions in matlabplatform 1, write an m file to determine the sum of the infinite series converges to π2 /6. Do this by computing the sum for a) n-100, b) n-1000 and c) n 10000. Do this by assigning n values using logspace command 2. Write an m-file to evaluate the following algebraic formula log( -a f i>a log) sa where t is a number that a user enters and a 100 3. A...

  • I need help with Problem 6. Thanks! 2. Calculate: 5221ddx 3. Find the area bounded by...

    I need help with Problem 6. Thanks! 2. Calculate: 5221ddx 3. Find the area bounded by the graphs of y = Cot(2x), y = 0,x = 5, and x = 37. Provide the exact and simplified answer. 4. Evaluate: Sov-*+2,2 dx 5. Determine whether the series 2n=25047" is convergent or divergent. If convergent, find the exact sum. 6. Determine whether the series 2n=22941 is convergent or divergent. If convergent, find the exact sum. 7. Find the interval of convergence of...

  • Matlab-How can i exit the for loop when counts exceeds the max value, then continue to...

    Matlab-How can i exit the for loop when counts exceeds the max value, then continue to the last loop and plot accepted values. counts = 0; for k = 2:length(partDiameter) overlaps = 1; while overlaps == 1 counts = counts + 1; if counts >= 10000 disp('Max particles packed') inCoord = [inCoord;[x,y]]; return; end x = (partDiameter(k)-L)*rand(1,1) + (L-partDiameter(k)/2); y = (partDiameter(k)-L)*rand(1,1) + (L-partDiameter(k)/2); % check if this x,y postion overlaps with previously packed % partices for m = 1:length(inCoord(:,1))...

  • This is a MATLAB Question. Below is my base code for a Fourier Series of a...

    This is a MATLAB Question. Below is my base code for a Fourier Series of a half triangle wave. So I am being asked to isolate the first 8 components so that only those first 8 components of the half triangle function are calculated by MATLAB fft function, and then afterwards I am asked to do the same thing but with the first 20 components rather than the first 8. How do I isolate the first x number of components...

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