Ask Question
24 October, 11:57

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. 24 October, 13:13
    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 you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers