# Calculate a hessian matrix?

GROUPS:
 Hello, I have to work on Mathematica for studies reasons but i'm not very familiar with it. I explain what we are trying to do with Mathematica: We want to calculate a hessian matrix but we want to keep the calculus theoretical as long as possible. So we have to determinate the size a the matrix : n and there is where my problems starts . I have some script written by a professor and we have to use them. Here is his instruction : Run the Mathematica script “double_chain.m” with the parameter n, for example in the terminal like this: /WolframKernel -nopromt -run “<
1 year ago
12 Replies
 I suspect that you just need to be more clear on the paths to the files. The input "<"\Program Files\Wolfram Research\Mathematica\11.1\wolfram.exe" -noprompt -run "<
1 year ago
 Thanks for you answer, I tried but it does not work, either when i lauch Mathematica.exe it says that the file "n" does not exist. And when I launch it with WolframKernel.exe there is nothing on it, like just white screen on the program. I really don't understand.
1 year ago
 I'm not sure the best way to run the script at launch of Mathematica, and I wouldn't recommend that approach. As you have shown, you can load the file in Mathematica (using 'Get'), but you would need to change how the value of 'n' is specified in that file.Using WolframKernel, you do not see a prompt because you passed the flag -noprompt. However, if you remove that flag, you'll have to change the code because 'n' will now be in the 4th position of \ $CommandLine (not the 5th). The simplest change to make would be to set 'n' to the last element in \$CommandLine. Now it will work regardless of the flags you pass to the kernel: input=$CommandLine; n=ToExpression[Last[input]];  Answer 1 year ago  okay I understand, and i have done exactly what you said and here is what i got : in my commands i type : D:\ProgrammeFiles\mathematica\WolframKernel -run "double_chain.m" mThen wolfram lauch and all i got is : l[1]=I'm sorry i'm really not friendly with that software but i can't understand **** Answer 1 year ago  Your input is missing the '<<'. Try this instead: D:\ProgrammeFiles\mathematica\WolframKernel -run "< Answer 1 year ago  Hey we are progressing (I guess ?). Now I got these messages: Syntax::stresc: Unknown string escape \U. Syntax::stresc: Unknown string escape \j. Syntax::stresc: Unknown string escape \D. Syntax::stresc: Unknown string escape \s. Syntax::stresc: Unknown string escape \d. ToExpression::sntxi: Incomplete expression; more input is needed . I'm sorry I keep asking, indeed it doesn't seem very trivial. I'm very thankful to you for answering. Answer 1 year ago  I can't tell at which point in your code these errors are coming from.The error messages indicate that there is a ToExpression wrapped around a string. Here is an input that gives the same error: In[6]:= ToExpression["\U"] During evaluation of In[6]:= Syntax::stresc: Unknown string escape \U. Out[6]=$Failed So perhaps this is in your -run "Get[ path to file]" code??? On windows machines, you have to be very careful with the path names because "\" is an escape character in Mathematica. A safer way to specify the path is to use FilenameJoin, e.g., In[7]:= FileNameJoin[{"Users","chadk","temp","demo.m"}] Out[7]= Users\chadk\temp\demo.m Then your command line input would look something like this: C:\Users\chadk> "\Program Files\Wolfram Research\Mathematica\11.1\WolframKernel.exe" -run "Get[FileNameJoin[{\"Users\",\"chadk\",\"temp\",\"demo.m\"}]]" n where the escape character (/) is used for the strings inside the FileName
1 year ago
 Okay so I managed to remove all the : Syntax::stresc: Unknown string escape \ errors.The only one remaining is ToExpression::sntxi: Incomplete expression; more input is needed . And in my script I can't see what's wrong with the ToExpression : n=ToExpression[input[[4]]];I think we are almost there (can't thank you enough).
1 year ago
 Progress! I suspect that the problem is in your command line input. Here is a simple example that gives the same error message: C:\Users\chadk\temp>"\Program Files\Wolfram Research\Mathematica\11.1\WolframKernel.exe" -run "1+" The kernel tries to evaluate ToExpression["1+"], and gives that error message.
 Okay so I managed to launch it (FINALLY) But (it would have been to easy) I have now these errors Table::iterb: Iterator {i, 2, n} does not have appropriate bounds. Table::iterb: Iterator {i, 1 + n, -1 + 2 n} does not have appropriate bounds. Table::iterb: Iterator {i, 1 + n, -1 + 2 n} does not have appropriate bounds. General::stop: Further output of Table::iterb will be suppressed during this calculation. Part::pkspec1: The expression i cannot be used as a part specification. Part::pkspec1: The expression i cannot be used as a part specification. Part::pkspec1: The expression i cannot be used as a part specification. General::stop: Further output of Part::pkspec1 will be suppressed during this calculation. NSum::nslim: Limit of summation -1. + 2. n is not a number. NSum::nslim: Limit of summation -1. + 2. n is not a number. NSum::nslim: Limit of summation -1. + 2. n is not a number. General::stop: Further output of NSum::nslim will be suppressed during this calculation. Do::iterb: Iterator {i, 1, dim} does not have appropriate bounds. I don't where is that coming from, I mean to me it seems like the script itself have a problem. But I really don't think my professor would set me a wrong script. Could it be like in C language and I have to give kernel more ram ?