Post Reply 
linear mode (Entry: algebraic)
01-13-2020, 03:25 PM (This post was last modified: 01-25-2020 03:16 AM by compsystems.)
Post: #1
linear mode (Entry: algebraic)
Hi. Good morning

The following code can be entered directly on the entry line, but only work in CAS and linear mode (Entry: algebraic/1D). Why? the definition failure in textbook mode (aka pretty print or 2D input)

Please copy and paste the following codes into the input line (simulator)

PHP Code:
function fract(X_,Y_,Nmax// Mandelbrot fractal, not using symmetry.
  
local x,y,z,c,j,w,h,res1,res2;
  
freeze;
  
w:=2.7/X_;
  
h:=-1.87/Y_;
  
res1:=[]; 
  
Y_:=Y_-1;
  for 
y from 0 to Y_ do
    
c:=-2.1+i*(h*y+0.935);
    for 
x from 0 to X_-do
      
z:=0;
      for 
j from 0 to Nmax-do
        if 
abs(z:=z^2+c)>2 then break; end;
      
end;
      
res1.append(pixon_p(x,y,126*j+2079));
      
c:=c+w;
    
end;
   
end;
  
//return res1; // hpprime: comment on this line, 10 thousand elements maximum
   
return "Done"
end

//deltalist(time(fract(320,240,10)));
fract(320,240,10)

from program editor with please add the header #cas ... #end

PHP Code:
function fract1(X_,Y_,Nmax// Mandelbrot fractal, using symmetry.
  
local x,y,z,c,j,w,h,res1,res2;
  
freeze;
  
w:=2.7/X_;
  
h:=-1.87/Y_;
  
res1:=makelist(-ceiling(X_*Y_/2)-1);   
  
res2:=res1;
  
Y_:=Y_-1;
  for 
y from 0 to Y_/do
    
c:=-2.1+i*(h*y+0.935);
    for 
x from 0 to X_-do
      
z:=0;
      for 
j from 0 to Nmax-do
        if 
abs(z:=z^2+c)>2 then break; end;
      
end;
      
res1.append(pixon_p(x,y,126*j+2079)); 
      
res2.append(pixon_p(x,Y_-y,126*j+2079)); 
      
c:=c+w;
    
end;
  
end;
  
//return res1,res2; // hpprime: comment on this line, 10 thousand elements maximum 
  
return "Done" 
end
//deltalist(time(fract1(320,240,10)));
fract1(320,240,10)
Find all posts by this user
Quote this message in a reply
01-13-2020, 04:03 PM
Post: #2
RE: linear mode (Entry: algebraic)
(01-13-2020 03:25 PM)compsystems Wrote:  Hi. Good morning

The following code can be entered directly on the entry line, but in linear mode (Entry: algebraic) mode why?
//deltalist(time(fract1(320,240,10)));
fract1(320,240,10)

Why not? In RPN mode, you'd enter the parameters on the stack then call the function.

320
ENTER
240
ENTER
10
ENTER
fract1()

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
01-13-2020, 07:00 PM
Post: #3
RE: linear mode (Entry: algebraic)
(01-13-2020 03:25 PM)compsystems Wrote:  The following code can be entered directly on the entry line, but in linear mode (Entry: algebraic) mode why? Failure in textbook mode

I have tried it in both modes and they work without problems. FW 2019 11 20 BETA
Have you tried restoring the Home and CAS settings? That code should work smoothly with a default setting.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
01-13-2020, 11:49 PM (This post was last modified: 01-14-2020 02:46 AM by compsystems.)
Post: #4
RE: linear mode (Entry: algebraic)
The code works well and the function is well defined only in Algebraic mode.

I just found the problem. When the function is defined from the input line and when this input mode (textbook) the comments are interpreted as double division // -> ÷÷

I hope that the problems that are reported are solved, the history view has problems just like the input line.
[Image: hpprime_entryline_textbookmode_bug00_imagen00.png]

Solution interpret double // as a comment, also interpret the symbols # and © as a comment
Find all posts by this user
Quote this message in a reply
01-14-2020, 12:31 AM
Post: #5
RE: linear mode (Entry: algebraic)
Acabo de entender tu punto, haces cosas extrañas xD.
Pues sí, ciertamente para trabajar perfectamente en el CAS se debe cambiar a modo algebraico, ya que Libro de texto adiciona caracteres para el formato, eso es algo normal y es una limitación esperada.

Estaba probando los códigos desde #cas #end en un contenedor de programa, te recomendaría que trabajes directamente ahí.


I just understood your point, you do strange things xD.
Well yes, certainly to work perfectly in the CAS must be changed to algebraic mode, since Textbook adds characters to the format, that is normal and is an expected limitation.

I was testing the codes from #cas #end in a program container, I would recommend that you work directly there.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
01-14-2020, 02:40 AM (This post was last modified: 01-14-2020 08:37 PM by compsystems.)
Post: #6
RE: linear mode (Entry: algebraic)
It is easier to copy a code made in an external editor or copy it from a website and paste it directly into the calculator (simulator) input line, instead of going to the calculator's program editor, due to its small screen limitation. The problem It is solved by working in linear mode but it is necessary to be constantly changing to pretty print (Text book), another solution is to previously remove the comments of each code to be defined, but the most practical solution is that the interpreter of the input line knows how to differentiate the operator division / of a commentary //

and even the definition fails if you enter from the variable editor
[shift]+[mem] + CAS Vars

using / * and * / also fails
PHP Code:
function fract(X_,Y_,Nmax/* Mandelbrot fractal, not using symmetry. */
  
local x,y,z,c,j,w,h,res1,res2;
  
freeze;
  
w:=2.7/X_;
  
h:=-1.87/Y_;
  
res1:=[]; 
  
Y_:=Y_-1;
  for 
y from 0 to Y_ do
    
c:=-2.1+i*(h*y+0.935);
    for 
x from 0 to X_-do
      
z:=0;
      for 
j from 0 to Nmax-do
        if 
abs(z:=z^2+c)>2 then break; fi;
      
od;
      
res1.append(pixon_p(x,y,126*j+2079));
      
c:=c+w;
    
od;
  
od;
  
//return res1:; 
ffunction 
Find all posts by this user
Quote this message in a reply
Post Reply 




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