Question


this assignment you will write two functions. The first function must calculate and return the exponent of the highest term i

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.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Problem 1

MatLab program

clear all
clc
% input the value of sum
n=input('Enter the value of n: ');
total=0;
k=0;
while n>total
    total=total+2^k;
    k=k+1;
end
k=k-1;
fprintf('\nNo. of terms=%d',k);

Screenshot

1 clear all 2 clc 3% input the value of sum 4 n=input(Enter the value of n: ); 5 total=0; 6 k=0; 7 while n>total total=tota

Save the above program and execute it.

Result

Enter the value of n: 12 No. of terms=3 >>

Problem 2

MatLab program

clear all
clc
% input the value of no. of terms
k=input('Enter the value of k: ');
% sum is zero initially
n=0;
for i=0:k-1
    n=n+2^i;
end
fprintf('\nSum of terms=%d',n);

Screenshot

1 clear all 2 clc 3% input the value of no. of terms 4 k=input(Enter the value of k: ); 5% sum is zero initially 6 n=0; 7 f

Save the above program and execute it.

Result

Enter the value of k: 4 Sum of terms=15 >>

I hope this will help you.

Add a comment
Know the answer?
Add Answer to:
Matlab function to solve an inequality that has a summation problem on one side. I have...
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
  • I want to create a program that first calculate the summation from 1 to R. This code will computes the summation from 1...

    I want to create a program that first calculate the summation from 1 to R. This code will computes the summation from 1 to R with single thread. #include <pthread.h> #include <unistd.h> #include <stdlib.h> #include <assert.h> #include <stdio.h> #define NuMBer_THREADS 2 #define R 1e4 long long sum = 0; // matrix multiplication is  c = a * b; void calculatesum() { int i=1; for(i=1;i<=N;i++) { sum+=i; asleep(100); } } // Thread function // Each thread calculates the summation over (R...

  • i) Write a Sigma-notation summation for: the sum of the first “n” odd positive integers. For...

    i) Write a Sigma-notation summation for: the sum of the first “n” odd positive integers. For example, if n=4, it should sum like this: 1 + 3 + 5 + 7. ii) Starting with: 1+sum r^n, n=1 to infinity, rewrite it as just one summation without the 1+ out front. iii) Starting with: sum 1/n, n=1 to infinity, rewrite it as two terms out front, and then the sum starting at n=3. iv) Starting with: sum 1/(n+1), n=0 to 5,...

  • Solve the following problem in MATLAB. Use format compact for all work to suppress extra lines....

    Solve the following problem in MATLAB. Use format compact for all work to suppress extra lines. Show all work and add comments as needed to explain your logic/steps. 1. The function f(x) = e* can be approximated by the following Taylor series: n=0 The first few terms of the Taylor series are: e 1 + x + + + + ...... 2! 3! 4! Keep in mind that the "!" symbol denotes factorial. For example, the factorial of 4 =...

  • Required functions def inputWithinRange (lowValue, highValue): This function will ask for a number from the keyboard....

    Required functions def inputWithinRange (lowValue, highValue): This function will ask for a number from the keyboard. The function will only return a value that is within the inclusive range of lowValue to highValue. If the entered value is not within the provided range, the function will ask again until the user has entered an acceptable value. The function will return the accepted value. def doContinue (prompt): This function will ask for a string using the prompt parameter. The function will...

  • Solve using Matlab Write a simple loop to list the squares of the first 10 integers....

    Solve using Matlab Write a simple loop to list the squares of the first 10 integers. Using a simple "while" loop, write a script to sum the series 1 + 2 + 3 + ... such that the sum is as large as possible without exceeding 100. The program should display how many terms are used in the sum. Write a script that takes as input an integer n and creates the n*n matrix A with (ij)th component given by...

  • Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST b...

    Objectives Work with functions Assignment Write each of the following functions using Python. The function header MUST be written as specified. In your main code test all of the specified functions. Each function must have a comment block explaining what it does, what the parameters are and what the return value is. Please remember the following two guidelines: unless the purpose of the function is to generate output DO NOT write to the screen within the function unless the purpose...

  • Write in C code: Define an array f=[23,-12,34,-56,-10,12,19], using call-by-reference (use pointers), to pass the array...

    Write in C code: Define an array f=[23,-12,34,-56,-10,12,19], using call-by-reference (use pointers), to pass the array to a function, named Summation. In main: Define array, pass array, print out the array and the result returned from Summation on screen. In function Summation: 1)take array and size from main 2) sum each element according to the following rules 3) if the value of f(i) is positive, add 2*f(i) to the sum 4)if the value of f(i) is negative, add -3*f(i) to...

  • MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts...

    MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts in order to get full credit. Help me out, thank you f LAB SECTION NAME HW6P3 (30 points) following are infinite series representations of the function, un pra i a script file HW6P3 that determines the value of the function from the sum of the series for a given value of x. The program (1 pt) must prompt the user to enter a value...

  • 8.         R-4.8 Order the following functions by asymptotic growth rate. 4nlogn + 2n 2^10    2^logn 3n...

    8.         R-4.8 Order the following functions by asymptotic growth rate. 4nlogn + 2n 2^10    2^logn 3n + 100logn      4n     2^n n^2 + 10n        n^3       nlogn 9.         R-4.9 Give a big-Oh characterization, in terms of n, of the running time of the example 1 method shown in Code Fragment 4.12. 10.       R-4.10 Give a big-Oh characterization, in terms of n, of the running time of the example 2 method shown in Code Fragment 4.12. 11.       R-4.11 Give a big-Oh characterization, in...

  • w Problem Statement: In mathematics, a series is, roughly speaking, a description of the operation of...

    w Problem Statement: In mathematics, a series is, roughly speaking, a description of the operation of adding infinitely many quantities, one after the other, to a given starting quantity. The study of series is a major part of calculus and its generalization, mathematical analysis. Mathematically, the n" number of a mathematical series is defined as follows: T. -Σ . . Write a CH program that: Reads a positive integer k from the user. If the user enters a negative value,...

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