Displaying 20 results from an estimated 5000 matches similar to: "Solving an equation in R (and using a loop)"
2020 Oct 06
0
Solving a simple linear equation using uniroot give error object 'x' not found
On 06/10/2020 11:00 a.m., Sorkin, John wrote:
> Colleagues,
> I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message,
> Error in yfu n(x,10,20) : object 'x' not found.
>
> I hope someone can tell we how I can fix
2020 Oct 06
4
Solving a simple linear equation using uniroot give error object 'x' not found
Colleagues,
I am trying to learn to use uniroot to solve a simple linear equation. I define the function, prove the function and a call to the function works. When I try to use uniroot to solve the equation I get an error message,
Error in yfu n(x,10,20) : object 'x' not found.
I hope someone can tell we how I can fix the problem
2009 Jun 09
1
Problem : solving a equation with R , fail with uniroot function
Hi ,
I would like to know if a R function have the same behaviour than the matlab
solve function.
I tried something with uniroot but I have some problems:
The equation I need to solve is :
exp(c0-r0)*(bb0+x)*(bb1-x)=(bb0+x+1)(bb1-x-1)
So I tried this:
STEP 1: my function test
test <- function(x,bb0=-3,bb1=5,c0=2,r0=0) {
+ ((exp(c0-r0)*(bb0+x)*(bb1-x))/((bb0+x+1)(bb1-x-1))-1)}
STEP 2:
>
2012 Mar 24
1
Solving the equation using uniroot
Hello all,
I was going to solve (n-m)! * (n-k)! = 0.5 *n! * (n-m-k)!
for m when values of n and k are provided
n1<-c(10,13,18,30,60,100,500) # values of n
kx<-seq(1,7,1); # values of k
slv2<-lapply(n1,function(n){
slv1<-lapply(kx,function(k){
lhs<-function(m)
{
2012 Jul 26
3
Solving quadratic equation in R
Hi there,
I would like to solve a simple equation in R
a^2 - a = 8.313
There is no real solution to this problem but I would like to get an
approximate numerical solution. Can someone suggest how I can set this up?
Thanks in advance,
Diviya
[[alternative HTML version deleted]]
2010 May 01
1
Solving equation
Hello,
I want to solve: x*(3^x)*log(4)-x*log(4/3)-(3^x)+1=0 for x. I used the following code,
uniroot(function(x) x*(3^x)*log(4)-x*log(4/3)-(3^x)+1, lower = -2, upper = 2, tol = 0.001 )
While using this I am getting the following error. Can anyone please help me out.
Error in uniroot(function(x) x * (3^x) * log(4) - x * log(4/3) - (3^x) + : f() values at end points not of opposite sign.
2007 Mar 19
1
Row wise solving an equation
Hello R-list,
How can I row wise solve a function for which the input variables are written in a matrix or a vector and have the calculated output added to the matrix or written in a vector?
To specify my case in particular I continue: I would like R to calculate for me a value for ‘t’ which is function of input parameters A and B, which are comprised in a matrix called ‘ddt’ and some other
2009 Nov 04
2
solving a linear equation
Hi all,
I've a linear equation of the form:
0.95=2 ( [3+ln(x/3)]^-13 + 4 [3+2ln(x/3)]^-13 + [3+4ln(x/3)]^-13 )
and I want to solve it for x, can I do this using R?
Thanks in advance.
Maram.
[[alternative HTML version deleted]]
2008 May 24
1
Solving 100th order equation
Hi R,
I have a 100th order equation for which I need to solve the value for x. Is there a package to do this?
For example my equation is:
(x^100 )- (2*x^99) +(10*x^50)+.............. +(6*x ) = 4000
I have only one unknown value and that is x. How do I solve for this?
BR, Shubha
Shubha Karanth | Amba Research
Ph +91 80 3980 8031 | Mob +91 94 4886 4510
Bangalore *
2011 Feb 21
1
question about solving equation using bisection method
Hi all,
I have the following two function f1 and f2.
f1 <- function(lambda,z,p1){
lambda*(p1*exp(-3*z-9/2)+(0.2-p1)*exp(4*z-8))-(1-lambda)*0.8}
f2 <- function(p1,cl, cu){
0.8*(pnorm(cl)+(1-pnorm(cu)))/(0.8*(pnorm(cl)+(1-pnorm(cu)))+p1*(pnorm(cl+3)+(1-pnorm(cu+3)))+(0.2-p1)*(pnorm(cl-4)+(1-pnorm(cu-4))))}-0.05
First fix p1 to be 0.15.
(i) choose a lambda value, say lamda=0.6,
(ii)
2009 Nov 04
1
Fw: solving a linear equation
Sorry, I didn't mean a linear equation, of course this equation is not linear, I meant an equation in one unknown.
Hi all,
I've a linear equation of the form:
0.95=2 ( [3+ln(x/3)]^-13? + 4 [3+2ln(x/3)]^-13? + [3+4ln(x/3)]^-13 )
and I want to solve it for x, can I do this using R?
Thanks in advance.
Maram.
? ? ?
??? [[alternative HTML version deleted]]
-------------- next
2008 Dec 02
3
How to solve following equation?
I need to solve a equation like this :
a = b/(1+x) + c/(1+x)^2 + d/(1+x)^3
where a,b,c,d are known constant. Is there any R-way to do that?
Thanks in advance
--
View this message in context: http://www.nabble.com/How-to-solve-following-equation--tp20785063p20785063.html
Sent from the R help mailing list archive at Nabble.com.
2012 Jul 23
2
Solving equations in R
Hi there,
I would like to solve the following equation in R to estimate 'a'. I have
the amp, d, x and y.
amp*y^2 = 2*a*(1-a)*(-a*d+(1-a)*x)^2
test data:
amp = 0.2370 y=
0.0233 d=
0.002 x=
0.091
Can anyone suggest how I can set this up?
Thanks,
Diviya
[[alternative HTML version deleted]]
2010 Jan 26
1
newton method for single nonlinear equation
Hi r-users,
I would like to solve for z values using newton iteration method. I 'm not sure which part of the code is wrong since I'm not very good at programming but would like to learn. There seem to be some output but what I expected is a vector of z values. Thank you so much for any help given.
newton.inputsingle <- function(pars,n)
{ runi <- runif(974, min=0, max=1)
2003 Apr 21
4
nonlinear equation solver?
Dear R-Help,
I am trying to use R to solve a nonlinear equation many times for different values. I am looking for a mathematical nonlinear equation solution which may not have a closed solution form. For example, I have equation:
2 = (t^2)/log(t)
What is t?
I am wondering how to solve it in R.
Many thanks,
Zhu Wang
Statistical Science Department
SMU.
2007 Jun 20
4
finding roots of multivariate equation
Hello,
I want to find the roots of an equation in two variables. I am aware of the
uniroot function, which can do this for a function with a single variable (as I
understand it...) but cannot find a function that does this for an equation
with more than one variable. I am looking for something implementing similar
to a Newton-Raphson algorithm.
Thanks.
--
Bill Shipley
North American Editor for
2010 Sep 24
1
Solving equations involving gamma functions
Hi,
I want to find a value of n1. I used the following code but I am getting the
error -
Error in as.vector(x, mode) :
cannot coerce type 'closure' to vector of type 'any'
n=10
a_g<-(1/(n*(n-1)))*((pi/3)*(n+1)+(2*sqrt(3)*(n-2))-4*n+6)
a_s<-function(n1)
{
t1=(n1-1)/2;
(t1*(gamma(t1)/gamma(n1/2))^2)/2-1-a_g
}
xm<-solve(a_s)
Can anyone help me out. Thanks in
2012 Oct 14
1
Finding root of quadratic equation
Dear R Helpers, I need to find the root of following equationy=x^2+3*x-1 by
substitution a random number from less to more in the certain segment.I had
tried using this codef <- function (x) x^2+x-12str(xmin <- uniroot(f, c(2,
4), tol = 0.0001)) but $ f.root : num -7.85e-07not 0, and so I'm not
shure it's right code and satisfactory answer. Please guide. sveta
--
View this
2007 Apr 25
4
How to solve difficult equations?
This below is not solvable with uniroot to find "a":
fn=function(a){
b=(0.7/a)-a
(1/(a+b+1))-0.0025
}
uniroot(fn,c(-500,500)) gives
"Error in uniroot(fn, c(-500, 500)) : f() values at end points not of
opposite sign"
I read R-help posts and someone wrote a function:
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/92407.html
but it is not very precise. Is there any
2010 Mar 12
2
looking for a package to solve current-voltage equation I=f(I)
Hello,
I'm looking for a R-package to solve such an equation :
http://n4.nabble.com/file/n1590462/iv.png
which is one current-voltage equation of a solar cell.
Thanks in advance,
Ptit Bleu.
--
View this message in context: http://n4.nabble.com/looking-for-a-package-to-solve-current-voltage-equation-I-f-I-tp1590462p1590462.html
Sent from the R help mailing list archive at Nabble.com.