Hyperbolic Secant in c++

Hello everyone!

Does anyone have a hyperbolic secant function?

I found this:
http://mathworld.wolfram.com/HyperbolicSecant.html

But i don't understand math that much to convert it into c++
Thanks!
-sh-
Last edited on
Is it really how hyperbolic secant works?
1
2
3
4
5
6
7
8
9
10
11
12
13
	while (1)
	{
		double in = 0.0;
		cin >> in;
		while (1)
		{
			in = 1.0 / cosh(in);
			std::cout << std::fixed;
			cout << "out:" << in << endl << endl;
			system("pause");
		}

	}




1.0
out:0.648054

Press any key to continue . . .
out:0.821396

Press any key to continue . . .
out:0.737059

Press any key to continue . . .
out:0.778726

Press any key to continue . . .
out:0.758241

Press any key to continue . . .
out:0.768342

Press any key to continue . . .
out:0.763368

Press any key to continue . . .
out:0.765819

Press any key to continue . . .
out:0.764611

Press any key to continue . . .
out:0.765206

Press any key to continue . . .
out:0.764913

Press any key to continue . . .
out:0.765058

Press any key to continue . . .
out:0.764986

Press any key to continue . . .
out:0.765022

Press any key to continue . . .
out:0.765004

Press any key to continue . . .
out:0.765013

Press any key to continue . . .
out:0.765009

Press any key to continue . . .
out:0.765011

Press any key to continue . . .
out:0.765010

Press any key to continue . . .
out:0.765010

Press any key to continue . . .
out:0.765010

Press any key to continue . . .


I was expecting something like:
0.99
0.98
0.96
0.92
0.80
0.70
0.50
0.40
0.32
0.18
0.15
0.12
0.10
0.09
...

Get the idea?
Umn like a hill would form from numbers.
-
--
----
-------
------------
-------
----
--
-

Hill representing momentum of how number changes
Last edited on
I was expecting something like:

Then perhaps you should feed it something other than what it ouputs.

Why would you expect the output for 1 to be 1? Take another gander at the graph on the page you linked to.
Hill representing momentum of how number changes
Even if sech(1) ~= 1, the series
A_0 = f(1)
A_n = f(A_{n-1})
is completely unrelated to the first derivative of f().
Topic archived. No new replies allowed.