Introduce new functions into OSL?

I don’t even know if this is the right support thread, that’s how little OSL is explained even after reading through the manual. There is a lot more depth hidden through the libraries and google seldom returns expected results.

There are transcendental functions that OSL knows how to approximate, like if I type exp(<numbers+variables>) OSL has some kind of secret script function definition library somewhere that knows what an exponential is, as indicated by its documentation.

Now, how does it calculate an exponential? I don’t know, it doesn’t go into much detail about that, but if I had to guess I would say it’s through its Taylor expansion. And, even though the Taylor expansion has an infinite radius of convergence, it’s possible OSL is told somewhere to approximate it as maybe an 8th degree polynomial or to use some kind finite differences method that centers around a new value for some discrete interval, I don’t know.

Suppose I have some other function that can be defined as a Taylor series, but that isn’t in OSL’s hidden database. How can I implement it? What if it’s multivalued how do I define a branch cut?

You can go and peek the implementation directly where the project is.

Just as a reference if you want to see how [log10] is created you can look here.

https://github.com/imageworks/OpenShadingLanguage/blob/master/src/include/OSL/sfmath.h

The rest more or less you might figure out.