LoginSignup
0
0

More than 5 years have passed since last update.

sympyで「双曲線関数(hyperbolic function)」をやってみた

Last updated at Posted at 2018-08-03

(参考)simplifying expressions with hyperbolic functions
https://stackoverflow.com/questions/11076263/simplifying-expressions-with-hyperbolic-functions
(参考)チュートリアルを読む 読書ノート v1.5dev > Trigonometric Simplification
https://showa-yojyo.github.io/notebook/python-sympy/tutorial.html#trigonometric-simplification

日本版wikipediaより

(参考)双曲線関数
https://ja.wikipedia.org/wiki/%E5%8F%8C%E6%9B%B2%E7%B7%9A%E9%96%A2%E6%95%B0#定義

途中から怪しくなります?

fullscript.py
from sympy import *
var('x')
print('定義--------------------------------')
expr=sinh(x)
print(expr,"=",expr.rewrite(exp))
expr=exp(x)-sinh(x)
print(simplify(expr),"=",expr)
expr=tanh(x)
print(expr,"=",simplify(expr*cosh(x)),"/cosh(x)")
expr=coth(x)
print(expr,"=",simplify(expr*tanh(x)),"/tanh(x)")
# expr=sech(x)
# print(expr,"=",simplify(expr*cosh(x)),"/cosh(x)")
# expr=cosech(x)
# print(expr,"=",simplify(expr*sinh(x)),"/sinh(x)")

# 定義--------------------------------
# sinh(x) = exp(x)/2 - exp(-x)/2
# cosh(x) = exp(x) - sinh(x)
# tanh(x) = sinh(x) /cosh(x)
# coth(x) = 1 /tanh(x)
# NotImplementedError: unhandled sech
# NameError: name 'cosech' is not defined

本家wikipediaより

(参考)Hyperbolic function
https://en.m.wikipedia.org/wiki/Hyperbolic_function#Definitions

本家wikipediaよりcosh(x)+sinh(x)

(2018/08/23)
(参考)Relationship to the exponential function
https://en.m.wikipedia.org/wiki/Hyperbolic_function#Relationship_to_the_exponential_function
(参考)simplifying expressions with hyperbolic functions
https://stackoverflow.com/questions/11076263/simplifying-expressions-with-hyperbolic-functions

fullscript.py
from sympy import *
x = Symbol('x')
print((cosh(x)+sinh(x)).simplify(),'=cosh(x)+sinh(x)')
print('-------------------------')
ans=(exp(x)-sinh(x))
print(ans)
ans=(exp(x)-sinh(x)).simplify()
print(ans)
ans=(cosh(x)).rewrite(exp)
print(ans)
ans=(exp(x)-sinh(x)).rewrite(exp)
print(ans)
# exp(x) =cosh(x)+sinh(x)
# exp(x) - sinh(x)
# cosh(x)
# exp(x)/2 + exp(-x)/2
# exp(x)/2 + exp(-x)/2
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0