'A=B+C'
{ 'A=X' 'B=2*Y' 'D=W' }
The following commands will apply all of the
applicable substitutions to the algebraic.
+ << SUBST >> STREAM
The result of the example is 'X=2*Y+C'.
Thanks to Peter Karp for the original problem
which got me thinking about this.
Sorry if this has been posted before.
Tom
The same thing can be done with the built in "where" command, using the
vertical stroke "|", found at right shift TOOL key.
'A=B+C' on level 2 and
{ 'A' 'X' 'B' '2*Y' 'D' 'W' } on level 1 then
| ENTER
will return 'X=2*Y+C'
The substitution list contains paired entries, first the variable to be
replaced and then the replacement.
The differences between the SUBST command and the "where" command,"|",
are that:
(1) the SUBST command can use an indirect equation of form 'SIN(X)=Y' to
replace X with ASIN(Y) whereas the "WHERE" command must have the
variable name, X, as its first argument.
(2) the SUBST command only does one substitution whereas the "where"
command, "|", will do as many as there are pairs in its list.
--
Virgil
vm...@frii.com
Virgil wrote:The same thing can be done with the built in "where" command,
using the
> vertical stroke "|", found at right shift TOOL key.
>
> 'A=B+C' on level 2 and
> { 'A' 'X' 'B' '2*Y' 'D' 'W' } on level 1 then
> | ENTER
> will return 'X=2*Y+C'
>
> The substitution list contains paired entries, first the variable to be
> replaced and then the replacement.
>
Good point and your method also works on the hp48 series.
>
> The differences between the SUBST command and the "where" command,"|",
> are that:
> (1) the SUBST command can use an indirect equation of form 'SIN(X)=Y' to
> replace X with ASIN(Y) whereas the "WHERE" command must have the
> variable name, X, as its first argument.
The SUBST method also seems to allow an expression on the
left of the equal sign in the substitution expressions, at least in
rom 1.19-3, but I have not explored this.
> (2) the SUBST command only does one substitution whereas the "where"
> command, "|", will do as many as there are pairs in its list.
(Hence the STREAM command in my suggestion.)
One further difference. On the hp49g (unlike the hp48) the
"where" command seems to do an automatic simplification
while SUBST just does the substitution. This may favor one
method over the other depending on the application.
Tom
: 'A=B+C'
: { 'A=X' 'B=2*Y' 'D=W' }
: The following commands will apply all of the
: applicable substitutions to the algebraic.
: + << SUBST >> STREAM
: The result of the example is 'X=2*Y+C'.
'A=B+C'
[ 'A=X' 'B=2*Y' 'D=W' ] SUBST
does the same.
--
Carsten Witzel -- E-Mail: Carsten...@Uni-Duesseldorf.de
> 'A=B+C'
> [ 'A=X' 'B=2*Y' 'D=W' ] SUBST
>
> does the same.
Thanks Carsten.
Darn. I'd pay a bundle for thorough documentation
on all the commands and legal arguments. MAP is
another one that apparently works with an array,
but it is only documented for a list in the AUG.
Is this functionality intentional (I hope) or an
accident that might disappear with a future rom
update?
By the way, SUBST seems to work differently
for the two methods in some cases:
'A=B+C'
[ 'A=X' 'B=2*Y' 'SIN(C)=Z' ]
SUBST
gives 'X=2*Y+C' but
'A=B+C'
{ 'A=X' 'B=2*Y' 'SIN(C)=Z' }
+ << SUBST >> STREAM
gives 'X=2*Y+ASIN(Z)'. Which one is the intended
behavior?
Tom
> 'A=B+C'
> [ 'A=X' 'B=2*Y' 'D=W' ] SUBST
>
> does the same.
I recall having used SUBST in a | way, but using a vector or a matrix:
'A=B+C'
[ A X B '2*Y' D W ] SUBST @ or [[ A X B '2*Y' D W ]] SUBST, I don't
remember.
BTW, you can use a higher dimension matrix with SUBST, and it works as
list processing:
'A=B+C'
[[A X B Y] [B X C T]] SUBST
yields
{'X=Y+C' 'A=X+T'}