## Search Mailing List Archives

Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through

# [protege-owl] error in swrl builtins?

Martin O'Connor martin.oconnor at stanford.edu
Tue Jan 8 17:42:35 PST 2008

```Actually, swrlb:divide returns 1.33333 for 4/3, which is a bug that I
will fix. Every other mathematical built-in does the right thing here.
In any case, if I try:

swrlb:divide(?ft, 4.0, 3.0)  ^  swrlb:multiply(?ftp, ?ft, 3.14159)  ^
swrlb:pow(?r3, 12.5, 3)  ^  swrlb:multiply(?v, ?ftp, ?r3) → sqwrl:select(?v)

I get 8080.701, which is correct. Are you sure that you are not pulling
an incorrect radius value (or have more than one)?

It is also worth noting that there is a mathematical expressions
built-in library [1] that can make queries like these a little easier to
write:

Circle(?c)  ^ hasRadius(?c, ?r)  ^ swrlm:eval(?v, "((4.0 / 3.0) * pi) *
(r ^ 3)", ?r) → sqwrl:select(?r, ?v)

(The ASCII '^' in the quoted expression is different from the SWRL
Unicode '^' and currently needs to be pasted in to the editor because
the editor will try to map the ASCII keyboard character to the Unicode one.)

Martin

[1] http://protege.cim3.net/cgi-bin/wiki.pl?SWRLTabMathematicalBuiltIns

Thomas Russ wrote:

>On Jan 8, 2008, at 12:42 PM, Andrew Crapo wrote:
>
>
>
>>I have a swrl rule to calculate the volume of a sphere:
>>Sphere(?x)  ∧
>>swrlb:divide(?ft, 4, 3)  ∧
>>swrlb:multiply(?ftp, ?ft, 3.14159)  ∧
>>swrlb:pow(?r3, ?r, 3)  ∧
>>swrlb:multiply(?v, ?ftp, ?r3)
>> → volume(?x, ?v)
>>
>>For an instance of a sphere with radius 12.5, Protege-OWL 3.4 beta
>>(build 125)
>>assigns a value of 6135.5254. I believe the correct answer, hand
>>calculated or
>>calculated with another reasoner, is 8181.1465.
>>
>>
>
>I'm not completely sure, but I think that the built-ins try to keep
>the same numeric datatype as their input arguments.  The discrepancy
>you see would be explained by 4/3 => 1 instead of 4.0/3.0 = 1.33333333
>
>Try changing all the constants to floating point numbers and see if
>that changes things.
>
>_______________________________________________
>protege-owl mailing list
>protege-owl at lists.stanford.edu
>https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
>Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
>

```