[R] equalize function with zero and convert it

Gabor Grothendieck ggrothendieck at gmail.com
Thu Aug 26 14:56:02 CEST 2010


On Thu, Aug 26, 2010 at 6:57 AM, Immanuel Seeger <jimmy-seeger at web.de> wrote:
> Dear all,
> I want to equalize a symbolic derivative (of a function with two
> variables) with zero and convert it to a variable, e.g. x.
>
> I'm computing the derivative by: (found it in the archive)
> library(Ryacas)
> f <- function(x,y) (100-x-y)*x-10*x
> yacas(f) # register f with yacas
> Df <- f
> body(Df) <- yacas(expression(deriv(f(x,y),x)))[[1]]
> Df
>
> R-Output:
> function (x, y)
> 100 - x - y - x - 10
>
> Questions :
> 1.      How can I equalize the derivative(140-x-y-x-20) with zero?
> 2.      How can I convert it to x?
>
> I want something like:
> 45-0.5*y=x
>
> With only one variable or two non-symbolic variables it's working with
> uniroot(f, c(-10, 10))$root.
>

This solves for x:

> library(Ryacas)
Loading required package: XML
> x <- Sym("x")
> y <- Sym("y")
> Solve((100-x-y)*x-10*x == 0, "x")
[1] "Starting Yacas!"
expression(list(x == -((10 - (100 - y) + root((100 - y - 10)^2,
    2))/2), x == -((10 - (100 - y) - root((100 - y - 10)^2, 2))/2)))

-- 
GKX Group
GKX Associates Inc.
1-877-GKX-GROUP
ggrothendieck at gmail.com



More information about the R-help mailing list