Syntax



Order of priority

An expression is in principle evaluated from left to right.
The interior of a parenthesis has a priority.
For others, the following order of priority has been adopted.

  1. Right function
  2. Power
  3. Multiplication without notation
  4. Left function
  5. Multiplication and division
  6. Addition and subtraction
  7. Comparative operation and logic operation

Argument of function

  1. For the left function, the argument is till one of arithmetic operators, logical operators, comparative operators, space or left function appears.
    Examples : sin a cos x2 + 1 = (sin a)(cos x2) + 1
    sina(x + 1)2 + 1 = sin (a (x + 1)2) + 1
    sina (x + 1)2 + 1 = (sin a)(x + 1)2 + 1

  2. If the power is just after the trigonometric function, both the power and the trigonometric function are recognized as a function.
    Example : in the case of "sin2n 2x", "sin2n" is a function and the argument is "2x". (The value is "(sin 2x)2n")
  3. The arguments of the right function and the power are just the letter in front of them, the value, and the parentheses.
    Example : 2n! = 2 (n!), 2ax2 = 2a (x2)
  4. For the user functions f, g, h, f1, and f2, the argument is from the begining of paratheses to the end.
    Example : f (cos 2x + 1)2 = (f (cos 2x + 1))2

If the relation of priority is not clear, write with parentheses or separate by space.



Examples of expression

Here is some examples of expression and their interpretations. The greater-than sign (>) in the explanation part means the relation of priority.

Example Interpretation Explanation
sin2xsin (2x)multiplication without sign > left function
sinx/2(sin x) / 2left function > arithmetic operation
sinx+2(sin x) + 2left function > arithmetic operation
sin(x+2)sin (x + 2)priority for the parentheses
sin(x+1)2sin ((x + 1)2)power > left function
sin2x(sin x)2power and exceptional treatment of trigonometric function
sin2axsin (2ax)The character sequence without separation becomes an argument.
sin2a x(sin2a) xseparation by space
2x32 * (x3)right function > multiplication without sign
1/2x1 / (2x)multiplication without sign > division
1/2 x(1 / 2) xseparation by space
4+x>1-2x(4 - x) > (1 - 2x)arithmetic operation > logical operation


Supplement 1 : Absolute value

The absolute value can be found by using the notation "[]" or "abs()", for example "[x + 2]" or "abs(x + 2)"
When GRAPES encounters "[x + 2]", it will interprete it as "abs(x + 2)".


Supplement 2 : the argument part of function

For the argument part of function, we have the very irregular usage.
For example,
We use "f(a+1) x" as "(f (a + 1)) x", but
"sin(a+1)x" means "(sin (a + 1)) x" or "sin ((a + 1) x)" ?
"sinx2" means "(sin x)2" or "sin (x2)" ?
"sinax" means "(sin a) x" or "sin (ax)" ?
"sina(x+1)" means "(sin a)(x + 1)" or "sin (a (x + 1))" ?
"sinxcosy" means "(sin x)(cos y)" or "sin (x cos y)" ?
It looks as if there is no explicit rule for which one to choose.
GRAPES decides the argument part by taking into account the following rules, in order to follow common sense as much as possible. Therefore, the general principle is

Is it hard ? Even if it is, it will enable you to write unambiguous expression.


Supplement 3 : Σ (Sum of series)

The syntax is write like Σ (index, initial value, last value, expression).
Example : Σ (m, 1, 5, m2) : 12 + 22 + 32 + 42 + 52

Restrictions
Note the following restrictions. If the following restrictions are not respected, you cannot get the correct calculation results. In particular, GRAPES does not verify the syntax for the 2 and 3 restrictions, so, you have to pay attention by yourself.
  1. The available letters for index are only a, b, c, d, m, n, p, q, s, t, u, v, θ, and k.
  2. An expression containing x is not permitted for the initial or the final values of the parameter.
    Example : Σ (k, 1, x, k2) is impossible.
    Example : Σ (k, 1, n, k2) is possible.
  3. If any of the function y1 to y9 appears in the expression part of Σ, then it cannot depend on the index of summation, and the elements of elementary objects are not permitted.
    Example : if y1 = kx, Σ (k, 1, 5, y1) is impossible.
    Example : if f (x) = kx, Σ (k, 1, 5, f (x)) is possible.
    Example : if y1 = x^2, Σ (k, 1, 5, k + y1) is possible.
  4. You cannot nest Σ in an expression.
    Example : y1 = Σ (n, 1, 10, Σ (k, 2, n, k2)) is impossible.
    Example : If f (x) = Σ (k, 2, n, k2), y1 = Σ (n, 1, 10, f (x)) is possible.


Supplement 4 : (definite integral)

Restrictions
Note the following restrictions. If the following restrictions are not respected, you cannot get the correct calculation results. In particular, GRAPES does not verify the syntax for the 2 and 3 restrictions, so, you have to pay attention by yourself.
  1. The parameters and the letters x and y can be used as an integration variable.
    But, x and y are not available as an integration variable in the point or the curves.
  2. An expression containing x is not permitted for the infimum (lower bound) and the supremum (upper bound).
  3. In the expression, the functions from y1 to y9, containing the integration variable, and the elementary objects are not available.
  4. The integrand = expression cannot contain the integral itself.