The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
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:

ChooseType()
BEGIN
LOCAL choice;
CHOOSE(choice,"Matrix or Wronskian","Fundamental Matrix","Wronskian");
RETURN choice;
END;

#cas
// Wronskian - input a [vector] of functions
// i.e. W(f,g)= fg'-f'g
wronskian(flist):=
BEGIN
local mat, s, j, k, d, t, h;
s:= size(flist);

IF (  (s < 2) OR (TYPE(flist) == 2) OR (TYPE(flist(1))==2) OR (TYPE(flist(2))==2) ) THEN return "Input a [vector] of functions";
ELSE
IF (TYPE(flist) <> 4) THEN print "It would be better use [vector] in []"; END;
mat:= makemat(0, s, s);
mat[1]:= flist;
FOR j FROM 2 TO s DO // diff

FOR k FROM 1 TO s DO // items
d:=diff(mat[j-1,k],x);
mat[j, k]:= d;

END; // for k
END; // for j
IF EXPR(" wronskian.ChooseType()")=1 THEN
return mat;
ELSE
return det(mat);
END; // if

END; // 1st if

END;
#end

Why the code
Code:

IF (type(flist)≠ DOM_MATRIX) THEN return "input [vector] of functions"; ELSE ...
accepts not only matrix but also input like (2,3) and ({x, x^2}), numbers or list? There is a way to accept only a real matrix of vector, with [] only?
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
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Wronskian - salvomic - 02-22-2015 11:10 PM
RE: Wronskian - salvomic - 02-23-2015, 06:57 PM
RE: Wronskian - salvomic - 02-23-2015, 07:21 PM
RE: Wronskian - Han - 02-23-2015, 07:29 PM
RE: Wronskian - salvomic - 02-23-2015, 09:46 PM
RE: Wronskian - Han - 02-23-2015, 10:24 PM
RE: Wronskian - salvomic - 02-23-2015, 10:51 PM
RE: Wronskian - Han - 02-23-2015, 10:53 PM
RE: Wronskian - salvomic - 02-23-2015, 11:02 PM
RE: Wronskian - Han - 02-24-2015, 12:49 AM
RE: Wronskian - salvomic - 02-24-2015, 06:32 AM



User(s) browsing this thread: 4 Guest(s)