Results 1 to 6 of 6

Thread: The tanh() function of C++

  1. #1
    Join Date
    Dec 2009
    Posts
    31

    The tanh() function of C++

    I am the student of the Bachelor of science in Information Technology. I have know about the C++ language. I am finding the problem while using the tanh() function in the C++ program. I want to know about the tanh() function of the C++ language. I also want know how can I implement these functions in my C++ program. Thus, Anyone knows about the these functions ? Please, Help me!!

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    The tanh() function of C++

    The tanh() function of the C++ language can be used to compute the hyperbolic tangent of the valarray of an elements. The tanh() function of the C++ language can returns an object of the valarray that can be containing the hyperbolic tangents of all of an elements of y. The tanh() function can an overloads c math's tanh function.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: The tanh() function of C++

    The tanh() function of the C++ language used to find out the tangent of an given element. The tanh() function can be a member function of the valarray. The following can be the general form of the tanh() function of the C++ language :
    Code:
    template<class S> valarray<S> tanh (const valarray<S>& y);

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Use of the tanh() function

    I can suggest you that to carefully go through the following code of lines that can demonstrates you how to use the tanh() function in the C++ programming as follows :
    Code:
    #include <iostream>
    #include <cmath>
    #include <valarray>
    using namespace std;
    int main ()
    {
      double vl[] = {0.35, 1.22, 3.4};
      vlarray<double> f (vl,3);
      vlarray<double> br = tanh (f);
      cout << "f: ";
      for (size_t k=0; k<f.size(); ++k)
    	  cout << f[k] << ' ';
      cout << endl;
      cout << "br: ";
      for (size_t k=0; k<br.size(); ++k)
    	  cout << br[k] << ' ';
      cout << endl;
      return 0;
    }
    Output:
    Code:
    f: 0.35 1.22 3.4
    br: 0.335376 0.839654 0.997775

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: The tanh() function of C++

    A valarray whose elements can be equal to the hyperbolic cos of an elements of the input valarray. The following can be the parameters of the tanh() function in the C++ programming language :
    1. y : This parameter of the tanh() function can be used to contains a valarray that can be containing an elements of a type for that the unary function tanh can be defined.

  6. #6
    Join Date
    Nov 2005
    Posts
    1,323

    Re: The tanh() function of C++

    The following can be an example that can uses the tanh() function of the C++ language to illustrate the tanh(0 function. The following an example can calculates y as the hyperbolic tangent of &pi./4.
    Code:
    #include <math.h>
    #include <stdio.h>
     int main(void)
    {
       double pi, y;
       pi = 3.1415926;
       y = tanh(pi/4);
        printf("tanh( %lf ) = %lf\n", pi/4, y);
    }
    Output :
    Code:
    tanh( 0.785398 ) = 0.655794

Similar Threads

  1. c++ equivalent function to the c-function 'sprintf
    By Dilbert in forum Software Development
    Replies: 6
    Last Post: 13-12-2011, 04:03 PM
  2. c# function equivalent to gettime function in javascript
    By Omaar in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:44 PM
  3. Replies: 5
    Last Post: 27-02-2010, 07:52 PM
  4. How does abstract function differs from virtual function?
    By Maddox G in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 11:32 AM
  5. Function keys don't function under windows XP
    By GunFighter in forum Hardware Peripherals
    Replies: 3
    Last Post: 08-04-2009, 11:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,309,740.45929 seconds with 17 queries