       Modify data to satisfy constraints

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

```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
xi=xi0-ei
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
f(x1,x2,x3)=x1+x2+x3

f[x1_,x2_,x3_]=x1+x2+x3
Solve[f[x1,x2,x3]==0,{x1,x2,x3}]
(* Obvious solution *)
f1[x2_,x3_]=-x2 - x3
x1=f1[x2,x3]
(* initial set x10, x20, x30 *)
e2=x20-x2
e3=x30-x3
e1=x10-x1
(* The distance *)
g[x2_,x3_]=e1^2+e2^2+e3^2
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 *)
2
(x10 + x20 + x30)
Out= ------------------
3

Serge

--
*--------------------------------------------*
| Serge Crouzy                               |
| CEN Grenoble BMC/DBMS  C3 252 B            |
| 17 Rue des Martyrs,                        |
| 38054 GRENOBLE cedex 9  FRANCE             |
| E.Mail address : crouzy at bonne.ceng.cea.fr  |
| 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?