Hi all,
I am trying to implement the following matlab code with Ryacas :
syms U x x0 C
d1=diff(U/(1+exp(-(x-x0)/C)),x);
pretty(d1)
d2=diff(U/(1+exp(-(x-x0)/C)),x,2);
pretty(d2)
solx2 = solve(d2 == 0, x, 'Real', true)
pretty(solx2)
slope2=subs(d1,solx2)
I have tried the following :
library(Ryacas)
x <- Sym("x");U <- Sym("U");x0 <- Sym("x0");C <- Sym("C")
my_func <- function(x,U,x0,C) {
return (U/(1+exp(-(x-x0)/C)))}
FirstDeriv <- deriv(my_func(x,U,x0,C), x)
PrettyForm(FirstDeriv)
slope <- yacas("Subst(x,x0),deriv(my_func(x,U,x0,C), x)")
PrettyForm(slope)
I don't understand how I should use the Subst command. I want the slope of
the first derivative at x=x0. How do I implement that?
I would appreciate any help that I can get.
Thanks,
Vivek
symbolic computing example with Ryacas
4 messages · Vivek Sutradhara, Bert Gunter, Gabor Grothendieck
Have you studied the "Introduction to Ryacas" vignette that come with the package? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Sep 19, 2017 at 2:37 AM, Vivek Sutradhara <viveksutra at gmail.com> wrote:
Hi all,
I am trying to implement the following matlab code with Ryacas :
syms U x x0 C
d1=diff(U/(1+exp(-(x-x0)/C)),x);
pretty(d1)
d2=diff(U/(1+exp(-(x-x0)/C)),x,2);
pretty(d2)
solx2 = solve(d2 == 0, x, 'Real', true)
pretty(solx2)
slope2=subs(d1,solx2)
I have tried the following :
library(Ryacas)
x <- Sym("x");U <- Sym("U");x0 <- Sym("x0");C <- Sym("C")
my_func <- function(x,U,x0,C) {
return (U/(1+exp(-(x-x0)/C)))}
FirstDeriv <- deriv(my_func(x,U,x0,C), x)
PrettyForm(FirstDeriv)
slope <- yacas("Subst(x,x0),deriv(my_func(x,U,x0,C), x)")
PrettyForm(slope)
I don't understand how I should use the Subst command. I want the slope of
the first derivative at x=x0. How do I implement that?
I would appreciate any help that I can get.
Thanks,
Vivek
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Thanks for the response. Yes, I did study the vignette but did not
understand it fully. Anyway, I have tried once again now. I am happy to say
that I have got what I wanted.
library(Ryacas)
x <- Sym("x");U <- Sym("U");x0 <- Sym("x0");C <- Sym("C")
my_func <- function(x,U,x0,C) {
return (U/(1+exp(-(x-x0)/C)))}
FirstDeriv <- deriv(my_func(x,U,x0,C), x)
PrettyForm(FirstDeriv)
#slope <- yacas("Subst(x,x0),deriv(my_func(x,U,x0,C), x)")
slope <- Subst(FirstDeriv,x,x0)
#PrettyForm(slope) - gives errors
PrettyForm(Simplify(slope))
I was confused by the references to the yacas command. Now, I have chosen
to omit it. Then I get what I want.
Thanks,
Vivek
2017-09-19 16:04 GMT+02:00 Bert Gunter <bgunter.4567 at gmail.com>:
Have you studied the "Introduction to Ryacas" vignette that come with the package? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Sep 19, 2017 at 2:37 AM, Vivek Sutradhara <viveksutra at gmail.com> wrote:
Hi all,
I am trying to implement the following matlab code with Ryacas :
syms U x x0 C
d1=diff(U/(1+exp(-(x-x0)/C)),x);
pretty(d1)
d2=diff(U/(1+exp(-(x-x0)/C)),x,2);
pretty(d2)
solx2 = solve(d2 == 0, x, 'Real', true)
pretty(solx2)
slope2=subs(d1,solx2)
I have tried the following :
library(Ryacas)
x <- Sym("x");U <- Sym("U");x0 <- Sym("x0");C <- Sym("C")
my_func <- function(x,U,x0,C) {
return (U/(1+exp(-(x-x0)/C)))}
FirstDeriv <- deriv(my_func(x,U,x0,C), x)
PrettyForm(FirstDeriv)
slope <- yacas("Subst(x,x0),deriv(my_func(x,U,x0,C), x)")
PrettyForm(slope)
I don't understand how I should use the Subst command. I want the slope of
the first derivative at x=x0. How do I implement that?
I would appreciate any help that I can get.
Thanks,
Vivek
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posti ng-guide.html and provide commented, minimal, self-contained, reproducible code.
Here are some more examples:
library(Ryacas)
x <- Sym("x")
yacas("x:=2")
Eval(x*x)
## [1] 4
# vignette has similar example
y <- Sym("y")
Eval(Subst(y*y, y, 3))
## [1] 9
# demo("Ryacas-Function") has similar example to this
f <- function(z) {}
body(f) <- yacas(expression(z*z))[[1]]
f(4)
## [1] 16
On Tue, Sep 19, 2017 at 2:08 PM, Vivek Sutradhara <viveksutra at gmail.com> wrote:
Thanks for the response. Yes, I did study the vignette but did not
understand it fully. Anyway, I have tried once again now. I am happy to say
that I have got what I wanted.
library(Ryacas)
x <- Sym("x");U <- Sym("U");x0 <- Sym("x0");C <- Sym("C")
my_func <- function(x,U,x0,C) {
return (U/(1+exp(-(x-x0)/C)))}
FirstDeriv <- deriv(my_func(x,U,x0,C), x)
PrettyForm(FirstDeriv)
#slope <- yacas("Subst(x,x0),deriv(my_func(x,U,x0,C), x)")
slope <- Subst(FirstDeriv,x,x0)
#PrettyForm(slope) - gives errors
PrettyForm(Simplify(slope))
I was confused by the references to the yacas command. Now, I have chosen
to omit it. Then I get what I want.
Thanks,
Vivek
2017-09-19 16:04 GMT+02:00 Bert Gunter <bgunter.4567 at gmail.com>:
Have you studied the "Introduction to Ryacas" vignette that come with the package? Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Tue, Sep 19, 2017 at 2:37 AM, Vivek Sutradhara <viveksutra at gmail.com> wrote:
Hi all,
I am trying to implement the following matlab code with Ryacas :
syms U x x0 C
d1=diff(U/(1+exp(-(x-x0)/C)),x);
pretty(d1)
d2=diff(U/(1+exp(-(x-x0)/C)),x,2);
pretty(d2)
solx2 = solve(d2 == 0, x, 'Real', true)
pretty(solx2)
slope2=subs(d1,solx2)
I have tried the following :
library(Ryacas)
x <- Sym("x");U <- Sym("U");x0 <- Sym("x0");C <- Sym("C")
my_func <- function(x,U,x0,C) {
return (U/(1+exp(-(x-x0)/C)))}
FirstDeriv <- deriv(my_func(x,U,x0,C), x)
PrettyForm(FirstDeriv)
slope <- yacas("Subst(x,x0),deriv(my_func(x,U,x0,C), x)")
PrettyForm(slope)
I don't understand how I should use the Subst command. I want the slope of
the first derivative at x=x0. How do I implement that?
I would appreciate any help that I can get.
Thanks,
Vivek
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posti ng-guide.html and provide commented, minimal, self-contained, reproducible code.
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com