Message Boards Message Boards

Solve this integration in a loop?

Posted 8 years ago
POSTED BY: Hallo vonMir

Assuming the formula are right, I do the following to make the program (as you wrote it) to work. Starting at the "For loop".

For[i = 1, i < step + 1, i++,

 (*Assigned integration to variable ans to make the next assignemnt \
easier to understand.*)
 ans = FindRoot[
   1/2 Integrate[ell^2, {phi, start, x}] == a*b*Pi/step, {x, 0.1}];
 (*We had solved for x in the previous line, so we need to extract \
the number other wise we would have {x->number}, which can't be \
re-used.*)
 start = x /. ans[[1]];

 (*This is just a debug print. You could assign the answers into a \
list.*)
 Print[i, " ", start]]

Are these the answers your anticipated (i,start) pairs? You can remove the 0.I with the Chop command. (1, 0.401966) (2, 0.727518+0. I) (3, 0.96804+0. I) (4,1.14777+0. I) (5, 1.28976+0. I) (6,1.40974+0. I) (7, 1.51829+0. I)

POSTED BY: Isaac Abraham
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