From mc@uga.edu Sun Jul 15 03:48:32 2001
Received: from mailbu.cc.uga.edu (malibu.cc.uga.edu [128.192.1.103])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f6F1mWX22687
	for <prolog@swi.psy.uva.nl>; Sun, 15 Jul 2001 03:48:32 +0200 (MET DST)
Received: from archa8.cc.uga.edu (arch8.cc.uga.edu) by mailbu.cc.uga.edu (LSMTP for Windows NT v1.1b) with SMTP id <2.000BC380@mailbu.cc.uga.edu>; Sat, 14 Jul 2001 21:48:30 -0400
Received: from MINERVA (dsl-64-128-248-185.telocity.com [64.128.248.185])
	by archa8.cc.uga.edu (8.9.1/8.9.1) with ESMTP id VAA126392
	for <prolog@swi.psy.uva.nl>; Sat, 14 Jul 2001 21:48:30 -0400
Message-ID: <004d01c10cd0$3f6e2b00$c901a8c0@MINERVA>
Reply-To: "Michael A. Covington" <mc@arches.uga.edu>
From: "Michael A. Covington" <mc@arches.uga.edu>
To: <prolog@swi.psy.uva.nl>
References: <20010714200815Q.sota@midway.uchicago.edu>
Subject: Re: [SWIPL] arithmetic_function
Date: Sat, 14 Jul 2001 21:48:29 -0400
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200

> ?- A is sum(0, 4, k).
> It does not work because:
> ERROR: Arithmetic: `k/0' is not a function
> Does anybody know why it did not work?

It does not work because the letter k is not the sum of two numbers.

Did you mean to write the variable K?  In that case, the reason it
doesn't work is that Prolog does not include an all-purpose equation
solver.  (Indeed, neither does all of mathematics as we know it.)
Prolog does not have a mechanism to search for numbers that solve
equations.  (How many numbers should it try?  There are infinitely
many.)

There are numerous algorithms that solve large classes of equations
numerically, though success with arbitrary functions is not guaranteed.
One of them is in the book Prolog Programming in Depth, by Covington,
Nute, and Vellino, Prentice-Hall edition, pp. 198-203.  The code,
solver.pl, is online at ftp.ai.uga.edu (somewhere), but you need the
book to explain how it works.

You can find such algorithms in numerical methods textbooks.  They are
basically search algorithms, but over an infinite search space.


