Re: A question on Newton's Method
- From: Dave Seaman <dseaman@xxxxxxxxxxxx>
- Date: Sun, 3 Apr 2005 19:19:00 +0000 (UTC)
On Sun, 3 Apr 2005 12:31:41 -0600, James Van Buskirk wrote:
> "Jon Harrop" <usenet@xxxxxxxxxxxxxx> wrote in message
> news:42500867$0$63445$ed2e19e4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>> What is Lisp-like about Mathematica and OCaml?
> They are equally incomprehensible.
>> Yes it does:
>> In[1]:= f[x_] = x^3 - x - 1
>> Out[1]= -1 - x + x^3
>> In[2]:= D[f[x], x]
>> Out[2]= -1 + 3 x^2
> No, the right context is:
> f[x_] := x^3-x-1
> fp[x_] := D[f[x],x]
> Plot[fp,{x,-1,2}]
> Which, unless they changed Mathematica recently, doesn't
> do anything useful.
There are two things wrong there. First, if you try Plot[f,{x,-1,2}],
you will find that it doesn't do anything useful, either. The first
message is
Plot::plnr : f is not a machine-size real number at x = -2.
This should be a clue that what you really wanted to do was
Plot[f[x],{x,-1,2}], since f[x] is a number but f is a function.
The Plot function expects something that evaluates to a number as its first
argument.
Second, you could have plotted the derivative by using Plot[f'[x],{x,-2,1}].
If you insist on using the D[f[x],x] syntax, then you need to use
delayed assignment (:=) instead of immediate assignment (=). The
following works:
In[1]:= f[x_] := x^3-x-1
In[2]:= fp[x_] = D[f[x],x]
2
Out[2]= -1 + 3 x
Then you could have plotted using D[fp[x],{x,-2,1}].
--
Dave Seaman dseaman@xxxxxxxxxx
Rosen Center for Advanced Computing YONG 517
http://www-rcd.cc.purdue.edu/~dseaman/ Phone: (765) 496-8218
.
- Follow-Ups:
- Re: A question on Newton's Method
- From: Dana
- Re: A question on Newton's Method
- References:
- A question on Newton's Method
- From: David M
- Re: A question on Newton's Method
- From: Jon Harrop
- Re: A question on Newton's Method
- From: beliavsky
- Re: A question on Newton's Method
- From: James Van Buskirk
- Re: A question on Newton's Method
- From: Roman Werpachowski
- Re: A question on Newton's Method
- From: Jon Harrop
- Re: A question on Newton's Method
- From: James Van Buskirk
- A question on Newton's Method
- Prev by Date: Re: A question on Newton's Method
- Next by Date: Re: can somebody verify this C program which calls dsaupd_ ? (longish)
- Previous by thread: Re: A question on Newton's Method
- Next by thread: Re: A question on Newton's Method
- Index(es):
Relevant Pages
|
Loading