Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
afd91740
Commit
afd91740
authored
Oct 21, 2012
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix computing derivative of negated exponential expressions
parent
283780a4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
src/rules/derivatives.py
src/rules/derivatives.py
+3
-3
tests/test_rules_derivatives.py
tests/test_rules_derivatives.py
+9
-0
No files found.
src/rules/derivatives.py
View file @
afd91740
...
...
@@ -208,7 +208,7 @@ def variable_root(root, args):
"""
x
,
n
=
root
[
0
]
return
n
*
x
**
(
n
-
1
)
return
(
n
).
negate
(
root
[
0
].
negated
)
*
x
**
(
n
-
1
)
MESSAGES
[
variable_root
]
=
\
...
...
@@ -225,9 +225,9 @@ def variable_exponent(root, args):
g
,
x
=
root
[
0
]
if
g
==
E
:
return
g
**
x
return
(
g
**
x
).
negate
(
root
[
0
].
negated
)
return
g
**
x
*
ln
(
g
)
return
(
g
**
x
).
negate
(
root
[
0
].
negated
)
*
ln
(
g
)
MESSAGES
[
variable_exponent
]
=
\
...
...
tests/test_rules_derivatives.py
View file @
afd91740
...
...
@@ -138,6 +138,11 @@ class TestRulesDerivatives(RulesTestCase):
x
,
n
=
root
[
0
]
self
.
assertEqual
(
variable_root
(
root
,
()),
n
*
x
**
(
n
-
1
))
def
test_variable_root_with_negation
(
self
):
root
=
tree
(
'd/dx -x ^ 2'
)
x
,
n
=
root
[
0
]
self
.
assertEqual
(
variable_root
(
root
,
()),
-
n
*
x
**
(
n
-
1
))
def
test_variable_exponent
(
self
):
root
=
tree
(
'd/dx 2 ^ x'
)
g
,
x
=
root
[
0
]
...
...
@@ -147,6 +152,10 @@ class TestRulesDerivatives(RulesTestCase):
e
,
x
=
root
[
0
]
self
.
assertEqual
(
variable_exponent
(
root
,
()),
e
**
x
)
root
=
tree
(
'd/dx -e ^ x'
)
e
,
x
=
root
[
0
]
self
.
assertEqual
(
variable_exponent
(
root
,
()),
-
e
**
x
)
def
test_chain_rule
(
self
):
root
=
tree
(
'(2 ^ x ^ 3)
\
'
'
)
l2
,
x3
=
root
[
0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment