Question

Please, I am evaluating an error term y = 5^(n+1)*(n+1) and wish to find the number...

Please, I am evaluating an error term y = 5^(n+1)*(n+1) and wish to find the number of terms n required for ln (1.2) to yield an error < 10^-5. The manual computation gave me n > 5. But I need to come out with a MATLAB code with explanations and an output to confirm my manual answer.

function error a = 1.2 - 1; n = 1;

while (1/(n+1) * a^(n+l)) > 10e-6 n = n+1;

end

fprintf ('n = %d is the smallest number of terms needed to get ln (1.2) with an error less than 10^-5\n',n)

n > 5 is the smallest number of terms needed to get In (1.2) with an error less than 10^-5

Please help with line by line explanations, I can't get the output. Don't know what is wrong with the code. Thank you.

Please the error output is less than 10^-5

function error
a=1.5-1;
n=1;
while (1/(n+1)* a^(n+1)) >10e-6
n = n+1;
end
fprintf ('n=% d is the smallest number of terms needed to get ln(1.5) to yield an error less than 10^-5 \n',n)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB:

function error a = 1.2 - 1; n = 1;
while (1/(n+1) * a^(n+1)) > 10e-6
n = n+1;
end
fprintf ('n = %d is the smallest number of terms needed to get ln (1.2) with an error less than 10^-5\n',n)
N=n
for n=1:N;
y=(1/(n+1) * a^(n+1));
fprintf ('For n = %d ,y=%d\n',n,y)
endfor
end

Command window(output):

n = 6 is the smallest number of terms needed to get ln (1.2) with an error less than 10^-5
N = 6
For n = 1 ,y=0.02
For n = 2 ,y=0.00266667
For n = 3 ,y=0.0004
For n = 4 ,y=6.4e-005
For n = 5 ,y=1.06667e-005
For n = 6 ,y=1.82857e-006

Add a comment
Know the answer?
Add Answer to:
Please, I am evaluating an error term y = 5^(n+1)*(n+1) and wish to find the number...
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
  • Due in 5 hours, 12 minutes, Due Mon 04/15/2019 11:5 Subtract the infinite series of In(1 -) from ...

    Due in 5 hours, 12 minutes, Due Mon 04/15/2019 11:5 Subtract the infinite series of In(1 -) from In(1 + z) to get a power series for Preview Evaluate this power series at z = to get 3 In(2)= Σ Preview What is the smallest N such that the Nth partial sum of this series approximates ln(2) with an error less than 0.001? Number of terms needed is: Points possible: 10 This Is attempt 1 of 3 Submit ービービーーーー1/1/1/10020000003- Due...

  • Consider the function f (x) = ln (1 + x). (a) Enter the degree-n term in...

    Consider the function f (x) = ln (1 + x). (a) Enter the degree-n term in the Taylor Series around x = 0. (b) Enter the error term En (z) which will also be a function of x and n. (c) Find an upper bound for the absolute value of the error term when x > 0. It may help to remember that z is between x and 0. (d) Use this formula to find how many terms are needed...

  • C++ Can someone please help with this code... even when the players number isnt a winning number the program always says the player wins: #include <stdio.h> #include <time.h> //main functi...

    C++ Can someone please help with this code... even when the players number isnt a winning number the program always says the player wins: #include <stdio.h> #include <time.h> //main function int main() {    //seeding a random number    srand(time(0));    //define the arrays for the wagered, winning amount, percent amount    double amounts[7] = { 1, 5, 10, 20, 50, 100, 1000 };    double payoff[7] = { 100, 500, 1000, 2000, 5000, 10000, 100000 };    double percent[7] = { 0.01, 0.05, 1, 2,...

  • I am having trouble figuring out what is wrong with my code. This is the error...

    I am having trouble figuring out what is wrong with my code. This is the error I get for the last for loop. TypeError: list indices must be integers or slices, not list. This is the code: for line in fhr: ls = line.split(',') customer_list.append([ls[0], ls[1], ls[2], ls[3], ls[4], ls[5], ls[6], int(ls[7]), ls[8], ls[9], ls[10].strip('\n')]) from operator import itemgetter customer_list.sort(key=itemgetter(7), reverse=True) print(customer_list) writepath = './loan-data-output-v1.csv' fwh = open(writepath, 'w', encoding='utf-8') fwh.write('Name' +','+ 'State' +','+'Age' +','+'Annual Income'+','+   'Loan Type' +','+' Loan...

  • " Number Guessing Game You should think of a number between 1 and 100. Then, over...

    " Number Guessing Game You should think of a number between 1 and 100. Then, over and over again, the computer can suggest an answer. Your response to the computer guess will be as following: If that answer is too small, you enter the character '>'. If the computer's answer is too large, you enter the character '<'. If the computer's answer is just right, you enter '=' Requirements: Your code should show the number of time the computer needed...

  • Am I getting this error because i declared 'n' as an int, and then asking it...

    Am I getting this error because i declared 'n' as an int, and then asking it to make it a double? This is the coude: #include "stdafx.h" #include <iostream> #include <fstream> #include <string> #include <algorithm> #include <vector> using namespace std; void sort(double grades[], int size); char calGrade(double); int main() {    int n;    double avg, sum = 0;;    string in_file, out_file;    cout << "Please enter the name of the input file: ";    cin >> in_file;   ...

  • please could you help me with the error i am getting while running this program void setup (){ Serial.begin (9600) //tu...

    please could you help me with the error i am getting while running this program void setup (){ Serial.begin (9600) //turn on serial monitor DHT11 sensor.begin (); initialize humidity sensor DHT11 Sensor pinMode (10, OUTPUT); //Must declare 10 an output and reserve it SD.begin (4): //Initialize the SD card reader void loop () DHT11 sensor.readTemperature ); // Read Temperature from DHT11 temp = hum DHT11 sensor.readHumidity ); //Read humidity FILE WRITE) SD.open ("PTData.txt"; mySensorData if (mySensorData) Serial.print ("The Temp is:...

  • Java Branches code not working please HELP!! I am trying to build this class that will...

    Java Branches code not working please HELP!! I am trying to build this class that will ask for an ingredient, and the number of cups of the ingredient. It should then branch into an if/else branch off to verify that the number entered is valid and that it is within range. Once that branch completes it should then continue on to ask for the calories per cup, and then calculate total calories. Once I get it to enter the branch...

  • I am creating a MATLAB game for my school project. The goal of the game is...

    I am creating a MATLAB game for my school project. The goal of the game is to create a 'Treasure Hunt Game' that asks the user to input the number of players, the difficult (easy, medium, or hard), and asks the user(s) to pick spots on a matrix until the correct spot is chosen, therefore winning the game. If a player misses the spot, the command window doesn't show how far away the treasure is, but what direction it is...

  • X) -1-2! +41-614 (2k)! k=0 he actual Write a script that will determine how many terms are needed...

    x) -1-2! +41-614 (2k)! k=0 he actual Write a script that will determine how many terms are needed in the series to get the error between t value and the estimate to be less than 0.0001. The user should input the value of x and a formatted print statement should be used to display the result. Use a while loop to complete this problem. Note: error I(cos 2x)actual - (cos 2x)estimatel. See below for an example. Enter a value of...

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