Question

Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are usually calculated on compuSample Output (3 cases): Enter the x value to determine the natural log (0 to 2): 1.125 Enter the precision for natural log:

Comments
    Answer #1

    Script: naturallog.m

    x = input("\nEnter the x value to determine the natural log (0 to 2): ");
    prec = input("Enter the precision for natural log : ");

    fprintf("-----------------------------\n");

    if x <= 0 || x >= 2.0
    fprintf("Error! Natural log must be greater than 0 and less than or equal to 2\n");
    else
    x = 1.0 * x;
    prec = 1.0 * prec;

    term = 1;
    sign = 1;
    sum = 0;
    diff = prec + 1;

    while diff > prec
        sum += sign * ((x-1.0) ^ term)/term;
        fprintf("\nTerm %d: Current value of Natural Log series is %f", term, sum);
        term += 1;
        diff = abs(sum - log(x));
        sign = -1 * sign;
    end

    fprintf("\n\nActual ln(%f) = %f", x, log(x));
    fprintf("\nSeries ln(%f) = %f", x, sum);
    fprintf("\n%d terms required to acheive a precision of %f\n", term-1, prec);
    end

    Execution and Output:

    naturallog Enter the x value to determine the natural log (θ to 2): 1.125 Enter the precision for natural log : .θ8801 Term 1

    Add a comment
    Know the answer?
    Add Answer to:
    Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are...
    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
    • Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in th...

      using matlab Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in the decimal to octal program Introduction: In file systems on servers (think of websites like Google, Amazon, etc.), permission to access the files come from the octal number system. Given an octal quadruple, permissions are defined for the user, the group, and other as follows: Permission First Digit Second Digit Third Digit Fourth Digit Always 01 (User-u) 0 」(Group-g) | (Other-o) Read (r) Write...

    • this is Matlab. Three images are consecutive and connected. I NEED PROBLEM 2 Chapter 6 Programming in Matlab Week 6 THE ALTERNATING HARMONIC SERIES The alternating harmonic series converges to the na...

      this is Matlab. Three images are consecutive and connected. I NEED PROBLEM 2 Chapter 6 Programming in Matlab Week 6 THE ALTERNATING HARMONIC SERIES The alternating harmonic series converges to the natural log of 2 +--...-In(2) = 0.6931471806 -1--+ Because of this, we can use the alternating harmonic series to approximate the In(2). But how far out do you have to take the series to get a good approximation of the final answer? We can use a while loop to...

    • Write in Python 3 Write a program that takes the value of an angle x in...

      Write in Python 3 Write a program that takes the value of an angle x in degrees, such that 0 s x <90, and calculates approximate value of sine of the given angel using the following series sin(x)-x-for all x The series given above has infinite number of terms. However, you can only include a finite number of terms in the series. The absolute value of each subsequent term is smaller than that of the term calculated before it. The...

    • Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly...

      Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly hours for all employees are stored in a text file where each line contains the employee name followed by the hours worked for each day of the week. The data is stored as follows (data is continuous in the file but represented in columns below): Kelly Brian Katie Michae Emily Jim John Jane Joe Doe Smith Hart Jones Hu Wright Young Green Hurley Write...

    • 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...

    • I need not in pic or handwriting, in keyboard Spring 19 (1) ESC 152 Programming with...

      I need not in pic or handwriting, in keyboard Spring 19 (1) ESC 152 Programming with MATLAB Section 2 1) The Taylor series expansion for cos(x) is: coS(x). where x is in radians. Write a MATLAB program that determines cos (x) using the Taylor series expansion. The program asks the user to type a value for an angle in degrees. Then the program uses a loop for adding the terms of the Taylor series. If a is the nth term...

    • In MATLAB The value of cos(x) can be approximated using a Maclaurin series + +... cos(x)=1-1...

      In MATLAB The value of cos(x) can be approximated using a Maclaurin series + +... cos(x)=1-1 2! 4! 6! Which can be expressed compactly as cos(x) = {(-1)+7 (2(k-1))! 00 2(k-1) k-1 Write Matlab code using a while loop that calculates cos(2) with 5 terms of Maclaurin series. Compare the value with the one calculated with a built-in function cos (2) in Matlab. The following is an expected output from your code: Using the Maclaurin series cos( 2.0) with 5...

    • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

      This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

    • Write a program that approximates the sum of this geometric series using a user- specified number...

      Write a program that approximates the sum of this geometric series using a user- specified number of terms. For example, if you named your program approx, calling approx(3) should use the first 3 terms of the series to calculate the approximation: Approximate result = 1/2 + 1/4 + 1/8 = 0.875... Note: the values are all powers of 1⁄2: (1/2)1, (1/2)2, (1/2)3, ... Next, have your program calculate the difference (rounded to 3 decimal places) between the value “1” and...

    • Problem 5 xx The Taylor series expansion for sin(x) is sin(x) = x -H + E-E+...

      Problem 5 xx The Taylor series expansion for sin(x) is sin(x) = x -H + E-E+ = o E- (-1) . 2n +1 no (2n+1)! !57 where x is in radians. Write a MATLAB program that determines sin(x) using the Taylor series expansion. The program asks the user to type a value for an angle in degrees. Then the program uses a while loop for adding the terms of the Taylor series. If an n is the nth term in...

    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