ExpressionSyntaxForGenericApplets¶

Expression syntax are used to describe mathematical operations and functions and conditions in applets.

1.Expression for math functions¶

In Genericframework these expressions are used to describe the value of a number or function variables.

Category Syntax Examples
Numbers 0-9 1+2
$\pi$ pi pi/2
Parantheses () (-x+1)*(x+2)
Standard Operations +,-,/,*,^,sqrt(x) 1+2, pi/2
Absolute value abs(arg) or |arg| abs(x),
Trigonometric functions sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh sin(2*pi), (cos(x))^2
Signum sign(arg) sign(x+2)
Theta theta(arg) theta(x)
Dirac delta function (1 for x = 0, 0 otherwise) dirac(arg) dirac(x)
Exponential function exp(x) or e^x exp(2*x)
Floor floor floor(x)
Faculty fac or ! fac(2) or 2!
Nth root x#n x#4, 8#3

2.Expression for conditions¶

This is used to described conditions, such as in \randadjustif or in the GenericVisualizations \IFELSE command
It is basically a relation between the values of two Operations or function from the 1st category

Category Syntax Examples Note
Equal left=right x=0, x=y, |(x)|=1 is true if the value of the left side equals the value of the right side
Not equal left!=right x!=0, x!=y
Greater than left>right x > y
Less than left < right x < y
Greater than or equal left >=right x >= y
Less than or equal left >=right x <= y, abs(x)<3, sin(x)<0.5
Grouping brackets [left>=right] [abs(x)>3] AND [abs(x)<5] use to group a relation
Negation NOT [left > right] NOT [x = y] negate the relation in the brackets, returns true if x != y
AND [cond1] AND [cond2] [x>0] AND [x<3]
OR [cond1] OR [cond2] [x<0] OR [x>3]

4.Special syntax in GenericVisualization¶

Using other variables with var()¶

In GenericVisualization, var(arg) can be used in Operations or Conditions and it will be replaced by the value of the variable with the name arg. Remember to write var as a function(var(x)) and not as a Tex-command(\var{x}).

  ...
\begin{variables}
\randint{x}{-5}{5} %create two random integers
\randint{y}{-5}{5}
\point{p1}{real}{var(x),var(y)} %creates a point on (x,y) depending on the values of x and y.
\end{variables}
...


Add picture from clipboard (Maximum size: 500 MB)