simplification of sin(0) and cos(0)



On 16-11-2013 23:37, Dieter Vanderelst wrote:
>
> Please tell me if this is not the right place to ask this but I've run 
> into a problem using maxima.
>
Please feel free to ask any questions regarding Maxima in this list.

> I have an expression (code below) involving a number of trigonometric 
> functions. Now, I want to simplify this expression assuming certain 
> variables are zero. This is, I want to assume that EL_1 and AZ_1 are 
> zero. This would imply that my expression can be simplified as 
> sin(0)=0 and cos(0)=1. However, calling various simplification 
> functions on sigma will not result in this (trivial) simplification.
>
> What am I missing? Typing sin(EL_1); will result in 0.
>
David Billinghurst already answered your question, but I'd like to add 
some comments that might be useful to you. In some computer languages 
variables are thought of as boxes in memory where you can save 
information; once you change the contents of that box, all other 
expressions that use it will get that new content.

That is not the case in Maxima; variables are symbols which at some 
point might be bound to a numerical value (i.e. x:1) but even after that 
happens you still have the symbol ('x) and the value to which it points 
(x). In your case:
(%i1) sigma: sin(EL_1) * sin(EL_2) + cos(EL_1) * cos(EL_2) * 
cos(abs(AZ_1-AZ_2))$

will bind sigma to the names of the symbols AZ_1 and EL_1, because at 
this point they do not point to any numerical values. If you then do:
(%i2) [EL_1,AZ_1]: [0,0]$

next time you type AZ_1 or EL_1 you will get the value 0, but sigma 
remains bound to the symbols 'AZ_1 and 'EL_1 and not to their values. If 
you want sigma to get updated, as if you had defined it after EL_1 and 
AZ_1 were bound to 0, you can reevaluate it:

(%i3) sigma: ev(sigma);
(%o3)                cos(abs(AZ_2)) cos(EL_2)

Notice also that Maxima tries to be "non-destructive"; namely, when you 
write ev(sigma) or
subst ([EL_1=0, AZ_1], sigma) a modified version of sigma will be 
returned, but sigma itself will not be modified. That's why I had to use 
sigma:ev(sigma) to modify the original definition of sigma.

Best regards,
Jaime