Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Modify data to satisfy constraints

  • To: mathgroup at
  • Subject: [mg8946] Modify data to satisfy constraints
  • From: Serge Crouzy <crouzy at>
  • Date: Mon, 6 Oct 1997 01:59:16 -0400
  • Organization: CEA Commissariat a l'Energie Atomique, France.
  • Sender: owner-wri-mathgroup at

Dear Mathematica experts,

        I have a set of independant variables xi0, (x10,x20.. xn0), which I
want to modify as little as possible into xi to satisfy a constraint
f(x1,x2,...xn)=0   assuming that f(x10,x20,..xn0) different from 0
        By as little as possible, I mean that the distance between the new set
xi satisfying the constraint and the initial set xi0 should be minimum.
For instance if I note
The sum of squares ei^2 should be minimum.
In the case of multiple solutions I'm only interested in the real one.. All
xi0, xi, ei should be real.
        What would a Mathematica program look like for solving this problem if
possible symbolically ? (maybe with the possibility to have several
constraining equations)
        To fix the ideas, I give here a trivial code in the case  n=3 and

(* Obvious solution *)
f1[x2_,x3_]=-x2 - x3
(* initial set x10, x20, x30 *)
(* The distance *)
Solve[{D[g[x2,x3],x2]==0, D[g[x2,x3],x3]==0},{x2,x3}]
(* gives the solutions *)
sol2=(-x10 + 2 x20 - x30)/3
sol3=(-x10 - x20 + 2 x30)/3
sol1 = f1[sol2,sol3]
(* The distance between the solution and the initial set being *)
         (x10 + x20 + x30)
Out[28]= ------------------

        Thanx in advance for your help,


  | Serge Crouzy                               |
  | CEN Grenoble BMC/DBMS  C3 252 B            |
  | 17 Rue des Martyrs,                        |
  | 38054 GRENOBLE cedex 9  FRANCE             |
  | E.Mail address : crouzy at  |
  | Tel. (33) 76884848  Fax: (33)76885487      |  

  • Prev by Date: MMA3.0.0 bug in symbolic summation
  • Next by Date: Setting precision in binary digits?
  • Previous by thread: Re: MMA3.0.0 bug in symbolic summation
  • Next by thread: Setting precision in binary digits?