Basic arithmetic + - * / **

Top  Previous  Next

Commonly it is desirable to add, subtract, multiply, divide or exponentiate items in replacement statements.  This is done employing the symbols + - * / **.  Examples follow (calculate.gms)

 

x=4+6+sqrt(7);

Z(i)=12+x;

Eq1[I].. zZ(i)=e=12+x;

Y(i)=+z(i);

x=x-3-sqrt(7);

Z(i)=12-x;

Eq2[I].. zZ(i)=e=12-x;

Y(i)=-z(i);

x=x-3-sqrt(7);

Z(i)=12*x;

Eq3[I].. zZ(i)=e=12*x;

Y(i)=44*z(i);

x=x-3/sqrt(7);

Z(i)=12/x;

Eq4[I].. zZ(i)=e=12/x;

Y(i)=1/z(i);

x=3**sqrt(7);

Z(i)=12.0**x;

Y(i)$(z(i)-1 gt 0)=z(i)**0.5;

Y(i)=14*x**2/4-3+2;

 

A + - * / or ** cannot go on the left hand side unless it is in the numerical evaluation of a Conditional.

These operators may be used with sets as described below or in the set arithmetic part of the Sets chapter.