Minor point: this is (^)/2 , not ^/2 , to indicate that ^ used as an operator and makes it a valid Prolog syntax and predicate indicator (7.1.6.6).
(**)/2 and (^)/2 are simultaneously evaluation functors (9), therefore, they can be used for arithmetic estimation (8.7) with (is)/2 and arithmetic comparison (8.7) with (=:=)/2 , (<)/2 and the like, Their definitions are slightly different.
(**)/2 always returns a float, just as (/)/2 always gives a float. (SWI is not compliant with the standard here; it has its own conventions).
?- X is 2**2. X = 4.0. ?- X is 2/2. X = 1.0.
(^)/2 here to provide integer exponentiation, which has become much more important in many systems supporting arbitrarily large integers. Think of 2^2^X That is, if both arguments are integers, the result is also an integer, in the same way that (*)/2 handles this case.
?- X is 2^2, Y is 2*2. X = 4, Y = 4. ?- X is 2.0^2, Y is 2.0*2. X = 4.0, Y = 4.0.
In cases where (^)/2 gives a real value with two integer arguments (for example, 2^ -1 ), a type error occurs, and then more errors appear for other complex or undefined results.
(^)/2 used for exponentiation for quite some time. An early use of the exponential operator in DHD's Warren Thesis of 1977 as an example of symbolic differentiation. (At least this is not mentioned in the 1975 Philip Russell manual). Throughout the dissertation and in the 1978 user manual, the ~ symbol ~ used sequentially, where it can be expected that ^ as in integers are restricted to the range -2~17 to 2~17-1 , ie. -131072 to 131071. integers are restricted to the range -2~17 to 2~17-1 , ie. -131072 to 131071. .. The announcement was as follows and has not changed since 1982.
:- op(300, xfy, ~). % 1977 :- op(200, xfy, ^). % 1982 - today
Since 1982, it has been used to quantify setof/3 and bagof/3 , but also as lambda in natural language parsers. For all these applications, he already had the right associativity and priority. As an evaluated functor, he was present in several systems.
The first system to use (^)/2 as the parsed functor, meaning force, is probably C-Prolog.
Compared to this legacy, (**)/2 appeared in Prolog relatively late, most likely inspired by Fortran. It was proposed for inclusion (N80 1991-07, Paris Documents) shortly before the Committee's first draft (CD 1992). Systems provided it as well as exp/2 .
(**)/2 has the same priority as (^)/2 , but does not have any associativity, which may be odd at first, since in some cases there is a fairly frequent exponentiation. Most noticeably, the Gauss function in its simplest form
e -x 2
Instead of using the constant e and raising to a power, a special evaluation functor exp/1 provided. The above, therefore, is written as exp(- X**2) . In fact, Wikipedia also uses this designation. Given this functor, in this general case there is no need for associativity.
If this is true, I would be very interested to see it.
Compared to other systems, it seems quite common to offer two types of exponentiation. Think of a Haskell that has ^ and ** .
In conclusion: there are no frequent cases when nesting of floats is required. Therefore, minimal support seems preferable.