Post Reply 
Existing CAS commands --> Prime discussion
12-24-2018, 03:15 AM
Post: #61
RE: Existing CAS commands --> Prime discussion
importance of UNQUOTE CMD, evaluate subparts of expressions.

y:=3; x:=5;
a:=quote(x+unquote(y)); [enter] returns
x+3

b:=quote(unquote(x)+y) [enter] returns
y+5

eval(a); eval(a,1); eval(a,2); [enter] returns
8, y+5, 8

LO SUFICIENTEMENTE BUENO ES ENEMIGO DE LA EXCELENCIA.
Find all posts by this user
Quote this message in a reply
02-19-2019, 02:52 AM (This post was last modified: 02-19-2019 08:08 PM by compsystems.)
Post: #62
RE: Existing CAS commands --> Prime discussion
undocumented functions and operators


1: increment at 1
a:=a+1
increment(a,1)
a+=1

2: decrement at 1
a:=a-1
decrement(a,1)
a-=1

3: increment
a:=a+b
increment(a,b)
a+=b

4: decrement
a:=a-b
decrement(a,b)
a-=b

5: mulcrement
a:=a*b
mulcrement (a,b)
a*=b

6: divcrement
a:=a/b
divcrement (a,b)
a/=b

7: float("3.14") [enter] 3.14
float(10) [enter] 10.0

8: bool( 1 ) [enter] true
bool( 0 ) [enter] false
bool( -1 ) [enter] true

LO SUFICIENTEMENTE BUENO ES ENEMIGO DE LA EXCELENCIA.
Find all posts by this user
Quote this message in a reply
02-22-2019, 08:36 PM (This post was last modified: 04-25-2019 08:46 PM by compsystems.)
Post: #63
RE: Existing CAS commands --> Prime discussion
getType command

The XCas getType() command is not synonymous with type or TYPE cmds, the important thing about this command that is not included in the hpprime
is that it groups several types of objects by common characteristics, for example

getType(5.0 ), getType( 5 ), getType( 3/4 ) [enter] "NUM", "NUM", "NUM"

Mathematical expressions as"EXPR" and math constants
getType( 3+4*i ), getType( x+i*y ), getType( 3*pi ), getType( sqrt(-1) ) , getType( e ) [enter]"EXPR", "EXPR", "EXPR", "EXPR", "EXPR"

Lists, sequences, sets and polynomials as “LIST"
seq1:=(1,2,3)
getType( seq1), getType( [9,[8,7],[6,5,4]]), getType( [9 ,8 ,7] ), getType( set[a , b, c, a] ), getType( poly1[1 ,-6 , 11 ,-6] ) [enter] "LIST", "LIST","LIST","LIST","LIST"
Difference matrix of lists
getType( [[1,2],[3,4]] ), getType( [[1,2,3,4]], getType( [[1],[2],[3],[4]] ) [enter] "MAT", "MAT", "MAT"

getType( var01 ) [enter] "VAR"
getType( "Hello" ) [enter] "STR"
getType( f(x):=x+1) [enter] "FUNC"


getType(5.0 ), getType( 5 ), getType( 3+4*i ), getType( x+i*y ), getType( [9,[8,7],[6,5,4]]), getType( [9 ,8 ,7] ), getType( set[a , b, c, a] ), getType( poly1[1 ,-6 , 11 ,-6] ), getType( [[1,2],[3,4]] ), getType( var01 ), getType( "Hello" ), getType( f(x):=x+1)
"NUM","NUM","EXPR","EXPR","LIST","LIST","LIST","LIST","MAT","VAR","STR","FUNC"

Example of use of the getType function.

PHP Code:
#Xcas
def legendre_nevalX="" ):
    
local pxxtype2argpurge(x)
    if 
getType(n) == "NUM":
      
px := 1/(2^n*n!)*diff((x^2-1)^n,x,n)
      
type2arg := getType(evalX)   
      if 
type2arg == "NUM" or type2arg == "EXPR" or type2arg == "VAR":
        
px := subst(px,x=evalX)
      
elif type2arg == "STR" and evalX=="LIST":
        
px:=e2r(px)  
 
        return 
px
    
return "Error: an integer number is expected in the first argument"
#end 
legendre_(2),legendre_(2,y),legendre_(2,"LIST"),legendre_(2,10),legendre_(2,cos(t)) enter

1/8*(12*x^2-4), 1/8*(12*y^2-4), poly1[3/2,0,-1/2],2 99/2, 1/8*(12*cos(t)**2-4)

LO SUFICIENTEMENTE BUENO ES ENEMIGO DE LA EXCELENCIA.
Find all posts by this user
Quote this message in a reply
04-25-2019, 08:35 PM
Post: #64
RE: Existing CAS commands --> Prime discussion
Please HpPrime team attach the console command help() to the catalog

Xcas:
help( abs ) [enter] returns

"Returns the absolute value or the norm of its argument.

abs( -4 );
abs( 1+2*i );
abs( (1+2*i)^2);
abs( [-2, 1+i, -4]);"

LO SUFICIENTEMENTE BUENO ES ENEMIGO DE LA EXCELENCIA.
Find all posts by this user
Quote this message in a reply
Post Reply 




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