HP Forums
Solution to the problem of pre-assigned variables to 0 - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Solution to the problem of pre-assigned variables to 0 (/thread-11663.html)



Solution to the problem of pre-assigned variables to 0 - compsystems - 10-25-2018 06:20 PM

Solution to the problem of pre-assigned variables A, ... Z, Z0, ..., Z9, F0, F9, ..., V0, ..., V9 etc. to 0

Hello HPPrimeTEAM and users, one of the difficulties of the HPPrime calculator, is that there is no integration between CAS and NUM/HOME mode and especially in applications, since they are using predefined variables, in addition students have problems in differentiating X with x, since X is predefined to zero, they always call me, I do not get what I expected, another student asks me if X is set to zero, because when creating the function does not evaluate it.

There is no consistency in the hpprime system

X [enter] returns 0
F1(X) := 8 * X - 5 This should return -5
solve((right(F1)) = 0,X,'=') returns [] // synonym of no solution.


x:=0 [enter] returns 0
assume(x,symbol) // Remove the value of 0, changing the data type to symbolic
x [enter] returns x
F10(x) := 8 * x - 5

One solution that I propose is that the variables are predefined with 'noValue' instead of zero, in this way

X + 3 [enter] in NUM/Home mode returns "Syntax error" // ok, because it can not evaluate X, X has symbolic value
X + 3 [enter] in CAS mode returns X + 3 // ok because X is considered a symbolic variable

then:
X:=5
X + 3 [enter] in NUM/Home mode returns 8
X + 3 [enter] in CAS mode returns 8

restore(X) [enter] returns 'noValue'
X + 3 [enter] in NUM/Home mode returns "Syntax error" // ok

What do you think of this idea?

Another Case:

V1(X,Y) := (X²/3 - Y²/5 = 1); [enter] returns (X,Y)->(((X^2/3)-(Y^2/5))==1) // error
(X,Y)->((X^2/3)-(Y^2/5))=1 // ok
right(V1) [Enter] returns 0 // (0 synonymous of false), error because although ((X^2/3)-(Y^2/5) == 1 is false, this should not be compared, it must be interpreted as equation (X,Y) -> ((X^2/3)-(Y^2/5))=1

I do not use x in lowercase because the internal user variable V1 requires it [SYMB KEY], I also want to perform analytical [CAS], graphical [PLOT KEY] and numeric analyzes [NUM KEY] using the same definition.

Thanks


RE: Solution to the problem of pre-assigned variables to 0 - compsystems - 11-11-2018 01:57 PM

Hello, in the first code using quotation marks the expression is not evaluated, that is to say it is kept symbolic.


PHP Code:
#cas
prg01(  ):=
    
begin
        
PRINT; 
        print(   
'X²/3 - Y²/5 = 1'  );  // ' Do not evaluate
        
print(   //1  );  //  X -> 0
        
return 'X²/3 - Y²/5 = 1' ;
    
end;
#end 
prg01( ) [enter]
show
X²/3 - Y²/5 = 1
0=1


in the second code, assume X as symbolic, there is no need to use ' '
this same procedure should work assuming X as noValue

PHP Code:
#cas
    
prg02(  ):=
    
begin
        local X
Y
        
assume(Xsymbol); //  assume X as symbolic
        
assume(Ysymbol); 
        print( 
//);
        return  
//1;
    
end;
#end 
prg02( ) [enter]
show
X²/3 - Y²/5 = 1


RE: Solution to the problem of pre-assigned variables to 0 - Han - 11-11-2018 06:20 PM

Those variables behave exactly the way they do by design. Rather than trying to change the design (which I highly doubt will ever happen as the HP Prime is several years now in the market), you would be better off using non-system variables for what you want to do.


RE: Solution to the problem of pre-assigned variables to 0 - compsystems - 11-12-2018 09:07 PM

Hello, Han, I do not propose to change the design, but to improve it, with the idea I propose it would be integrated NUM mode (HOME) with CAS MODE, since the idea is to use the same variables for example to expose a graphic analysis [PLOT], analysis numerical [NUM key] with symbolic analysis [CAS], simply defining the type of variable to symbolic (CAS mode) and then restart ([HOME MODE]).

sample:
http://www.hpmuseum.org/forum/thread-11736.html

Likewise MATLAB works, this was born as a numerical software, but they incorporated the symbolic calculation engine (Maple, then MuPAD) and everything operates very well integration between NUM / CAS mode

PHP Code:
x=-50.00015;
=.^ .* .^ 2.*
plot 
(x,y),grid;
= [1, -3, -9,2
r1 roots (p);
syms x;         % assume x as symbolic var
x^3-3*x^2-9*x+
D
=diff(f) % 3*x^2-6*x-