Question

Question #15. Write a function file that determines the following sum using a for loop: y=i=1n(3-2i)2...

Question #15. Write a function file that determines the following sum using a for loop:

y=i=1n(3-2i)2

Use n as input and test the function for n=100.

Question #15. Write a function file that determines the following sum using a for loop:

y=i=1n(3-2i)2

Use n as input and test the function for n=100.

Homework Answers

Answer #1

SOLUTION -

15 )

CODE -
function y = perform(n)

y = 0;

% looping from 1 to n
for i = 1:n
  
% adding each term to y
y += (3 - 2*i)^2;
  
end
  
end

% sample run
y = perform(100)

SCREENSHOT-

OUTPUT

IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK YOU!!!!!!!!----------

Know the answer?
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
Similar Questions
Consider the following function: double arrayavg(int a[], int n){ int sum=0; for(int i=0; i!=n; ++i){ sum+=a[i];...
Consider the following function: double arrayavg(int a[], int n){ int sum=0; for(int i=0; i!=n; ++i){ sum+=a[i]; } return (double)sum/n; } Rewrite the function to eliminate the array subscripting (a[i]), using pointer arithmatic instead. Write a program that reads a line of input and checks if it is a palindrome (ignoring spaces) Write a program that takes the name of a file as a command line argument, and prints the contents of the file (similar to the linux 'cat' program). Write...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop...
IN C++ AS SIMPLE AS POSSIBLE ______ Re-write the given function, printSeriesSquareFifth,  to use a while loop (instead of for). • The function takes a single integer n as a parameter • The function prints a series between 1 and that parameter, and also prints its result • The result is calculated by summing the numbers between 1 and n (inclusive). If a number is divisible by 5, its square gets added to the result instead. • The function does not...
Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2...
Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2 ) = ?1 2 + ?2 2 − 26 ?(?1?2 ) = 3?1 2 + 25?2 2 − 100 (1 Mark) b) Use MATLAB’s FSOLVE operator to solve these equations with x1 = 2 and x2 = 2 as your starting point. How many iterations did MATLAB use to solve them? (1 Mark)
1) Write an algorithm to calculate the sum of the following series:           Sum =x-x3/3! +...
1) Write an algorithm to calculate the sum of the following series:           Sum =x-x3/3! + x5/5! – x7/7! +…….     Stop when the                     term<0.0001.    2) An internet service provider charges its subscribers per month as follows:           Data usage (n), in gbs           charges (NIS)           0.0<n<=1.0                                250           1.0<n<=2.0                                500           2.0<n<=5.0                              1000           5.0<n<=10.0                            1500                   n>10                                 2000          Write a C program to read the usage(n) from a file and print the charges to be paid by...
Problem 3. Let n ∈ N. Prove, using induction, that Σi^2= Σ(n + 1 − i)(2i...
Problem 3. Let n ∈ N. Prove, using induction, that Σi^2= Σ(n + 1 − i)(2i − 1). Note: Start by expanding the righthand side, then look at the following pyramid (see link) from
By using the R-Studio answer the following question: 1. a) write a simple loop to list...
By using the R-Studio answer the following question: 1. a) write a simple loop to list the squares of the first 10 integers. b) Generate the 10*10 matrix A, whose (i;j) entry is sin(2*pi*(i-j))
*********I need question 6 answered which is from question 5 which is ********* Question 5 :...
*********I need question 6 answered which is from question 5 which is ********* Question 5 : Program Correctness I (1 point) Use the loop invariant (I) to show that the code below correctly computes n P−1 k=0 2k (this sum represents the sum of the first n even integers where n ≥ 1). Algorithm 1 evenSum(int n) 1: p = 2(n − 1) 2: i = n − 1 3: while i > 0 do 4: //(I) p = nP−1...
solve it as soon as and i will upvote you directly i need details plz Question#1:...
solve it as soon as and i will upvote you directly i need details plz Question#1: Write the complement of the following function using product of maxterms F(A,B,C,D) = ∑(0,2,4,6,8,10,12,14) Question#2: Write the following function using sum of minterms F(A,B,C,D) = ABC` + ABCD` + AC` Question#3: Write the truth table for the complement of the following function F(A,B,C,D) = ∏(0,2,4,6,8,10,12,14) Question#4: Simplify the following function using Algebra F = Y(X + Y) + (X+Y)’Z + YZ Question#5: What is...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads...
Curve-Fit Function USING MATLAB Using the top-down design approach, develop a MATLAB function A8P2RAlastname.m that reads data from a file and performs regression analysis using polyfit and polyval. The function shall have the following features: The input arguments shall include the file name (string), a vector of integers for the degrees of polynomial fits to be determined, and an optional plot type specifier (‘m’ for multiple plots, ‘s’ for a single plot - default). The data files will be text...
using dr.racket programing language If we write a function that tests whether a list contains only...
using dr.racket programing language If we write a function that tests whether a list contains only strings, odd numbers, or even numbers, you will notice that the code that iterates through the list stays the same, with the only change being the predicate function that checks for the desired list element. If we were to write a new function for each of the tests listed above, it would be more error-prone and an example of bad abstraction. We could write...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT