Write a computer program that takes as input a floating point number x in the interval [−π, π], and an integer n in the range 1, 2, ..., 10, and calculates sin(x) using the Taylor series definition within an accuracy of 10−n . Indicate your programming language of choice, and include a screen shot of your test cases.
x=input('Enter a floating no between -pi and pi : ');
n=input('Enter an integer between 1 and 10 : ');
tol=10^-n;
sin_val=0;
i=0;
error=1;
while(error>tol)
nw_sin_val=sin_val;
sin_val=sin_val+(-1)^i*x^(2*i+1)/factorial(2*i+1);
i=i+1;
error=abs(nw_sin_val-sin_val);
end
disp('The Value of sin(x) is : ')
disp(vpa(sin_val))
Write a computer program that takes as input a floating point number x in the interval...
Write a C function called display_dollar which takes a floating point number as input, and displays this is a dollar value to the screen. This means that it should have a ‘$’ in front of it, and be displayed to exactly two decimal places in non-scientific form. Your function should not put spaces or newlines before or after the output?
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...
(Matlab) Suppose we have a function “hw5f.m” that takes as input
x and outputs the value for a function f(x). Write a Matlab program
that inputs: • interval [a, b]; • m, the number of data points with
evenly spaced nodes from x1 = a to xm = b, and values from f(x); •
location z satisfying x2 < z < xm−1, where h = (b − a)/(m −
1); and outputs the value of the interpolaton polynomial using only...
USING C# 1. Write a program that takes outputs a string, an integer and a floating-point number separated by commas. Sample output: Bob Marley, 20, 5.2 2. 2. Write a program that asks the user for a string of letters of any size (no spaces), and finally a special character (values 33 to 47 in the Ascii table, or ‘!’ to ‘/’). Generate a random number of any size, integer or floating point, and combine those three pieces of information...
Write a program in Python that accepts as input an integer N and a real number c, and outputs the coefficient of the Nth degree term of the Taylor series for the function f(x) = ex centered at c. This process should recur until the user enters a quit code. Erroneous input should be excepted as necessary, and should result in a new prompt.
1. Write a program that takes a number as input and check whether the number is positive, negative or zero. 2. Write a C++ program that prompts the user to enter a number and checks whether the entered number is even or odd. 3. Using switch-case statement write a C++ program that prompts the user to enter 1, 2 or 3 and display "Red" if selection is 1, "Yellow" if selection is 2, or "Green" if selection is 3. 4. Write...
Write a program in MIPs Assembly Language to compute nth number of a fibonacci number sequence. Your program should prompt for an integer input n from the user. The program should call a recursive function to compute the nth fibonacci number. Your program must follow programming convention. You should submit program and screenshot of output in a single word/pdf file. You should use following recursive definition of fibonacci function: fib(0) = 0 fib(1) = 1 fib(n) = fib(n-1) +fib(n-2)
1. (a) We need to calculate accurate values of the function for very large values of x. However, it is found that just programming this formula into a computer gives very poor accuracy for large x Explain why this happens, and show how to re-write the function so that it can be used reliably, even when x is large. [6 points] (b) In diffraction theory, it is sometimes necessary to evaluate the function sin θ f(x) for small to moderate...
• Next to these lines, write functional Java codes that will: (1) ask user to input a positive integer, such as 15; (2) create a void type of method named "findSum" that takes a parameter of int type named "n". Make sure the "findSum" method can calculate the sum of 1+2+3+ ... +n; and (3) use the "System.out.println(" to display the newly calculated sum. The following is a sample output: Enter an integer: 15 120 Enter an integer: 10 Enetr...
Write a computer code that: 1. (5 points total) Takes as input: a. (1 point) A position vector (in km) and a velocity vector (in km/s) in ECI coordinates b. (1 point) An initial time t (in secs) c. (1 point) A later time t2 (in secs) d. (1 point) The tolerance Ar e. (1 point) The tolerance AA 2.(5 points total) Outputs the input data with labels and units (as appropriate) 3. (39 points total) Calculates the following: a....