views:

183

answers:

1

Hi

I am trying to write a sparql query where I want to filter on the square of something, but I am simply unable to figure out how to square a number (x^2) (except by multiplying it with itself of cause.) I guessed a square root function called math:sqrt() which works, yet nothing like math:pow seems to exist.

How do I get the square of something in sparql, and more interesting where can I read about it and other math functions such as math:sqrt in sparql?

(This is related to my previous question on querying all wikipedia articles geotagged withing a specific distance of some point.)

+1  A: 

SPARQL supports some XPath arithmetic functions such as + - * /. They are described in the SPARQL spec.

The power function is not supported by the spec. And in any case x*x is more efficient way to compute squares than pow(x,2) would be.

laalto
Hi. Thanks. What about specification of other math functions, such as the square root (math:sqrt seems to work fine) and the trigonometric functions sin, and cos? I updated the question a bit.
bjarkef
Those would be implementation-specific extensions, not part of the core SPARQL.
laalto
Where would I find documentation on these implementation-specific extensions?
bjarkef
Well, start with your SPARQL query engine documentation. I cannot read your mind and don't know which one you are using.
laalto