Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7160 > unrolled thread

Re: NMinimize problem: fct minimized uses FindRoot

Started byAndrzej Kozlowski <akoz@mimuw.edu.pl>
First post2011-12-13 10:41 +0000
Last post2011-12-13 10:41 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: NMinimize problem: fct minimized uses FindRoot Andrzej Kozlowski <akoz@mimuw.edu.pl> - 2011-12-13 10:41 +0000

#7160 — Re: NMinimize problem: fct minimized uses FindRoot

FromAndrzej Kozlowski <akoz@mimuw.edu.pl>
Date2011-12-13 10:41 +0000
SubjectRe: NMinimize problem: fct minimized uses FindRoot
Message-ID<jc7a47$ome$1@smc.vnet.net>
On 12 Dec 2011, at 12:43, Oleksandr Rasputinov wrote:

> For example, the erroneous usage:
>
> Block[{a = 1, b = 2}, Return[a]; Return[b]]
>
> gives:
>
> Return[1]
>
> but a correct usage:
>
> Do[Block[{a = 1, b = 2}, Return[a]; Return[b]], {1}]
>
> gives (because of the enclosing Do):
>
> 1

This is not quite the whole story. For example, while the above use of Return in Block does not work, this one (in a function call) does:

f[] := Block[{a = 1, b = 2}, Return[a]; Return[b]]

f[]

1

Moreover, if you replace the Do loop in your example with a While loop, you will get:

n = 1; While[n < 10, Block[{a = 1, b = 2}, Return[a]; Return[b]]]

Return[1]

All of this is purposeful design and can be explained and justified but I don't think it's worth the bother since Mathematica has far superior means of flow control than this clumsy and arcane construct.

Andrzej 

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web