Wronskian
|
02-22-2015, 11:10 PM
(This post was last modified: 02-23-2015 06:51 PM by salvomic.)
Post: #1
|
|||
|
|||
Wronskian
hi,
I made a (CAS) program to calculate Wronskian of a list of functions (it gives both fundamental matrix and wronskian = det|mat|) Code:
Why the code Code:
Definitely the program sees "flist" always as a list with input [x, x^2], {x, x^2}, (x, x^2)... With a vector the program (correctly) gives a matrix, with list it gives a vector with 2 elements, a list and a vector, like [{x, x^2}[1, 2*x]], not correct as format, and I would like to avoid that. Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-23-2015, 06:57 PM
(This post was last modified: 02-23-2015 07:00 PM by salvomic.)
Post: #2
|
|||
|
|||
RE: Wronskian
This code
Code:
is a bit "dirty": I would control *every* part of an input like [x, x^2, 1-x, ...] not only the first two, to be NOT a string. I thought to use something like Code:
And that IF Code:
Any help is much appreciated! Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-23-2015, 07:21 PM
(This post was last modified: 02-23-2015 10:18 PM by salvomic.)
Post: #3
|
|||
|
|||
RE: Wronskian
A little better version:
Code:
It is not so elegant (it's perhaps "folkloristic", but with Code:
∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-23-2015, 07:29 PM
(This post was last modified: 02-23-2015 10:43 PM by Han.)
Post: #4
|
|||
|
|||
RE: Wronskian
Why not just convert it for the user? The code below assumes CAS-programming. In CAS view, SIZE() (note the upper case) will return a real number for a list delimited by [ ] and a CAS list (in the form [ row col ]) for a matrix.
Code: IF TYPE(flist)==4 THEN EDIT: it appears we don't even really need to convert; a list is a list in CAS regardless of the actual delimiters displayed. Graph 3D | QPI | SolveSys |
|||
02-23-2015, 09:46 PM
Post: #5
|
|||
|
|||
RE: Wronskian
(02-23-2015 07:29 PM)Han Wrote: Why not just convert it for the user? The code below assumes CAS-programming. In CAS view, SIZE() (note the upper case) will return a real number for a list delimited by [ ] and a CAS list (in the form [ row col ]) for a matrix. thank you for your effort, Han. I'm trying applying that to my program, but for now I'm not able to do it, willing also to save the other controls for type, number arguments... Also the calculations should be changed; i.e. I create a mat with make mat(0, s, s), put in it flist, then (in two cycles) differentiate and add rows with mat[j,k]:=d Now, having already a matrix... I'm a bit confused, sorry. Salvo ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-23-2015, 10:24 PM
(This post was last modified: 02-23-2015 10:25 PM by Han.)
Post: #6
|
|||
|
|||
RE: Wronskian
Try this:
Code: #cas Usage: wronskm([f1,f2,...,fn]) returns the matrix; wronsk([f1,f2,...,fn]) returns the determinant of the matrix The error message regarding single-variable functions can occur when: 1) the "variable" already exists and contains a value of some sort (e.g. exported from a non-CAS program, defined by user, or exists in the CAS view); OR 2) the functions in the vector of functions are multivariate (or are all constants) Graph 3D | QPI | SolveSys |
|||
02-23-2015, 10:51 PM
(This post was last modified: 02-23-2015 11:00 PM by salvomic.)
Post: #7
|
|||
|
|||
RE: Wronskian
(02-23-2015 10:24 PM)Han Wrote: Try this: thanks a lot! this works well, and finally the controls are what I would have to get! Please, can you tell me the use of the $ sign in diff() function? Another think: wronsk(f) take also the IF in the other function, as I can see, is it right? IF TYPE(s) THEN ... after the control of s==0 and <>6: controls it if there is another value for s? You prefer two CAS function and it's ok also for me; another idea is to have only a command and a Choose routine, as in the my previous version... Ad libitum Salvo EDIT: variables r, c: shouldn't they be in local? ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-23-2015, 10:53 PM
Post: #8
|
|||
|
|||
RE: Wronskian
(02-23-2015 10:51 PM)salvomic Wrote: Please, can you tell me the use of the $ sign in diff() function? Example: x$2 means differentiate with respect to x twice. Graph 3D | QPI | SolveSys |
|||
02-23-2015, 11:02 PM
Post: #9
|
|||
|
|||
RE: Wronskian
(02-23-2015 10:53 PM)Han Wrote: Example: x$2 means differentiate with respect to x twice. very interesting! I didn't know that, than you... please, see again my post above: I edited it while are writing... ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
02-24-2015, 12:49 AM
Post: #10
|
|||
|
|||
RE: Wronskian
(02-23-2015 10:51 PM)salvomic Wrote: Another think: wronsk(f) take also the IF in the other function, as I can see, is it right? If I understand your question correctly, then the answer is no. Only one scenario is allowed: when the input f consists of a list. In CAS-view, the SIZE() command returns a real number if f is a list (whether of the form f1,f2,…,fn or [f1,f2,…,fn] or {f1,f2,…,fn} or any non-matrix type). Otherwise, SIZE() returns a list if f is a matrix. That is, if f is an m x n matrix, then SIZE(f) returns [m n]. So the first IF statement checks to see that an input was actually specified and that it necessarily a list. A symbolic matrix is just a list of lists (or, one can also think of it as a matrix). So after the first IF statement, the only possible scenario is that f is a list, or it is a list of lists. To determine which, we check the TYPE() of the SIZE() result. If the SIZE() command returned a real number, then we have a simple list (or we can think of it as a vector). Otherwise, if SIZE() is not a real number, then it could not be a simple list (likely a list of list, for example) and so we throw an error message. Quote:EDIT: variables r, c: shouldn't they be in local? No, they are automatically local, and local to the function (r,c)->diff(f(c), v$(r-1)) because they are simply placeholders (dummy variables). Graph 3D | QPI | SolveSys |
|||
02-24-2015, 06:32 AM
Post: #11
|
|||
|
|||
RE: Wronskian
(02-24-2015 12:49 AM)Han Wrote: If I understand your question correctly, then the answer is no. ... perfect! thank you, now it is more clear for me. Your code is also more compact than mine! ∫aL√0mic (IT9CLU) :: HP Prime 50g 41CX 71b 42s 39s 35s 12C 15C - DM42, DM41X - WP34s Prime Soft. Lib |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)