# Simultaneous equations Classic List Threaded 5 messages Open this post in threaded view
|

## Simultaneous equations

 Dear all, I am relatively new to R and have had some difficulty in understanding the user manual for a package that I have downloaded to evaluate non-linear simultaneous equations. The package is called systemfit. Does anyone have any experience of this package? What I am trying to do is solve a non linear simultaneous equations... Could anyone give me an example (please) of the code that would be needed to return solutions for the following system using systemfit (or any other better package): y=1/x y=sin(x) within a range of say x=-10 to 10 (x in radians) Thanks, I really appreciate your help in advance. Ben
Open this post in threaded view
|

## Re: Simultaneous equations

 benhartley903 wrote Dear all, I am relatively new to R and have had some difficulty in understanding the user manual for a package that I have downloaded to evaluate non-linear simultaneous equations. The package is called systemfit. Does anyone have any experience of this package? What I am trying to do is solve a non linear simultaneous equations... Could anyone give me an example (please) of the code that would be needed to return solutions for the following system using systemfit (or any other better package): y=1/x y=sin(x) within a range of say x=-10 to 10 (x in radians) Thanks, I really appreciate your help in advance. Ben systemfit is intended for estimating a system of simultaneous equations. You seem to want to solve a system. I assume you want to solve this system for x and y. You could use package nleqslv as follows: library(nleqslv) fun <- function(x) {      f <- numeric(length(x))      f <-  x - 1/x      f <-  x - sin(x)      f } x.start <- c(1,1) nleqslv(x.start,fun)  # will give 1.1141571 0.8975395 x.start <- c(2,2) nleqslv(x.start,fun)  # will give 2.7726047 0.3606717 Berend
Open this post in threaded view
|