Ask Question
15 October, 02:51

3. Given the Taylor series expansion for sin x = x - x3 / 3! + x5/5! - x7/7!. Write a program that takes in an arbitrary integer for an angle in degrees, converted the degrees to radians and performs the calculation above. Remember you will need a loop to calculate the! term and float variables to hold the term (s) in the expansion and the converted degrees to radian.

+2
Answers (1)
  1. 15 October, 03:14
    0
    clc

    clear

    x = input ('type value of angle in degrees:/n');

    x = x*pi/180; %convverting fron degree to radian

    sin_x = x; %as first term of taylor series is x

    E = 1; %just giving a value of error greater than desired error

    n = 0;

    while E > 0.000001

    previous = sin_x;

    n = n+1;

    sin_x = sin_x + ((-1) ^n) * (x^ (2*n+1)) / factorial (2*n+1);

    E = abs (sin_x - previous); %calculating error

    end

    a = sprintf ('sin (x) = %1.6f', sin_x);

    disp (a)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “3. Given the Taylor series expansion for sin x = x - x3 / 3! + x5/5! - x7/7!. Write a program that takes in an arbitrary integer for an ...” in 📗 Engineering if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers