Effacer les filtres
Effacer les filtres

Cosh of a variable

1 vue (au cours des 30 derniers jours)
John
John le 9 Mar 2021
Commenté : John le 9 Mar 2021
Hi. I need to solve the equation to get a variable from another variable. The equation is:
C(w)=Cosh[acosh(x1)+acosh(x2)+acosh(x3)+acosh(x4)]
x1=(w-0.641)/(1-0.641*w)
x2=(w+0.641)/(1+0.641*w)
x3=w
x4=w
Now since w ranges from -inf to inf I'm supposed to get C(w) as a function of w. Any guidance on how I can solve this?

Réponse acceptée

John D'Errico
John D'Errico le 9 Mar 2021
Modifié(e) : John D'Errico le 9 Mar 2021
You do it by writing much like what you did, but in the proper order, and using proper syntax. For example, using symbolic tools, we might do this:
syms w
x1=(w-0.641)/(1-0.641*w);
x2=(w+0.641)/(1+0.641*w);
x3=w;
x4=w;
LEARN TO USE SEMICOLONS! As well, LEARN TO USE PARENS PROPERLY. Functions use (), NOT []. Just because you think an expression is easier to read if you use [] in some places, that does not make MATLAB understand your syntax. {} and () do different things.
C = cosh(acosh(x1)+acosh(x2)+acosh(x3)+acosh(x4))
C = 
fplot(C)
If you wanted to write this purely using function handles, it is as easy.
x1 = @(w) (w-0.641)./(1-0.641*w);
x2 = @(w) (w+0.641)./(1+0.641*w);
x3 = @(w) w;
x4 = @(w) w;
As you can see here, I used ./ to denote a division, so this will work for vectorized computations.
Cfun = @(w) cosh(acosh(x1(w))+acosh(x2(w))+acosh(x3(w))+acosh(x4(w)))
Cfun = function_handle with value:
@(w)cosh(acosh(x1(w))+acosh(x2(w))+acosh(x3(w))+acosh(x4(w)))
And now we can evaluate the function handle in Cfun as:
Cfun([0:0.25:1]')
ans = 5×1
1.0000 0.6242 -0.3057 -0.9999 1.0000
Be careful, as for large magnitude inputs, it seems there is a small imaginary part that seems to arise when the computations are performed in double precision.
  3 commentaires
John D'Errico
John D'Errico le 9 Mar 2021
Sure. All you need to do is recognize the identity...
cosh(X) = (exp(X) + exp(-X))/2
That allows you to eliminate the cosh calls. As for the acosh, no such luck.
But I think you do not mean something so trivial. The answer then is no. As it is, you should/can be happy there is a simply evaluatable expression. But there will be no simple expression in the form of a polynomial, or something as trivial to write.
Could you express this function as a polynomial approximation? Probably. Well, possibly. And without a moderate amount of analysis, I would not tell you where that polynommial approximation would have any value in terms of convergence. But you might try to approximate the result in the form of a truncated Taylor series approximation that would be valid over some interval, or you might try using a Pade approximant. I don't see the point of using an approximation here that will be highly problematic in terms of convergence, when you have a rather simple expression that can be evaluated directly.
John
John le 9 Mar 2021
Thank you John. That makes a lot of sense. Just one more question. Is there a reason, why I can't get a value for C less than -1?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Tags

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by