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
5445504d
Commit
5445504d
authored
Apr 17, 2012
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added shortcut rules for derivatives with 'ln(e)', (more) corrseponding to the VWO function list.
parent
00241cdd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
13 deletions
+18
-13
src/rules/__init__.py
src/rules/__init__.py
+2
-3
src/rules/derivatives.py
src/rules/derivatives.py
+13
-8
src/rules/logarithmic.py
src/rules/logarithmic.py
+3
-2
No files found.
src/rules/__init__.py
View file @
5445504d
...
...
@@ -7,8 +7,7 @@ from .powers import match_add_exponents, match_subtract_exponents, \
match_raised_fraction
,
match_remove_negative_exponent
,
\
match_exponent_to_root
,
match_extend_exponent
,
match_constant_exponent
from
.numerics
import
match_add_numerics
,
match_divide_numerics
,
\
match_multiply_numerics
,
match_multiply_zero
,
match_multiply_one
,
\
match_raise_numerics
match_multiply_numerics
,
match_multiply_zero
,
match_raise_numerics
from
.fractions
import
match_constant_division
,
match_add_fractions
,
\
match_multiply_fractions
,
match_divide_fractions
,
\
match_extract_fraction_terms
...
...
@@ -36,7 +35,7 @@ RULES = {
match_combine_groups
,
match_add_quadrants
,
match_add_logarithms
],
OP_MUL
:
[
match_multiply_numerics
,
match_expand
,
match_add_exponents
,
match_multiply_zero
,
match_negated_factor
,
match_multiply_one
,
match_multiply_zero
,
match_negated_factor
,
match_sort_multiplicants
,
match_multiply_fractions
,
match_factor_in_multiplicant
],
OP_DIV
:
[
match_subtract_exponents
,
match_divide_numerics
,
...
...
src/rules/derivatives.py
View file @
5445504d
...
...
@@ -200,11 +200,14 @@ def variable_exponent(root, args):
"""
der(g ^ x, x) -> g ^ x * ln(g)
Note that (in combination with logarithmic/constant rules
):
der(e ^ x
) -> e ^ x * ln(e) -> e ^ x * 1
-> e ^ x
Shortcut rule (because of presence on formula list
):
der(e ^ x
, x)
-> e ^ x
"""
g
,
x
=
root
[
0
]
if
g
==
E
:
return
g
**
x
return
g
**
x
*
ln
(
g
)
...
...
@@ -236,10 +239,16 @@ def match_logarithmic(node):
def
logarithmic
(
root
,
args
):
"""
der(log(x, g), x) -> 1 / (x * ln(g))
der(log(x, g), x) -> 1 / (xln(g))
Shortcut function (because of presence on formula list):
der(ln(x), x) -> 1 / x
"""
x
,
g
=
root
[
0
]
if
g
==
E
:
return
L
(
1
)
/
x
return
L
(
1
)
/
(
x
*
ln
(
g
))
...
...
@@ -331,13 +340,9 @@ def match_sum_product_rule(node):
if
len
(
functions
)
<
2
:
return
[]
p
=
[]
handler
=
sum_rule
if
node
[
0
].
op
==
OP_ADD
else
product_rule
for
f
in
functions
:
p
.
append
(
P
(
node
,
handler
,
(
scope
,
f
)))
return
p
return
[
P
(
node
,
handler
,
(
scope
,
f
))
for
f
in
functions
]
def
sum_rule
(
root
,
args
):
...
...
src/rules/logarithmic.py
View file @
5445504d
...
...
@@ -179,7 +179,8 @@ def match_raised_base(node):
logs
,
others
=
partition
(
is_matching_logarithm
,
scope
)
for
other
,
log
in
product
(
others
,
logs
):
# TODO: Give this function a high precedence
# Add this possibility so that a 'raised_base' possibility is
# generated in the following iteration
p
.
append
(
P
(
node
,
factor_in_exponent_multiplicant
,
(
scope
,
other
,
log
)))
...
...
@@ -250,7 +251,7 @@ MESSAGES[factor_out_exponent] = _('Factor out exponent {0[0][0]} from {0}.')
def
match_factor_in_multiplicant
(
node
):
"""
Only bring a multiplicant inside a logarithm
s
if both the multiplicant and
Only bring a multiplicant inside a logarithm if both the multiplicant and
the logaritm's content are constants. This will yield a new simplification
of constants inside the logarithm.
2log(2) -> log(2 ^ 2) # -> log(4)
...
...
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