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

Using equation solutions for additional calculations

0 views
Skip to first unread message

Salmon Egg

unread,
Dec 4, 2009, 4:07:03 PM12/4/09
to
After a hiatus of over a year,I am trying to get back to Maple. While I
still am trying to look up the answer, any help would be appreciated. My
example is from a simple electric circuit but has much broader
situations.

I have a circuit of resistors and an applied voltage V. I set up the
linear equations that describe various loop currents In,
Using solve, I get a solution for the In in terms of V and the various
R's. That is, every solution is in the form

In = V * {a rational function of the R's}

Now, I want to calculate some other algebraic expression such as

Vnew := V + R1*I1 + R2*I2

Instead of getting a new expression in V and the R's, I get back

Vnew := V + R1*I1 + R2*I2

How do I get the solutions already obtained for I1 and I2 to substituted
for I1 and I2 so that the no longer appear explicitly?

Bill

--
An old man would be better off never having been born.

A N Niel

unread,
Dec 4, 2009, 6:35:28 PM12/4/09
to
In article <SalmonEgg-DE8F2...@news60.forteinc.com>,
Salmon Egg <Salm...@sbcglobal.net> wrote:

assign?

Ray Vickson

unread,
Dec 5, 2009, 1:51:43 AM12/5/09
to

There are two ways, at least. Say you have used > sol:=solve(eqs,
{I1,I2});
One way is to issue the command > assign(sol); now I1 and I2 will
have their "solved" values, so won't exist anymore as abstract
symbols. That may be what you want. However, if you want to have the
solutions , say I1s and I2s (while leaving the abstract symbols I1 and
I2 unchanged) you can look at sol. If, for example, it has the form
sol:={I2=formula2, I1=formula1} you can say I1s:=rhs(sol[2]); and
I2s:=rhs(sol[2]); Now I1 and I2 are still available for later use, but
you can use commands like new_so_and_so:=subs
({I1=I1s,I2=I2s},so_and_so) to use the solved values in the expression
so_and_so. If you don't need the unevaluated versions of I1 and I2
anymore, the first way is easiest. Of course, you can then always
restore I1 and I2 to unevaluated status by issuing commands like
I1:='I1';, etc, after you have used them as much as you want. Even so,
it might be advisable to make copies of them, say using J1:=I1, etc.,
before removing the assignments, just so you can use them again if you
find that you have erased them prematurely.

R.G. Vickson

acer

unread,
Dec 5, 2009, 10:07:55 AM12/5/09
to


One way of doing this is to use the so-called "2-argument form" of the
`eval` command.

Suppose that the solution from `solve` is,
> sol := solve(....);
sol := {l1=..expression with V,Ri,
l2=..another expression with V,Ri}

The, you can substitute those values for l1 and l2 into the expression
assigned to Vnew as follows,
> eval( Vnew, sol );
something containing V and Ri, but without l1
and l2

One reason this is popular is that (lists or sets of, or individual)
equations can be re-used many times in this convenient programmatic
way without needing any intermediate assignment to other names.

ps. I quoted the term "2-argument form" since the `eval` command has
yet another 2-argument calling sequence, where the extra argument is a
posint which denotes the level of evaluation to apply. But that's not
relevant here, and the term usually refers to the usage above.

Ray Vickson

unread,
Dec 5, 2009, 10:22:52 PM12/5/09
to

Sorry: that should be rhs(sol[1]).

RGV

Salmon Egg

unread,
Dec 7, 2009, 1:55:58 AM12/7/09
to

<snip>

> How do I get the solutions already obtained for I1 and I2 to substituted
> for I1 and I2 so that the no longer appear explicitly?

In article
<b133b08e-503b-4ebb...@m7g2000prd.googlegroups.com>,


Ray Vickson <RGVi...@shaw.ca> wrote:
> > There are two ways, at least. Say you have used > sol:=solve(eqs,
> > {I1,I2});
> > One way is to issue the command �> assign(sol); now I1 and I2 will
> > have their "solved" values, so won't exist anymore as abstract
> > symbols. That may be what you want. However, if you want to have the
> > solutions , say I1s and I2s (while leaving the abstract symbols I1 and
> > I2 unchanged) you can look at sol. If, for example, it has the form
> > sol:={I2=formula2, I1=formula1} you can say I1s:=rhs(sol[2]); and
> > I2s:=rhs(sol[2]);
>
> Sorry: that should be rhs(sol[1]).
>

In article
<7fd17dff-b74b-4b8f...@20g2000vbz.googlegroups.com>,


acer <ma...@rogers.com> wrote:
> One way of doing this is to use the so-called "2-argument form" of the
> `eval` command.
>
> Suppose that the solution from `solve` is,
> > sol := solve(....);
> sol := {l1=..expression with V,Ri,
> l2=..another expression with V,Ri}
>
> The, you can substitute those values for l1 and l2 into the expression
> assigned to Vnew as follows,
> > eval( Vnew, sol );
> something containing V and Ri, but without l1
> and l2
>
> One reason this is popular is that (lists or sets of, or individual)
> equations can be re-used many times in this convenient programmatic
> way without needing any intermediate assignment to other names.

Thank you and others for the help.

What frustrates me about Maple is its apparent lack of heuristic
insight. In a way, it reminds me of the spaghetti code prevalent in
BASIC and FORTRAN programming before structured programming came onto
the scene. As I get more exposure, I might change my mind.

0 new messages