Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
trs
Commits
5445504d
Commit
5445504d
authored
13 years ago
by
Taddeus Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Added shortcut rules for derivatives with 'ln(e)', (more) corrseponding to the VWO function list.
parent
00241cdd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/rules/__init__.py
+2
-3
2 additions, 3 deletions
src/rules/__init__.py
src/rules/derivatives.py
+13
-8
13 additions, 8 deletions
src/rules/derivatives.py
src/rules/logarithmic.py
+3
-2
3 additions, 2 deletions
src/rules/logarithmic.py
with
18 additions
and
13 deletions
src/rules/__init__.py
+
2
−
3
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
,
...
...
This diff is collapsed.
Click to expand it.
src/rules/derivatives.py
+
13
−
8
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
):
...
...
This diff is collapsed.
Click to expand it.
src/rules/logarithmic.py
+
3
−
2
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)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment