Re: FindMinimum[Print[]]

• To: mathgroup at smc.vnet.net
• Subject: [mg86987] Re: FindMinimum[Print[]]
• From: Szabolcs Horvát <szhorvat at gmail.com>
• Date: Fri, 28 Mar 2008 03:15:36 -0500 (EST)
• Organization: University of Bergen
• References: <fsg6o2\$j61\$1@smc.vnet.net>

```Michaël Cadilhac wrote:
>   Hello list !
>
>   I'm really new to Mathematica (though I can already say wow), and,
> following the tutorial[1] (which might be quite outdated), one of the
> exercise got me in trouble.
>
>   The author asks to reformulate the following actions
>
> m = {{12,      1 + x,  4 - x,  x},
>      {4 - x,   11,     1 + x,  x},
>      {1 + x,   1 - x,  15,     x},
>      {x - 1,   x - 1,  x - 1,  x - 1}};
> expr = Max[Re[Eigenvalues[m]]];
> FindMinimum[expr, {x, 0, 1}]
>
>   into a more optimized version.  In the course of doing that, I wanted
> to do something like
>     FindMinimum[Print[x]; x^2, {x, 1}],
> hoping to see how is this whole thing is expanded/parsed.  But, despite
> the fact that some articles on that newsgroup used the same form, this
> didn't print the iterations as expected.
>
>   I wanted to understand how I should write
>     FindMinimum[Max[Eigenvalues[m]], {x, 0, 1}]
> so that the eigenvalues are computed on the fully numerical
> (non-symbolic) matrix.
>
>   Thanks in advance for any information on that simple matter.
>
> Footnotes:
> [1]  http://library.wolfram.com/conferences/devconf99/withoff/

Hi,

One solution is to define a function that only evaluates with numerical
(not symbolic) arguments:

expr[x_?NumericQ] :=
Max[Re[Eigenvalues[{{12, 1 + x, 4 - x, x}, {4 - x, 11, 1 + x,
x}, {1 + x, 1 - x, 15, x}, {x - 1, x - 1, x - 1, x - 1}}]]]

FindMinimum[expr[x], {x, 1}]

You can use the same technique to print each x value while FindMinimum
is working, or you could use the EvaluationMonitor option.

```

• Prev by Date: Re: symbolic evaluation
• Next by Date: Re: The FinancialData Function
• Previous by thread: Re: FindMinimum[Print[]]
• Next by thread: Re: FindMinimum[Print[]]