       Re: Coding for Mathematica

• To: mathgroup at smc.vnet.net
• Subject: [mg100596] Re: [mg100555] Coding for Mathematica
• From: "David Park" <djmpark at comcast.net>
• Date: Tue, 9 Jun 2009 03:53:20 -0400 (EDT)
• References: <1636751.1244442028734.JavaMail.root@n11>

```I think that the problem may be that you typed in the "In:=" portion of
the statements. Mathematica generates that, you don't need to type it.

Copy and paste the following into your notebook, evaluate, and you will see
the results immediately. (Each statement begins on a new line, but they can
all be in one cell and evaluated all at once.)

(* David Park, 06/08/09 *)
(* Newton's Method *)
f[x_] := x^2 - 2
x = 1.0
For[n = 1, n < 10, n++, {x[n + 1] = x[n] - f[x[n]]/f'[x[n]];
Print[n + 1, "  ", N[x[n + 1], 10]];}]
Plot[f[x], {x, 0, 2}]

David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/

From: FAQneeds [mailto:thegodfather7769 at aol.com]

Im a first time user of Mathematica. So im trying to put in a command
related to Newton's Method. I would just like to know if once im done typing
this command in am i suppose to see the results immediately or do i have go
to something in the program to see the results of my command. Here is the
Code please can anyone tell me what im doing wrong i will be really
grateful:

In :=(*Newton's Method*)
In := f[x_] := x^2 - 2
In := x = 1.0
In := For[n = 1, n < 10, n++,
{x[n + 1] = x[n] - f[x[n]]/f'[x[n]];
Print[n + 1, "  ", N[x[n + 1], 10]];}]
In := Plot[f[x], {x, 0, 2}]

```

• Prev by Date: Re: Why is recursion so slow in Mathematica?
• Next by Date: Re: Polygon Union
• Previous by thread: Re: Coding for Mathematica
• Next by thread: Re: Struggling to figure out the correct coding for a multiple