Cosh of a variable
3 views (last 30 days)
Show older comments
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?
0 Comments
Accepted Answer
John D'Errico
on 9 Mar 2021
Edited: John D'Errico
on 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))
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)))
And now we can evaluate the function handle in Cfun as:
Cfun([0:0.25:1]')
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 Comments
John D'Errico
on 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.
More Answers (0)
See Also
Categories
Find more on Polynomials in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!