Cosh of a variable

1 次查看(过去 30 天)
John
John 2021-3-9
评论: John 2021-3-9
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?

采纳的回答

John D'Errico
John D'Errico 2021-3-9
编辑:John D'Errico 2021-3-9
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 个评论
John D'Errico
John D'Errico 2021-3-9
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 2021-3-9
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by