HP Prime - vector question « Next Oldest | Next Newest »

 ▼ bluesun08 Member Posts: 207 Threads: 48 Joined: Feb 2010 11-18-2013, 05:20 PM 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? ▼ Michael de Estrada Posting Freak Posts: 1,665 Threads: 142 Joined: Jan 2009 11-18-2013, 07:15 PM 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. Han Senior Member Posts: 709 Threads: 104 Joined: Nov 2005 11-18-2013, 07:15 PM 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 ▼ Han Senior Member Posts: 709 Threads: 104 Joined: Nov 2005 11-18-2013, 07:26 PM You might be able to find more useful info here:

 Possibly Related Threads... Thread Author Replies Views Last Post HP Prime: adding an entry to a vector Alberto Candel 12 2,110 12-02-2013, 01:18 PM Last Post: Alberto Candel HP Prime Matrix TERRIBLE bug and question uklo 19 2,644 11-25-2013, 12:10 PM Last Post: Mic Question about transfering programs to the HP Prime Namir 10 1,639 11-17-2013, 04:01 PM Last Post: Namir Another HP Prime CAS question Michael de Estrada 3 880 11-09-2013, 10:56 AM Last Post: Michael de Estrada XCas / Prime "solve" question Nigel J Dowrick 4 1,055 11-08-2013, 04:01 AM Last Post: Nigel J Dowrick Non-Prime question alert: Hp-41 and synthetic instructions Marcel Samek 11 1,984 11-04-2013, 09:31 PM Last Post: sjthomas [HP-Prime CAS] Vector Calculus Library CompSystems 7 1,461 10-31-2013, 12:48 PM Last Post: Han HP-Prime/Xcas: vector/list indexing fhub 6 1,308 10-27-2013, 04:52 PM Last Post: fhub HP PRIME - APP Programing question dg1969 2 666 10-27-2013, 10:23 AM Last Post: dg1969 WP-34S (Prime Number Test) question Barry Mead 3 865 10-20-2013, 05:28 PM Last Post: Dieter

Forum Jump: