The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

HP Prime - vector question
Message #1 Posted by bluesun08 on 18 Nov 2013, 5:20 p.m.

I define the following 3d-vector:
[2*a 3*a 4*a] Sto v(a)
Naturally v(2) = [4 6 8] and 3*v=[6*a 9*a 12*a]
But the HP Prime don't show these results. Why not?

      
Re: HP Prime - vector question
Message #2 Posted by Michael de Estrada on 18 Nov 2013, 7:15 p.m.,
in response to message #1 by bluesun08

You have created the CAS program function v(CAS):

(c)->Begin 2*a; 3*a; 4*a; END:

What you are seeing is the last result which is 4*a. This is not a vector.

      
Re: HP Prime - vector question
Message #3 Posted by Han on 18 Nov 2013, 7:15 p.m.,
in response to message #1 by bluesun08

Quote:
I define the following 3d-vector:
[2*a 3*a 4*a] Sto v(a)
Naturally v(2) = [4 6 8] and 3*v=[6*a 9*a 12*a]
But the HP Prime don't show these results. Why not?

You are expecting v to be both a function of a and also a vector. Based only on syntax, how would anyone distinguish between the functional notation v(x), or the index notation v(i) -- as in the i-th element of v -- or even multiplication? The only way to determine what is meant is based on context.

So whatever it is you want v to be (a vector vs a function), it cannot be both. To create a function so that v(2) is [ 4 6 8 ] you can do:

v(a):=[[ 2*a, 3*a, 4*a ]]

or

[[2*a, 3*a, 4*a]] > v(a) // ">" is the STO character and note the double brackets

Now v is more like a function that returns a vector. However, 2*v would be a function. If you just want a vector, then either

v:=[2*a, 3*a, 4*a]

or

[2*a, 3*a, 4*a] > v // ">" is the STO character

To get the equivalent of v(2) you would do

a:=2; eval(v);

or

v|a=3

And 3v would return the expected vector object [3a, 9a, 12a]. However, v(2) would return the second element of the vector v.

That said, there is an issue with the way vectors are interpreted, however -- or at least there is an issue with expected behavior and actual behavior. That is, I too expected that

[2a, 3a, 4a] > v(a) // ">" represents the STO character

to create a function so that v(2) returns [4, 6, 8]. However, it neither returns [4,6,8] nor even the second element of the vector! Unfortunately, the way vectors and matrices are implemented is quite confusing. This has been discussed (somewhat) before but I feel as though I was on the losing side of the argument in suggesting that [[ a11, a12], [a21, a22]] be matrices whereas [ v1, v2, v3, , vn ] be vectors.

Edited: 18 Nov 2013, 8:33 p.m. after one or more responses were posted

            
Re: HP Prime - vector question
Message #4 Posted by Han on 18 Nov 2013, 7:26 p.m.,
in response to message #3 by Han

You might be able to find more useful info here:

http://www-fourier.ujf-grenoble.fr/~parisse/giac/cascmd_en.pdf


[ Return to Index | Top of Index ]

Go back to the main exhibit hall