# Re: [R] Linear system

From: Arne Henningsen <ahenningsen_at_email.uni-kiel.de>
Date: Wed 25 May 2005 - 23:02:10 EST

On Wednesday 25 May 2005 14:30, Jim Gustafsson wrote:
> Dear R-help
>
> I have a problem solving a linear system like
>
> 353a+45b+29c=79
> 45a+29b+3c=5
> 29a+3b+4c=8
>
> Is there any way of doing this in R?

You can write this equation system in matrix form: M * x = y

with
x = ( a, b, c )

```M = ( 353, 45, 29,
45, 29,  3,
29,  3,  4 )
```

y = ( 79, 5, 8 )

you can solve the system by
x = M^(-1) * y

In R you can do this by
R> M = matrix( c( 353, 45, 29, 45, 29, 3, 29, 3, 4 ),

ncol = 3, byrow = TRUE )
R> y <- c( 79, 5, 8 )
R> x <- solve( M ) %*% y
or
R> x <- solve( M, y )

Arne

> Best Regards
> Jim
>
>
> ---------------------------------------------------------------------------
>--- This e-mail and any attachment may be confidential and may also be
> privileged. If you are not the intended recipient, please notify us
> immediately and then delete this e-mail and any attachment without
> retaining copies or disclosing the contents thereof to any other person.
> Thank you.
> ---------------------------------------------------------------------------
>--- [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html

```--
Arne Henningsen
Department of Agricultural Economics
University of Kiel
Olshausenstr. 40
D-24098 Kiel (Germany)
Tel: +49-431-880 4445
Fax: +49-431-880 1397
ahenningsen@agric-econ.uni-kiel.de
http://www.uni-kiel.de/agrarpol/ahenningsen/

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help