Re: Using results of "Solve"
- To: mathgroup at smc.vnet.net
- Subject: [mg25750] Re: [mg25693] Using results of "Solve"
- From: "Mark Harder" <harderm at ucs.orst.edu>
- Date: Sat, 21 Oct 2000 14:42:58 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Helge,
You are in the same situation as Phillip Gunz, see msg 25658, and the
solutions are the same as I and several others posted yesterday. See Bob
Hanlon's reply [msg 25714].
In my opinion, the solution given by your colleague is not a hack, but
the most straightforward method:
q /. h[m, b] [[2]]
says in effect "replace q with a value given by the rule(s) found in part 2
of h[m,b]", which is exactly what needs to be done.
The second method given in Hanlon's posting is to simply retrieve the
rhs of the rule(s) as part 2 of each rule. The advantage of this method is
that it is straightforward to index a list of solutions-as-rules, should
there be multiple solutions to Solve[], and, for instance, sum them.
Consider:
In[138]:=
rls = {{q -> rhs1}, {q -> rhs2}};
Qsum = Sum[rls[[i, 1, 2]], {i, 1, 2} ]
Out[139]=
rhs1 + rhs2
, which looks to me to be exactly what you want to do.
-mark harder
-----Original Message-----
From: Helge Kreutzmann <helgek at studserv.stud.uni-hannover.de>
To: mathgroup at smc.vnet.net
Subject: [mg25750] [mg25693] Using results of "Solve"
>Hello !
>I have a series of matrices which depend on several parameters. I can
>create those matrices fine and display them. They are called
>
>S[k_,m_,b_,n_]
>
>Now there is an unkown called "q" in the matrix which is evaluated by
>setting the determinant of the matrix zero and solving the resulting
>equation for q:
>
>Solve[Det[S[2, m, b, 2]] == 0, q]
>
>Now I want to use this function. The result is given in a form like:
>{{ q -> rhs1 },{ q -> rhs2}} and so on. I would like now to plot q.
>
>A colleque gave me the following "hack":
>h =.;
>h[m_, b_] := Solve[Det[S[2, m, b, 2]] == 0, q];
>Plot3D[q /. h[m, b] [[2]], {m, 0, 3}, {b, 0, 3}]
>
>Is there a more straightforward way ? Especially I would like to create
>several functions this way and their sum is the resulting function I
>am interested in (actually it's a series).
>
>Regards
>
> Helge
>
>
>