<div dir="ltr"><a id="v:jacobian" class="" style="margin:0px;padding:0px;font-weight:bold;color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px">jacobian</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> :: (</span><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Traversable.html#t:Traversable" style="margin:0px;padding:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:16.12px">Traversable</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> f, </span><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Data-Functor.html#t:Functor" style="margin:0px;padding:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:16.12px">Functor</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> g, </span><a href="https://hackage.haskell.org/package/base-4.9.0.0/docs/Prelude.html#t:Num" style="margin:0px;padding:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:16.12px">Num</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> a) => (</span><span class="" style="margin:0px;padding:0px;color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px">forall</span><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> s. </span><a href="https://hackage.haskell.org/package/reflection-2.1.2/docs/Data-Reflection.html#t:Reifies" style="margin:0px;padding:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:16.12px">Reifies</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> s </span><a href="https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD-Internal-Reverse.html#t:Tape" style="margin:0px;padding:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:16.12px">Tape</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> => f (</span><a href="https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD-Mode-Reverse.html#t:Reverse" style="margin:0px;padding:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:16.12px">Reverse</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> s a) -> g (</span><a href="https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD-Mode-Reverse.html#t:Reverse" style="margin:0px;padding:0px;text-decoration:none;color:rgb(171,105,84);font-family:monospace;font-size:13px;line-height:16.12px">Reverse</a><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"> s a)) -> f a -> g (f a)</span><br><div><span style="color:rgb(0,0,0);font-family:monospace;font-size:13px;line-height:16.12px;background-color:rgb(240,240,240)"><br></span></div><div><span style="font-size:12.8px"> Thanks a lot for your help</span><br></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Jonas BÉAL</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 August 2016 at 10:40, Jonas Béal <span dir="ltr"><<a href="mailto:jonas.beal@novadiscovery.com" target="_blank">jonas.beal@novadiscovery.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello,<div><br></div><div>I have some questions about the Automatic Differentiation package in Haskell (<a href="https://hackage.haskell.org/package/ad-4.3.2.1/docs/Numeric-AD.html" target="_blank">https://hackage.haskell.org/p<wbr>ackage/ad-4.3.2.1/docs/Numeric<wbr>-AD.html</a>)<br clear="all"><div>I need to compute the jacobian with that method and I have a type problem, here a simplified example in order to focus on the error:</div><div><br></div><div>According to documentation I need to write "<i>jacobian function values</i>". So I built the input <i>function. </i>Please notice this is important for me that my function may depend on an external parameter (named factor here)</div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">testFunctionForJacobian </span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">:: Fractional a </span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">=> a </span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">-> [a] </span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">-> [a]</span><br style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">testFunctionForJacobian factor inputs = [(sum inputs) * factor]</span></div><div><div><br></div></div><div><span style="background-color:rgb(255,255,255)">Then, using <i>jacobian</i> function of Numeric.AD in terminal, as a test, it works perfectly</span></div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">>jacobian (testFunctionForJacobian 2) [1,2]</span></div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">< [[2.0,2.0]]</span></div><div><br></div><div>No apparent type problem here <br></div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">> :t (testFunctionForJacobian 2)</span><br></div><div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">(testFunctionForJacobian 2) :: Fractional a => [a] -> [a]</span></div></div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"><br></span></div><div>But, I would like to insert that in a bigger function computing the jacobian</div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">testJacobian </span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">:: Fractional a </span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">=> a </span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">-> [a] </span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">-> [[a]]</span><br style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">testJacobian factor inputs =</span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"> jacobian (testFunctionForJacobian factor) inputs</span><br></div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"><br></span></div><div>This time it generates an error message about <i>factor</i><br></div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">Couldn't match expected type ‘</span><a href="http://numeric.ad.internal.reverse.reverse/" rel="noopener noreferrer" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;text-decoration:none;color:rgb(0,140,227);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";line-height:20px;background-color:rgba(0,0,0,0.0235294)" target="_blank">Numeric.AD.Internal.Reverse.<wbr>Reverse</a><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"> s a’ with actual type ‘a’</span><br style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">‘a’ is a rigid type variable bound by the type signature for</span><br style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)">testJacobian :: Fractional a => a -> [a] -> [[a]] s a’</span><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"><br></span></div><div><span style="color:rgb(68,68,68);font-family:"Helvetica Neue",Helvetica,Roboto,Arial,sans-serif,"Meiryo UI";font-size:14px;line-height:20px;background-color:rgba(0,0,0,0.0235294)"><br></span></div><div>All in all, my type seems implicitly correct in the terminal example but I did not manage to write it explicitly in my function.<br></div><div><br></div><div>Here the <i>jacobian</i> function signature to help you answer me: </div><span class="HOEnZb"><font color="#888888"><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div style="font-family:sans-serif;font-size:13px;padding:2px 0px 2px 13px;font-stretch:normal;color:rgb(54,57,79)">Jonas Béal</div></div></div>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="font-family:sans-serif;font-size:13px;padding:2px 0px 2px 13px;font-stretch:normal;color:rgb(54,57,79)">Jonas Béal</div><div style="font-family:sans-serif;padding:2px 0px 2px 13px;font-stretch:normal;font-size:11px;color:rgb(65,115,171)">R&D Scientist Intern</div><div style="font-family:sans-serif;padding:2px 13px;font-stretch:normal;font-size:11px;color:rgb(128,134,150)"><a href="mailto:jonas.beal@novadiscovery.com" style="color:rgb(128,134,150);text-decoration:none" target="_blank">jonas.beal@novadiscovery.com</a></div><div style="font-family:sans-serif;padding:2px 0px 1px 13px;margin:15px 0px 0px;font-size:20px;color:rgb(54,57,79)">Novadiscovery</div><div style="font-family:sans-serif;padding:0px 0px 2px 13px;font-size:12px;color:rgb(65,115,171)">The Effect Model Co.</div><div style="color:rgb(51,51,51);font-family:sans-serif;padding:2px 13px;margin:0px;font-stretch:normal;font-size:11px"><a href="http://www.novadiscovery.com/" title="Visit our website" style="color:rgb(128,134,150);text-decoration:none" target="_blank">www.novadiscovery.com</a></div><div style="font-family:sans-serif;padding:2px 13px;font-stretch:normal;font-size:11px;color:rgb(128,134,150)">+33 9 72 53 13 00</div><div style="font-family:sans-serif;padding:2px 13px;font-stretch:normal;font-size:11px;color:rgb(128,134,150)">Bioparc Laënnec, 60 avenue Rockefeller, 69008 Lyon</div></div></div>
</div>

<br>
<i style="color:rgb(187,187,187);font-family:sans-serif;font-size:10px;text-align:justify">This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.</i>