Python の数学関数 |セット 4 (特殊関数と定数)
いくつかの数学関数については、以下のセット 1、セット 2、およびセット 3 で説明します。 Python の数学関数 |セット 1 (数値関数) Python の数学関数 |セット 2 (対数関数とべき乗関数) Python の数学関数 |セット 3 (三角関数と角度関数) 特殊関数と定数については、この記事で説明します。 1.ガンマ() :- この関数は、 ガンマ関数 of the argument. Python
2.円周率 :- これは、を出力する組み込み定数です。 円周率の値(3.141592) 。 3.そして :- これは、を出力する組み込み定数です。 eの値(2.718281) . Python
4.inf :- これは 正の浮動小数点無限定数 。 -inf は、負の浮動小数点の無限大を示すために使用されます。この定数は Python 3.5 以降で定義されています。 5. あなたのために() :- この関数は次の目的で使用されます。 チェック 値が 無限かどうか。 6.で :- この定数は ' を表します 数字ではありません ' Pythonで。この定数は Python 3.5 以降で定義されています。 7. イスナン() :- この関数は戻り値を返します 数値が「nan」の場合は true else returns false. Python
# Python code to demonstrate the working of # gamma() # importing 'math' for mathematical operations import math a = 4 # returning the gamma() of 4 print ( 'The gamma() of 4 is : ' end = '' ) print ( math . gamma ( a ))
Output: The gamma() of 4 is : 6.0
2.円周率 :- これは、を出力する組み込み定数です。 円周率の値(3.141592) 。 3.そして :- これは、を出力する組み込み定数です。 eの値(2.718281) . Python
# Python code to demonstrate the working of # const. pi and e # importing 'math' for mathematical operations import math # returning the value of const. pi print ( 'The value of const. pi is : ' end = '' ) print ( math . pi ) # returning the value of const. e print ( 'The value of const. e is : ' end = '' ) print ( math . e )
Output: The value of const. pi is : 3.141592653589793 The value of const. e is : 2.718281828459045
4.inf :- これは 正の浮動小数点無限定数 。 -inf は、負の浮動小数点の無限大を示すために使用されます。この定数は Python 3.5 以降で定義されています。 5. あなたのために() :- この関数は次の目的で使用されます。 チェック 値が 無限かどうか。 6.で :- この定数は ' を表します 数字ではありません ' Pythonで。この定数は Python 3.5 以降で定義されています。 7. イスナン() :- この関数は戻り値を返します 数値が「nan」の場合は true else returns false. Python
# Python code to demonstrate the working of # inf nan isinf() isnan() # importing 'math' for mathematical operations import math # checking if number is nan if ( math . isnan ( math . nan )): print ( 'The number is nan' ) else : print ( 'The number is not nan' ) # checking if number is positive infinity if ( math . isinf ( math . inf )): print ( 'The number is positive infinity' ) else : print ( 'The number is not positive infinity' )
Output: The number is nan The number is positive infinity