# Symbolic Differentiation Support in HLSL GPU Programs

Microsoft has updated the HLSL language of Direct3D with the support of symbolic differentiation or derivatives.

Derivatives are specified with the ‘ operator, which was previously unused:

float times = a*b;
float Dtimes = times‘(a); \\partial with respect to a
float DDtimes = times‘(a,a); \\second partial
float DaDbtimes = times‘(a,b); \\partial a, partial b


Derivatives arise frequently in graphics and scientific computation applications. As GPU’s become more widely used for scientific computation the need for derivatives can be expected to increase. To meet this need we have added symbolic differentiation as a built in language feature in the HLSL shading language. The symbolic derivative is computed at compile time so it is available in all types of shaders (geometry, pixel, vertex, etc.). The algorithm for computing the symbolic derivative is simple and has reasonable compilation and run time overhead.

## 5 thoughts on “Symbolic Differentiation Support in HLSL GPU Programs”

1. DrBalthar

I guess this is either just a forward, backward or central differentiation. Nice to see definitely saves you a bit of coding time

2. ywa

Its not numerical differentiation (so it does not have forward, backward or central differentiation), its symbolic.

3. Greg

I guess I might be stupid, however, I am not sure I understood exactly how this could be used for graphic shaders…

Could anyone give me a simple practical example on how this could be used ?