# Partial derivatives, Rotor/Curl of a field, Normal of a surface

See original GitHub issueTwo separate-but-related differential operators that seem pretty important/essential to me for 3D math:

- Rotor/Curl - https://en.wikipedia.org/wiki/Curl_(mathematics)

I’ve managed to get the rotor of a given field at the point [X,Y,Z] in the following example: https://www.math3d.org/MrIboI6x

Notice that I had to define 9 intermediate functions in order to accomplish this… not great fun. I also wasn’t able to use this method to create a generic rotor function, because I had to use the constants X,Y,Z in the intermediate functions.

(note that I mean the un-normalized vector Ru×Rv)

Again, I was able to do this for a single point using two intermediate functions: https://www.math3d.org/3Iqv6XXf

I’ve looked through `math`

in the console and math.js, and wasn’t able to find a ready-made way to calculate these at given coordinates. Please add one, and/or make an example of it so it’s more discoverable!

What these two things have in common: they involve partial derivatives. I’ve tried using diff with functions of multiple variables, but I just can’t find a way to work with them! If you can expose them a little better to the end-used, that might help.

### Issue Analytics

- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)

## Top GitHub Comments

Note to self: This is implemented but still needs documented examples.

I understand that

`diff(f,x,y,z)`

returns a matrix, where each partial derivative is a row (or column?) in the matrix, but I can’t find a way to get one row(/column) of the matrix as a 3D vector. There is no`row`

function, see https://github.com/josdejong/mathjs/issues/230Edit: I can’t tell you how many failed attempts this took me: https://www.math3d.org/UdFijsnH

Apparently I was using subset/index wrong. To get the partial derivative of R(u,v) in regards to u, apparently we use:

`Ru(u,v) = flatten(subset(diff(R,u,v),index(1,[1,2,3])))`

I was stuck for

hourstrying to figure out why`index(1,[1,3])`

wasn’t working. This would have been easier to solve if I could actually see the values that were being output.This is related to the “see something’s type” topic discussed here: https://github.com/ChristopherChudzicki/math3d-react/issues/193#issuecomment-505530098, but for variables (that aren’t functions) we might as well be able to see the actual output value - preferably as a nicely formatted matrix/table.

I know I’m making

a lotof requests, some of which are big, but it’s only because I like this software so much and want to see it improve. 😃(I will try to make some PRs eventually, but for the next ~month it will definitely not be possible)

Edit: Curl still requires partial derivatives as intermediate functions, but at least it can be made generic: https://www.math3d.org/bNLU7FfY -

`RotF(x,y,z)`

here works for any x,y,z.