Funk - symbolic differentiation 
Author Message
 Funk - symbolic differentiation

Following is a Funk program, a symbolic differentiation program.
It was written on a trial and error basis, without much computer algerbra
theory. The point is to show off Funk, not how little I know about computer
algebra.

Funk is an extremely simple and elegant language / formal system. It can be
completely defined in a few paragraphs, just like URMs or Turing machines.
But it is nevertheless a high level symbolic computation language, like Lisp
and Prolog, except that arithmetic is not built in and it is far simpler.
Funk is a pure symbol processing language. It backtracks to find multiple
solutions like Prolog. It can be viewed as a very natural an extension of a
finite state machine viewed as a digraph of states.

Please visit my web site. I have an ulterior motive: I need a collaborator
in the further development of Funk. Funk sits on the borderline between
computing and mathematics. So I need someone so inclined. But comments
are also welcome.

-Dave Davis    


www.davestuff.org   or  www.spc.edu/~davis_d

Look under Computing, then under Funk.
============================================================================
: start
        => D tan u .
        x .

: x : y : z    

        Const .
        Func .

        - - x => x .
        - x .

        sin + x y => + * sin x cos y * sin y cos x .
        sin x .

        cos + x y =>  + * cos x cos y - * sin x sin y  .
        cos x .

        tan x => / sin x cos x .

        exp + x y => * exp x exp y .
        exp x .

        ln * x y => + ln x ln y .
        ln x .

        D Const => 0 .
        D sin x => * cos x D x .
        D cos x => - * sin x D x .
        D exp x => * exp x D x .
        D + x y  => + D x D y .
        D * x y => + * D x y * x D y .
        D / x y => / + * y D x - * x D y * y y .
        D x .

        ^ x + y z => * ^ x y ^ x z .
        ^ x y .

        * + x y z  => + * x z * y  z .
        * - x y => - * x y .
        * 0 x => 0 .
        * 1 x => 1 .
        * x 0 => 0 .
        * x 1 => x .
        * x x => x ^ 2 .
        * x + y z => + * x y * x z .
        * x * y z => * * x y z .
        * x - y => * - x y .
        * x y .

        / / x => x .
        / x 1 => x .
        / x x => 1 .
        / x 0 => DIV_ZERO .
        / x y .

        + * cos x ^ 2 y * sin x ^ 2 y => y .
        + 0 x => x .
        + x 0 => x .
        + x + y z => + + x y z .
        + x y .

: Const
        0 . 1 . a . b .

: Func
        u . v .



Sun, 30 May 2004 18:06:23 GMT  
 Funk - symbolic differentiation

Quote:

> Funk is an extremely simple and elegant language / formal system. It can be
> completely defined in a few paragraphs, just like URMs or Turing machines.
> But it is nevertheless a high level symbolic computation language, like Lisp
> and Prolog, except that arithmetic is not built in and it is far simpler.
> Funk is a pure symbol processing language. It backtracks to find multiple
> solutions like Prolog. It can be viewed as a very natural an extension of a
> finite state machine viewed as a digraph of states.

What are the essential advantages of Funk over Lisp and
Prolog in practice? Thanks.

M. K. Shen



Sun, 30 May 2004 23:29:00 GMT  
 Funk - symbolic differentiation


: > Funk is an extremely simple and elegant language / formal system. It can be
: > completely defined in a few paragraphs, just like URMs or Turing machines.
: > But it is nevertheless a high level symbolic computation language, like Lisp
: > and Prolog, except that arithmetic is not built in and it is far simpler.
: > Funk is a pure symbol processing language. It backtracks to find multiple
: > solutions like Prolog. It can be viewed as a very natural an extension of a
: > finite state machine viewed as a digraph of states.

: What are the essential advantages of Funk over Lisp and
: Prolog in practice? Thanks.

: M. K. Shen

I believe that attached program could not have been written so transparently
and cleanly in Lisp or Prolog.

-Dave D.



Mon, 31 May 2004 11:10:29 GMT  
 Funk - symbolic differentiation

Quote:
>    * 1 x => 1 .

Don't you want * 1 x => x . ???

Quote:
>    + * cos x ^ 2 y * sin x ^ 2 y => y .

Why isn't that + * ^ cos x 2 y * ^ sin x 2 y => y . It seems to me
that all your operators are prefix except ^ which appears to be infix.

        Ole



Mon, 31 May 2004 17:58:56 GMT  
 Funk - symbolic differentiation

Quote:

> I believe that attached program could not have been written so transparently
> and cleanly in Lisp or Prolog.

There were very early programs developed for differentiation,
because that's comparatively simple of all CAS capabilities.
Without knowing their existence, I attempted in the sixties
to write a program in ALGOL60 to do (patial) differentiation,
with rules provided by the user, the coefficients of
the terms in the rules being read in and stored in a
matrix form, so that the machine could easily apply them
accordingly. That was surely a relatively primitive way of
doing the job, but the program helped my colleague and
me nonetheless to solve a problem that we repeatedly failed
to do with paper and pencil (in many days each time) due
to inevitable human errors.

M. K. Shen



Tue, 01 Jun 2004 05:20:47 GMT  
 Funk - symbolic differentiation


: >  * 1 x => 1 .

: Don't you want * 1 x => x . ???

: >  + * cos x ^ 2 y * sin x ^ 2 y => y .

: Why isn't that + * ^ cos x 2 y * ^ sin x 2 y => y . It seems to me
: that all your operators are prefix except ^ which appears to be infix.

:       Ole

You are correct on both counts. Funk runs much faster using prefix because
the interpreter scans left to write and constants are dealt with much faster
than variables.

-Dave D.
symbols are scanned left to right, and the more constants are  to the left



Tue, 01 Jun 2004 02:34:00 GMT  
 Funk - symbolic differentiation


: >  * 1 x => 1 .

: Don't you want * 1 x => x . ???

: >  + * cos x ^ 2 y * sin x ^ 2 y => y .

: Why isn't that + * ^ cos x 2 y * ^ sin x 2 y => y . It seems to me
: that all your operators are prefix except ^ which appears to be infix.

:       Ole

And there's another error:
      * x x => x ^ 2 .
should be
      * x x => ^ x 2 .

I couldn't figure out why it seemed to run correctly despite the errors
you pointed out! I think this is why.

Anyway, thanks.

-Dave



Tue, 01 Jun 2004 02:58:51 GMT  
 Funk - symbolic differentiation

Quote:
> Funk is an extremely simple and elegant language / formal system.

Interesting.  Even in this message, where he tries to tell us the
advantages of the language, he has mistakes in his own coding?


Tue, 01 Jun 2004 22:16:26 GMT  
 Funk - symbolic differentiation



Quote:

> > Funk is an extremely simple and elegant language / formal system.

> Interesting.  Even in this message, where he tries to tell us the
> advantages of the language, he has mistakes in his own coding?

So?  What is that supposed to mean?

--
Coby



Wed, 02 Jun 2004 00:08:43 GMT  
 Funk - symbolic differentiation



: >
: > > Funk is an extremely simple and elegant language / formal system.
: >
: > Interesting.  Even in this message, where he tries to tell us the
: > advantages of the language, he has mistakes in his own coding?
: >

: So?  What is that supposed to mean?

: --
: Coby

Thank you. I make lots of mistakes. I don't have a collaborator and its hard to
see one's own mistakes.

-Dave D.



Wed, 02 Jun 2004 04:35:12 GMT  
 Funk - symbolic differentiation

Quote:



>: >     * 1 x => 1 .

>: Don't you want * 1 x => x . ???

>: >     + * cos x ^ 2 y * sin x ^ 2 y => y .

>: Why isn't that + * ^ cos x 2 y * ^ sin x 2 y => y . It seems to me
>: that all your operators are prefix except ^ which appears to be infix.

I seem to recall the following trig identity from my youth:

     sin^2(x)+cos^2(x)=1 .

Quote:

>:       Ole

>And there's another error:
>      * x x => x ^ 2 .
>should be
>      * x x => ^ x 2 .



Wed, 02 Jun 2004 04:47:52 GMT  
 Funk - symbolic differentiation

Quote:



> > > Funk is an extremely simple and elegant language / formal system.

> > Interesting.  Even in this message, where he tries to tell us the
> > advantages of the language, he has mistakes in his own coding?

> So?  What is that supposed to mean?

I think it means the implementation could use a read-eval-print loop :-)

--
           /|_     .-----------------------.                        
         ,'  .\  / | No to Imperialist war |                        
     ,--'    _,'   | Wage class war!       |                        
    /       /      `-----------------------'                        
   (   -.  |                              
   |     ) |                              
  (`-.  '--.)                              
   `. )----'                              



Wed, 02 Jun 2004 10:18:33 GMT  
 Funk - symbolic differentiation




: >
: >: >     * 1 x => 1 .
: >
: >: Don't you want * 1 x => x . ???
: >
: >: >     + * cos x ^ 2 y * sin x ^ 2 y => y .
: >
: >: Why isn't that + * ^ cos x 2 y * ^ sin x 2 y => y . It seems to me
: >: that all your operators are prefix except ^ which appears to be infix.

: I seem to recall the following trig identity from my youth:

:      sin^2(x)+cos^2(x)=1 .

Yes, but that's not good enough here because

     * + x y z => + * x z * y z

might have already separated x and y. Again, this program is simply illustrative
of what kinds of things one can do easily in Funk. The program itself is not
of significance except to show a quick and dirty Funk program.

-Dave D.

: >:       Ole
: >
: >And there's another error:
: >      * x x => x ^ 2 .
: >should be
: >      * x x => ^ x 2 .



Wed, 02 Jun 2004 11:40:16 GMT  
 Funk - symbolic differentiation



 >
 >: >     * 1 x => 1 .
 >
 >: Don't you want * 1 x => x . ???
 >
 >: >     + * cos x ^ 2 y * sin x ^ 2 y => y .
 >
 >: Why isn't that + * ^ cos x 2 y * ^ sin x 2 y => y . It seems to me
 >: that all your operators are prefix except ^ which appears to be infix.
 >
 >You are correct on both counts. Funk runs much faster using prefix because
 >the interpreter scans left to write and constants are dealt with much faster
 >than variables.

In this day and age, it seems like a bad idea to design language syntax
based on efficiency of interpretation.  Human factors are much more important.

--

The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.



Thu, 03 Jun 2004 16:12:03 GMT  
 Funk - symbolic differentiation

Quote:
> In this day and age, it seems like a bad idea to design language syntax
> based on efficiency of interpretation.  Human factors are much more
> important.

Mixed yes and no. I agree that good human interfacing is very very
important. After all that's at the end all what programming languages are
about. However a programming language should also be as easy as possible be
implemented. A popular negative example is C++, how long did it take
compilers got even anywhere near the idea? How many really ANSI
complicant C++ are out there? (0?)

- Axel



Thu, 03 Jun 2004 16:53:37 GMT  
 
 [ 16 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Funk - symbolic differentiation

2. Funk - symbolic differentiation

3. Funk - symbolic differentiation

4. Symbolic differentiation

5. OT: Algorithms for symbolic differentiation?

6. Symbolic Differentiation

7. Symbolic Differentiation of Algebraic Expressions

8. Funk - a minimalist programming language

9. Funk - a minimalist programming language

10. Funk - a minimalist programming language

11. Automatic Differentiation (was Re: Derivative Approximation)

12. differentiation

 

 
Powered by phpBB® Forum Software