Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with composite function #6

Closed
VilmosProkaj opened this issue Oct 30, 2015 · 3 comments
Closed

problem with composite function #6

VilmosProkaj opened this issue Oct 30, 2015 · 3 comments
Assignees
Labels

Comments

@VilmosProkaj
Copy link

Hi,

Thanks for the package. I am using version

Package: Deriv
Type: Package
Title: Symbolic Differentiation
Version: 3.5.6
Date: 2015-09-23
Authors@R: c(person(given="Andrew", family="Clausen", role="aut"), person(given="Serguei",
          family="Sokol", role=c("aut", "cre"), email="sokol@insa-toulouse.fr"))
Description: R-based solution for symbolic differentiation. It admits user-defined
          function as well as function substitution in arguments of functions to be
          differentiated. Some symbolic simplification is part of the work.
License: GPL (>= 3)
Suggests: testthat
BugReports: https://github.com/sgsokol/Deriv/issues
NeedsCompilation: no
Packaged: 2015-09-24 13:50:15 UTC; sokol
Author: Andrew Clausen [aut], Serguei Sokol [aut, cre]
Maintainer: Serguei Sokol <sokol@insa-toulouse.fr>
Repository: CRAN
Date/Publication: 2015-09-25 00:43:31
Built: R 3.2.2; ; 2015-10-26 06:31:56 UTC; unix

I used in a computation and run into a problem when the function to be differentiated contains a call to another function in which body there are more than one expression.
Here is a simple example

f<-function(x){ t<-x^2; log(t) }
g<-function(x) cos(f(x))
Deriv(g,"x")

returns the function

function (x) 
-(sin(f(x)) * {
    t <- x^2
    .t_x <- .t_x
    .t_x/t
})

Here t_x is not defined. I guess that this is somehow the result of some simplification step, but I could not really follow what Deriv does during the debugging. At some stage the expected code

dargs
$x
{
    t <- x^2
    .t_x <- 2 * x
    .t_x/t
}

was in the dargs variable within Deriv_.

During the differentiation of a more complicated function it happened that the variable .e1 was used before a value was assigned to it, and also many assignment of the type .esomething <- .esomething (the left hand side and the right hand side are the same) I do not know whether these issues are related.

Thanks
Vilmos Prokaj

@sgsokol sgsokol added the bug label Oct 30, 2015
@sgsokol sgsokol self-assigned this Oct 30, 2015
sgsokol pushed a commit that referenced this issue Oct 30, 2015
@sgsokol
Copy link
Owner

sgsokol commented Oct 30, 2015

Thanks for this bug report.
The problem was an over-simplification.
Could you give a ride to the fixed version in the devel branch on github? (devtools::install_github("sgsokol/Deriv", ref="devel"))

@VilmosProkaj
Copy link
Author

Thanks .
It seems to work now.
Viilmos Prokaj

@sgsokol
Copy link
Owner

sgsokol commented Nov 4, 2015

Submitted to CRAN as v3.6.0

@sgsokol sgsokol closed this as completed Nov 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants