Clear Filters
Clear Filters

Why is the word "and" coming up in my output?

1 view (last 30 days)
I am trying to simplify an expression, but the word "and" keeps popping up in my result. When I try to work with this further, I get, "unexpected matlab expression." My script is:
syms A B C D p q r s t u;
y00 = cos(A + B + C + D);
y0 = expand(y00);
y1 = subs(y0,cos(A),(cosh(p)*cosh(q)-cosh(t)) / (sinh(p)*sinh(q)));
y2 = subs(y1,cos(B),(cosh(q)*cosh(r)-cosh(u)) / (sinh(q)*sinh(r)));
y3 = subs(y2,cos(C),(cosh(r)*cosh(s)-cosh(t)) / (sinh(r)*sinh(s)));
y4 = subs(y3,cos(D),(cosh(s)*cosh(p)-cosh(u)) / (sinh(s)*sinh(p)));
y5 = subs(y4,sin(A),(1-cosh(p)^2-cosh(q)^2-cosh(t)^2+cosh(p)*cosh(q)&cosh(t)) / (sinh(p)*sinh(q)));
y6 = subs(y5,sin(B),(1-cosh(q)^2-cosh(r)^2-cosh(u)^2+cosh(q)*cosh(r)&cosh(u)) / (sinh(q)*sinh(r)));
y7 = subs(y6,sin(C),(1-cosh(r)^2-cosh(s)^2-cosh(t)^2+cosh(r)*cosh(s)&cosh(t)) / (s inh(r)*sinh(s)));
y8 = subs(y7,sin(D),(1-cosh(s)^2-cosh(p)^2-cosh(u)^2+cosh(s)*cosh(p)&cosh(u)) / (sinh(s)*sinh(p)));
y8
the answer that I keep getting is:
y8 =
(((cosh(u) and cosh(q)*cosh(r) - cosh(q)^2 - cosh(r)^2 - cosh(u)^2 + 1)*(cosh(t) and cosh(p)*cosh(q) - cosh(p)^2 - cosh(q)^2 - cosh(t)^2 + 1))*(cosh(u) and cosh(p)*cosh(s) - cosh(p)^2 - cosh(s)^2 - cosh(u)^2 + 1)*(cosh(t) and cosh(r)*cosh(s) - cosh(r)^2 - cosh(s)^2 - cosh(t)^2 + 1))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(t) and cosh(p)*cosh(q) - cosh(p)^2 - cosh(q)^2 - cosh(t)^2 + 1)*(cosh(u) and cosh(p)*cosh(s) - cosh(p)^2 - cosh(s)^2 - cosh(u)^2 + 1))*(cosh(u) - cosh(q)*cosh(r))*(cosh(t) - cosh(r)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(t) and cosh(p)*cosh(q) - cosh(p)^2 - cosh(q)^2 - cosh(t)^2 + 1)*(cosh(u) and cosh(q)*cosh(r) - cosh(q)^2 - cosh(r)^2 - cosh(u)^2 + 1))*(cosh(u) - cosh(p)*cosh(s))*(cosh(t) - cosh(r)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(t) and cosh(p)*cosh(q) - cosh(p)^2 - cosh(q)^2 - cosh(t)^2 + 1)*(cosh(t) and cosh(r)*cosh(s) - cosh(r)^2 - cosh(s)^2 - cosh(t)^2 + 1))*(cosh(u) - cosh(p)*cosh(s))*(cosh(u) - cosh(q)*cosh(r)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(u) and cosh(q)*cosh(r) - cosh(q)^2 - cosh(r)^2 - cosh(u)^2 + 1)*(cosh(u) and cosh(p)*cosh(s) - cosh(p)^2 - cosh(s)^2 - cosh(u)^2 + 1))*(cosh(t) - cosh(p)*cosh(q))*(cosh(t) - cosh(r)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(u) and cosh(q)*cosh(r) - cosh(q)^2 - cosh(r)^2 - cosh(u)^2 + 1)*(cosh(t) and cosh(r)*cosh(s) - cosh(r)^2 - cosh(s)^2 - cosh(t)^2 + 1))*(cosh(t) - cosh(p)*cosh(q))*(cosh(u) - cosh(p)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) - (((cosh(t) and cosh(r)*cosh(s) - cosh(r)^2 - cosh(s)^2 - cosh(t)^2 + 1)*(cosh(u) and cosh(p)*cosh(s) - cosh(p)^2 - cosh(s)^2 - cosh(u)^2 + 1))*(cosh(t) - cosh(p)*cosh(q))*(cosh(u) - cosh(q)*cosh(r)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2) + ((cosh(t) - cosh(p)*cosh(q))*(cosh(u) - cosh(p)*cosh(s))*(cosh(u) - cosh(q)*cosh(r))*(cosh(t) - cosh(r)*cosh(s)))/(sinh(p)^2*sinh(q)^2*sinh(r)^2*sinh(s)^2)
when I try to do
factor(y8)
I get "unexpected matlab expression," pointing to the "and." Could anyone help me with this? Thanks

Accepted Answer

Mischa Kim
Mischa Kim on 10 May 2014
Edited: Mischa Kim on 10 May 2014
Lucy, for example, in the expression for y5 there is a term
cosh(p)*cosh(q)&cosh(t)
(typo?) which results in an and. The same (copy-paste?) happens in the other expressions, y6 thru y8.
  1 Comment
Lillian
Lillian on 10 May 2014
wow, yeah, I can't believe I didn't see that. I must have typed & instead of * and copied it into the other lines. thanks so much!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!