Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.1K Views
|
6 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Find the Hessian of a function of 30 variables?

Posted 5 years ago

TIA!! I think main problems are defining such a function.

POSTED BY: Brian Tenneson
6 Replies

You need a function for creating as many variables as you need.

createVar[name_, num_] := Table[Subscript[name, i], {i, 1, num}] 

Now, suppose that $f$ is a function of 30 variables and try this

f@@createVar[x, 30]
POSTED BY: Ta'a Nwa Dombou
Posted 5 years ago
POSTED BY: Brian Tenneson

Here is a way to generate a list of 30 variables, a random function of them, and its hessian:

vars = Table[ToExpression[StringJoin["a", ToString[n]]], {n, 30}]
function = 
 Times @@ RandomChoice[vars, 8] + 3 Times @@ RandomChoice[vars, 3]
hessian = D[function, {vars, 2}]
POSTED BY: Gianluca Gorni
Posted 5 years ago

Thank you! Works perfectly!

POSTED BY: Brian Tenneson
Posted 5 years ago

How would you specifically do this dozens of variables? I can see how to do it with two variables, perhaps 3 or maybe even 10. I tried

hessian[Function[Table[x[[k]], {k, 1, 2}], x[[1]]^3 + x[[2]]^6], 
 Table[x[[k]], {k, 1, 2}]]

And the 2 is something I want to allow to be higher than 20. What am I doing wrong?

POSTED BY: Updating Name
POSTED BY: Ta'a Nwa Dombou
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard