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
Find all posts by this user
Quote this message in a reply
02-19-2019, 02:52 AM (This post was last modified: 11-08-2019 12:46 AM by compsystems.)
Post: #62
RE: Existing CAS commands --> Prime discussion
undocumented functions and operators

1: increment at 1

PHP Code:
a:=15;
a+=1;  // a  -> 16
a:=a+1// a -> 17, 16+1
increment(a,1); // a -> 18, 17+1
increment(a); // a -> 19, 18+1 

2: decrement at 1
PHP Code:
a:=a-1;  // a  -> 18
decrement(a,1); // a  -> 17
a-=1  // a  -> 16
decrement(a); // a  -> 15 

3: increment
PHP Code:
b:=20;
a:=a+b;  // a  -> 35
increment(a,b); // a  -> 55
a+=b;  // a  -> 75 

4: decrement
PHP Code:
a:=a-b;  // a  -> 55
decrement(a,b); // a  -> 35
a-=// a  -> 15 

5: multcrement
PHP Code:
a:=a*b// a -> 300, 15*20
mulcrement(a,b); // a -> 6000, 300*20
a*=b// a -> 120000, 6000*20 

6: divcrement
PHP Code:
a:=a/b// a -> 6000, 120000/20
divcrement(a,b); // a -> 300, 6000/20
a/=// a -> 15, 300/20 

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
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)
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]);"
Find all posts by this user
Quote this message in a reply
11-06-2019, 04:50 PM
Post: #65
RE: Existing CAS commands --> Prime discussion
There commands that are very important within a program, for example, changing the display of exponents in polynomials (increasing-decreasing) without having to do it manually [shift]+[mode-cas], but from the source code.

◉ increasing_power(False) [↵]
◉ x^3 - 6*x² + 11*x -6 [↵] Xcas returns x^3 - 6*x^2 + 11*x -6
◉ increasing_power() [↵] Xcas returns 0


◉ increasing_power(True) [↵]
◉ x^3 - 6*x² + 11*x -6 [↵] Xcas returns -6+11*x-6*x^2+x^3
◉ increasing_power() [↵] returns 1
Find all posts by this user
Quote this message in a reply
11-06-2019, 10:40 PM
Post: #66
RE: Existing CAS commands --> Prime discussion
(02-19-2019 02:52 AM)compsystems Wrote:  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

I'd love to be able to use these in non-CAS programs!

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-07-2019, 01:41 AM (This post was last modified: 11-08-2019 12:49 AM by compsystems.)
Post: #67
RE: Existing CAS commands --> Prime discussion
a:=15; [ENTER] 15 // ok
a+=1; [ENTER] increment(a,1) => 16, a:=a+1, a:=15+1 // ok
increment(a,1) [ENTER] increment(a,1) ? // expected 17

now
a:=16;
b:=20;
a/=b [ENTER] a/▣ ? // expected 4/5

textbook => off
a/=b [ENTER] 4/5 // ok
Find all posts by this user
Quote this message in a reply
11-07-2019, 02:41 AM (This post was last modified: 11-07-2019 02:42 AM by toml_12953.)
Post: #68
RE: Existing CAS commands --> Prime discussion
(11-07-2019 01:41 AM)compsystems Wrote:  a:=15; [ENTER] 15 // ok
a+=1; [ENTER] increment(a,1) => 16 // ok
increment(a,1) [ENTER] increment(a,1) ? // expected 17

now
a:=16;
b:=20;
a/=b [ENTER] a/▣ ?

textbook => off
a/=b [ENTER] ok

Try

a:=increment(a,1)

Parameters are passed by value, not reference so the variable a can't be changed when used as a parameter.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-08-2019, 12:57 AM (This post was last modified: 11-08-2019 12:58 AM by compsystems.)
Post: #69
RE: Existing CAS commands --> Prime discussion
increment(a,1) stores the result of a: = a+1 the problem is that the hpprime does not update the history view engine, the xCAS evolves but when the CAS is updated within the firmware it is necessary to update the expression interpreter, otherwise not It will work many things.
Find all posts by this user
Quote this message in a reply
11-08-2019, 01:00 AM
Post: #70
RE: Existing CAS commands --> Prime discussion
(11-08-2019 12:57 AM)compsystems Wrote:  increment(a,1) stores the result of a: = a+1

No, it doesn't. It increments a temporary copy of a, not a itself. That's why you have to store the result back to the variable a yourself.

a:=increment(a,1)

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-08-2019, 08:12 AM
Post: #71
RE: Existing CAS commands --> Prime discussion
(11-08-2019 01:00 AM)toml_12953 Wrote:  
(11-08-2019 12:57 AM)compsystems Wrote:  increment(a,1) stores the result of a: = a+1

No, it doesn't. It increments a temporary copy of a, not a itself. That's why you have to store the result back to the variable a yourself.

a:=increment(a,1)

In Xcas, increment(a,1) gets turned into a+=1, incrementing a in place.

— Ian Abbott
Find all posts by this user
Quote this message in a reply
11-08-2019, 10:59 AM
Post: #72
RE: Existing CAS commands --> Prime discussion
(11-08-2019 08:12 AM)ijabbott Wrote:  
(11-08-2019 01:00 AM)toml_12953 Wrote:  No, it doesn't. It increments a temporary copy of a, not a itself. That's why you have to store the result back to the variable a yourself.

a:=increment(a,1)

In Xcas, increment(a,1) gets turned into a+=1, incrementing a in place.

Really? On Prime when I try it, it does this:

I type a:=5
Prime shows 5
I type increment(a,1)
Prime shows increment(5,1)
I type a
Prime shows 5

Prime has not incremented a.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
11-08-2019, 03:00 PM
Post: #73
RE: Existing CAS commands --> Prime discussion
(11-08-2019 10:59 AM)toml_12953 Wrote:  
(11-08-2019 08:12 AM)ijabbott Wrote:  In Xcas, increment(a,1) gets turned into a+=1, incrementing a in place.

Really? On Prime when I try it, it does this:

I type a:=5
Prime shows 5
I type increment(a,1)
Prime shows increment(5,1)
I type a
Prime shows 5

Prime has not incremented a.

In Home Settings, page 2 (not page 1), turn ON "Textbook Display". Now in CAS type:

a:=5
a+=1

You'll see that your a+=1 gets displayed as

increment(a,1)

... but if you turn Textbook Display mode OFF, it's displayed as

a:=a+1

However, typing increment() on the command line does not work; it's not recognized, like typing foobar() or any other nonexistent command.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
11-09-2019, 03:28 PM
Post: #74
RE: Existing CAS commands --> Prime discussion
Testing the four "crement" commands in programming:

Code:
EXPORT TEST7788()
BEGIN
// CREMENT TEST
// EWS 2019-11-07
LOCAL a:=100;
LOCAL b:=5;
PRINT();

CAS.increment(a,b);
PRINT("+  "+a);

CAS.decrement(a,b);
PRINT("-  "+a);

CAS.mulcrement(a,b);
PRINT("*  "+a);

CAS.divcrement(a,b);
PRINT("/  "+a);

PRINT("-------");

a:=CAS.increment(a,b);
PRINT("+  "+a);

a:=CAS.decrement(a,b);
PRINT("-  "+a);

a:=CAS.mulcrement(a,b);
PRINT("*  "+a);

a:=CAS.divcrement(a,b);
PRINT("/  "+a);

END;

The results may show why these four commands are not in the catalog:
Code:

+  100
-  100
*  100
/  100
-------
+  increment(100,5)
-  decrement(increment(100,5),5)
*  mulcrement(decrement(increment(100,5),5),5)
/  divcrement(mulcrement(decrement(increment(100,5),5),5),5)


Attached File(s) Thumbnail(s)
   
Visit this user's website Find all posts by this user
Quote this message in a reply
11-09-2019, 03:51 PM
Post: #75
RE: Existing CAS commands --> Prime discussion
Hello

If you write on the entry line a: = 15; a + = 1; [enter] is shown in the history view [a: = 15, increment(a, 1)] [15,16] where a+=1 is interpreted as increment (a, 1) but the entry line of this sentence is not interpreted.

increment(a, 1) [enter] increment(a, 1)? expected 17


A command that is not in the catalog does not imply that the command internally is not within the functions of the Xcas source code, they may not make it visible yet, like many that I have reported and have ignored.

For example

bool( 1 ); [enter] true
bool( 0 ); [enter] false
bool( -1 ); [enter] true
Find all posts by this user
Quote this message in a reply
Post Reply 




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