## [Maxima-bugs] problem with integration

 [Maxima-bugs] problem with integration From: - 2010-11-29 17:42:50 ```Integrals for some relatively simple functions cannot be computed by maxima. For instance. for sqrt(x+sqrt(1+x^2))/x integral is (sqrt(1+x^2)*(x+sqrt(1+x^2))*(2*sqrt(x+sqrt(1+x^2))-2*atan(sqrt(x+sqrt(1+x^2)))+log(-1+sqrt(x+sqrt(1+x^2)))-log(1+sqrt(x+sqrt(1+x^2)))))/(1+x^2+x*sqrt(1+x^2)) latest maxima (5.22.1) is not able to compute that: > maxima Maxima 5.22.1 http://maxima.sourceforge.net using Lisp SBCL 1.0.14-gentoo Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. (%i1) integrate(sqrt(x+sqrt(1+x^2))/x, x); / 2 [ sqrt(sqrt(x + 1) + x) (%o1) I ---------------------- dx ] x / Tried it with a few previous versions of maxima with the same result. Regards, G. ```

 [Maxima-bugs] problem with integration From: - 2010-11-29 17:42:50 ```Integrals for some relatively simple functions cannot be computed by maxima. For instance. for sqrt(x+sqrt(1+x^2))/x integral is (sqrt(1+x^2)*(x+sqrt(1+x^2))*(2*sqrt(x+sqrt(1+x^2))-2*atan(sqrt(x+sqrt(1+x^2)))+log(-1+sqrt(x+sqrt(1+x^2)))-log(1+sqrt(x+sqrt(1+x^2)))))/(1+x^2+x*sqrt(1+x^2)) latest maxima (5.22.1) is not able to compute that: > maxima Maxima 5.22.1 http://maxima.sourceforge.net using Lisp SBCL 1.0.14-gentoo Distributed under the GNU Public License. See the file COPYING. Dedicated to the memory of William Schelter. The function bug_report() provides bug reporting information. (%i1) integrate(sqrt(x+sqrt(1+x^2))/x, x); / 2 [ sqrt(sqrt(x + 1) + x) (%o1) I ---------------------- dx ] x / Tried it with a few previous versions of maxima with the same result. Regards, G. ```
 [Maxima-bugs] [ maxima-Bugs-2797885 ] problem with integration From: SourceForge.net - 2009-05-28 12:39:52 ```Bugs item #2797885, was opened at 2009-05-28 12:39 Message generated for change (Tracker Item Submitted) made by nobody You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2797885&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: problem with integration Initial Comment: (%i3) integrate((%e**(%i*x))*sin(x),x); Division by 0 -- an error. To debug this try debugmode(true); (%i4) integrate((cos(x) + %i*sin(x))*sin(x),x); sin(2 x) %i (x - --------) 2 2 cos (x) (%o4) ----------------- - ------- 2 2 Maxima version: 5.18.1 Maxima build date: 11:35 5/25/2009 host type: i686-pc-linux-gnuoldld lisp-implementation-type: CLISP lisp-implementation-version: 2.44.1 (2008-02-23) (built 3437275172) (memory 3452232938) Maybe I don't know something... maybe some mathematic details? Or maybe maxima is using two different methods in each case? ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2797885&group_id=4933 ```
 [Maxima-bugs] [ maxima-Bugs-2797885 ] problem with integration From: SourceForge.net - 2009-05-28 17:21:18 ```Bugs item #2797885, was opened at 2009-05-28 14:39 Message generated for change (Comment added) made by crategus You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2797885&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None >Group: Includes proposed fix Status: Open Resolution: None Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: problem with integration Initial Comment: (%i3) integrate((%e**(%i*x))*sin(x),x); Division by 0 -- an error. To debug this try debugmode(true); (%i4) integrate((cos(x) + %i*sin(x))*sin(x),x); sin(2 x) %i (x - --------) 2 2 cos (x) (%o4) ----------------- - ------- 2 2 Maxima version: 5.18.1 Maxima build date: 11:35 5/25/2009 host type: i686-pc-linux-gnuoldld lisp-implementation-type: CLISP lisp-implementation-version: 2.44.1 (2008-02-23) (built 3437275172) (memory 3452232938) Maybe I don't know something... maybe some mathematic details? Or maybe maxima is using two different methods in each case? ---------------------------------------------------------------------- >Comment By: Dieter Kaiser (crategus) Date: 2009-05-28 19:21 Message: The problem is the routine sce-int, which uses the following formula: (%i7) integrate(exp(a*x)*sin(b*x),x); (%o7) %e^(a*x)*(a*sin(b*x)-b*cos(b*x))/(b^2+a^2) But for a=%i and b=1 this does not work. b^2+a^2 is zero and we get the error division by zero. A correct solution after a fix is: (%i8) integrate(exp(%i*x)*sin(x),x); (%o8) %i*x/2-%e^(2*%i*x)/4 This is a possible fix: (defun sce-int (exp s-c var) (let* ((e-coef (car (islinear (caddr exp) var))) (sc-coef (car (islinear (cadr s-c) var))) (sc-arg (cadr s-c)) (abs-val (add (power e-coef 2) (power sc-coef 2)))) (if (zerop1 abs-val) ;; The numerator is zero. Exponentialize the expression ;; and try again. (\$expand (integrator (\$exponentialize (mul exp s-c)) var)) (mul (div exp (add (power e-coef 2) (power sc-coef 2))) (add (mul e-coef s-c) (if (eq (caar s-c) '%sin) (mul* (neg sc-coef) `((%cos) ,sc-arg)) (mul* sc-coef `((%sin) ,sc-arg)))))))) Dieter Kaiser ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2797885&group_id=4933 ```
 [Maxima-bugs] [ maxima-Bugs-2797885 ] problem with integration From: SourceForge.net - 2009-05-28 21:43:46 ```Bugs item #2797885, was opened at 2009-05-28 14:39 Message generated for change (Comment added) made by crategus You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2797885&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: Includes proposed fix >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: problem with integration Initial Comment: (%i3) integrate((%e**(%i*x))*sin(x),x); Division by 0 -- an error. To debug this try debugmode(true); (%i4) integrate((cos(x) + %i*sin(x))*sin(x),x); sin(2 x) %i (x - --------) 2 2 cos (x) (%o4) ----------------- - ------- 2 2 Maxima version: 5.18.1 Maxima build date: 11:35 5/25/2009 host type: i686-pc-linux-gnuoldld lisp-implementation-type: CLISP lisp-implementation-version: 2.44.1 (2008-02-23) (built 3437275172) (memory 3452232938) Maybe I don't know something... maybe some mathematic details? Or maybe maxima is using two different methods in each case? ---------------------------------------------------------------------- >Comment By: Dieter Kaiser (crategus) Date: 2009-05-28 23:43 Message: The suggested change has been checked out. Maxima now gets the result: (%i14) expand(integrate(exp(%i*x)*sin(x),x)); (%o14) %i*x/2-%e^(2*%i*x)/4 These are the results for related integrands: (%i15) expand(integrate(exp(x)*sin(%i*x),x)); (%o15) %i*%e^(2*x)/4-%i*x/2 (%i16) expand(integrate(exp(%i*x)*cos(x),x)); (%o16) x/2-%i*%e^(2*%i*x)/4 (%i17) expand(integrate(exp(x)*cos(%i*x),x)); (%o17) %e^(2*x)/4+x/2 Closing this bug report as fixed. Dieter Kaiser ---------------------------------------------------------------------- Comment By: Dieter Kaiser (crategus) Date: 2009-05-28 19:21 Message: The problem is the routine sce-int, which uses the following formula: (%i7) integrate(exp(a*x)*sin(b*x),x); (%o7) %e^(a*x)*(a*sin(b*x)-b*cos(b*x))/(b^2+a^2) But for a=%i and b=1 this does not work. b^2+a^2 is zero and we get the error division by zero. A correct solution after a fix is: (%i8) integrate(exp(%i*x)*sin(x),x); (%o8) %i*x/2-%e^(2*%i*x)/4 This is a possible fix: (defun sce-int (exp s-c var) (let* ((e-coef (car (islinear (caddr exp) var))) (sc-coef (car (islinear (cadr s-c) var))) (sc-arg (cadr s-c)) (abs-val (add (power e-coef 2) (power sc-coef 2)))) (if (zerop1 abs-val) ;; The numerator is zero. Exponentialize the expression ;; and try again. (\$expand (integrator (\$exponentialize (mul exp s-c)) var)) (mul (div exp (add (power e-coef 2) (power sc-coef 2))) (add (mul e-coef s-c) (if (eq (caar s-c) '%sin) (mul* (neg sc-coef) `((%cos) ,sc-arg)) (mul* sc-coef `((%sin) ,sc-arg)))))))) Dieter Kaiser ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=2797885&group_id=4933 ```