Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[49G] multiple algebraic substitutions fast

2 views
Skip to first unread message

Tom Sears

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to
Assume an algebraic in level 2 and a list
of substitutions in level 1:

'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

Virgil

unread,
Jul 17, 2000, 3:00:00 AM7/17/00
to

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

Tom Sears

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to

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

Carsten Witzel

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
Tom Sears <toms...@sockets.net> wrote:
: Assume an algebraic in level 2 and a list
: of substitutions in level 1:

: '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

Tom Sears

unread,
Jul 18, 2000, 3:00:00 AM7/18/00
to
Carsten Witzel wrote:

> '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

Máximo Castañeda

unread,
Jul 19, 2000, 3:00:00 AM7/19/00
to
Carsten Witzel escribió:

> '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'}

0 new messages