Maclaurin series are a type of Mathematic series expansion in which all terms are nonnegative real powers of the variable. The Maclaurin series expansion for sin(x) is given by the following formula that is valid for all real values of x such that x is in radians (Note that: radians(x) = x × 1/180): sin(x) = x – 3! 5! Implement a Java program to compute the value of Maclaurin series expansion for sin(x) where x is a nonnegative real value according to the following: a. Write a java method named Factorial that takes as an argument an integer value n and returns the mathematical factorial n! of n as a long value such that: n! = n x (n – 1) × (n – 2) x ... × 2 × 1 b. In the main method: i. Ask the user to enter the value of the angle x to be calculate in the Maclaurin series expansion for sin(x) as given above. x Should be entered in degrees, i.e., 0° < x < 360° and then converted into radians using the formula: (radians(x) = x × 1/180). ii. Ask the user to enter the number of terms to be calculated in the Maclaurin series expansion for sin(x). ii. Print the calculated sum of the first n number of terms to be calculated in the Maclaurin series expansion for sin(x) rounded to 6 decimal places. iv. Print the difference between the calculated sum of the first n number of terms to be calculated in the Maclaurin series expansion for sin(x) and the value using Math. sin(x) rounded to 6 decimal places. Sample run: Enter an angle in degrees: 30 Enter number of terms of maclaurin series: 5 Sum of first 5 terms of Maclaurin sries of sin(30) is 0.500000. Math.sin(5) is 0.500000. Math.sin(30) Maclaurin series = 0.000000.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question

write a java algorithm to solve 

Maclaurin series are a type of Mathematic series expansion in which all terms are nonnegative real
powers of the variable. The Maclaurin series expansion for sin(x) is given by the following formula
that is valid for all real values of x such that x is in radians (Note that: radians(x) = x x 1/180):
sin(x) =
3!
5!
Implement a Java program to compute the value of Maclaurin series expansion for sin(x) where x is a
nonnegative real value according to the following:
a. Write a java method named Factorial that takes as an argument an integer valuen and
returns the mathematical factorial n! of n as a long value such that:
n! = n x (n – 1) x (n – 2) ... × 2 × 1
b. In the main method:
i. Ask the user to enter the value of the angle x to be calculate in the Maclaurin series
expansion for sin(x) as given above. x Should be entered in degrees, i.e., 0° < x <
360° and then converted into radians using the formula: (radians(x) = x × 1/180).
ii. Ask the user to enter the number of terms to be calculated in the Maclaurin series
expansion for sin(x).
iii. Print the calculated sum of the first n number of terms to be calculated in the Maclaurin
series expansion for sin(x) rounded to 6 decimal places.
iv. Print the difference between the calculated sum of the first n number of terms to be
calculated in the Maclaurin series expansion for sin(x) and the value using
Math. sin(x) rounded to 6 decimal places.
Sample run:
Enter an angle in degrees: 30
Enter number of terms of maclaurin series: 5
Sum of first 5 terms
of Maclaurin sries of sin (30) is 0.500000.
Math.sin (5) is 0.500000.
Math.sin (30)
Maclaurin
series = 0.000000.
Transcribed Image Text:Maclaurin series are a type of Mathematic series expansion in which all terms are nonnegative real powers of the variable. The Maclaurin series expansion for sin(x) is given by the following formula that is valid for all real values of x such that x is in radians (Note that: radians(x) = x x 1/180): sin(x) = 3! 5! Implement a Java program to compute the value of Maclaurin series expansion for sin(x) where x is a nonnegative real value according to the following: a. Write a java method named Factorial that takes as an argument an integer valuen and returns the mathematical factorial n! of n as a long value such that: n! = n x (n – 1) x (n – 2) ... × 2 × 1 b. In the main method: i. Ask the user to enter the value of the angle x to be calculate in the Maclaurin series expansion for sin(x) as given above. x Should be entered in degrees, i.e., 0° < x < 360° and then converted into radians using the formula: (radians(x) = x × 1/180). ii. Ask the user to enter the number of terms to be calculated in the Maclaurin series expansion for sin(x). iii. Print the calculated sum of the first n number of terms to be calculated in the Maclaurin series expansion for sin(x) rounded to 6 decimal places. iv. Print the difference between the calculated sum of the first n number of terms to be calculated in the Maclaurin series expansion for sin(x) and the value using Math. sin(x) rounded to 6 decimal places. Sample run: Enter an angle in degrees: 30 Enter number of terms of maclaurin series: 5 Sum of first 5 terms of Maclaurin sries of sin (30) is 0.500000. Math.sin (5) is 0.500000. Math.sin (30) Maclaurin series = 0.000000.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning