Post Reply 
HP_PRIME PYTHON SYNTAX: HP_PPY
11-12-2017, 03:59 PM (This post was last modified: 05-09-2021 10:23 PM by compsystems.)
Post: #1
HP_PRIME PYTHON SYNTAX: HP_PPY
cas + pixels cmds

Example with standard CAS notation.
PHP Code:
#cas
fract1X_Y_Nmax ):=
begin
        
// Mandelbrot fractal, not using symmetry.
    
local xyzcjwhres1;
    
//freeze;
    
:= 2.7/X_;
    
:= -1.87/Y_;
    
res1 := []; 
    
Y_ := Y_-1;
    for 
y from 0 to Y_ do
        
:= -2.1 i*(h*y+0.935);
        for 
x from 0 to X_-do
            
:= 0;
            for 
j from 0 to Nmax-do
                if 
abs:= z^2+)>2 then break; end;
            
end;
            
res1.appendpixon_pxy126*j+2079 )); 
            
:= c+w;
        
end;
    
end;
    
wait(0); 
    return 
"Done"//return res1; 
end;
#end 
fract1( 320, 240, 10 ); [enter]
[Image: xcas_and_gui_image00.png]

As function xcas compatibility
PHP Code:
#cas
function fract2X_Y_Nmax )
        
// Mandelbrot fractal, not using symmetry.
    
local xyzcjwhres1;
    
:= 2.7/X_;
    
:= -1.87/Y_;
    
res1 := []; 
    
Y_ := Y_-1;
    for 
y from 0 to Y_ do
        
:= -2.1 i*(h*y+0.935);
        for 
x from 0 to X_-do
            
:= 0;
            for 
j from 0 to Nmax-do
                if 
abs:= z^2+)>2 then break; end;
            
end;
            
res1.appendpixon_pxy126*j+2079 )); // Xcas pixon_p -> pixon
            
:= c+w;
        
end;
    
end;
    
wait(0); // Xcas: comment on this line
    
return "Done" ;
end;
#end 
fract2( 320, 240, 10 ); [enter]
deltalist(time(fract2(320,240,10))); // only for Xcas to determine the execution time

using symmetry
PHP Code:
#cas
function fract2aX_Y_Nmax )  
        
// Mandelbrot fractal, using symmetry.      
    
local xyzcjwhres1res2;
    
//freeze;
    
:= 2.7/X_;
    
:= -1.87/Y_;
    
res1:=makelist(-ceilingX_*Y_/)-1);
    
res2 := res1
    
Y_ := Y_-1;
    for 
y from 0 to Y_/do
        
:= -2.1 i*(h*y+0.935);
        for 
x from 0 to X_-do
            
:= 0;
            for 
j from 0 to Nmax-do
                if 
abs:= z^2+)>2 then break; end;
            
end;
            
res1.appendpixon_pxy126*j+2079 )); 
            
res2.appendpixon_pxY_-y126*j+2079 ));
            
:= c+w;
        
end;
    
end;
    
wait(0); 
    return 
"Done"//    return res1,res2;
end;
#end 


With Python syntax.
PHP Code:
#cas
def fract3X_Y_Nmax ):
    
local xyzc
    
for x in rangeX_ ):
        for 
y in rangeY_ ):
            
0
            c 
2.7*X_-2.1 i*( -1.87*y/Y_ .935)
            for 
j in rangeNmax ):
                
z*c
                
if abs) > 2:  # abs(z = z*z+c)>2:
                    
break
            
pixon_pxy255*20*256 )
    
wait(0)
    return 
"Done"
#end 
fract3( 320, 240, 10 ); [enter]
[Image: xcas_and_gui_image01.png]

XCAS only
PHP Code:
function fract2X_Y_Nmax )
    
local xyzcjwhres1;
    
:= 2.7/X_;
    
:= -1.87/Y_;
    
res1 := []; 
    
Y_ := Y_-1;
    for 
y from 0 to Y_ do
        
:= -2.1+i*(h*y+0.935);
        for 
x from 0 to X_-do
            
:= 0;
            for 
j from 0 to Nmax-do
                if 
abs:= z^2+)>2 then break; end;
            
end;
            
res1.appendpixonxy126*j+2079 )); // hpprime pixon -> pixon_p
            
:= c+w;
        
end;
    
end;
    return 
res1;
end 
deltalist(time(fract2(320,240,10))); [enter]

XCAS only
PHP Code:
function fract2aX_Y_Nmax )  
    
// Mandelbrot fractal, using symmetry.      
    
local xyzcjwhres1res2;
    
:= 2.7/X_;
    
:= -1.87/Y_;
    
res1:=makelist(-ceilingX_*Y_/)-1);
    
res2 := res1
    
Y_ := Y_-1;
    for 
y from 0 to Y_/do
        
:= -2.1 i*(h*y+0.935);
        for 
x from 0 to X_-do
            
:= 0;
            for 
j from 0 to Nmax-do
                if 
abs:= z^2+)>2 then break; end;
            
end;
            
res1.appendpixonxy126*j+2079 )); 
            
res2.appendpixonxY_-y126*j+2079 ));
            
:= c+w;
        
end;
    
end;
    return 
res1,res2;
end 
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP_PRIME PYTHON SYNTAX: HP_PPY - compsystems - 11-12-2017 03:59 PM
RE: HP_PRIME PYTHON: HP_PPY - toml_12953 - 11-12-2017, 04:42 PM
RE: HP_PRIME PYTHON: HP_PPY - webmasterpdx - 11-12-2017, 05:58 PM
RE: HP_PRIME PYTHON: HP_PPY - Carlos295pz - 11-12-2017, 06:08 PM
RE: HP_PRIME PYTHON: HP_PPY - webmasterpdx - 11-12-2017, 06:12 PM
RE: HP_PRIME PYTHON: HP_PPY - Carlos295pz - 11-12-2017, 06:19 PM
RE: HP_PRIME PYTHON: HP_PPY - webmasterpdx - 11-12-2017, 06:21 PM
RE: HP_PRIME PYTHON: HP_PPY - Carlos295pz - 11-12-2017, 06:26 PM
RE: HP_PRIME PYTHON: HP_PPY - parisse - 11-12-2017, 07:35 PM



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