[Request] Control of algebraic expressions CAS

06082016, 11:48 AM
(This post was last modified: 06082016 08:56 PM by compsystems.)
Post: #1




[Request] Control of algebraic expressions CAS
1: In the first version of the CAS of hpprime, I suggested control the exit (simplify none, minimum, maximum), my request was accepted, to port some good programs that I have, I need also the output controlled from a program
simplifyFlag (arg); arg = 0 > none arg = 1 > minimum arg = 2 > maximum 2: also I need entries are not rewritten or simplified for example, the followings line of code, the logic says must be true and not false getOperator:=0; _________________________ part(x^(1/2),getOperator)=="^"; > true ok ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ part(√(x),getOperator)=="√"; > false ? ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ part(1/x),getOperator)=="/"; > false ? ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ part(inv(x),getOperator)=="inv"; > true ok ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ part(cot(x)),getOperator)=="cot"; > false ? ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ part(sec(x)),getOperator)=="sec"; > false ? sec(x)=1/cos(x) ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ part(asec(x)),getOperator)=="asec"; > false ? ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ part(acos((1/x)),getOperator)=="acos"; > true ok ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ part((x^3/x^2),0))=="/"; > false ? ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ 

06082016, 12:58 PM
Post: #2




RE: [Request] Control of algebraic expressions CAS
sqrt(x) is evaled to pow(x,1/2) and 1/x to inv(x)


06082016, 01:50 PM
(This post was last modified: 06082016 02:33 PM by compsystems.)
Post: #3




RE: [Request] Control of algebraic expressions CAS
expressions rewrite alters the domains of expressions in many cases, rewrite the expressions is difficult to identify entry
fabulous if you can include a flag, so that the entries are not evaluated, at least in xcas for example I want to know what the numerator and denominator of the following expression 'x^3/x^2', to make a symbolic derivation step as didactic project from my university, unfortunately this is evaluated as X =( the following code will never be executed, the CAS hpprime is good, but does not allow me to do I want, with simple improvements could be the best CAS on calculators, the hp48/50 calculator retains the inputs to run obj> that is similar to PART function (see PART FUNCTION on HP48/50) http://www.hpmuseum.org/forum/thread6377.html) if (operator=="/") then Return (part2*diff_table(part1,var)part1*diff_table(part2,var))/(part2^2); end; ∂(x^3/x^2,x) > ((x^2*∂(x^3,x))(x^3*∂(x^2,x)))/x^2^2 > 1 Code: 

06082016, 07:18 PM
Post: #4




RE: [Request] Control of algebraic expressions CAS
quote() prevents evaluation.


06082016, 08:55 PM
(This post was last modified: 06082016 09:10 PM by compsystems.)
Post: #5




RE: [Request] Control of algebraic expressions CAS
very well
but It requires placing parenthesis '()' IT IS A PROBLEM OF HISTORY VIEW? please follow the following... simplify maximum, '' = [()] KEY _________________________ x^3/x^2 input returns x^3/x^2 , outpu returns x OK ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ _________________________ 'x^3/x^2' returns ERROR ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ with '()' _________________________ '(x^3/x^2)' input returns 'x^3/x^2' OK ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ also if I write quote (x^3/x^2) [enter], then under the input, to entry line also generates an error 

06082016, 09:10 PM
Post: #6




RE: [Request] Control of algebraic expressions CAS
(06082016 08:55 PM)compsystems Wrote: but It requires placing parenthesis '()' IT IS A PROBLEM OF HISTORY VIEW? No, it is a problem of ' being used for "stop evaluation by quoting the object" (legacy HP usage) and ' being used for taking a derivative (CAS useage). It works fine provided you aren't touching your ' directly. Add a space before/after and your are fine. Other simple solution is to not alloy x^2' as syntax for a derivative... : TW Although I work for HP, the views and opinions I post here are my own. 

06082016, 09:13 PM
(This post was last modified: 06082016 09:27 PM by compsystems.)
Post: #7




RE: [Request] Control of algebraic expressions CAS
try again
quote (x^3 / x^2) [enter] '(x^3/x^2)' ok then up to history and copy the entry into the input line [enter] > ERROR SINTAX '(x^3/x^2') this moving a quotation mark (right) outside the brackets '(x^3/x^2') your agree with the problem? 

06082016, 09:31 PM
Post: #8




RE: [Request] Control of algebraic expressions CAS
including a space at the beginning works, but to copy the expression to the input line fails
' + [SPC] + x^3/x^2 + ' [ENTER] '(x^3/x^2)' ok then up to history and copy the entry into the input line [enter] > ERROR SINTAX '(x^3/x^2') 

06082016, 10:12 PM
(This post was last modified: 06082016 10:20 PM by compsystems.)
Post: #9




RE: [Request] Control of algebraic expressions CAS
for Bernard
getOperator:=0; part1:=1; part2:=2; part(x^3/x^2); > part(x^3 * 1/x^2) > returns 2 OK part(x^3/x^2,getOperator); > part(x^3 * 1/x^2,0) > returns "*" OK part(x^3/x^2,part1); > part(x^3 * 1/x^2, 1) > returns x^3 OK part(x^3/x^2,part2); > part(x^3 * 1/x^2, 2) > returns 1/x^2 OK now part(quote(x^3/x^2)); > part( '(x^3 / x^2)' ); > returns 2 OK part(quote(x^3/x^2),getOperator); > part( '(x^3 / x^2)', 0 ); > returns "/" OK OK part(quote(x^3/x^2),part1); > part( '(x^3 / x^2)', 1 ); > returns x^3 OK part(quote(x^3/x^2),part2); > part( '(x^3 / x^2)', 2 ); > returns x^2 OK but expr1:=quote(x^3/x^2) ; part(expr1); > part( '(x^3 / x^2)' ) > returns 2 OK part(expr1,getOperator); > part( '(x^3 / x^2)', 0 ); > returns "*" ??????????? part(expr1,part1); > part( '(x^3 / x^2)', 1 ); > returns x^3 OK part(expr1,part2); > part( '(x^3 / x^2)', 2 ); > returns 1/x^2 ??????????? 

06092016, 05:44 AM
Post: #10




RE: [Request] Control of algebraic expressions CAS
Evaluation replaces division by *inv()
For quoting, you can use the quote() function to avoid confusion with ' derivative 

06092016, 10:45 AM
(This post was last modified: 06092016 10:46 AM by compsystems.)
Post: #11




RE: [Request] Control of algebraic expressions CAS
quote apparently is not working
Try this again and tells me within a program ... getOperator:=0; part1:=1; part2:=2; expr1:=quote(x^3/x^2) ; part(expr1); >returns 2 OK part(expr1,getOperator); > returns "*" ??? must be "/" part(expr1,part1); > returns x^3 OK part(expr1,part2); > returns 1/x^2 ??? ??? must be x^2 

06092016, 10:58 AM
Post: #12




RE: [Request] Control of algebraic expressions CAS
That's because part does not quote it's arguments, they are evaluated.


06092016, 11:04 AM
(This post was last modified: 06092016 11:55 AM by compsystems.)
Post: #13




RE: [Request] Control of algebraic expressions CAS
but this makes useless the QUOTE command, the expression must be preserved, which proposes solution to code my problem?, it is possible with the CAS language of HPprime or not?
the idea is to store the math expressions as identifiers, they are part of the arguments of a function, also as inserted an expression into an argument if this can change 

06092016, 11:59 AM
Post: #14




RE: [Request] Control of algebraic expressions CAS
You should not try to prevent evaluation and live with the fact that some operations are rewritten differently after evaluation. Think of *inv() as a division, +neg() as a substraction and pow(.,1/2) as a sqrt. This should not change much a derivation program, in fact there are a little less rules to write.


06092016, 12:20 PM
(This post was last modified: 06092016 12:42 PM by compsystems.)
Post: #15




RE: [Request] Control of algebraic expressions CAS
sorry for my bad English, I hope you can understand
in fact there are a little less rules to write. >> it is true, it is possible for many cases, the idea is to show step by step the partial derivation for program educational, not intend to show the final answer, the only way is keeping the entry as entered, for example: ∂(x^3/x^2,x) > "((x^2*∂(x^3,x))(x^3*∂(x^2,x)))/x^2^2" y not "1" the QUOTE instruction loses all his power, when the argument is an identifier that contains a symbolic expression. [challenge] please can improve your command at least xcas? QUOTE (expr) > 'expr' I think adding a new data type type ('expr') > DOM_unmodifiedSYMBOLIC I think that would be the only "cas" that allow you to manipulate expressions, ideal for developing programs step by step, I want to write programs similar to those that are in http://www.tinspireapps.com but free 

06092016, 02:23 PM
Post: #16




RE: [Request] Control of algebraic expressions CAS
But you can already write that kind of programs. It will just require adaptations, if you want to recognize a quotient for example you must first find a root node * then look in the arguments for an inv, and if you find one (or more) collect them into what will be your denominator. For sqrt, you don't have anything special to do, the rule for pow is OK (it is also for *inv() but this will not be exactly the rule that is usually teached, at least in France).


06092016, 06:32 PM
Post: #17




RE: [Request] Control of algebraic expressions CAS
What am I doing wrong so that the following code does not work?
Code: #cas prg_cas((x^3/x^2)) [ENTER] 

06102016, 04:46 AM
Post: #18




RE: [Request] Control of algebraic expressions CAS
you can't use quote on a variable name you want to evaluate.


06102016, 06:33 AM
Post: #19




RE: [Request] Control of algebraic expressions CAS
You shoud use part(eval(.,1),.)
for example a:=quote(sqrt(x)); part(eval(a,1),0); will return sqrt 

06102016, 03:27 PM
(This post was last modified: 06102016 07:30 PM by compsystems.)
Post: #20




RE: [Request] Control of algebraic expressions CAS
I can not find documentation of the EVAL command, which means the second argument of EVAL
part( eval(a,1), 0); The following code, why not call QUOTE to xpr ID or argument of p1(xpr)? Code:


« Next Oldest  Next Newest »

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