ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 13 Aug 2014 15:46:25 +0200Specifying variables to be included in Hessian calculationhttps://ask.sagemath.org/question/23738/specifying-variables-to-be-included-in-hessian-calculation/I want to calculate the Hessian of a function that has 5 variables and 6 parameters.
I do not want the derivatives taken by the parameters.
Is there a way to separately define parameters and variables in sage?
Alternatively, is there a way to make the Hessian function only use some variables for derivation?Mon, 11 Aug 2014 14:58:23 +0200https://ask.sagemath.org/question/23738/specifying-variables-to-be-included-in-hessian-calculation/Answer by tmonteil for <p>I want to calculate the Hessian of a function that has 5 variables and 6 parameters.
I do not want the derivatives taken by the parameters.</p>
<p>Is there a way to separately define parameters and variables in sage?</p>
<p>Alternatively, is there a way to make the Hessian function only use some variables for derivation?</p>
https://ask.sagemath.org/question/23738/specifying-variables-to-be-included-in-hessian-calculation/?answer=23744#post-id-23744You can try something like this (with ``x`` and ``y`` as variables and ``z`` as parameter):
sage: var('x y z')
(x, y, z)
sage: f(x,y) = x*y*z
sage: f.arguments()
(x, y)
sage: f.variables()
(x, y, z)
sage: f.hessian()
[(x, y) |--> 0 (x, y) |--> z]
[(x, y) |--> z (x, y) |--> 0]
Mon, 11 Aug 2014 23:54:20 +0200https://ask.sagemath.org/question/23738/specifying-variables-to-be-included-in-hessian-calculation/?answer=23744#post-id-23744Comment by Shimi for <p>You can try something like this (with <code>x</code> and <code>y</code> as variables and <code>z</code> as parameter):</p>
<pre><code>sage: var('x y z')
(x, y, z)
sage: f(x,y) = x*y*z
sage: f.arguments()
(x, y)
sage: f.variables()
(x, y, z)
sage: f.hessian()
[(x, y) |--> 0 (x, y) |--> z]
[(x, y) |--> z (x, y) |--> 0]
</code></pre>
https://ask.sagemath.org/question/23738/specifying-variables-to-be-included-in-hessian-calculation/?comment=23757#post-id-23757Thank you. That's exactly what I was looking for.Wed, 13 Aug 2014 15:46:25 +0200https://ask.sagemath.org/question/23738/specifying-variables-to-be-included-in-hessian-calculation/?comment=23757#post-id-23757