Message Boards Message Boards

0
|
3047 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Help with code and FindRoot Error

Posted 10 years ago

Hello I'm very new to using mathematica. Basically I was given a code and just have to see if I can get it to run. If someone could look over my code and tell me whats wrong with it and why I'm getting these errors that would be greatly apprecitated.

    gamma[kappa] := Sqrt[(1.5^2 - 1.48^2) (k i)^2 - kappa^2];
    beta = Table[
       Re [N [Sqrt [
          1.5^2 (k i)^2 - (FindRoot[
               Tan[h kappa /2] == gamma[kappa]/kappa, {kappa, 100}][[1, 
               2]])^2]]], {i, 1, 60, 1}];
    ListPlot[beta]
    deltabeta = 
      Table[ (beta[[i]] - beta[[i - 1]])/(500 Pi), {i, 2, 60, 1}];
    ListPlot[deltabeta, PlotRange -> {1.48, 1.505}]
    doubledeltabeta = Table[-((k i)^2 / (6 Pi))
        (deltabeta[[i]] - deltabeta[[i - 1]])/(500 Pi), {i, 2, 59, 1}];
    ListPlot[doubledeltabeta]

FindRoot::nlnum: The function value {-0.01 Sqrt[-10000.+0.0596 k^2]+Tan[50. h]} is not a list of numbers with dimensions {1} at {kappa} = {100.}. >>
FindRoot::nlnum: The function value {-0.01 Sqrt[-10000.+0.2384 k^2]+Tan[50. h]} is not a list of numbers with dimensions {1} at {kappa} = {100.}. >>
FindRoot::nlnum: The function value {-0.01 Sqrt[-10000.+0.5364 k^2]+Tan[50. h]} is not a list of numbers with dimensions {1} at {kappa} = {100.}. >>
General::stop: Further output of FindRoot::nlnum will be suppressed during this calculation. >>
POSTED BY: John Shilling

The message is due to h and k not being numbers; FindRoot requires a numerically valued function.

POSTED BY: Ilian Gachevski
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract