Problem 3 (20 scores): 1. Write a MATLAB function that calculates the following sum function [S] = Sum (x, M) $S = \sum_{n=0}^{M} \frac{(x+1)^n}{n!}$ at arbitrary $x$ and $M$ using for-end loop. 2. Apply this function to calculate the sum at $x = -0.1$ and $M = 8$.
Added by Spencer E.
Close
Step 1
The function should take two inputs, M and x, and return the sum S. We will use a for-end loop to calculate the sum from i=0 to n. Here is the MATLAB code for the function: ```matlab function [S] = Sumx(M, x) S = 0; % Initialize the sum n = 100; % Set Show more…
Show all steps
Your feedback will help us improve your experience
Anand Jangid and 55 other Physics 101 Mechanics educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
function s = myharmonic(n) % Computes the sum from k=1 to k=n of 1/k % Input: n -- the upper limit on the sum % Output: The value of the sum Run it for a few values of n to demonstrate that it is working.
Supreeta N.
(Sum series) Write a recursive function to compute the following series: \[ m(i)=1+\frac{1}{2}+\frac{1}{3}+\ldots+\frac{1}{i} \] Write a test program that displays $m(i)$ for $i=1,2, \dots, 10$
(a) For the series, y = 3^k-1 + k, (i) use a while loop to determine how many terms in the series are required for the sum of these terms to exceed 5000. (ii) If the answer of (i) is n, then use a for loop to determine the sum of these series for k=1,2,...n. Compare the results of (i) and (ii). Show the MATLAB codes, and the corresponding flow chart for each of these (i) and (ii).
Sri K.
Recommended Textbooks
University Physics with Modern Physics
Physics: Principles with Applications
Fundamentals of Physics
Watch the video solution with this free unlock.
EMAIL
PASSWORD