Arithmetic Expressions

You can use arithmetic expression in C.a.R. to

Use the expression tool  to place expressions on the screen (and the right mouse button to move them). You will have to enter a valid expression into the dialog. Expressions may have an explaining text, and may or may not display the computed value. They are moved like any other object with the right mouse button.

Here is a short description of the valid elements. This description is also contained in the on-line help.

Name

Example

Description

+, -, *, /,^ or **

3.5*3+3/(4-5^2)

Elementary math.

Name of object

AB/CD

The name of a segment, circle, angle and other expression. The object must be defined before the object that uses the expression.

@Name of object

x(@P1)

This form can refer to objects defined later, but will not work in macros.

Function

sin(a)

The functions abs, sign, sin, cos, tan, arcsin, arccos, arctan, sqrt, exp, log, round, ceil, floor, angle180 and angle360. Note that sin works in radians. There is a function deg to convert and rad to convert back.

Pi

pi

The constant Pi.

x,y

x(P), y(P)

x- and y-coordinates of a point.

d

d(P,Q)

Distance of two points.

d

d(x)

Computes changes of the expression x. If x is a point, it computes movements.

sum

sum(x,f)

Sums up x. If f is negative or invalid, the sum is reset to 0.

a a(P,Q,Z) Size of angle PQZ.
scale scale(x,a,b) The relative position of x in [a,b), if x is in that interval. Else the expression becomes invalid.
if if(e,e1,e2) Returns e1, if e is valid, else e2.
invalid invalid Returns an invalid expression.
&&,||,! ! (x<4 && y<4) Logical expressions. 1 is true, 0 is false.
<, >, <=, >=, ==, ~= x<y Comparing numbers. ~= means "about equal".
integrate integrate(f,a,b) Integrates the function f from a to b using the Romberg method. f must be a function object.
zero zero(f,a,b) Find the zero of f between a and b using the secant method with interval check. f must have opposite sign in a and b.
diff diff(f,x) Differentiate f in x.