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


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

Can I solve this system of nonlinear equations?

Started byAndy <andy732a@gmail.com>
First post2012-02-29 12:28 +0000
Last post2012-03-03 11:54 +0000
Articles 9 — 4 participants

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


Contents

  Can I solve this system of nonlinear equations? Andy <andy732a@gmail.com> - 2012-02-29 12:28 +0000
    Re: Can I solve this system of nonlinear equations? "Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com> - 2012-03-02 12:51 +0000
      Re: Can I solve this system of nonlinear equations? "Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com> - 2012-03-03 11:56 +0000
    Re: Can I solve this system of nonlinear equations? "Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com> - 2012-03-02 12:52 +0000
    Re: Can I solve this system of nonlinear equations? Ray Koopman <koopman@sfu.ca> - 2012-03-03 11:58 +0000
      Re: Can I solve this system of nonlinear equations? "Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com> - 2012-03-04 09:33 +0000
      Re: Can I solve this system of nonlinear equations? Ray Koopman <koopman@sfu.ca> - 2012-03-04 09:36 +0000
        Re: Can I solve this system of nonlinear equations? "Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com> - 2012-03-05 06:05 +0000
    Re: Can I solve this system of nonlinear equations? danl@wolfram.com - 2012-03-03 11:54 +0000

#8792 — Can I solve this system of nonlinear equations?

FromAndy <andy732a@gmail.com>
Date2012-02-29 12:28 +0000
SubjectCan I solve this system of nonlinear equations?
Message-ID<jil5ld$rrm$1@smc.vnet.net>
I'm dealing with systems of nonlinear equations that have 8 equations
and 8 unknowns.  Here's an example:

Solve[{(((c - a)/0.002) - (0.995018769272803 + h*b)) == 0,
  (((d - b)/0.002) - (0.990074756047929 + h*c)) == 0,
  (((e - c)/0.002) - (0.985167483257382 + h*d)) == 0,
  (((f - d)/0.002) - (0.980296479563062 + h*e)) == 0,
  (((g - e)/0.002) - (0.975461279165159 + h*f)) == 0,
  (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 + h*c)) ==
0,
  (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 + h*d)) ==
0,
  (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 + h*e)) ==
0}, {a, b, c, d, e, f, g, h}]

Whenever I try this, Mathematica 7 just returns the empty set {}.  How
can I tell if this is unsolvable?  Shouldn't I at least be able to get
a numerical approximation with NSolve?  I've tried using stochastic
optimization to get approximate answers but every method gives poor
results, and that's why I would like to at least approximately solve
this if possible.  Thanks very much for any help~

[toc] | [next] | [standalone]


#8831

From"Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com>
Date2012-03-02 12:51 +0000
Message-ID<jiqfpe$6c$1@smc.vnet.net>
In reply to#8792
equations = {(((c - a)/0.002) - (0.995018769272803 + h*b)) ==
    0, (((d - b)/0.002) - (0.990074756047929 + h*c)) ==
    0, (((e - c)/0.002) - (0.985167483257382 + h*d)) ==
    0, (((f - d)/0.002) - (0.980296479563062 + h*e)) ==
    0, (((g - e)/0.002) - (0.975461279165159 + h*f)) ==
    0, (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 +
        h*c)) ==
    0, (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 +
        h*d)) ==
    0, (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 +
        h*e)) == 0};

Construct an objective function that is minimised when all of the equations 
are satisfied. The sum of the squares of the left hand sides of all of the 
equations (whose right hand sides are all zero) will achieve the desired 
effect.

objective = Total[eqns /. (x : _) == 0 :> x^2]

giving ...

(-0.995019 + 500. (-a + c) - b h)^2 + (-0.990075 + 500. (-b + d) -
   c h)^2 + (-0.990075 + 83.3333 (a - 8 b + 8 d - e) -
   c h)^2 + (-0.985167 + 500. (-c + e) - d h)^2 + (-0.985167 +
   83.3333 (b - 8 c + 8 e - f) - d h)^2 + (-0.980296 + 500. (-d + f) -
    e h)^2 + (-0.980296 + 83.3333 (c - 8 d + 8 f - g) -
   e h)^2 + (-0.975461 + 500. (-e + g) - f h)^2

Minimise the objective function.

solution = NMinimize[obj, {a, b, c, d, e, f, g, h}]

giving ...

{3.94032*10^-11, {a -> 0.314882, b -> 0.315979, c -> 0.317109,
  d -> 0.318197, e -> 0.319318, f -> 0.320396, g -> 0.321509,
  h -> 0.374577}}

which has a satisfyingly small value of the objective function at the found 
solution.

I'll bet there are other ways of solving this particular problem, but 
minimising an appropriate objective function is a very useful general 
approach.

-- 
Stephen Luttrell
West Malvern, UK

"Andy" <andy732a@gmail.com> wrote in message 
news:jil5ld$rrm$1@smc.vnet.net...
> I'm dealing with systems of nonlinear equations that have 8 equations
> and 8 unknowns.  Here's an example:
>
> Solve[{(((c - a)/0.002) - (0.995018769272803 + h*b)) == 0,
>  (((d - b)/0.002) - (0.990074756047929 + h*c)) == 0,
>  (((e - c)/0.002) - (0.985167483257382 + h*d)) == 0,
>  (((f - d)/0.002) - (0.980296479563062 + h*e)) == 0,
>  (((g - e)/0.002) - (0.975461279165159 + h*f)) == 0,
>  (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 + h*c)) ==
> 0,
>  (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 + h*d)) ==
> 0,
>  (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 + h*e)) ==
> 0}, {a, b, c, d, e, f, g, h}]
>
> Whenever I try this, Mathematica 7 just returns the empty set {}.  How
> can I tell if this is unsolvable?  Shouldn't I at least be able to get
> a numerical approximation with NSolve?  I've tried using stochastic
> optimization to get approximate answers but every method gives poor
> results, and that's why I would like to at least approximately solve
> this if possible.  Thanks very much for any help~
> 

[toc] | [prev] | [next] | [standalone]


#8851

From"Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com>
Date2012-03-03 11:56 +0000
Message-ID<jit0u6$e6r$1@smc.vnet.net>
In reply to#8831
Let me repost to fix the equations/eqns and objective/obj confusion I 
inadvertently introduced above:

eqns = {(((c - a)/0.002) - (0.995018769272803 + h*b)) ==
    0, (((d - b)/0.002) - (0.990074756047929 + h*c)) ==
    0, (((e - c)/0.002) - (0.985167483257382 + h*d)) ==
    0, (((f - d)/0.002) - (0.980296479563062 + h*e)) ==
    0, (((g - e)/0.002) - (0.975461279165159 + h*f)) ==
    0, (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 +
        h*c)) ==
    0, (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 +
        h*d)) ==
    0, (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 +
        h*e)) == 0};

obj = Total[eqns /. (x : _) == 0 :> x^2]

giving ...

(-0.995019 + 500. (-a + c) - b h)^2 + (-0.990075 + 500. (-b + d) -
   c h)^2 + (-0.990075 + 83.3333 (a - 8 b + 8 d - e) -
   c h)^2 + (-0.985167 + 500. (-c + e) - d h)^2 + (-0.985167 +
   83.3333 (b - 8 c + 8 e - f) - d h)^2 + (-0.980296 + 500. (-d + f) -
    e h)^2 + (-0.980296 + 83.3333 (c - 8 d + 8 f - g) -
   e h)^2 + (-0.975461 + 500. (-e + g) - f h)^2

solution = NMinimize[obj, {a, b, c, d, e, f, g, h}]

giving ...

{3.94032*10^-11, {a -> 0.314882, b -> 0.315979, c -> 0.317109,
  d -> 0.318197, e -> 0.319318, f -> 0.320396, g -> 0.321509,
  h -> 0.374577}}

-- 
Stephen Luttrell
West Malvern, UK

"Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com> wrote in 
message news:jiqfpe$6c$1@smc.vnet.net...
> equations = {(((c - a)/0.002) - (0.995018769272803 + h*b)) ==
>    0, (((d - b)/0.002) - (0.990074756047929 + h*c)) ==
>    0, (((e - c)/0.002) - (0.985167483257382 + h*d)) ==
>    0, (((f - d)/0.002) - (0.980296479563062 + h*e)) ==
>    0, (((g - e)/0.002) - (0.975461279165159 + h*f)) ==
>    0, (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 +
>        h*c)) ==
>    0, (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 +
>        h*d)) ==
>    0, (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 +
>        h*e)) == 0};
>
> Construct an objective function that is minimised when all of the 
> equations
> are satisfied. The sum of the squares of the left hand sides of all of the
> equations (whose right hand sides are all zero) will achieve the desired
> effect.
>
> objective = Total[eqns /. (x : _) == 0 :> x^2]
>
> giving ...
>
> (-0.995019 + 500. (-a + c) - b h)^2 + (-0.990075 + 500. (-b + d) -
>   c h)^2 + (-0.990075 + 83.3333 (a - 8 b + 8 d - e) -
>   c h)^2 + (-0.985167 + 500. (-c + e) - d h)^2 + (-0.985167 +
>   83.3333 (b - 8 c + 8 e - f) - d h)^2 + (-0.980296 + 500. (-d + f) -
>    e h)^2 + (-0.980296 + 83.3333 (c - 8 d + 8 f - g) -
>   e h)^2 + (-0.975461 + 500. (-e + g) - f h)^2
>
> Minimise the objective function.
>
> solution = NMinimize[obj, {a, b, c, d, e, f, g, h}]
>
> giving ...
>
> {3.94032*10^-11, {a -> 0.314882, b -> 0.315979, c -> 0.317109,
>  d -> 0.318197, e -> 0.319318, f -> 0.320396, g -> 0.321509,
>  h -> 0.374577}}
>
> which has a satisfyingly small value of the objective function at the 
> found
> solution.
>
> I'll bet there are other ways of solving this particular problem, but
> minimising an appropriate objective function is a very useful general
> approach.
>
> -- 
> Stephen Luttrell
> West Malvern, UK
>
> "Andy" <andy732a@gmail.com> wrote in message
> news:jil5ld$rrm$1@smc.vnet.net...
>> I'm dealing with systems of nonlinear equations that have 8 equations
>> and 8 unknowns.  Here's an example:
>>
>> Solve[{(((c - a)/0.002) - (0.995018769272803 + h*b)) == 0,
>>  (((d - b)/0.002) - (0.990074756047929 + h*c)) == 0,
>>  (((e - c)/0.002) - (0.985167483257382 + h*d)) == 0,
>>  (((f - d)/0.002) - (0.980296479563062 + h*e)) == 0,
>>  (((g - e)/0.002) - (0.975461279165159 + h*f)) == 0,
>>  (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 + h*c)) ==
>> 0,
>>  (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 + h*d)) ==
>> 0,
>>  (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 + h*e)) ==
>> 0}, {a, b, c, d, e, f, g, h}]
>>
>> Whenever I try this, Mathematica 7 just returns the empty set {}.  How
>> can I tell if this is unsolvable?  Shouldn't I at least be able to get
>> a numerical approximation with NSolve?  I've tried using stochastic
>> optimization to get approximate answers but every method gives poor
>> results, and that's why I would like to at least approximately solve
>> this if possible.  Thanks very much for any help~
>>
>
> 

[toc] | [prev] | [next] | [standalone]


#8832

From"Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com>
Date2012-03-02 12:52 +0000
Message-ID<jiqfqd$6q$1@smc.vnet.net>
In reply to#8792
On further investigation is see that in the objective function approach

NMinimize[obj, {a, b, c, d, e, f, g, h}]

NMinimize[obj, {a, b, c, d, e, f, g, h}, Method -> "DifferentialEvolution"]

NMinimize[obj, {a, b, c, d, e, f, g, h}, Method -> "SimulatedAnnealing"]

give radically different, but equally good, solutions to the equations.

So, the solution space is not 0-dimensional (i.e. a single point), and more 
work is needed to characterise it. Over to you!

-- 
Stephen Luttrell
West Malvern, UK 

[toc] | [prev] | [next] | [standalone]


#8842

FromRay Koopman <koopman@sfu.ca>
Date2012-03-03 11:58 +0000
Message-ID<jit112$e7i$1@smc.vnet.net>
In reply to#8792
On Feb 29, 4:28 am, Andy <andy7...@gmail.com> wrote:
> I'm dealing with systems of nonlinear equations that have 8 equations
> and 8 unknowns.  Here's an example:
>
> Solve[{(((c - a)/0.002) - (0.995018769272803 + h*b)) == 0,
>   (((d - b)/0.002) - (0.990074756047929 + h*c)) == 0,
>   (((e - c)/0.002) - (0.985167483257382 + h*d)) == 0,
>   (((f - d)/0.002) - (0.980296479563062 + h*e)) == 0,
>   (((g - e)/0.002) - (0.975461279165159 + h*f)) == 0,
>   (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 + h*c)) ==
> 0,
>   (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 + h*d)) ==
> 0,
>   (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 + h*e)) ==
> 0}, {a, b, c, d, e, f, g, h}]
>
> Whenever I try this, Mathematica 7 just returns the empty set {}.  How
> can I tell if this is unsolvable?  Shouldn't I at least be able to get
> a numerical approximation with NSolve?  I've tried using stochastic
> optimization to get approximate answers but every method gives poor
> results, and that's why I would like to at least approximately solve
> this if possible.  Thanks very much for any help~

To see if there is an exact solution to the problem,
make all the coefficients exact and use Solve:

x = {              500(c - a) - (995018769272803*^-15 + h*b),
                   500(d - b) - (990074756047929*^-15 + h*c),
                   500(e - c) - (985167483257382*^-15 + h*d),
                   500(f - d) - (980296479563062*^-15 + h*e),
                   500(g - e) - (975461279165159*^-15 + h*f),
(-1*e + 8*d - 8*b + a)1000/12 - (990074756047929*^-15 + h*c),
(-1*f + 8*e - 8*c + b)1000/12 - (985167483257382*^-15 + h*d),
(-1*g + 8*f - 8*d + c)1000/12 - (980296479563062*^-15 + h*e)};

Solve[Thread[x == 0],{a,b,c,d,e,f,g,h}]

{}

To get an approximate solution, minimize some measure of the
differences between the two sides of the equations. The sum of
the squared differences is convenient and not obviously improper;
that is, there is nothing to suggest that the equations are on
vastly different scales.

TimeConstrained[Minimize[x.x,{a,b,c,d,e,f,g,h}],300] aborted.

Both Minimize[N[x.x],{a,b,c,d,e,f,g,h}] and
NMinimize[x.x,{a,b,c,d,e,f,g,h}] finished in < 2 sec
and gave identical results:

{3.7850320584543324`*^-11,
 {a -> 1.78322069825487`,
  b -> 1.7856155567256693`,
  c -> 1.7880252569409105`,
  d -> 1.79041402958568`,
  e -> 1.7928176848807527`,
  f -> 1.7952004996719013`,
  g -> 1.7975982365756977`,
  h -> 0.7881096531282696`}}

The fit is a little better than Stephen Luttrell got,
but the parameter estimates are far what he got.

x /. %[[2]]

{-2.832840262367853`*^-7,
  1.7089251762580915`*^-6,
  3.9068509285478115`*^-6,
  1.6397939603951528`*^-6,
 -2.7478474384778906`*^-7,
 -1.6998965117753784`*^-6,
 -3.348694662008711`*^-6,
 -1.6487347667126784`*^-6}

It looks like only the first 5 digits of the 15-digit constants
are accurate.

[toc] | [prev] | [next] | [standalone]


#8859

From"Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com>
Date2012-03-04 09:33 +0000
Message-ID<jivctf$n3m$1@smc.vnet.net>
In reply to#8842
"Ray Koopman" <koopman@sfu.ca> wrote in message 
news:jit112$e7i$1@smc.vnet.net...
> On Feb 29, 4:28 am, Andy <andy7...@gmail.com> wrote:
>> I'm dealing with systems of nonlinear equations that have 8 equations
>> and 8 unknowns.  Here's an example:
>>
>> Solve[{(((c - a)/0.002) - (0.995018769272803 + h*b)) == 0,
>>   (((d - b)/0.002) - (0.990074756047929 + h*c)) == 0,
>>   (((e - c)/0.002) - (0.985167483257382 + h*d)) == 0,
>>   (((f - d)/0.002) - (0.980296479563062 + h*e)) == 0,
>>   (((g - e)/0.002) - (0.975461279165159 + h*f)) == 0,
>>   (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 + h*c)) ==
>> 0,
>>   (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 + h*d)) ==
>> 0,
>>   (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 + h*e)) ==
>> 0}, {a, b, c, d, e, f, g, h}]
>>
>> Whenever I try this, Mathematica 7 just returns the empty set {}.  How
>> can I tell if this is unsolvable?  Shouldn't I at least be able to get
>> a numerical approximation with NSolve?  I've tried using stochastic
>> optimization to get approximate answers but every method gives poor
>> results, and that's why I would like to at least approximately solve
>> this if possible.  Thanks very much for any help~
>
> To see if there is an exact solution to the problem,
> make all the coefficients exact and use Solve:
>
> x = {              500(c - a) - (995018769272803*^-15 + h*b),
>                   500(d - b) - (990074756047929*^-15 + h*c),
>                   500(e - c) - (985167483257382*^-15 + h*d),
>                   500(f - d) - (980296479563062*^-15 + h*e),
>                   500(g - e) - (975461279165159*^-15 + h*f),
> (-1*e + 8*d - 8*b + a)1000/12 - (990074756047929*^-15 + h*c),
> (-1*f + 8*e - 8*c + b)1000/12 - (985167483257382*^-15 + h*d),
> (-1*g + 8*f - 8*d + c)1000/12 - (980296479563062*^-15 + h*e)};
>
> Solve[Thread[x == 0],{a,b,c,d,e,f,g,h}]
>
> {}
>
> To get an approximate solution, minimize some measure of the
> differences between the two sides of the equations. The sum of
> the squared differences is convenient and not obviously improper;
> that is, there is nothing to suggest that the equations are on
> vastly different scales.
>
> TimeConstrained[Minimize[x.x,{a,b,c,d,e,f,g,h}],300] aborted.
>
> Both Minimize[N[x.x],{a,b,c,d,e,f,g,h}] and
> NMinimize[x.x,{a,b,c,d,e,f,g,h}] finished in < 2 sec
> and gave identical results:
>
> {3.7850320584543324`*^-11,
> {a -> 1.78322069825487`,
>  b -> 1.7856155567256693`,
>  c -> 1.7880252569409105`,
>  d -> 1.79041402958568`,
>  e -> 1.7928176848807527`,
>  f -> 1.7952004996719013`,
>  g -> 1.7975982365756977`,
>  h -> 0.7881096531282696`}}
>
> The fit is a little better than Stephen Luttrell got,
> but the parameter estimates are far what he got.
>
> x /. %[[2]]
>
> {-2.832840262367853`*^-7,
>  1.7089251762580915`*^-6,
>  3.9068509285478115`*^-6,
>  1.6397939603951528`*^-6,
> -2.7478474384778906`*^-7,
> -1.6998965117753784`*^-6,
> -3.348694662008711`*^-6,
> -1.6487347667126784`*^-6}
>
> It looks like only the first 5 digits of the 15-digit constants
> are accurate.
>

When I try to reproduce your solution using NMinimize I get my solution (not 
yours). I am using version 8.0.1 for Windows (32-bit). I presume that the 
discrepency is because the solution space is not a single point, so 
different versions and/or methods will arrive at different points in the 
solution space.

Anyway, I derived the Hessian matrix to have a close look at the 
neighbourhood of my solution point to see how the objective function 
behaved, where the solution space seems to be 2-dimensional. This doesn't 
tell us what it might look like further away. More work would be needed to 
characterise it all.

Equations.

eqns = {(((c - a)/0.002) - (0.995018769272803 + h*b)) ==
    0, (((d - b)/0.002) - (0.990074756047929 + h*c)) ==
    0, (((e - c)/0.002) - (0.985167483257382 + h*d)) ==
    0, (((f - d)/0.002) - (0.980296479563062 + h*e)) ==
    0, (((g - e)/0.002) - (0.975461279165159 + h*f)) ==
    0, (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 +
        h*c)) ==
    0, (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 +
        h*d)) ==
    0, (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 +
        h*e)) == 0};

Objective function.

obj = Total[eqns /. (x : _) == 0 :> x^2];

Minimise.

vars = {a, b, c, d, e, f, g, h};
soln = NMinimize[obj, vars]

giving what I got before ...

{3.94032*10^-11, {a -> 0.314882, b -> 0.315979, c -> 0.317109,
  d -> 0.318197, e -> 0.319318, f -> 0.320396, g -> 0.321509,
  h -> 0.374577}}

Now compute the matrix of second derivatives (Hessian) of the objective 
function at this solution point.

hessian = Outer[D[obj, #1, #2] &, vars, vars] /. soln[[2]];

Then compute the eigenvalues of the Hessian.

evals = Eigenvalues[hessian]

{4.19009*10^6, 3.42241*10^6, 1.39642*10^6,
 1.00435*10^6, 403393., 0.0159205, -2.57089*10^-10, 7.18138*10^-12}

Eyeballing this (or using ListPlot[evals, Filling -> Axis]) you see 5 large 
(order 10^6), 1 very small (order 10^-2), and 2 noise level (order 10^(-10 
or -11)) eigenvalues, so the the objective function stays at its minimum 
value as you move away from the solution point in 2 (or 3, almost) 
independent directions. The solution space is 2-dimensional (at least) 
around the solution point.

You can use EigenSystem[hessian] to look at this 2D solution space in more 
detail.

{evals, evects} = Eigensystem[hessian];

The last 2 eigenvectors (i.e. with noise level eigenvalues) span the 
2-dimensional solution space using coefficients (u,v).

solnoffset = Thread[vars -> vars + {u, v}.Take[evects, -2]]

{a -> a + 0.37754 u - 0.000830755 v,
 b -> b + 0.377681 u - 0.000462092 v,
 c -> c + 0.377823 u - 0.000199144 v,
 d -> d + 0.377964 u + 0.000171975 v,
 e -> e + 0.378106 u + 0.000437376 v,
 f -> f + 0.378247 u + 0.000810937 v,
 g -> g + 0.378389 u + 0.00107878 v,
 h -> h - 0.000381899 u + 0.999999 v}

Check what the objective function now looks like in the 2-dimensional 
neighbourhood of the solution point.

objsoln[u_, v_] = obj /. solnoffset /. soln[[2]] // Expand // Chop

1.66682*10^-7 u^4 - 0.000872909 u^3 v + 1.14285 u^2 v^2 +
 0.000884953 u v^3 + 1.39221*10^-6 v^4

The coefficients are not all minuscule, but all of the terms are quartic 
which helps the objective function to stay close to zero over a sizeable 
2-dimensional region around the solution point.

Check what the objective function looks like in this region by generating a 
contour plot.

ContourPlot[objsoln[u, v], {u, -0.1, 0.1}, {v, -0.1, 0.1}]

which shows that the (u,0) and (0,v) directions are the "flattest".

Anyway, those are the sorts of techniques that I would use to get a "toe 
hold" on the solution space around a particular found solution point.

-- 
Stephen Luttrell
West Malvern, UK 

[toc] | [prev] | [next] | [standalone]


#8863

FromRay Koopman <koopman@sfu.ca>
Date2012-03-04 09:36 +0000
Message-ID<jivd29$n60$1@smc.vnet.net>
In reply to#8842
On Mar 3, 3:58 am, Ray Koopman <koop...@sfu.ca> wrote:
> On Feb 29, 4:28 am, Andy <andy7...@gmail.com> wrote:
>> I'm dealing with systems of nonlinear equations that have 8 equations
>> and 8 unknowns.  Here's an example:
>>
>> Solve[{(((c - a)/0.002) - (0.995018769272803 + h*b)) == 0,
>>   (((d - b)/0.002) - (0.990074756047929 + h*c)) == 0,
>>   (((e - c)/0.002) - (0.985167483257382 + h*d)) == 0,
>>   (((f - d)/0.002) - (0.980296479563062 + h*e)) == 0,
>>   (((g - e)/0.002) - (0.975461279165159 + h*f)) == 0,
>>   (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 + h*c)) ==
>> 0,
>>   (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 + h*d)) ==
>> 0,
>>   (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 + h*e)) ==
>> 0}, {a, b, c, d, e, f, g, h}]
>>
>> Whenever I try this, Mathematica 7 just returns the empty set {}.  How
>> can I tell if this is unsolvable?  Shouldn't I at least be able to get
>> a numerical approximation with NSolve?  I've tried using stochastic
>> optimization to get approximate answers but every method gives poor
>> results, and that's why I would like to at least approximately solve
>> this if possible.  Thanks very much for any help~
>
> To see if there is an exact solution to the problem,
> make all the coefficients exact and use Solve:
>
> x = {              500(c - a) - (995018769272803*^-15 + h*b),
>                    500(d - b) - (990074756047929*^-15 + h*c),
>                    500(e - c) - (985167483257382*^-15 + h*d),
>                    500(f - d) - (980296479563062*^-15 + h*e),
>                    500(g - e) - (975461279165159*^-15 + h*f),
> (-1*e + 8*d - 8*b + a)1000/12 - (990074756047929*^-15 + h*c),
> (-1*f + 8*e - 8*c + b)1000/12 - (985167483257382*^-15 + h*d),
> (-1*g + 8*f - 8*d + c)1000/12 - (980296479563062*^-15 + h*e)};
>
> Solve[Thread[x == 0],{a,b,c,d,e,f,g,h}]
>
> {}
>
> To get an approximate solution, minimize some measure of the
> differences between the two sides of the equations. The sum of
> the squared differences is convenient and not obviously improper;
> that is, there is nothing to suggest that the equations are on
> vastly different scales.
>
> TimeConstrained[Minimize[x.x,{a,b,c,d,e,f,g,h}],300] aborted.
>
> Both Minimize[N[x.x],{a,b,c,d,e,f,g,h}] and
> NMinimize[x.x,{a,b,c,d,e,f,g,h}] finished in < 2 sec
> and gave identical results:
>
> {3.7850320584543324`*^-11,
>  {a -> 1.78322069825487`,
>   b -> 1.7856155567256693`,
>   c -> 1.7880252569409105`,
>   d -> 1.79041402958568`,
>   e -> 1.7928176848807527`,
>   f -> 1.7952004996719013`,
>   g -> 1.7975982365756977`,
>   h -> 0.7881096531282696`}}
>
> The fit is a little better than Stephen Luttrell got,
> but the parameter estimates are far what he got.
>
> x /. %[[2]]
>
> {-2.832840262367853`*^-7,
>   1.7089251762580915`*^-6,
>   3.9068509285478115`*^-6,
>   1.6397939603951528`*^-6,
>  -2.7478474384778906`*^-7,
>  -1.6998965117753784`*^-6,
>  -3.348694662008711`*^-6,
>  -1.6487347667126784`*^-6}
>
> It looks like only the first 5 digits of the 15-digit constants
> are accurate.

Not only is there no exact solution, there is also no finite
approximate solution. To see why, note that if the last unknown, h,
is treated as a fixed constant then the system is linear in the
seven other unknowns, a,...,g. Hence for any given value of h we
can get a closed-form expression for a,...,g that minimizes x.x .
The conditionally minimized value of x.x turns out to be

              8782274623591681
 ------------------------------------------ .
 320000000000000000000000*(6312500 + 9*h^2)

The corresponding conditional values of {a,...,g} are

{(-57239352511710937500000 + h*(7888018985908781250000 +
  h*(-1578205521876264250000 + 9*(1249663134566125 -
  249999762898476*h)*h)))/(250000000000000*h^3*(6312500 + 9*h^2)),
 (-228957410046843750000000 + 3*h*(10441039511196093750000 +
  h*(-2093794831545500750000 + 3*(4962147772987500 -
  995018769272803*h)*h)))/(1000000000000000*h^3*(6312500 + 9*h^2)),
 (-228957410046843750000000 + h*(31094161123541437500000 +
  h*(-6250175850437880437500 + 9*(4925643007710500 -
  990074756047929*h)*h)))/(1000000000000000*h^3*(6312500 + 9*h^2)),
 (3*((-610553093458250000 + (82307209902652250 -
  16583652634832597*h)*h)/h^3 - 66361078251875/(6312500 + 9*h^2)))/
  50500000000000000,
 (-114478705023421875000000 + h*(15318123151723875000000 +
  h*(-3094222721505445625000 + 9*(2426551023055750 -
  490148239781531*h)*h)))/(500000000000000*h^3*(6312500 + 9*h^2)),
 (-228957410046843750000000 + 3*h*(10135762964466968750000 +
  h*(-2052641226594174625000 + 3*(4817065849789500 -
  975461279165159*h)*h)))/(1000000000000000*h^3*(6312500 + 9*h^2)),
 (-228957410046843750000000 + h*(30178331483354062500000 +
  h*(-6127630865224089437500 + 9*(4781029653467500 -
  970662347863483*h)*h)))/(1000000000000000*h^3*(6312500 + 9*h^2))}.

All those go to 0 as h -> Infinity.

[toc] | [prev] | [next] | [standalone]


#8864

From"Stephen Luttrell" <steve@_removemefirst_stephenluttrell.com>
Date2012-03-05 06:05 +0000
Message-ID<jj1l38$s02$1@smc.vnet.net>
In reply to#8863
"Ray Koopman" <koopman@sfu.ca> wrote in message 
news:jivd29$n60$1@smc.vnet.net...
> On Mar 3, 3:58 am, Ray Koopman <koop...@sfu.ca> wrote:

<SNIPPED>

> Not only is there no exact solution, there is also no finite
> approximate solution. To see why, note that if the last unknown, h,
> is treated as a fixed constant then the system is linear in the
> seven other unknowns, a,...,g. Hence for any given value of h we
> can get a closed-form expression for a,...,g that minimizes x.x .
> The conditionally minimized value of x.x turns out to be
>
>              8782274623591681
> ------------------------------------------ .
> 320000000000000000000000*(6312500 + 9*h^2)
>
> The corresponding conditional values of {a,...,g} are
>
> {(-57239352511710937500000 + h*(7888018985908781250000 +
>  h*(-1578205521876264250000 + 9*(1249663134566125 -
>  249999762898476*h)*h)))/(250000000000000*h^3*(6312500 + 9*h^2)),
> (-228957410046843750000000 + 3*h*(10441039511196093750000 +
>  h*(-2093794831545500750000 + 3*(4962147772987500 -
>  995018769272803*h)*h)))/(1000000000000000*h^3*(6312500 + 9*h^2)),
> (-228957410046843750000000 + h*(31094161123541437500000 +
>  h*(-6250175850437880437500 + 9*(4925643007710500 -
>  990074756047929*h)*h)))/(1000000000000000*h^3*(6312500 + 9*h^2)),
> (3*((-610553093458250000 + (82307209902652250 -
>  16583652634832597*h)*h)/h^3 - 66361078251875/(6312500 + 9*h^2)))/
>  50500000000000000,
> (-114478705023421875000000 + h*(15318123151723875000000 +
>  h*(-3094222721505445625000 + 9*(2426551023055750 -
>  490148239781531*h)*h)))/(500000000000000*h^3*(6312500 + 9*h^2)),
> (-228957410046843750000000 + 3*h*(10135762964466968750000 +
>  h*(-2052641226594174625000 + 3*(4817065849789500 -
>  975461279165159*h)*h)))/(1000000000000000*h^3*(6312500 + 9*h^2)),
> (-228957410046843750000000 + h*(30178331483354062500000 +
>  h*(-6127630865224089437500 + 9*(4781029653467500 -
>  970662347863483*h)*h)))/(1000000000000000*h^3*(6312500 + 9*h^2))}.
>
> All those go to 0 as h -> Infinity.
>

I agree with and like your result.

If I reevaluate everything (in my previous comment) starting with h=10^6 
(i.e. a large value) and minimise w.r.t. {a,b,c,d,e,f,g} (i.e. omitting h), 
then I get Hessian eigenvalues

{4.*10^12, 4.*10^12, 4.*10^12, 2.*10^12, 2.*10^12, 6958.34, 6930.56}

where are still 2 (relatively) small eigenvalues whose eigenvectors are

{{1., -0.000499972, 0.0000419583, -4.87781*10^-8,
 7.10513*10^-9, -4.33947*10^-8, -0.0000867811},
{0.0000867811, -4.33864*10^-8, 7.07126*10^-9,
-4.8444*10^-8, -0.000041375, 0.000500028, 1.}}

which approximate {1,0,0,0,0,0,0} and {0,0,0,0,0,0,1}, so (for large h) 
variables a and g are much more weakly constrained by the minimisation than 
variables {b, c, d, e, f}. Looking at the equations, I see that variables a 
and g are different from the rest, because the structure of the first 5 
equations suggests that variables a and g are associated with "boundaries" 
of some sort.

This begs the question of where the equations came from in the first place. 
Maybe h is a parameter, and "solving" for {a, b, c, d, e, f, g} is actually 
an optimisation problem. The equations given would then define an 
unattainable "ideal" solution.

-- 
Stephen Luttrell
West Malvern, UK 

[toc] | [prev] | [next] | [standalone]


#8844

Fromdanl@wolfram.com
Date2012-03-03 11:54 +0000
Message-ID<jit0qa$e4v$1@smc.vnet.net>
In reply to#8792
On Wednesday, February 29, 2012 6:28:29 AM UTC-6, Andy wrote:
> I'm dealing with systems of nonlinear equations that have 8 equations
> and 8 unknowns.  Here's an example:
>
> Solve[{(((c - a)/0.002) - (0.995018769272803 + h*b)) == 0,
>   (((d - b)/0.002) - (0.990074756047929 + h*c)) == 0,
>   (((e - c)/0.002) - (0.985167483257382 + h*d)) == 0,
>   (((f - d)/0.002) - (0.980296479563062 + h*e)) == 0,
>   (((g - e)/0.002) - (0.975461279165159 + h*f)) == 0,
>   (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 + h*c)) ==
> 0,
>   (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 + h*d)) ==
> 0,
>   (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 + h*e)) ==
> 0}, {a, b, c, d, e, f, g, h}]
>
> Whenever I try this, Mathematica 7 just returns the empty set {}.  How
> can I tell if this is unsolvable?  Shouldn't I at least be able to get
> a numerical approximation with NSolve?  I've tried using stochastic
> optimization to get approximate answers but every method gives poor
> results, and that's why I would like to at least approximately solve
> this if possible.  Thanks very much for any help~

It is not solvable. Or at least, a rationalized version has no solution. Here is one way to show this.

polys = Apply[
   Subtract, {(((c - a)/0.002) - (0.995018769272803 + h*b)) ==
     0, (((d - b)/0.002) - (0.990074756047929 + h*c)) ==
     0, (((e - c)/0.002) - (0.985167483257382 + h*d)) ==
     0, (((f - d)/0.002) - (0.980296479563062 + h*e)) ==
     0, (((g - e)/0.002) - (0.975461279165159 + h*f)) ==
     0, (((-1*e + 8*d - 8*b + a)/(12*0.001)) - (0.990074756047929 +
         h*c)) ==
     0, (((-1*f + 8*e - 8*c + b)/(12*0.001)) - (0.985167483257382 +
         h*d)) ==
     0, (((-1*g + 8*f - 8*d + c)/(12*0.001)) - (0.980296479563062 +
         h*e)) == 0}, 1];

p2 = Rationalize[polys, 0];
p3 = Expand[p2];
vars = Variables[p2];

For showing non-solvability, it suffices (by Hilbert's Nullstellensatz, apologies for pulling that bit of math jargon out of a hat) to find a way to write a constant as an algebraic sum of these polynomials. That is to say, we show the ideal defined by those polynomials contains 1. One way to do so uses a bit of code that I posted to MathGroup around a year ago.

http://forums.wolfram.com/mathgroup/archive/2011/Mar/msg00362.html

I'll just copy it here for completeness.

moduleGroebnerBasis[polys_, vars_, cvars_, opts___] :=
 Module[{newpols, rels, len = Length[cvars], gb, j, k, rul},
  rels = Flatten[
    Table[cvars[[j]]*cvars[[k]], {j, len}, {k, j, len}]];
  newpols = Join[polys, rels];
  gb = GroebnerBasis[newpols, Join[cvars, vars], opts];
  rul = Map[(# :> {}) &, rels];
  gb = Flatten[gb /. rul];
  Collect[gb, cvars]]


conversionMatrix[polys_, vars_] :=
 Module[{aa, coords, pmat, len = Length[polys], newpolys, mgb, gb,
   convmat, fvar, rvars}, coords = Array[aa, len + 1];
  fvar = First[coords];
  rvars = Rest[coords];
  pmat = Transpose[Join[{polys}, IdentityMatrix[len]]];
  newpolys = pmat.coords;
  mgb = moduleGroebnerBasis[newpolys, vars, coords];
  gb = mgb /. Join[{fvar -> 1}, Thread[rvars -> 0]] /. 0 :> Sequence[];
  convmat = Select/. fvar -> 0;
  {gb, convmat /.
    Thread[rvars -> Table[UnitVector[len, j], {j, len}]]}]

On your example we proceed as follows.

In[40]:= {gb, cmat} = conversionMatrix[p3, vars]

Out[40]= {{2321109176622379997592951205}, \
{{-2476806404274022328337996647266500,
   19814451234192178626703973178132000,
   29721676851288267940055959767198 h, \
-19814451234192178626703973178132000,
   2476806404274022328337996647266500, \
-14860838425644133970027979883599000, \
-29721676851288267940055959767198 h,
   14860838425644133970027979883599000}}}

We check the result. Specifically we show that the conversion matrix, multiplied by the polynomial system input regarded as a vector, indeed gives a constant.

In[42]:= Expand[cmat.p3]

Out[42]= {2321109176622379997592951205}

So there you have it: no solution for this system.

Daniel Lichtblau
Wolfram Research

[toc] | [prev] | [standalone]


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


csiph-web