# Re: [Jprogramming] Multidimensional Root Finding with Newton Solver

```Solving many algebraic equations in many unknowns can be done by eliminating
the unknowns one by one obtaining many algebraic equations in one unknown each,
and then solving these equations numerically.
Example: Two equations in two unknowns. 0 = (x^2)+(y^2)-16 = (y-2) .
0 = y-2 = y(y-2) = (y^2)-(2*y)= ((x^2)+(y^2)-16)-((y^2)-(2*y)) = (x^2)+(2*y)-16
= ((x^2)+(2*y)-16)-2*(y-2) = (x^2)-12
Now the system 0 = (x^2)+(y^2)-16 = (y-2)  is reduced to 0 = (x^2)-12 = (y-2)
These are solved:
p. _12 0 1 p. _2 1```
```
The method is general, but  cumbersome for equations of high degree in many
unknowns.
Thanks. Bo.

Den 0:06 fredag den 11. august 2017 skrev Louis de Forcrand
<ol...@bluewin.ch>:

I find it interesting that N-R works for vectors and complex functions (and
mixes of both). Just replace all those scalar functions by their vector
equivalents:

vn=: 1 : '- n * u %. u D.1'

I added a scaling factor; it makes the convergence slower, but it fixes
problems due to precision-loss.

It works reasonably well:

f=: ^&0 1 - 1 2 ^~ {.
f vn 0.1^:1e3 ] 0 0
1 1

Louis

> On 10 Aug 2017, at 13:07, Martin <d...@famic.de> wrote:
>
> Hi there,
>
> J looks very interesting. I have no previous experience with array
> languages and, being curious, started to experiment.  Now, I would
> like to solve a system of non-linear equations. I could only examples
> solving single equations like this one:
>
>  N=: 1 : '- u % u d. 1'  NB. Adverb implementing Newton-Raphson iteration.
>  (_2 + *:) N^:_ ]1        NB. Find root of “0 = _2+x^2”, starting guess of
>“1”.
>
> Is it also possible to solve a system of equation like the following
> one in a similar elegant manner?
>
>  f1(x) = a*(1-x1)
>  f2(x) = b*(x2-x1^2)
>
> Example from
> https://www.gnu.org/software/gsl/doc/html/multiroots.html#examples
>
> Thanks for any ideas!
> -Martin
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm```