Question

The mathematician Euler proved that: tan-(x) = x -. Write a C program to do the following: -Ask user to enter the value of (x

Solve using C language

0 0
Add a comment Improve this question Transcribed image text
Answer #1
 #include <stdio.h> #include <math.h> #include <stdlib.h> #define PI 3.14159265359 int main(){ double x; while(1){ printf("enter x\n"); scanf("%lf", &x); if(x==-99){ printf("End, Thank you\n"); return 0; } if(fabs(x)>0.5){ printf("Re-enter x, it should be >=-0.5 and <=0.5\n"); } else{ double aTan_actual = atan(x); double aTan_calculated = 0.0; // dhyan dena hai yha int count = 0; int i=1; while(fabs(aTan_actual - aTan_calculated)*(180.0/PI) > 0.001){ if(i%4 == 1) aTan_calculated += pow(x, (double)i)/(double)i; if(i%4 == 3) aTan_calculated -= pow(x, (double)i)/(double)i; i+=2; count++; } printf("the actual value is %lf deg.\n", aTan_actual*(180.0/PI)); printf("the series value is %lf deg.\n", aTan_calculated*(180.0/PI)); printf("number of iterations = %d\n\n",count); } } }

// Note that number of iteration may differ due to different value of PI used and different datatype used.

// compile the code with      gcc filename.c -lm      (for math.h header)

Add a comment
Know the answer?
Add Answer to:
Solve using C language The mathematician Euler proved that: tan-(x) = x -. Write a C...
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
  • a.) Write a C++ program that calculates the value of the series sin x and cos...

    a.) Write a C++ program that calculates the value of the series sin x and cos x, sin 2x or cos 2x where the user enters the value of x (in degrees) and n the number of terms in the series. For example, if n= 5, the program should calculate the sum of 5 terms in the series for a given values of x. The program should use switch statements to determine the choice sin x AND cos x, sin...

  • in c++ language 1.Re-write the following for loop statement by using a while loop statement: int...

    in c++ language 1.Re-write the following for loop statement by using a while loop statement: int sum = 0; for(int i=0;i<=1000;i++){                 sum+=i; } 1 (b). Following is the main () function of a program. The program asks a user to enter 150 integers and print the largest integer user entered. int main() {    int score, highest;             //missing portion of the program             return 0;    } 1(c). Find the missing portion of the following code, so the...

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

  • Write a C++ program to analyze a variety of triangles. The program should determine all angles...

    Write a C++ program to analyze a variety of triangles. The program should determine all angles and all sides for a triangle for three different options (give the user a menu of choices): 1) Given two sides and the angle between 2) Given two angles and one side 3) Given three sides More details for each option is provided below. Option 1: Given two sides and the angle between First check to be sure that the three values entered are...

  • write a programming code for the following problem using Visual Basic Studio VB. Write a program that will allow the user to enter series of mumbers and will give some useful statistics about the mam...

    write a programming code for the following problem using Visual Basic Studio VB. Write a program that will allow the user to enter series of mumbers and will give some useful statistics about the mambers Enter Numbers Button Click-Allow the user to enter series of nambers using imput dialog boxes. Use a loop and add the numbers to the listBox as they are input.. Prompt the user to enter"x" to stop addang numbers. Compute Statistics Button Click-Compute the following statistics...

  • Please answere using python language codes. Write a program to print out Collatz sequence for a...

    Please answere using python language codes. Write a program to print out Collatz sequence for a user-supplied number. Prompt the user for a positive integer which will become the first number in the sequence. Next number in the sequence is derived as follows: If previous number is odd, the next number is 3 times the previous, plus 1. If previous number is even, the next number is half of the previous According to Collatz proposition, the sequence ultimately reaches 1...

  • Student ID: 123 Write a C+ program with the following specifications: a. Define a C++ function (name it function_Student...

    Student ID: 123 Write a C+ program with the following specifications: a. Define a C++ function (name it function_StudentlD where StudentID is your actual student ID number) that has one integer input (N) and one double input (x) and returns a double output S, where N S = n 0 and X2 is given by 0 xeVn n 0,1 Хл —{2. nx 2 n 2 2 m2 x2 3 (Note: in the actual quiz, do not expect a always, practice...

  • Write VBA functions to calculate sin (x) using the Maclaurin arcsine series, and compare the values...

    Write VBA functions to calculate sin (x) using the Maclaurin arcsine series, and compare the values for sin-1(x) from your program to those given by the Excel spreadsheet function ASIN(x). The Maclaurin arcsine expansion is given by x 3x 6 40 (2n)! sin1(x)-2((2n+1) Note: This function by definition is only defined for-1 SxS1. When you write the code for calculating it, you will need to include code that assigns a value to it that reflects it is undefined for values...

  • Three C Code Questions: 5. Write a C program that declares an array of 10 strings,...

    Three C Code Questions: 5. Write a C program that declares an array of 10 strings, each of max length 50 characters, and then reads an entire line of text from the keyboard into each string. 6. Write C code that finds the longest name in this array of strings that you read in Q5. Hint: find the position of the longest string, not the string itself. 7. Write a C program that creates a 4 x 6 two dimensional...

  • Consider the equation f(x) = 2*sin(pi*x) + 3*cos(pi*x) Write a c program that computes the values...

    Consider the equation f(x) = 2*sin(pi*x) + 3*cos(pi*x) Write a c program that computes the values of f(x) for the following values of x: 0.25, 0.5, 1, 2. Your program should allow the user to enter the value from the standard input and the results will be displayed as follows: /*****************************************************************/ Value of x Value of f(x) 0.25 3.5355 0.5 1 2

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