how to compute tan?

This is a discussion on how to compute tan? within the C++ Programming forums, part of the General Programming Boards category; can somebody please help me with this problem? Given the function f(x) : 2tanx-x-1=0, write a program that will compute ...

  1. #1
    Registered User
    Join Date
    May 2003
    Posts
    1

    how to compute tan?

    can somebody please help me with this problem?

    Given the function f(x) : 2tanx-x-1=0, write a program that will compute the value for x using trial and error.

    Let me explain again, the user inputs a value for x and substitutes it in the formula above. The left side of the equation should equal to 0 once it's computed. If the x entered does not satisfy the equation, then the program should output the correct value for x. My problem is, I can't figure out how to do the tangent in the formula and I can't even find out what x should be.

    I'm thinking of placing my code here but I think it's useless anyway cos it's all wrong. I'm using MS Visual C++ to write the code. please help... >_<

    wait! i'm not asking you to write the whole program for me but i just want to know how to calculate formulas with tangents in it like the one above. thank you!

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    Code:
    #include <math.h>
    #include <stdio.h>
    
    void main( void )
    {
       double pi = 3.1415926535;
       double x, y;
    
       x = tan( pi / 4 );
       y = tanh( x );
       printf( "tan( %f ) = %f\n", pi/4, x );
       printf( "tanh( %f ) = %f\n", x, y );
    }
    ... from MSDN.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 02-22-2009, 02:54 PM
  2. Compute without Limit - support for fractions and 2G Digits!
    By etlam in forum Projects and Job Recruitment
    Replies: 14
    Last Post: 02-07-2008, 12:46 PM
  3. Help creating function of sin cos and tan
    By Niz in forum C Programming
    Replies: 12
    Last Post: 01-09-2007, 05:55 PM
  4. Inverse Tan
    By spidereen in forum C++ Programming
    Replies: 2
    Last Post: 03-04-2003, 08:55 AM
  5. does not compute (30/35)?!?!?!?!?!!!?!?!?!
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 11-01-2001, 04:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21