Comparison of R vs Z3

Simple manipulations; numbers and vectors

Vectors and assignment

Z3 operates on named data structures. The simplest such structure is the numeric vector,which is a single entity consisting of an ordered collection of numbers. 

To set up a vector named x, say, consisting of five numbers, namely 10.4, 5.6, 3.1, 6.4 and 21.7, use the R command

> x <- c(10.4, 5.6, 3.1, 6.4, 21.7)

Z3 command to set up a vector is:

x<==[10.4, 5.6, 3.1, 6.4, 21.7];

Alternatively we can use the simple "=" also.

 x=[10.4, 5.6, 3.1, 6.4, 21.7]

Assignment can also be made using the function ASSIGN(). An equivalent way of making the same assignment as above is with: In R,

> assign("x", c(10.4, 5.6, 3.1, 6.4, 21.7))

In Z3, use the "ASSIGN" function as:

ASSIGN("x", [10.4, 5.6, 3.1, 6.4, 21.7])

Assignments can also be made in the other direction, using the obvious change in theassignment operator. So the same assignment could be made using

[10.4, 5.6, 3.1, 6.4, 21.7]==>x 

The reciprocals of the above five values for x in R, > 1/x In Z3, We can use the function called Reciprocal,

RECIPROCAL(x) (the value of x is [10.4, 5.6, 3.1, 6.4, 21.7]

Also we can use directly,

([10.4,5.6,3.1,6.4,21.7]<>d40)@(x=>1/x)

The further assignment

> y <- c(x, 0, x)

would create a vector y with 11 entries consisting of two copies of x with a zero in the middle place.

Vector arithmetic

Please check back in couple of days. We are updating the page.