-1

I'm having trouble convincing maple to simplify a complicated trig expression. It appears the bottleneck is that I don't know how to tell maple that it's OK to simplify expressions like:

arccos(cos(x))

into

x

Instead, if I issue:

simplify(arccos(cos(x)));

I just get

arccos(cos(x));

Is there some set of assumes that I should be using? My actual expression is much more complicated so I'd prefer a generic solution where the expressions inside arccos and cos might each be complicated expressions.

Update:

Here's the more complicated simplify example where this came up (or at least where I thought this was the issue):

# Angles
hac := arccos( (lab^2 + lbc^2 - lca^2)/(2*lab*lbc) ):
hcd := arccos( (lbc^2 + lbd^2 - lcd^2)/(2*lbc*lbd) ):
had := hac+hcd:
# length of AD
lad := sqrt( lab^2 + lbd^2 - 2*lab*lbd*cos(had) ):
sin_hbd := lbd*sin(had)/lad:
sin_hbp := sin_hbd:         
hbp := arcsin( sin_hbp ):
hap := hac:
hab := Pi - hbp - hap:
# length of BP
lbp := lab*sin_hbp/sin(hab):
# factor we're looking for
s := lbp/lbc:
simplify(s);

produces:

                                           lab lbd sin(%2)
   -----------------------------------------------------------------------------------------------
       2      2                     1/2                        lbd sin(%2)
   (lab  + lbd  - 2 lab lbd cos(%2))    sin(arcsin(------------------------------------) + %1) lbc
                                                       2      2                     1/2
                                                   (lab  + lbd  - 2 lab lbd cos(%2))

                                                   2      2      2
                                                lab  + lbc  - lca
                                   %1 := arccos(------------------)
                                                    2 lab lbc

                                                     2      2      2
                                                  lbc  + lbd  - lcd
                                %2 := %1 + arccos(------------------)
                                                      2 lbc lbd

The symbols lab,lbc,lca are lengths of a triangle. Similarly lab,lbd,lcd. So the angles h* should all be between 0 and Pi. I'm not sure a priori how simple the expression for s can be made. But all my attempts at assumptions so far (e.g., adding the triangle inequalities explicitly, adding bounds like acer's partial answer below) have not had an effect.

Alec Jacobson
  • 6,032
  • 5
  • 51
  • 88

1 Answers1

1

Maple follows the usual convention for the principal value of arccos.

You can simplify arccos(cos(x)) back to just x under the assumptions that x lies with [0,Pi].

simplify(arccos(cos(x))) assuming x>=0, x<=Pi;

                      x

plot(arccos(x),x=-1..1,tickmarks=[default,piticks]);

enter image description here

acer
  • 6,671
  • 15
  • 15
  • This will work if the expression inside cos is simple. But suppose the expression inside the cos is very complicated. Will have to pull it out manually to build this assumption? – Alec Jacobson Jul 15 '17 at 17:36
  • 1
    Obviously that requires inference. You need to start somewhere, and since you didn't bother to clearly specify the condition I used the simplest one. If you want another then specify it in full. Your question is so general otherwise that the answer to what you actually asked needs the complete internal code of the `solve` command as response. You really need to provide a representative example. Note that pulling out the argument to any cos call is easy with a computer algebra system and language. What to throw that to (e.g. `solve` etc) will depend on the example. Show one. – acer Jul 15 '17 at 18:24
  • So far your Question amount something like: under what conditions will a general expression be greater than zero and less than Pi? – acer Jul 15 '17 at 18:29