Why does this error occur when using simplify?

>> eq=sym('3.1*cos(sin(x))*tanh(x)')
eq =
3.1*cos(sin(x))*tanh(x)
>> simplify(eq)
Error using mupadmex
Error in MuPAD command: Illegal argument [icontent];
during evaluation of 'Simplify::tan'
Error in sym/simplify (line 98)
r = mupadmex('symobj::simplify',s.s,num2str(n),options);
My Matlab version is 2011b
Other details: Operating System: Mac OS X Version: 10.7.5 Build: 11G63 Java VM Version: Java 1.6.0_37-b06-434-11M3909 with Apple Inc. Java HotSpot™ 64-Bit Server VM mixed mode
Thanks,
Dominic

1 个评论

It is surprising that the error message contain "tan", while you operate on "tanh". I suggest to ask the technical support.

请先登录,再进行评论。

回答(1 个)

Because you are misusing the function. I think you want this:
syms x
eq = 3.1*cos(sin(x))*tanh(x)
simplify(eq) % Try on: eq = sin(x)/cos(x)

4 个评论

I do not see any misuse. Dominic used sym() on the quoted expression, which is a correct mechanism to form the symbolic expression to be simplified.
Thanks Matt,
I did not realise that
eq=sym('3.1*cos(sin(x))*tanh(x)')
was an incorrect usage of the sym function, I have been using it in this form for a while and had not run into any problems with it until now.
Interestingly, using a slightly different math function:
eq=sym('3.1*cos(cos(x))*tanh(x)')
eq =
3.1*cos(cos(x))*tanh(x)
>> simplify(eq)
ans =
3.1*cos(cos(x))*tanh(x)
Appears to work OK. As does:
>> eq=sym('3*sin(cos(x))*tanh(x)')
eq =
3*sin(cos(x))*tanh(x)
>> simplify(eq)
ans =
3*sin(cos(x))*tanh(x)
Dominic
Ah yes, my mistake! It was I who misread the documentation. I apologize for this.
So back to your question... I guess I don't know why you got that error. Bug? The method I proposed does seem to work as a workaround anyway.
Ok, well I guess if no-one else has any comments then we can chalk this up as a bug.
Dominic

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by