[R] What solve() does?

David Winsemius dwinsemius at comcast.net
Sat Sep 4 21:51:05 CEST 2010


On Sep 4, 2010, at 2:29 PM, Petar Milin wrote:

> Thank you so much! This is very useful!
> Any thoughts about how to run Gaussian elimination?

Do some searching?

RSiteSearch("gaussian elimination", restrict = c("Rhelp10", "Rhelp08",  
"Rhelp02", "functions"  ) )

.... returns (among other things) a link to a John Fox post from 2005:

http://finzi.psych.upenn.edu/R/Rhelp02/archive/49950.html

-- 
David.
>
> Best,
> PM
>
> On 04/09/10 20:23, Paul Johnson wrote:
>> On Wed, Sep 1, 2010 at 5:36 AM, Petar Milin<pmilin at ff.uns.ac.rs>   
>> wrote:
>>
>>> Hello!
>>> Can anyone explain me what solve() function does: Gaussian  
>>> elimination or
>>> iterative, numeric solve? In addition, I would need both the  
>>> Gaussian
>>> elimination and iterative solution for the course. Are the two  
>>> built in R?
>>>
>>> Thanks!
>>>
>>
>>> PM
>>>
>> Hello, Petar:
>>
>> I think you are assuming that solve uses an elementary linear algebra
>> "paper and pencil" procedure, but I don't think it does.  In a  
>> digital
>> computer, those things are not precise, and I think the folks here
>> will even say you shouldn't use solve to get an inverse, but I can't
>> remember all of the details.
>>
>> To see how solve works ...
>>
>> Let me show you a trick I just learned. Read
>>
>> ?solve
>>
>> notice it is a "generic method", meaning it does not actually do the
>> calculations for you. Rather, there are specific implementations for
>> different types of cases. To find the implementations, run
>>
>> methods(solve)
>>
>> I get:
>>
>>
>>> methods(solve)
>>>
>> [1] solve.default solve.qr
>>
>> Then if you want to read HOW solve does what it does (which I think
>> was your question), run this:
>>
>>
>>> solve.default
>>>
>> or
>>
>>
>>> solve.qr
>>>
>> In that code, you will see the chosen procedure depends on the linear
>> algebra libraries you make available.  I'm no expert on the details,
>> but it appears QR decomposition is the preferred method.  You can  
>> read
>> about that online or in numerical algebra books.
>>
>>
>>
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list