示例#1
0
def c8_tanh ( c ):

#*****************************************************************************80
#
## C8_TANH evaluates the hyperbolic tangent of a C8.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    12 February 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, complex C, the argument.
#
#    Output, complex VALUE, the function value.
#
  from c8_exp import c8_exp

  value = ( c8_exp ( c ) - c8_exp ( - c ) ) / ( c8_exp ( c ) + c8_exp ( - c ) )

  return value
示例#2
0
def c8_cos ( c ):

#*****************************************************************************80
#
## C8_COS evaluates the cosine of a C8.
#
#  Discussion:
#
#    Here we use the relationship:
#
#      C8_COS ( C ) = ( C8_EXP ( i * C ) + C8_EXP ( - i * C ) ) / 2
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    11 February 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, complex C, the argument.
#
#    Output, complex VALUE, the function value.
#
  from c8_exp import c8_exp

  value = ( c8_exp ( 1j * c ) + c8_exp ( - 1j * c ) ) / 2.0

  return value
def c8_cosh ( c ):

#*****************************************************************************80
#
## C8_COSH evaluates the hyperbolic cosine of a C8.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    12 February 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, complex C, the argument.
#
#    Output, complex, the function value.
#
  from c8_exp import c8_exp

  value = ( c8_exp ( c ) + c8_exp ( -c ) ) / 2.0

  return value
def c8_sin ( c ):

#*****************************************************************************80
#
## C8_SIN evaluates the sine of a C8.
#
#  Discussion:
#
#    Here we use the relationship:
#
#      C8_SIN ( C ) = -i ( C8_EXP ( i * C ) - C8_EXP ( - i * C ) ) / 2
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    12 February 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, complex C, the argument.
#
#    Output, complex VALUE, the function value.
#
  from c8_exp import c8_exp

  value = - 1j * ( c8_exp ( 1j * c ) - c8_exp ( - 1j * c ) ) / 2.0

  return value
示例#5
0
def c8_sinh ( c ):

#*****************************************************************************80
#
## C8_SINH evaluates the hyperbolic sine of a C8.
#
#  Discussion:
#
#    Here we use the relationship:
#
#      C8_SINH ( C ) = ( C8_EXP ( C ) - C8_EXP ( - C ) ) / 2
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    12 February 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, complex C, the argument.
#
#    Output, complex VALUE, the function value.
#
  from c8_exp import c8_exp

  value =  ( c8_exp ( c ) - c8_exp ( - c ) ) / 2.0

  return value
示例#6
0
def c8_tan ( c ):

#*****************************************************************************80
#
## C8_TAN evaluates the tangent of a C8.
#
#  Discussion:
#
#    We use the relationship:
#
#      C8_TAN ( C ) = - i * ( C8_EXP ( i * C ) - C8_EXP ( - i * C ) ) 
#                         / ( C8_EXP ( I * C ) + C8_EXP ( - i * C ) )
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license.
#
#  Modified:
#
#    12 February 2015
#
#  Author:
#
#    John Burkardt
#
#  Parameters:
#
#    Input, complex C, the argument.
#
#    Output, complex VALUE, the function value.
#
  from c8_exp import c8_exp

  value =  - 1j * ( c8_exp ( 1j * c ) - c8_exp ( - 1j * c ) ) \
     /            ( c8_exp ( 1j * c ) + c8_exp ( - 1j * c ) )

  return value
def c8_log_test ( ):

#*****************************************************************************80
#
## C8_LOG_TEST tests C8_LOG.
#
#  Licensing:
#
#    This code is distributed under the GNU LGPL license. 
#
#  Modified:
#
#    11 February 2015
#
#  Author:
#
#    John Burkardt
#
  import numpy as np
  from c8_exp import c8_exp
  from c8_uniform_01 import c8_uniform_01

  print ''
  print 'C8_LOG_TEST'
  print '  C8_LOG computes the logarithm of a C8.'
  print ''
  print '       C1=C8_UNIFORM_01          C2=C8_LOG(C1)             C3=C8_EXP(C2)'
  print '     ---------------------     ---------------------     ---------------------'
  print ''

  seed = 123456789

  for i in range ( 0, 10 ):
    c1, seed = c8_uniform_01 ( seed )
    c2 = c8_log ( c1 )
    c3 = c8_exp ( c2 );
    print '  (%12f,%12f)  (%12f,%12f)  (%12f,%12f)' \
      % ( c1.real, c1.imag, c2.real, c2.imag, c3.real, c3.imag )

  print ''
  print 'C8_LOG_TEST:'
  print '  Normal end of execution.'

  return