edA-qa mort-ora-y | 2 Jan 15:49 2005

Defining derivative functions.

I need a way to define a function and its derivative as functions.  That 
is, I want to accomplish what one might expect the following would do:

f(x) := q*x^2 + r;
df(x) := diff( f('x), 'x );

But if you do this the x variable in df(x) is in no way related to the x 
variable in f(x).  If you try this:

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

It fails as obviously you are differentiating with whatever is passed to 
df(x), not the symbolic variable x anymore.

I even tried using an intermediary:

eq : q*x^2 + r;
f(x) := eq;
df(x) := diff( eq, 'x );

But this also didn't work.

So, how do I do this, that is, create a function and then create its 
derivative (also as a function).

--

-- 
edA-qa mort-ora-y
Idea Architect
http://disemia.com/
(Continue reading)

Albert Reiner | 2 Jan 16:22 2005
Picon

Re: Defining derivative functions.

[edA-qa mort-ora-y <eda-qa <at> disemia.com>, Sun, 02 Jan 2005 15:49:41 +0100]:
> I need a way to define a function and its derivative as functions.
> That is, I want to accomplish what one might expect the following
> would do:
> 
> f(x) := q*x^2 + r;
> df(x) := diff( f('x), 'x );

One way if it is acceptable to differentiate only once (so that a
redefinition of f(x) won't be detected):

    (%i1) f(x) := q*x^2 + r;

                                              2
    (%o1)                          f(x) := q x  + r
    (%i2) df(x) := ''(block([x], diff(f(x), x)));

    (%o2)                           df(x) := 2 q x
    (%i3) df(1);

    (%o3)                                 2 q

(The block is a safeguard against a possible value of x:

    (%i4) x: 3;

    (%o4)                                  3
    (%i5) df(x) := ''(block([x], diff(f(x), x)));

    (%o5)                           df(x) := 2 q x
(Continue reading)

Donna and Dan Stanger | 2 Jan 16:28 2005
Picon

Re: Defining derivative functions.

Use funmake.
(C1)      f(x) := q*x^2 + r;
(D1)      f(x) := q x^2  + r

(C2) df:funmake(lambda,[[x],diff(f(x),x)]);
(D2)     LAMBDA([x], 2 q x)
(C3) df(2);
(D3)     4 q

edA-qa mort-ora-y wrote:

> I need a way to define a function and its derivative as functions.  That
> is, I want to accomplish what one might expect the following would do:
>
> f(x) := q*x^2 + r;
> df(x) := diff( f('x), 'x );
>
> But if you do this the x variable in df(x) is in no way related to the x
> variable in f(x).  If you try this:
>
> df(x) := diff( f(x), x );
>
> It fails as obviously you are differentiating with whatever is passed to
> df(x), not the symbolic variable x anymore.
>
> I even tried using an intermediary:
>
> eq : q*x^2 + r;
> f(x) := eq;
> df(x) := diff( eq, 'x );
(Continue reading)

Viktor T. Toth | 2 Jan 16:49 2005

RE: Defining derivative functions.

I think what you're looking for is define():

(%i1) f(x):=q*x^2+r;
                                          2
(%o1)                          f(x) := q x  + r
(%i2) define(df(x),diff(f(x),x));
(%o2)                           df(x) := 2 q x
(%i3) df(a);
(%o3)                                2 a q

That said, one of your comments suggests that you may always be wanting to
differentiate with respect to the symbolic variable x, so that you don't get
this result:

(%i4) df(x^2);
                                         2
(%o4)                               2 q x

In this case, the solution is even simpler:

(%i5) df(x):=diff(f(x),'x);
(%o5)                       df(x) := diff(f(x), 'x)
(%i6) df(x^2);
                                         3
(%o6)                               4 q x

But notice that

(%i7) df(a);
(%o7)                                  0
(Continue reading)

Nikos Apostolakis | 2 Jan 19:41 2005

Re: Defining derivative functions.

On Sun, Jan 02, 2005 at 03:49:41PM +0100, edA-qa mort-ora-y wrote:
> I need a way to define a function and its derivative as functions.  That 
> is, I want to accomplish what one might expect the following would do:
> 
> f(x) := q*x^2 + r;
> df(x) := diff( f('x), 'x );
> 
> But if you do this the x variable in df(x) is in no way related to the x 
> variable in f(x).  If you try this:
> 
> df(x) := diff( f(x), x );
> 
> It fails as obviously you are differentiating with whatever is passed to 
> df(x), not the symbolic variable x anymore.
> 
> I even tried using an intermediary:
> 
> eq : q*x^2 + r;
> f(x) := eq;
> df(x) := diff( eq, 'x );
> 
> But this also didn't work.
> 
> So, how do I do this, that is, create a function and then create its 
> derivative (also as a function).
> 
> 

I can't give exact refference, but I had asked a similar
question in the past, and the kind folks in this list gave
(Continue reading)

edA-qa mort-ora-y | 2 Jan 22:19 2005

Re: Defining derivative functions.

Thanks to the feedback, I'll just follow up and provide my final 
solution (I chose the easiest method, that is, least amount of typing ;)

eq : s*x^3 + t*x^2 +u*x + v $
define( f(x), eq ) $
define( df(x), diff( eq, 'x ) ) $

edA-qa mort-ora-y wrote:
> I need a way to define a function and its derivative as functions.  That 
> is, I want to accomplish what one might expect the following would do:
> 
> f(x) := q*x^2 + r;
> df(x) := diff( f('x), 'x );
> 
> But if you do this the x variable in df(x) is in no way related to the x 
> variable in f(x).  If you try this:
> 
> df(x) := diff( f(x), x );
> 
> It fails as obviously you are differentiating with whatever is passed to 
> df(x), not the symbolic variable x anymore.
> 
> I even tried using an intermediary:
> 
> eq : q*x^2 + r;
> f(x) := eq;
> df(x) := diff( eq, 'x );
> 
> But this also didn't work.
> 
(Continue reading)

Daniel van Leeuwen | 4 Jan 20:51 2005
Picon
Picon

Problems with font set / cursor keys do't work anymore

Hi there!

Since upgrading my maxima to version 5.9.1 the cursor keys won't work anymore. 
I cant scroll through the lines and the command history isn't accessible 
anymore. I wonder, how I can fix this problem, I was unable to find any 
information yet.

Im running Fedora Core 2 linux, using keyboard style german/latin-1/nodeadkeys 
and my /etc/sysconfig/i18n file consists of the following lines:

LANG="de_DE"
SUPPORTED="de_DE.UTF-8:de_DE:de"
SYSFONT="latarcyrheb-sun16"

Are there other german users reading this list, or does somebody know what to 
do?

Would be very pleased to get back cursor keys ;-)

Thx,

/DvL
--

-- 
If Windows is the answer then it probably has been a stupid question
Frank Thieme | 4 Jan 21:05 2005
Picon

Re: Problems with font set / cursor keys do't work anymore

Daniel van Leeuwen wrote:
> Since upgrading my maxima to version 5.9.1 the cursor keys won't work anymore. 
> I cant scroll through the lines and the command history isn't accessible 
> anymore. I wonder, how I can fix this problem, I was unable to find any 
> information yet.

Depends on the underlying lisp. Clisp has readline support. If you use 
cmucl there is no command line editing support...
Robert Dodier | 4 Jan 23:14 2005
Picon

Re: Problems with font set / cursor keys do't work anymore

Hello Daniel, you wrote:

> Since upgrading my maxima to version 5.9.1 the cursor keys 
> won't work anymore. I cant scroll through the lines and the
> command history isn't accessible anymore. 

Whether command line editing is enabled depends on the Lisp
version. Clisp and GCL support it, CMUCL doesn't.

You mention upgrading and linux. I'm assuming you are
using rpm. The only Maxima 5.9.1 rpm available from SourceForge
is built with CMUCL, so that does not have command line editing.

What does build_info() say?

For what it's worth,
Robert Dodier

		
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page  Try My Yahoo!
http://my.yahoo.com 
Raymond Toy | 4 Jan 23:51 2005
Picon

Telling maxima something is an integer


Is there a way to tell maxima something is an integer?  I know I can
use askinteger(n) to ask me if N is an integer, but then I have to
answer yes.  Is there some other way to tell maxima that n is an
integer?  

Ray

Gmane