Post Reply 
PART function (TI89, HPPRIME) for HP48/49/50
06-08-2016, 04:03 PM (This post was last modified: 06-08-2016 04:31 PM by Gilles.)
Post: #2
RE: PART function (TI89, HPPRIME) for HP48/49/50
By the way, why not use the OBJ-> command for this ?

Exemple

'SIN(x)+COS(y)' OBJ->

returns on the stack:

4 : 'SIN(x)'
3 : 'COS(y)'
2: 2.
1: +


'SIN(x)' OBJ->

returns on the stack:

3 : 'x'
2: 1.
1: SIN

I think it will be more powerfull and quicker

About your 'dérivative' examples I think you could use the MATCH commands wich are very powerfull and quite 'automatic' for this

AUR :

"Match Pattern Down Command: Rewrites an expression that matches a specified pattern. ↓MATCH rewrites expressions or subexpressions that match a specified pattern 'symbpat'. An optional condition, 'symbcond', can further restrict whether a rewrite occurs. A test result is also returned to indicate if command execution produced a rewrite; 1 if it did, 0 if it did not.


The pattern 'symbpat' and replacement 'symbrepl' can be normal expressions; for example, you can replace .5 with 'SIN(π/6)'. You can also use a “wildcard” in the pattern (to match any subexpression) and in the replacement (to represent that expression).

A wildcard is a name that begins with &, such as the name '&A', used in replacing 'SIN(&A+&B)' with 'SIN(&A)*COS(&B)+COS(&A)*SIN(&B)'.

Multiple occurrences of a particular wildcard in a pattern must match identical subexpressions."

Example 1: .5 { .5 'SIN(π/6)' } ↓MATCH
returns
'SIN(π/6)' to level 2 and 1 to level 1.

Example 2: 'SIN(U+V)' { 'SIN(&A+&B)'
'SIN(&A)*COS(&B)+COS(&A)*SIN(&B)' } ↓MATCH
returns
'SIN(U)*COS(V)+COS(U)*SIN(V)' to level 2 and 1 to level 1.

Example 3: This sequence: 'SIN(5*Z)' { 'SIN(&A+&B)'
'Σ(K=0,&A,COMB(&A,K)*SIN(K*π)*COS(&B^(&A-K)*SIN(&B)^K)'
'ABS(IP(&A))==&A' } ↓MATCH
returns
'Σ(K=0,5,COMB(5,K)*SIN(K*π)*COS(Z^(5-K)*SIN(Z)^K)' to level 2
and 1 to level 1.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: PART function (TI89, HPPRIME) for HP48/49/50 - Gilles - 06-08-2016 04:03 PM



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