# Understand this part of the Zygote docs

**URL:** <https://discourse.julialang.org/t/understand-this-part-of-the-zygote-docs/36816>\
**Category:** Machine Learning\
**Created:** [March 31, 2020, 7:48pm UTC](https://discourse.julialang.org/t/understand-this-part-of-the-zygote-docs/36816 "2020-03-31T19:48:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaynick](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@jaynick](https://discourse.julialang.org/u/jaynick)\
**Post date:** [March 31, 2020, 7:48pm UTC](https://discourse.julialang.org/t/understand-this-part-of-the-zygote-docs/36816/1 "2020-03-31T19:48:08Z")

</div>

I am wondering if there are several typos in introduction example to custom adjoints,  
[https://fluxml.ai/Zygote.jl/dev/adjoints/](https://fluxml.ai/Zygote.jl/dev/adjoints/)

> In other words `pullback(sin, x)` behaves the same as
> 
> ```julia
> dsin(x) = sin(x), ȳ -> (ȳ * cos(x),)
> 
> ```

Is the dsin(x) = sin(x) correct? Does this mean that pullback(sin,x) returns a tuple containing 1) an new aliased function for sin, 2) a function that returns whatever its argument is times cos(x)?

Then the next example says

> `gradient` takes a function l=f(x) and … feeds this in to the pullback. In the case of `sin` ,

```julia
julia> function gradsin(x)
         _, back = dsin(x)
         back(1)
       end

```

Multiple strange things here (to me). 1) pullback is not called anywhere,  
2) dsin(x) = sin(x), so back is equal to sin(0.5), and is not a function (so back(1) should give an error)

Are there any more clear documentation?

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [March 31, 2020, 7:54pm UTC](https://discourse.julialang.org/t/understand-this-part-of-the-zygote-docs/36816/2 "2020-03-31T19:54:57Z")

</div>

> [@jaynick](#):
>
> Is the dsin(x) = sin(x) correct?

That is not what it says, adding the redundant parenthesis might show this more clearly:

```julia
dsin(x) = (sin(x), ȳ -> (ȳ * cos(x),))

```

In other words, `dsin(x)` returns a tuple with the value of `sin(x)` as the first element and an anonymous function that does the derivative propagation (chain rule).

---

<div class="post-metadata">

**Author:** ![jaynick](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@jaynick](https://discourse.julialang.org/u/jaynick)\
**Post date:** [April 3, 2020, 8:24pm UTC](https://discourse.julialang.org/t/understand-this-part-of-the-zygote-docs/36816/3 "2020-04-03T20:24:32Z")

</div>

thank you
