[Date Index]
[Thread Index]
[Author Index]
Re: FindMinimum during NMimimize
*To*: mathgroup at smc.vnet.net
*Subject*: [mg65606] Re: FindMinimum during NMimimize
*From*: dh <dh at metrohm.ch>
*Date*: Tue, 11 Apr 2006 04:04:11 -0400 (EDT)
*References*: <e15el3$2ri$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Hi Mario,
if I understand you correctly, then you want do calculate the distance
of a point r0 from a line L1. This can be calculated with much less effort.
Imagine a vector v from a point r1 on the line L1 to the given point r0.
If we then project this vector on a line L2 perpendicular to L1, the
length of the projection is the searched distance. To make life easier
we choose a unit vector u along line L2. The distance can then be got by
the scalar product v.u:
given line: y1=c0+c1 x1
r0: {x0,y0}
r1: {x1,y1} if we choose x1==0, this becames r1={0,c0}
vector parallel to L1: {1,c1}
vector perpendicular to L1: {-c1,1} (to check, take the scalar product)
Unit vector perpendicular to L1: u={-c1,1}/Sqrt[1+c1^2]
vector from r1 to r0: r0-r1= {x0,y0}-{0,c0} ={x0,y0-c0}
distance= Abs[ {x0,y0-c0}.{-c1,1}/Sqrt[1+c1^2] ]
Daniel
mfific at gmail.com wrote:
> Dear all,
>
> Math ver 5.0
> Here is my problem:
>
> discra[x_,slopex_,intx_]:=x*slopex+intx
>
> distanceOverX[ma1_,ma2_,slopex_,intx_]:=
> FindMinimum[Sqrt[(ma1-x)^2+(ma2-discra[x,slopex,intx])^2],{x,10,20}][[1]]
>
> NMinimize[{(distanceOverX[1,1,0,intx]-100)^2,0<intx<10},
> {{intx,2,3}},Methodï?®{"NelderMead","RandomSeed"ï?®15},MaxIterationsï?®100]
>
>
> I defined a function distanceOverX above that includes FindMinimum for
> x variable. And that function works fine by itslef: as an otput I take
> the minimized value.
>
> But when I used distanceOverXfunction for finding global Min using
> NMinimize, I got the error which indicates that FindMinimum could not
> do the job:
> for example: The function value ....is not a number at {x}={10}....
>
> I would appreciate for a suggestion how to unlock that problem.
> (Note that for NMinmize I let only one variable (intx) from the
> function distanceOverX to be free parameter while other values are
> provided)
>
> thank you very much,
>
> Mario Fific
>
> Cognitive Psychology and Cognitive Science
> Indiana University
>
Prev by Date:
**Re: Code problem**
Next by Date:
**Re: Problem with compiled function (is this a bug?)**
Previous by thread:
**Re: FindMinimum during NMimimize**
Next by thread:
**64-bit GraphPlot problem**
| |