Frequently Occuring Problems
- Multiplication like "2x" doesn't seem to work!
- Matrix- and Vectorproduct does not seem to work!
- Why don't you predefine pi, e, i or j, ... in Rascal?
- In the online version Rascal seems to forget my definitions!
- Plotting does not seem to work online!
- Rascal does not solve my equations!
- Rascal does not know how to divide!
- Rascal does not understand my function definitions!
If you have other problems (with Rascal!),
use this form
to send me an email. You can find further information in the
user manual or at the
homepage of Rascal. You may
also experiment with
the online
version of Rascal.
- Multiplication like "2x" doesn't seem to work!
The reason is that this was never intended to work. This would introduce
too much ambiguity which does not justify the slight increase in comfort. On
the other hand "x2" cannot be recognized as a multiplication as this is a
correct variable name.
Solution: Use the multiplication symbol "*": "2*x"
- Matrix- and Vectorproduct does not seem to work!
If you try to multiply two vectors or matrices a*b, then the number of
columns of a must be equal the number of lines in b; else the multiplication
is not possible! Often you need to transpose one of the factors to get it
right.
Example: Think of two vectors
a=[1;2;3]
and
b=[4;5;6]
Let's compute a usual scalar product. As both vectors are column
vectors, we need to transpose the first, else the dimensions would not fit.
>a'
[1 2 3]
>a'*b
[32]
If we transposed b, then the result would be a matrix:
>a*b'
[4 5 6;8 10 12;12 15 18]
So it is important to be careful about the dimensions, as there are several
ways of multiplying vectors and matrices!
Solution: Check dimensions and transpose appropriately
- Why don't you predefine pi, e, i or j, ... in Rascal?
This question seems to be obsolete, as now pi,e and i are being predefined
using "rascal.rc", but still there is the question why it isn't hardwired
into rascal, as these special numbers are well-known constants.
The reason is that pi and e are infinitesimal numbers, they cannot be
represented as a finite floating point number. Thus the user has to decided
what accuracy is suitable and what datatype shall be used to represent the
constants. Here are some examples for suitable definitions and the resulting
accuracy on my system.
- Approximations:
- pi=3.14
2 digits accuracy
sin(pi)=0.0016
- pi=22/7
2 digits accuracy
sin(pi)=-0.0013
- pi=atan(1)*4
15 digits accuracy
sin(pi)=1.22E-16
- pi=3.1415926535897932384626433832795028841971693993751
15 digits accuracy (due to rounding to double)
sin(pi)=1.22E-16
- Stagprec(4);pi=atan(LReal(1))*4
64 digits accuracy
sin(pi)=1.01E-64
- Stagprec(10);pi=atan(LReal(1))*4
160 digits accuracy
sin(pi)=4.43E-163
- Enclosings:
- pi=[3.14,3.15]
diam(pi)=0.01
sin(pi)=[-0.0084,0.0016]
- pi=atan([1,1])*4
diam(pi)=1.29E-14
sin(pi)=[-6.98E-15,5.90E-15]
- pi=Interval(3.1415926535897932384626433832795028841971693993751)
diam(pi)=4.44E-16
sin(pi)=[-3.21E-16,1.23E-16]
- Stagprec(4);pi=atan(LInterval(1,1))*4
diam(pi)=3.04E-64
sin(pi)=[-2.13E-64,3.84E-64]
- Stagprec(10);pi=atan(LInterval(1,1))*4
diam(pi)=2.22E-162
sin(pi)=[-1.93E-162,2.79E-162]
As you can see there are a lot different ways of defining pi, depending on
your needs. Generally using intervals is adviseable, as this way you are not
starting from a false assumption; in above interval definitions pi is always
enclosed in the interval and the worst result in your computation could be
that the result cannot be determined in the arithmetic that was used.
With rounded scalar representation you just get a result and you don't know how
much the error you made in the beginning propagated.
In current versions that have the c-xsc-modules included, rascal.rc
predefines "pi" and "e" as string constants with an accuracy of about 300
digits. They are rounded to the corresponding datatype as soon (or late)
you use them. Without the c-xsc-modules "pi" and "e" are being defined as double-precision
constants.
The complex unit "i" can be represented accurately, but many engineers
prefer using "j" as the imaginary unit, as "i" is used otherwise. In Rascal
you have the freedom to use "j" instead of "i", just enter
>i=0;j=complex(0,1);
>sqrt(-16)
(4*j)
Solution: Understand that Rascal doesn't dictate what definition you
have to use... :)
- In the online version Rascal seems to forget my definitions!
Each time you load that page Rascal is started again; thus everything
you computed before is discarded. If you would like to use definitions,
don't erase them from the text-area-field in that page, but add further
lines below. Rascal will execute each line one after the other.
Also if you would like to try out some of the examples from the
documentation, you have to enter the full examples, not just the last lines.
Solution: Don't leave out the definitions, Rascal cannot guess what
you want him to remember!
- Plotting does not seem to work online!
Sorry, this was not intended to work online. Rascal uses gnuplot for
plotting and this program is not designed for online purposes. Well, it
_could_ be done, but the online version is just a try-out version, so live
with it.
Solution: Try it at home!
- Rascal does not solve my equations!
Rascal will only answer questions that are posed right:
- Rascal does not understand:
- But can get you the result this way:
>A=[1 2;3 4];y=[5;7];
>x=inv(A)*y;
[-3;4]
>a=x(1)
-3
>b=x(2)
4
Solution: Read the manual to find out how to ask the proper way...
- Rascal does not know how to divide!
Actually Rascal can do even more, Rascal can deal with fractions: Computing
1/2-1/6 would result in 1/3! If you
really want to get the decimal equivalent, just add a dot '.' to one of the
numbers you would like to divide: Then Rascal will display the result as a
floating point number and get the result you had expected. Some examples:
>38/12+7/3
11/2
>38/12.+7/3
5.5
>38/12+7/3+0.
5.5
Solution: Add a decimal point '.' to one of the numbers.
- Rascal does not understand my function definitions!
Perhaps you encountered trouble like this:
>f(x)=5*x
parse error
>g=sin+cos
Error:SYMREC+SYMREC
Sadly Rascal does not yet tell you properly what went wrong, something that
will be changed in future. You need to follow the correct syntax for
function definitions. In the first case there is a final semicolon missing,
in the second there are no variables: The correct versions are
>f(x)=5*x;
>g(x)=sin(x)+cos(x);
Solution: Follow the correct syntax.
Sebastian Ritterbusch
25. 07. 2001