using inverse hyperbolic functions cosh in matlab

Hi every one
I have vector of complex data that has real and imaginary part. I want to use cosh of this data in MATLAB. then I want to use the invers of cosh to return me to the data input. I used in MATLAB this code
A= [ 10.9837193883460 + 26.5347537674488i 9.08578029925812 + 27.2688648124603i 7.13892338965110 + 27.8674662179979i 5.15283024456107 + 28.3273169598239i 3.13739622908723 + 28.6458664819948i 1.10268121205304 + 28.8212686991090i -0.941140621386700 + 28.8523924881452i -2.98383161797377 + 28.7388286111658i -5.01514191135404 + 28.4808930279443i -7.02486082745132 + 28.0796265756387i -9.00286818246618 + 27.5367910108141i -10.9391852159635 + 26.8548614273679i -12.8240249028140 + 26.0370150821188i -14.6478413905078 + 25.0871166778933i -16.4013783122172 + 24.0097001718231i -18.0757157312878 + 22.8099471941067i -19.6623154792203 + 21.4936621796417i -21.1530646568884 + 20.0672443316137i -22.5403170775323 + 18.5376565522323i -23.8169324400296 + 16.9123914912512i -24.9763130319849 + 15.1994348776115i -26.0124377741751 + 13.4072263135169i -26.9198934309609 + 11.5446177232455i -27.6939028251654 + 9.62082966110862i -28.3303499106663 + 7.64540569408595i -28.8258015714740 + 5.62816508468216i -29.1775260322726 + 3.57915400845697i -29.3835077821777 + 1.50859554847569i -29.4424589308279 - 0.573161284572463i -29.3538269336532 - 2.65569325247631i -29.1177986412982 - 4.72855505165752i -28.7353006465233 - 6.78133167652808i -28.2079959204595 - 8.80369072161829i -27.5382767486756 - 10.7854343599834i -26.7292539961117 - 12.7165507365551i -25.7847427483981 - 14.5872645175724i -24.7092443953497 - 16.3880863410096i -23.5079252403681 - 18.1098609180221i -22.1865917370961 - 19.7438135417332i -20.7516624717032 - 21.2815947673119i -19.2101370258051 - 22.7153230359575i -17.5695618707992 - 24.0376250254637i -15.8379934596274 - 25.2416735209560i -14.0239586962942 - 26.3212226115406i -12.1364129769286 - 27.2706400316673i -10.1846960087276 - 28.0849364800239i -8.17848562456214 - 28.7597917636580i -6.12774982152663 - 29.2915776306869i -4.04269726096728 - 29.6773771713292i -1.93372647568119 - 29.9150006840109i];
B= cosh(A);
C=acosh(B);
In theoretically, I should get C=A but I couldn’t find in MATLAB. Can you help me with this problem?

 Accepted Answer

"theoretically, I should get C=A"
Not necessarily.
x = -1.5:0.1:1.5;
plot(x,cosh(x))
line([1 1],[1 cosh(1)],'Color','r','LineStyle','--')
text(-1,1,'x = -1','HorizontalAlignment','right','VerticalAlignment','bottom')
line([-2 1],cosh([1 1]),'Color','r','LineStyle','--')
text(-2,cosh(1),sprintf('y = cosh(x) = %.2f',cosh(1)),'VerticalAlignment','bottom')
line([-1 1],cosh([1 1]),'LineStyle','none','Marker','o','Color','r')
line([-1 -1],[1 cosh(1)],'Color','r','LineStyle','--')
text(1,1,'x = 1','VerticalAlignment','bottom')
cosh(1) == cosh(-1), and they are both approximately 1.54.
So acosh(1.54) returns 1, but what if you started with x = -1? You could not say that acosh(cosh(x)) = x.
A= [ 10.9837193883460 + 26.5347537674488i 9.08578029925812 + 27.2688648124603i 7.13892338965110 + 27.8674662179979i 5.15283024456107 + 28.3273169598239i 3.13739622908723 + 28.6458664819948i 1.10268121205304 + 28.8212686991090i -0.941140621386700 + 28.8523924881452i -2.98383161797377 + 28.7388286111658i -5.01514191135404 + 28.4808930279443i -7.02486082745132 + 28.0796265756387i -9.00286818246618 + 27.5367910108141i -10.9391852159635 + 26.8548614273679i -12.8240249028140 + 26.0370150821188i -14.6478413905078 + 25.0871166778933i -16.4013783122172 + 24.0097001718231i -18.0757157312878 + 22.8099471941067i -19.6623154792203 + 21.4936621796417i -21.1530646568884 + 20.0672443316137i -22.5403170775323 + 18.5376565522323i -23.8169324400296 + 16.9123914912512i -24.9763130319849 + 15.1994348776115i -26.0124377741751 + 13.4072263135169i -26.9198934309609 + 11.5446177232455i -27.6939028251654 + 9.62082966110862i -28.3303499106663 + 7.64540569408595i -28.8258015714740 + 5.62816508468216i -29.1775260322726 + 3.57915400845697i -29.3835077821777 + 1.50859554847569i -29.4424589308279 - 0.573161284572463i -29.3538269336532 - 2.65569325247631i -29.1177986412982 - 4.72855505165752i -28.7353006465233 - 6.78133167652808i -28.2079959204595 - 8.80369072161829i -27.5382767486756 - 10.7854343599834i -26.7292539961117 - 12.7165507365551i -25.7847427483981 - 14.5872645175724i -24.7092443953497 - 16.3880863410096i -23.5079252403681 - 18.1098609180221i -22.1865917370961 - 19.7438135417332i -20.7516624717032 - 21.2815947673119i -19.2101370258051 - 22.7153230359575i -17.5695618707992 - 24.0376250254637i -15.8379934596274 - 25.2416735209560i -14.0239586962942 - 26.3212226115406i -12.1364129769286 - 27.2706400316673i -10.1846960087276 - 28.0849364800239i -8.17848562456214 - 28.7597917636580i -6.12774982152663 - 29.2915776306869i -4.04269726096728 - 29.6773771713292i -1.93372647568119 - 29.9150006840109i]
A =
10.9837 +26.5348i 9.0858 +27.2689i 7.1389 +27.8675i 5.1528 +28.3273i 3.1374 +28.6459i 1.1027 +28.8213i -0.9411 +28.8524i -2.9838 +28.7388i -5.0151 +28.4809i -7.0249 +28.0796i -9.0029 +27.5368i -10.9392 +26.8549i -12.8240 +26.0370i -14.6478 +25.0871i -16.4014 +24.0097i -18.0757 +22.8099i -19.6623 +21.4937i -21.1531 +20.0672i -22.5403 +18.5377i -23.8169 +16.9124i -24.9763 +15.1994i -26.0124 +13.4072i -26.9199 +11.5446i -27.6939 + 9.6208i -28.3303 + 7.6454i -28.8258 + 5.6282i -29.1775 + 3.5792i -29.3835 + 1.5086i -29.4425 - 0.5732i -29.3538 - 2.6557i -29.1178 - 4.7286i -28.7353 - 6.7813i -28.2080 - 8.8037i -27.5383 -10.7854i -26.7293 -12.7166i -25.7847 -14.5873i -24.7092 -16.3881i -23.5079 -18.1099i -22.1866 -19.7438i -20.7517 -21.2816i -19.2101 -22.7153i -17.5696 -24.0376i -15.8380 -25.2417i -14.0240 -26.3212i -12.1364 -27.2706i -10.1847 -28.0849i -8.1785 -28.7598i -6.1277 -29.2916i -4.0427 -29.6774i -1.9337 -29.9150i
B = cosh(A);
C = acosh(B)
C =
10.9837 + 1.4020i 9.0858 + 2.1361i 7.1389 + 2.7347i 5.1528 - 3.0886i 3.1374 - 2.7701i 1.1027 - 2.5947i 0.9411 + 2.5635i 2.9838 + 2.6771i 5.0151 + 2.9350i 7.0249 - 2.9469i 9.0029 - 2.4040i 10.9392 - 1.7221i 12.8240 - 0.9043i 14.6478 + 0.0456i 16.4014 + 1.1230i 18.0757 + 2.3228i 19.6623 - 2.6441i 21.1531 - 1.2177i 22.5403 + 0.3119i 23.8169 + 1.9372i 24.9763 - 2.6331i 26.0124 - 0.8409i 26.9199 + 1.0218i 27.6939 + 2.9455i 28.3303 - 1.3622i 28.8258 + 0.6550i 29.1775 + 2.7040i 29.3835 - 1.5086i 29.4425 + 0.5732i 29.3538 + 2.6557i 29.1178 - 1.5546i 28.7353 + 0.4981i 28.2080 + 2.5205i 27.5383 - 1.7809i 26.7293 + 0.1502i 25.7847 + 2.0209i 24.7092 - 2.4615i 23.5079 - 0.7397i 22.1866 + 0.8943i 20.7517 + 2.4320i 19.2101 - 2.4174i 17.5696 - 1.0951i 15.8380 + 0.1089i 14.0240 + 1.1885i 12.1364 + 2.1379i 10.1847 + 2.9522i 8.1785 - 2.6561i 6.1277 - 2.1243i 4.0427 - 1.7385i 1.9337 - 1.5009i
isequal(A,C)
ans = logical
0

4 Comments

thank you very much for your answer. i would like to ask , if i neglect the negative part in all data ( all data is positive part )
for example A=[A= [ 10.9837193883460 + 26.5347537674488i 9.08578029925812 + 27.2688648124603i 7.13892338965110 + 27.8674662179979i 5.15283024456107 + 28.3273169598239i 3.13739622908723 + 28.6458664819948i 1.10268121205304 + 28.8212686991090i];
is there any way in mtlab to get C=A
That's a nice idea, and that would work if the inputs to cosh were all real. But I was showing real inputs just because it's easier to depict graphically, and to show that even in the real case, there's ambiguity with acosh.
Of course, the A you have are complex. Consider the definition of cosh(x):
For purely imaginary x, exp(x) is periodic with period 2*pi; therefore, for complex x, there's that periodic component in there, with a varying magnitude coming from the real part of x.
% all elements of A have positive real and imaginary parts:
A= [ 10.9837193883460 + 26.5347537674488i 9.08578029925812 + 27.2688648124603i 7.13892338965110 + 27.8674662179979i 5.15283024456107 + 28.3273169598239i 3.13739622908723 + 28.6458664819948i 1.10268121205304 + 28.8212686991090i]
A =
10.9837 +26.5348i 9.0858 +27.2689i 7.1389 +27.8675i 5.1528 +28.3273i 3.1374 +28.6459i 1.1027 +28.8213i
B = cosh(A);
C = acosh(B)
C =
10.9837 + 1.4020i 9.0858 + 2.1361i 7.1389 + 2.7347i 5.1528 - 3.0886i 3.1374 - 2.7701i 1.1027 - 2.5947i
isequal(A,C) % still not the same
ans = logical
0
Consider the fact that the (non-hyperbolic) cosine function is also periodic. If you were given cos(x) = 0.4 and asked "What's the value of x?" what could you say? There are infinitely many values of x such that cos(x) = 0.4
x = -8:0.01:8;
plot(x,cos(x))
y = 0.4;
acy = acos(y);
xd = [acy+2*pi*(-1:1) -acy+2*pi*(-1:1)];
xd = [xd; xd; NaN(1,numel(xd))];
line(xd(:),repmat([y; -1; NaN],size(xd,2),1),'LineStyle','--','Color','r')
line([-8 8],[y y],'LineStyle','--','Color','r')
line(xd(1,:),y*ones(1,size(xd,2)),'LineStyle','none','Color','r','Marker','o')
So the only way you'll get C = A is to change A to something else. It's like if I said, can you make 1 = 2? Yeah, you can, if you change what "2" means.
It's math, and there's nothing MATLAB or anything else in the universe (or any possible universe) can do to make it work differently.

Sign in to comment.

More Answers (0)

Asked:

on 6 May 2022

Commented:

on 7 May 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!