# Writing AD rules for Rotations.jl

**URL:** <https://discourse.julialang.org/t/writing-ad-rules-for-rotations-jl/116222>\
**Category:** Modelling & Simulations\
**Tags:** question, package\
**Created:** [June 25, 2024, 9:12pm UTC](https://discourse.julialang.org/t/writing-ad-rules-for-rotations-jl/116222 "2024-06-25T21:12:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sonofwatt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sonofwatt/32/210246_2.png) [@sonofwatt](https://discourse.julialang.org/u/sonofwatt)\
**Post date:** [June 25, 2024, 9:12pm UTC](https://discourse.julialang.org/t/writing-ad-rules-for-rotations-jl/116222/1 "2024-06-25T21:12:14Z")

</div>

I’m trying to create a coordinate transformation, via LinearAlgebra and Rotations.jl ([Home · Rotations.jl](https://juliageometry.github.io/Rotations.jl/dev/)), and can be optimized via Zygote.jl, or the like.

I’m running into a problem because some of the functions in Rotations.jl (RotZ(), MRP()) don’t have automatic differentiation (AD) rules, and I have to write my own. Rotations.jl comes with the Rotations.jacobian() function, which can be applied to rotation functions, but I’m having trouble getting the syntax right for ChainRules.jl

Because its just linear algebra, I’ve implemented some simpler functions to work around this problem, but getting Rotations.jl working would be much more elegant.

Any advice or concrete examples would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [June 26, 2024, 5:14am UTC](https://discourse.julialang.org/t/writing-ad-rules-for-rotations-jl/116222/2 "2024-06-26T05:14:46Z")

</div>

Welcome! Can you give a concrete example of a rule which doesn’t seem to work?
