log(x*y) -> log(x) + log(y); x > 0, y > 0
>>> def rule_algebric_integrand_1_1_1_1(expr, symbol):
... return log(expr)
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/8efee19b-fedd-4188-b00f-e68ecf288eb5%40googlegroups.com.
>>> x, y, z, F, fx = symbols('x, y, z, F, fx')
>>> a = Wild('a', exclude=[x])
>>> b = Wild('b', exclude=[x])
>>> c = Wild('c', exclude=[x])
>>> d = Wild('d', exclude=[x])
>>> e = Wild('e', exclude=[x])
>>> f = Wild('f', exclude=[x])
>>> g = Wild('g', exclude=[x])
>>> p = Wild('p', exclude=[x])
>>> n = Wild('n', exclude=[x])
>>> m = Wild('m', exclude=[x])
>>> expr = ((1 + 2*x)**3) * ((F**(4*(5 + fx)))**6) * (6 + 7*(F**(4*(5 + fx))))**8
>>> pattern = ((c + d*x)**m) * ((F**(g*(e + fx)))**n) * (a + b*(F**(g*(e + fx))))**p
>>> pprint(pattern)
p n
⎛ g⋅(fx + e) ⎞ m ⎛ g⋅(fx + e)⎞
⎝F ⋅b + a⎠ ⋅(x⋅d + c) ⋅⎝F ⎠
>>> pprint(expr)
8
24⋅fx + 120 ⎛ 4⋅fx + 20 ⎞ 3
F ⋅⎝7⋅F + 6⎠ ⋅(2⋅x + 1)
>>> expr.match(pattern)
{p_: 1, g_: 1, m_: 3, d_: 2, n_: 0, e_: 23*fx + 120, c_: 1, a_: 0, b_: (7*F**(4*fx + 20) + 6)**8}
We need to find a way to convert the expresison into known standard form so pattern matching can be done peoperly or implement such functionality in `.match()` itself.
Thanks
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/6e64ae8e-2c19-49ca-9d74-fb873ac77112%40googlegroups.com.
I'd love to help out on this. The stuff I've written in Mathics I'm happy to relicense under BSD for Sympy and I can certainly give guidance for working with Mathics too.
I've contributed to the pattern matcher but I'm not the original author of most of that code so we'll need to get approval from Jan and a couple others as well.
The Mathics pattern matcher might be useful to study but I'm worried about the performance on 10000 integration rules. Mathics will try each rule in turn until it finds a match.
The most useful parts of Mathics for this would be the parser and the to/from Sympy converters. Both of these should be simple to relicense but maybe that's not even needed and you can use Mathics as a compiler.
if expr.is_Pow: b1 = expr.base m = expr.exp ... if b1.match(a + b*x): a = ... b = ... ... if not a.has(x): ... if not b.has(x): ... if m != -1:
&
.... you could snarf down huge
piles of "application" code -- at least at some superficial level --and then cut in the sympy alternatives as necessary for theapplication,.
Hi Aaron,
I find srepr
in SymPy a powerful tool and can be applied in many ways to compare and traverse expressions and subexpressions in a tree.
>>> x = Symbol('x')
>>> a = Symbol('a')
>>> b = Symbol('b')
>>> m = Symbol('m')
>>> expr = (a + b*x)**m
>>> srepr(expr)
"Pow(Add(Symbol('a'), Mul(Symbol('b'), Symbol('x'))), Symbol('m'))"
>>> expr.args
(Add(Symbol('a'), Mul(Symbol('b'), Symbol('x', positive=True))), Symbol('m'))
>>> expr.args[1]
Symbol('m')
>>> expr.args[0]
Add(Symbol('a'), Mul(Symbol('b'), Symbol('x', positive=True)))
>>> expr.args[0]
Add(Symbol('a'), Mul(Symbol('b'), Symbol('x', positive=True)))
>>> expr.args[0].args
(Symbol('a'), Mul(Symbol('b'), Symbol('x', positive=True)))
>>> expr.args[0].args[1]
Mul(Symbol('b'), Symbol('x', positive=True))
&
Hi everyone,I have proposed a rough draft on Rubi Integrator here. This is not complete yet, I wish if anyone could suggest on its improvement or something I've missed. Much of it is referred from Francesco's proposal and Mathematica.
Application:>>> match(f(x), [f(wn1), wn2(wn1)]) {matched: 0, wn1: x}
type = match(Expr, [((a + b*x)**m), ((b*x)**m)])
if type[matched] == 1:
a = 0
if (m == -1):
return log(a + b*x)/b ...