Ask Your Question

wobbuuu's profile - activity

2024-02-11 20:06:00 +0200 received badge  Notable Question (source)
2022-01-12 15:19:47 +0200 received badge  Popular Question (source)
2020-06-09 13:40:33 +0200 asked a question Assume expression to be noninteger

Hello! How to assume expression to be an integer? I try to do some symbolic integration while Sage asks to provide additional info about expression. MWE:

var('x a b')
assume(b > 0)
f = (exp((x-a)/b) + 1)**(-1)
(f*f).integrate(x, 0, oo)

gives:

ValueError: Computation failed since Maxima requested additional constraints; using the 'assume' command before evaluation may help (example of legal syntax is 'assume((2a)/b>0)', see assume? for more details) Is (2a)/b an integer?

How to assume that (2*a)/b is an arbitrary positive real number? Straightforward assume((2*a)/b, 'noninteger') gives:

TypeError: self (=2*a/b) must be a relational expression

Thanks!

2017-11-19 12:44:06 +0200 commented answer Substitution of subexpression

Interesting and confusing.. Why do I have to include w in subexpression?

2017-11-19 12:11:50 +0200 asked a question Substitution of subexpression

Hi! My task is to derive some expression and then find subexpressions in it and substitute. In details I need to find derivative of psi and then substitute expressions back. The way I found this derivative looks ugly but I suppose it's easier to do substitution in such form of expression.

var('x, y, t, a, w, alpha, beta')
assume(w > 0)
assume(a > 0)
assume(x, y, t, 'real')
x1 = x*cos(w*t) + y*sin(w*t)
y1 = y*cos(w*t) - x*sin(w*t)

psi10 = 2/a * sin(2*pi/a*x2) * sin(pi/a*y2)
psi01 = 2/a * sin(pi/a*x2) * sin(2*pi/a*y2)

psi = alpha*psi10 + beta*psi01

psi_der = psi.diff(x2)*x1.diff(t) + psi.diff(y2)*y1.diff(t)
psi_der

$-2{\left(w x \cos\left(t w\right) + w y \sin\left(t w\right)\right)} {\left(\frac{\pi \alpha \cos\left(\frac{\pi y_{2}}{a}\right) \sin\left(\frac{2 \pi x_{2}}{a}\right)}{a^{2}} + \frac{2 \pi \beta \cos\left(\frac{2 \pi y_{2}}{a}\right) \sin\left(\frac{\pi x_{2}}{a}\right)}{a^{2}}\right)}+$ $+2{\left(w y \cos\left(t w\right) - w x \sin\left(t w\right)\right)} {\left(\frac{\pi \beta \cos\left(\frac{\pi x_{2}}{a}\right) \sin\left(\frac{2 \pi y_{2}}{a}\right)}{a^{2}} + \frac{2 \pi \alpha \cos\left(\frac{2\pi x_{2}}{a}\right) \sin\left(\frac{\pi y_{2}}{a}\right)}{a^{2}}\right)}$

Then I need to substitute xcos(wt) + ysin(wt) to x2 and ycos(wt) - xsin(wt) to y2 for further integration over x2 and y2. Unfortunately, I didn't understand how to do this except that I need to use wild cards. So

w0 = SR.wild(0)
w1 = SR.wild(1)
pattern = x1*w0 + w1*y1
pattern

$\$0 {\left(x \cos\left(t w\right) + y \sin\left(t w\right)\right)} + \$1 {\left(y \cos\left(t w\right) - x \sin\left(t w\right)\right)}$ which is looks pretty the same but somehow don't match:

print psi_der.match(pattern)

gives None.

Could someone explain what is going on or maybe I should use something else?