Ask Your Question
1

integrate and simplify

asked 2016-05-02 03:41:16 -0600

pvquere gravatar image

updated 2016-05-02 06:28:00 -0600

calc314 gravatar image

Hello, Here is a list of command lines that used to work fine one year ago, but today, it's not :

> fksin=piecewise([[(-2,0),f1(t)*sin(k*w*t)],[(0,1),f2(t)*sin(k*w*t)],[(1,2),f3(t)*sin(k*w*t)]])
>var('t k')
>assume(k,'integer')
>f1(t)=0
>f2(t)=t
>f3(t)=2-t
>T=4
>w=2*pi/T
>f=piecewise([[(-2,0),f1],[(0,1),f2],[(1,2),f3]])
>fkcos=piecewise([[(-2,0),f1(t)*cos(k*w*t)],[(0,1),f2(t)*cos(k*w*t)],[(1,2),f3(t)*cos(k*w*t)]])
>bkf=(2/T)*integral(fksin,t,-T/2,T/2)
>bkf.simplify_trig()
4*sin(1/2*pi*k)/(pi^2*k^2)

But today, the answer is : Error in lines 1-1 Traceback (most recent call last): File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 905, in execute exec compile(block+'\n', '', 'single') in namespace, locals File "", line 1, in <module> File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/misc/functional.py", line 664, in integral return x.integral(args, *kwds) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/functions/piecewise.py", line 837, in integral F = self.integral(x) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/functions/piecewise.py", line 877, in integral area += fun.integral(x, start, end) File "sage/symbolic/expression.pyx", line 11352, in sage.symbolic.expression.Expression.integral (/projects/sage/sage-6.10/src/build/cythonized/sage/symbolic/expression.cpp:60288) return integral(self, args, *kwds) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 761, in integrate return definite_integral(expression, v, a, b, hold=hold) File "sage/symbolic/function.pyx", line 988, in sage.symbolic.function.BuiltinFunction.__call__ (/projects/sage/sage-6.10/src/build/cythonized/sage/symbolic/function.cpp:11343) res = super(BuiltinFunction, self).__call__( File "sage/symbolic/function.pyx", line 503, in sage.symbolic.function.Function.__call__ (/projects/sage/sage-6.10/src/build/cythonized/sage/symbolic/function.cpp:7110) res = g_function_evalv(self._serial, vec, hold) File "sage/symbolic/function.pyx", line 1059, in sage.symbolic.function.BuiltinFunction._evalf_or_eval_ (/projects/sage/sage-6.10/src/build/cythonized/sage/symbolic/function.cpp:12072) return self._eval0_(args) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/integration/integral.py", line 176, in _eval_ return integrator(args) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/symbolic/integration/external.py", line 24, in maxima_integrator result = maxima.sr_integral(expression, v, a, b) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 776, in sr_integral return max_to_sr(maxima_eval(([max_integrate],[sr_to_max(SR(a)) for a in args]))) File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage/interfaces/maxima_lib.py", line 1630, in max_to_sr args=[max_to_sr(a) for a in max_args] File "/projects/sage/sage-6.10/local/lib/python2.7/site-packages/sage ... (more)

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2016-05-03 08:08:21 -0600

calc314 gravatar image

updated 2016-05-04 10:17:54 -0600

Not an answer:

In SMC, I'm running into the error that the question mentions. I'm not certain of the current version of Sage that SMC is using.

The following command produces the error:

integrate(sin(pi*k*t/2),t,0,1)

However, the next two commands do not.

integrate(sin(k*t/2),t,0,1)
integrate(sin(pi*k*t/2. ),t,0,1)

This seems quite odd. For more oddness, I found that integrate(sin(pi*k1*t/2),t,0,1) works just fine if k1 is defined as a variable. According to the other answer, the original integral works in 7.1. So, there must have been an odd error in version 6.10. My advice is to switch your code to have k1 rather than k. I tried this with your code, and it worked.

edit flag offensive delete link more
0

answered 2016-05-02 22:15:04 -0600

updated 2016-05-03 16:40:34 -0600

Your code is giving me an error different from the one indicated, because the definition of fksin needs to be moved down below the definition of w. After that it produces the correct answer for me in both Sage 6.9 and 7.1.

EDIT: have verified the error occurs for SMC, which is running Sage 6.10 as indicated in the error message

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-05-02 03:41:16 -0600

Seen: 107 times

Last updated: May 04 '16