my problem with FindRoot and Replace
- To: mathgroup@smc.vnet.net
- Subject: [mg11593] my problem with FindRoot and Replace
- From: jeglin@4pi.com (Stefan Jeglinski)
- Date: Tue, 17 Mar 1998 10:43:20 -0500
- Organization: 4pi Analysis
I am solving 2 equations in two unknowns. The equations have a number of
variables that are known, but unrelated to the two I am trying to find.
Because of the complicated nature of the expressions, and for
organizational sanity, I have defined certain parts elsewhere in the
notebook. IOW, I have something like this:
LHS1[n_,k_]:= f1[n,k,e]
RHS1[n_,k_]:= f2[n,k,e]
LHS2[n_,k_]:= Tan[omega]
RHS2[n_,k_]:= f3[n,k,e]
f1, f2, and f3 are explicitly written out, but omega is previously
defined as another function g[e_,q_].
Anyway, for my needs I write FindRoot in these terms:
SolveForNK[a_,b_]:=FindRoot[{
LHS1[n,k]/.{e->a} == RHS1[n,k]/.{e->a},
LHS2[n,k]/.{e->a,omega->g[a,b]} == RHS2[n,k]/.{e->a}},
{n, {1,2}},{k, {3,4}}]
I can then use SolveForNK in further constructs. I know it seems
complicated, but to put f1, f2, and f3 into the FindRoot function
directly is horribly difficult to troubleshoot and keep track of. I may
have left out a few parentheses above. That is not my problem. I've got
all my variables covered. If I write 'omega->2' for example, it works
fine. Likewise, if I beforehand define r=g[a,b] and put in 'omega->r',
this also works fine. There's something about this function g itself as
I'm wanting to use it that doesn't work. I have also tried
LHS2[n_,k_]:= Tan[g[e,q]]
but this doesn't work either. In all cases, the error I get is something
to the effect of:
# - Tan[<<1>>] is not a length 2 list at n=1, k=2.
I'm rethinking the whole way of doing my problem, but the way I have it
above will work well with the rest of my notebook and I prefer it, if I
can get it to work. What exactly is this error indicating, anyway?
Stefan Jeglinski