| New Reply |
While loops in Mathematica |
Share Thread | Thread Tools |
| Nov26-11, 02:40 PM | #1 |
|
|
While loops in Mathematica
I am trying to do some Newton's method-type stuff in Mathematica.
I want to build a While loop that does the following: - Take input r. - Compute some quantity f(r). - Update the value of r to f(r). - Repeat until |g(r)| < C for some fixed constant C. The third (boldfaced) step is the one I'm having trouble with. I don't know how to do this. Can someone help? |
| Nov26-11, 08:10 PM | #2 |
|
|
Something like this?
f[r_]:=r^2; g[r_]:=r-1/100; c=1/20; r=Input["What's r?"];(*Enter something between -1 and 1 *) While[Abs[g[r]]>c, r=f[r]; Print[r] ] If that doesn't give you enough then we need to see what you have already done |
| New Reply |
| Thread Tools | |
Similar Threads for: While loops in Mathematica
|
||||
| Thread | Forum | Replies | ||
| Mathematica Beginner question: Nested loops | Math & Science Software | 6 | ||
| circuit with 2 loops, find the current in one of the loops | Introductory Physics Homework | 2 | ||
| Loops '08 will be in the UK! | Beyond the Standard Model | 13 | ||
| Should Loops '06 be QG '06? | Beyond the Standard Model | 23 | ||
| loops | Introductory Physics Homework | 3 | ||