# Ruby code for tanh() methodrequire'cmath'# Initializing variable
a =0.3584
b =2
puts "tanh value of a : #{CMath.tanh(a)}\n\n"
puts "tanh value of b : #{CMath.tanh(b)}\n\n"
Ruby
输出
//WriteJava code here
Ruby
tanh value of a :0.3438039328469827
tanh value of b :0.9640275800758169
Ruby
例子#2 。
# Ruby code for tanh() methodrequire'cmath'# Initializing variable
a =0
b =-0.247
puts "tanh value of a : #{CMath.tanh(a)}\n\n"
puts "tanh value of b : #{CMath.tanh(b)}\n\n"
Ruby
输出
tanh value of a :0.0
tanh value of b :-0.24209655276165779