# [Maxima] simple derivative function question

sen1 at math.msu.edu sen1 at math.msu.edu
Wed Jan 17 15:56:52 CST 2007

```As Stavros noted, I actually meant that to write the function.

g(x):= diff(f(x),x);

I would like to understand the difference between the functions g(x)
and h(x) defined below.  In particular, lines
(%i3) and (%i6) seem to produce the same output to the screen, but
give different outputs when \$x\$ is set to be 2.

TIA,
-sen

(%i1) f(x):= x^3;
3
(%o1)                             f(x) := x
(%i2) h(x):= ''(diff(f(x),x));
2
(%o2)                            h(x) := 3 x
(%i3) h(x);
2
(%o3)                                3 x
(%i4) h(2);
(%o4)                                 12
(%i5) g(x):= diff(f(x),x);
(%o5)                        g(x) := diff(f(x), x)
(%i6) g(x);
2
(%o6)                                3 x
(%i7) g(2);

Non-variable 2nd argument to diff:
2
#0: g(x=2)
-- an error.  To debug this try debugmode(true);

On Wed, 17 Jan 2007, Robert Dodier wrote:

> On 1/17/07, sen1 at math.msu.edu <sen1 at math.msu.edu> wrote:
>
>> 1. What does maxima actually do with the next definition?
>>
>>    (A)   f(x):= diff(f(x),x)
>
> The body of a function defined by := is neither evaluated nor
> simplified. Each time the function is called, the body is
> evaluated and simplified.
>
> This particular function definition is going to cause a stack overflow
> when it is called (from recursively calling f).
>
>> 2. What is the meaning of the following words in the manual on "diff"
>>
>>       The noun form of `diff' is required in some contexts, such as
>>       stating a differential equation.
>>
>>     What is a "noun form" in maxima?
>
> A noun is a function which isn't called even if it could be.
> E.g. foo(x) := x^2; foo(10) => 100, but 'foo(10) => 'foo(10).
> This is useful because functions manipulating expressions can
> look for specific function names (e.g. foo) and take special action
> when they appear. In the case of differential equations, you don't
> want Maxima to actually try to compute diff(y, x), you just want
> dy/dx to float around as an unevaluated symbol.
> So you write 'diff(y, x).
>
> Hope this helps
> Robert
>

--
---------------------------------------------------------------------------
| Sheldon E. Newhouse            |    e-mail: sen1 at math.msu.edu           |
| Mathematics Department         |       				   |
| Michigan State University      | telephone: 517-355-9684                |
| E. Lansing, MI 48824-1027 USA  |       FAX: 517-432-1562                |
---------------------------------------------------------------------------
```