%   MATLAB  Program on Hyperbolic/Invhyperbol functions
%   AUTHOR: Santhanam, Balu
%   DATE: 04/23/99
%   Concepts Illustrated: 
%   Hyperbolic Trig functions 
%   Inverse Hyperbolic Trig Functions
%   Complex arithmetic functions 
%   Pausing, user input and diary files
%**************************************************************
clear
x = input('Enter real number in [-1,1] ---->');
%
%****************************************************
s = sinh(x); c = cosh(x); t = tanh(x); 
is = csch(x); ic = sech(x); ct = coth(x);
%*****************************************************
%  Display table with Trig function and corresponding 
%  numerical value for the entered angle.
%  Save text to hyperbol and save the data to 
%  hyperbol.mat
%***************************************************** 
diary hyperbol 
fprintf('\n') 
fprintf('Table of Hyperbolic Trig Functions for x = %f : \n',x)
fprintf('%s\n','--------------------------')
fprintf('%s \t %s\n','Trig Fctn  |','Value')
fprintf('%s\n','--------------------------') 
fprintf('%s \t %0.4f\n','sinh(x)    |',s)
fprintf('%s \t %0.4f\n','cosh(x)    |',c)
fprintf('%s \t %0.4f\n','tanh(x)    |',t)
fprintf('%s \t %0.4f\n','csch(x)    |',is)
fprintf('%s \t %0.4f\n','sech(x)    |',ic)
fprintf('%s \t %0.4f\n','coth(x)    |',ct)
fprintf('%s\n','--------------------------')
diary off
fprintf('Pausing for 2 seconds please wait....\n')
pause(2)
save hyperbol.mat s c t is ic ct
%**************************************************************  
%   Loading the Hyperbolic trig function values from the 
%   previous part and use of inverse hyperbolic trig functions
%   Note that y ou may not get back the same answer for x 
%   because the inverse cosh function is not a bijective mapping 
%   unless x is positive
%**************************************************************
load hyperbol.mat
theta1 = asinh(s);  theta2 = acosh(c);
theta3 = atanh(t);  theta4 = acsch(is);
theta5 = asech(ic); theta6 = acoth(ct); 
diary hyperbol 
fprintf('\n')
fprintf('Inverse Hyperbolic Trig Functions Values : \n')
fprintf('%s\n','--------------------------')
fprintf('%s \t %s\n','Function   |','Value')
fprintf('%s\n','--------------------------')
fprintf('%s \t %0.4f\n','arcsinh    |',theta1)
fprintf('%s \t %0.4f\n','arccosh    |',theta2)
fprintf('%s \t %0.4f\n','arctanh    |',theta3)
fprintf('%s \t %0.4f\n','arccsch    |',theta4)
fprintf('%s \t %0.4f\n','arcsech    |',theta5)
fprintf('%s \t %0.4f\n','arccoth    |',theta6)
fprintf('%s\n','--------------------------')
diary off
fprintf('Pausing for 2 seconds please wait....\n')
pause(2)
save invr.mat theta1 theta2 theta3 theta4 theta5 theta6

%*************************************************************
%  Complex Arithmetic functions with user prompted input
%  Display results in tabular form
%  Save the text to comp and save the data to comp.mat      
%*************************************************************
fprintf('\n')
z = input('Enter the complex number: (a,b) = a+bj--->');
a = real(z); b = imag(z); z_star = conj(z); 
r = abs(z); theta = angle(z); 
diary comp
fprintf('Complex arithmetic function values: \n')
fprintf('%s\n','----------------------------------')
fprintf('%s \t %s\n','Function    |','Value')
fprintf('%s\n','----------------------------------')
fprintf('%s \t %0.4f\n','Real(z)     |',a)
fprintf('%s \t %0.4f\n','Imag(z)     |',b)
fprintf('%s\t %4.4f + %4.4fj\n','Conjugate   |',a,-b)
fprintf('%s \t %0.4f\n','|z|         |',r)
fprintf('%s \t %0.4f\n','Arg(z)      |',theta*(180/pi))
fprintf('%s\n','----------------------------------')
diary off
fprintf('Pausing for 2 seonds please wait...\n')
pause(2)
save comp.mat a b z_star r theta 

