Question

Create a Function file using Matlab.

function sums = estimSum (nTerms) Before we go much further, save your file and name it the exact name of the function, estimMake a table (by hand) listing nTerms, the corresponding value of the sum Sn, along with the corresponding (exact) remainder

function sums = estimSum (nTerms) Before we go much further, save your file and name it the exact name of the function, estimSum Inside the function file just created, write the code needed to compute partial sums 1)k+1 2k 1 k-1 and compare the output in each case to the value of by computing the remainder Rn- _Snl for each n - 20,50, 100, 1000. When calling the function in Matlab's command window for varying values of nTerms (n = 20, 50, 100, 1000) use (for example) sumS20 estimSum (20)
Make a table (by hand) listing nTerms, the corresponding value of the sum Sn, along with the corresponding (exact) remainder Rn, as well as the next term in the sequence that was not included in the sum, an+il. How does Rn compare to lant for all the different n values tested (write this conclusion in a sentence)?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB CODE:

function sumS = estimSum(n)
    syms k
    f    = ((-1)^(k+1))/(2*k - 1);
    sumS = symsum(f,k,1,n);
    fprintf('Sum of %d terms,Sum = %0.3f\n',n,sumS)
    Remainder = abs((pi/4)-sumS);
    fprintf('Remainder = %0.3f',Remainder)
end

OUTPUT:

sumS20-estimSum (20) Sum of 20 terms,Sum0.773 Remainder - 0.012 sumS20- 129049485078524/166966608033225

Add a comment
Know the answer?
Add Answer to:
Create a Function file using Matlab. function sums = estimSum (nTerms) Before we go much further, save your file and 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
  • C++ 3. Write a program that reads integers from a file, sums the values and calculates...

    C++ 3. Write a program that reads integers from a file, sums the values and calculates the average. a. Write a value-returning function that opens an input file named in File txt. You may "hard-code" the file name, i.e., you do not need to ask the user for the file name. The function should check the file state of the input file and return a value indicating success or failure. Main should check the returned value and if the file...

  • Function / File Read (USING MATLAB) A) create a user-defined function : [maxsample , maxvalue , numsamples]=writetofile(sname,strgth) to do the following: The user-defined function shall: -Accept as t...

    Function / File Read (USING MATLAB) A) create a user-defined function : [maxsample , maxvalue , numsamples]=writetofile(sname,strgth) to do the following: The user-defined function shall: -Accept as the input a provided string for the sample name (sname) and number for strength (strgth) - open a text file named mytensiledata.txt, with permission to read or append the file. - Make sure to capture any error in opening the file - Write sname and strgth to the file - Close the file...

  • by using matlab linreg() function file given below On average, the surface area A of human...

    by using matlab linreg() function file given below On average, the surface area A of human beings is related to weight W and height H. Measurements of several individuals of height 180cm are provided below. It is believed that the following data can be modelled using an exponential equation A = aeBW W (kg) 70 2.1 75 2.12 77 2.15 80 2.20 82 2.22 84 2.23 87 2.26 90 2.30 A (m2) A. Show by hand with pen and paper...

  • use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a...

    use MatLab to answer these questions 1. (10 points) Create an m-file called addup.m Use a for loop with k = 1 to 8 to sum the terms in this sequence: x(k) = 1/3 Before the loop set sumx = 0 Then add each term to sumx inside the loop. (You do not need to store the individual values of the sequence; it is sufficient to add each term to the sum.) After the loop, display sumx with either disp()...

  • 1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector...

    1) a) Write MATLAB function that accepts a positive integer parameter n and returns a vector containing the values of the integral (A) for n= 1,2,3,..., n. The function must use the relation (B) and the value of y(1). Your function must preallocate the array that it returns. Use for loop when writing your code. b) Write MATLAB script that uses your function to calculate the values of the integral (A) using the recurrence relation (B), y(n) for n=1,2,... 19...

  • MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demo...

    MATLAB Create a function that provides a definite integration using Simpson's Rule Problem Summar This example demonstrates using instructor-provided and randomized inputs to assess a function problem. Custom numerical tolerances are used to assess the output. Simpson's Rule approximates the definite integral of a function f(x) on the interval a,a according to the following formula + f (ati) This approximation is in general more accurate than the trapezoidal rule, which itself is more accurate than the leftright-hand rules. The increased...

  • Can you help me with this question please? For the code, please do it on MATLAB. Thanks

    Can you help me with this question please? For the code, please do it on MATLAB. Thanks 7. Bonus [3+3+4pts] Before answering this question, read the Google page rank article on Pi- azza in the 'General Resources' section. The Google page rank algorithm has a lot to do with the eigenvector corresponding to the largest eigenvalue of a so-called stochastic matrix, which describes the links between websites.2 Stochastic matrices have non-negative entries and each column sums to1, and one can...

  • *Write a parallel program pie.c in C or C++ (pie.cc) for Linux that computes an approximation of the number π using a se...

    *Write a parallel program pie.c in C or C++ (pie.cc) for Linux that computes an approximation of the number π using a series with N+1 terms.* --The series sum is partitioned in T non-overlapping partial sums, each computed by T separate child processes created with the fork() library function.* --This program demonstrates data parallelism and interprocess communication using pipes. Each child process could perform a (potentially) long computation on a separate CPU (or core). Depending on the computer architecture, the...

  • (a) Load the data file data/tips.csv into a pandas DataFrame called tips_df using the pandas read_table()...

    (a) Load the data file data/tips.csv into a pandas DataFrame called tips_df using the pandas read_table() function. Check the first five rows. (b) Create a new dataframe called tips by randomly sampling 6 records from the dataframe tips_df. Refer to the sample() function documentation. (c) Add a new column to tips called idx as a list ['one', 'two', 'three', 'four', 'five', 'six'] and then later assign it as the index of tips dataframe. Display the dataframe. (d) Create a new...

  • matlab 1. [suDmit as Iwo JPEGS in Canvas with your netiD in the title of each...

    matlab 1. [suDmit as Iwo JPEGS in Canvas with your netiD in the title of each plot] An electricity startup is looking into the viability of putting solar panels on the rooftops of buildings in Newark, NJ. They want you to help them come up with visualizations for data they have from the National Renewable Energy Laboratory and the National Oceanic and Atmospheric Administration about: - The average amount of sunshine received each month in the form of Global Horizonal...

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