Difference between revisions of "RvsZ3"
Jump to navigation
Jump to search
| Line 2: | Line 2: | ||
== Simple manipulations; numbers and vectors== | == Simple manipulations; numbers and vectors== | ||
===Vectors and assignment=== | ===Vectors and assignment=== | ||
| − | Z3 operates on named data structures. The simplest such structure is the numeric vector, | + | <pre> |
| − | which is a single entity consisting of an ordered collection of numbers. | + | 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 | + | 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 |
| − | command | ||
> x <- c(10.4, 5.6, 3.1, 6.4, 21.7) | > x <- c(10.4, 5.6, 3.1, 6.4, 21.7) | ||
Z3 command to set up a vector is: | Z3 command to set up a vector is: | ||
x<==[10.4, 5.6, 3.1, 6.4, 21.7]; | x<==[10.4, 5.6, 3.1, 6.4, 21.7]; | ||
| − | |||
| − | |||
Alternatively we can use the simple "=" also. | Alternatively we can use the simple "=" also. | ||
| Line 24: | Line 21: | ||
ASSIGN("x", [10.4, 5.6, 3.1, 6.4, 21.7]) | 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 | + | 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 | [10.4, 5.6, 3.1, 6.4, 21.7]==>x | ||
| Line 36: | Line 33: | ||
([10.4,5.6,3.1,6.4,21.7]<>d40)@(x=>1/x) | ([10.4,5.6,3.1,6.4,21.7]<>d40)@(x=>1/x) | ||
| − | + | </pre> | |
Please check back in couple of days. We are updating the page. | Please check back in couple of days. We are updating the page. | ||
Revision as of 03:09, 6 July 2021
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 to 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)
Please check back in couple of days. We are updating the page.