MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: solution of equation

  • To: mathgroup at
  • Subject: [mg116400] Re: solution of equation
  • From: Bill Rowe <readnews at>
  • Date: Sun, 13 Feb 2011 03:07:28 -0500 (EST)

On 2/12/11 at 5:21 AM, pi.munik at (Piotr Munik) wrote:

>I want to solve equation like this:

>L := 100; h := 1;

While the above is valid Mathematica syntax, it isn't the best
choice. First, there are a variety of built-in symbols in
Mathematica that are named with a single uppercase letter. So,
even though there currently is no built-in symbol L, it is a
good idea to not use single upper case letters as variables.

Second, SetDelayed (:=) delays assignment until the symbol is
used. What this means in algorithms such as FindRoot that supply
numeric values to the variables, is that every time FindRoot
samples your function it re-evaluates L and h. Now for simple
assignments such as what you are using, the evaluation time
isn't going to be significant. But, it would be better to use
Set so that the assignment is done once rather than repeatedly.

>n Tan[n L] == h

>I need roots of this equation in a list form

You are aware there are infinitely many roots for this equation
and FindRoot will only find one right?

>but I have a problem. I try findfoot

>FindRoot[n Tan[n L] == h, {n, 0.01}]

>but it's not good

What is not good? If I copy and past from your post I get

In[10]:= L := 100; h := 1;

In[11]:= FindRoot[n Tan[n L] == h, {n, 0.01}]

Out[11]= {n->0.202208}

In[12]:= n Tan[n L] /. %

Out[12]= 1.

So, FindRoot is clearly doing what it is intended to do, find a
root for your equation.

Did you need FindRoot to find the root nearest n = 0.01? If so, try

In[13]:= FindRoot[n Tan[n L] == h, {n, 0.01, .0156}]

Out[13]= {n->0.0155525}

  • Prev by Date: Re: Applying function only if the output is positive
  • Next by Date: Re: Nonorthogonal Eigenvectors
  • Previous by thread: Re: solution of equation
  • Next by thread: NDSolve Unable to find initial conditions that satisfy the residual function