From: SourceForge.net <no...@so...> - 2010-11-08 15:24:36
|
Bugs item #3085498, was opened at 2010-10-11 16:45 Message generated for change (Comment added) made by dgildea You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3085498&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: Lisp Core - Integration Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Aleksas Domarkas (alex108) Assigned to: Nobody/Anonymous (nobody) Summary: integration error Initial Comment: The arc length S of one arch of cycloid x(t)=a*(t-sin(t)) y(t)=a*(1-cos(t)) (%i1) x(t):=a*(t-sin(t)); y(t):=a*(1-cos(t)); (%o1) x(t):=a*(t-sin(t)) (%o2) y(t):=a*(1-cos(t)) (%i3) assume(a>0); (%o3) [a>0] (%i4) S='integrate(sqrt(diff(x(t),t)^2+diff(y(t),t)^2),t,0,2*%pi); (%o4) S=integrate(sqrt(a^2*sin(t)^2+a^2*(1-cos(t))^2),t,0,2*%pi) (%i5) trigsimp(%); (%o5) S=integrate(sqrt(2*a^2-2*a^2*cos(t)),t,0,2*%pi) (%i6) ev(%, nouns); (%o6) S=0 S=8*a ??? ---------------------------------------------------------------------- >Comment By: Dan Gildea (dgildea) Date: 2010-11-08 10:24 Message: Fixed in rpart.lisp rev 1.39 by using the flag generate-atan2. ---------------------------------------------------------------------- Comment By: Dieter Kaiser (crategus) Date: 2010-11-07 17:28 Message: I have committed a patch with revision 1.80 of sin.lisp to restore the behavior of trigint to change the variable of integration. This solves the first problem of this bug report. The second change, that carg(exp(%i*t)) simplifies to atan2(sin(t),cos(t)) and not to t is still present. Dieter Kaiser ---------------------------------------------------------------------- Comment By: Dieter Kaiser (crategus) Date: 2010-11-07 10:34 Message: You are right and I think I have got the bug I have introduced. In a old version of trigint the name of the variable is changed before calling again the integrator. This has changed and causes no problems as long as we have no assumptions on the variable of integration. But defint puts assumptions on the variable of integration into the database. Because of this in a old version of trigint Maxima does not get a result because the assumptions are not present for the integration. The new version gets a result, because of the additional assumptions. The following code and the end of the routine trigint restores the old behavior and changes the name of the variable of integration. With this code the integration is done without any assumption on the variable of integration. (return (let (($triginverses '$all) (genvar (gensym))) (substint repl genvar (integrator (maxima-substitute genvar var y) genvar)))))) With this correction I get: (%i42) S=integrate(sqrt(a^2*sin(t)^2+a^2*(1-cos(t))^2),t,0,2*%pi); (%o42) S = 8 a Dieter Kaiser ---------------------------------------------------------------------- Comment By: Dan Gildea (dgildea) Date: 2010-11-07 08:34 Message: It looks like in current cvs, rischint is not called for this integral. If I revert rpart.lisp to 1.35, I still get: (%i3) integrate(sqrt(1-cos(t)),t,0,2*%pi); (%o3) 0 If I revert sin.lisp to 1.68, or if I make the change below, I get the call to rischint with a result containing atan2 as you show. (In this case, the final result is computed with easy-subs, and the limit code is not called.) If I revert sin.lisp to 1.68 and I revert rpart.lisp to 1.35, I get the correct answer. *** sin.lisp.~1.79.~ Sun Nov 7 08:23:04 2010 --- sin.lisp Sun Nov 7 08:23:40 2010 *************** *** 1614,1620 **** getout (setq y (list '(mtimes) *yy* *yz*)) get2 ! (setq y (maxima-substitute var 'x y)) (when *debug-integrate* (format t "~& Call the INTEGRATOR with:~%") --- 1614,1620 ---- getout (setq y (list '(mtimes) *yy* *yz*)) get2 ! ;(setq y (maxima-substitute var 'x y)) (when *debug-integrate* (format t "~& Call the INTEGRATOR with:~%") *************** *** 1624,1630 **** ;; See Bug 2880797. We want atan(tan(x)) to simplify to x, so ;; set $triginverses to '$all. (return (let (($triginverses '$all)) ! (substint repl var (integrator y var)))))) (defmvar $integration_constant_counter 0) (defmvar $integration_constant '$%c) --- 1624,1630 ---- ;; See Bug 2880797. We want atan(tan(x)) to simplify to x, so ;; set $triginverses to '$all. (return (let (($triginverses '$all)) ! (substint repl 'x (integrator y 'x)))))) (defmvar $integration_constant_counter 0) (defmvar $integration_constant '$%c) ---------------------------------------------------------------------- Comment By: Dieter Kaiser (crategus) Date: 2010-11-05 18:17 Message: I think the problem is not revision 1.69 of sin.lisp, but the generalization of carg(exp(x+%i*y)) -> atan2(sin(y),cos(y)) with revision 1.36 of rpart.lisp. The example of this problem is not integrated by trigint but by rischint. rischint takes the realpart of the following expression: (-sqrt(2)*%i*%e^(%i*t)-sqrt(2)*%i)/sqrt(-%e^(%i*t)); With Maxima 5.21 we get for the realpart: (%i16) res:(-sqrt(2)*%i*%e^(%i*t)-sqrt(2)*%i)/sqrt(-%e^(%i*t)); (%o16) (-sqrt(2)*%i*%e^(%i*t)-sqrt(2)*%i)/sqrt(-%e^(%i*t)) (%i17) realpart(res); (%o17) (-sqrt(2)*cos(t)-sqrt(2))*sin((t+%pi)/2)+sqrt(2)*sin(t)*cos((t+%pi)/2) But with Maxima 5.22post we get: (%i21) res:(-sqrt(2)*%i*%e^(%i*t)-sqrt(2)*%i)/sqrt(-%e^(%i*t)); (%o21) (-sqrt(2)*%i*%e^(%i*t)-sqrt(2)*%i)/sqrt(-%e^(%i*t)) (%i22) realpart(res); (%o22) (-sqrt(2)*cos(t)-sqrt(2))*sin((atan2(sin(t),cos(t))+%pi)/2) +sqrt(2)*sin(t)*cos((atan2(sin(t),cos(t))+%pi)/2) atan2(sin(t),cos(t)) is no longer simplified to t. In the limit we have limit(atan2(sin(y),cos(y)),t,2*%pi) -> 0 but limit(t,t,2*%pi) -> 2*%pi This causes the error for the integral. Dieter Kaiser ---------------------------------------------------------------------- Comment By: Dan Gildea (dgildea) Date: 2010-11-05 17:04 Message: Simple test case: (%i3) integrate(sqrt(1-cos(t)),t,0,2*%pi); (%o3) 0 Before the commit of sin.lisp rev 1.69, we got: (%i3) integrate(sqrt(1-cos(t)),t,0,2*%pi); (%o3) 2^(5/2) ---------------------------------------------------------------------- Comment By: Robert Dodier (robert_dodier) Date: 2010-10-19 00:17 Message: Observed w/ Maxima 5.22.1 + Clisp 2.48 + Linux and Maxima 5.22post + Clozure CL + Windows. Not observed w/ Maxima 5.21.1 + GCL + Windows, so maybe it's a recent bug. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=3085498&group_id=4933 |