From: Eduardo O. <edu...@gm...> - 2024-08-25 22:58:33
|
Hi list, sometimes changevar "expanded roots" in a way that was not what I wanted but I was able to fix its results using just rootscontract, like here: [trans,nvar,ovar] : [x=sin(theta), theta, x]; obody : sqrt(1-x^2); oexpr : 'integrate(obody, ovar); nexpr : changevar(oexpr,trans,nvar,ovar); nexpr : rootscontract(nexpr); but here is a case in which changevar decides to pull some "%i"s out of the roots, and rootscontract contracts the roots but leaves the "%i"s outside: [trans,nvar,ovar] : [x=2*u, u, x]; obody : sqrt(4-x^2)^3; oexpr : 'integrate(obody, ovar); nexpr : changevar(oexpr,trans,nvar,ovar); nexpr : rootscontract(nexpr); display2d : false; nexpr; /* 'integrate(sqrt(u^2-1)*(16*%i-16*%i*u^2),u) */ display2d : true; Here is a way to do that change of variables by hand that gives the result that I was trying to get - if I didn't commit any errors, of course... [trans,nvar,ovar] : [x=2*u, u, x]; obody : sqrt(4-x^2)^3; oexpr : 'integrate(obody, ovar); ovar_eq_tfun_nvar : solve(trans, ovar)[1]; deriv : diff(rhs(solve(trans, nvar)[1]), ovar); nbody : subst(ovar_eq_tfun_nvar, obody/deriv); nexpr_by_hand : 'integrate(nbody, nvar); nexpr_maxima : changevar(oexpr, trans, nvar, ovar); nexpr_maxima : rootscontract(nexpr_maxima); I thought that I would be able to find the flags that control how changevar expands roots by reading its source in src/outmis.lisp and trying to understand what it does... but that didn't work - I'm not even sure where in the (defun changevar ...) it calls the thing that expands roots. Any suggestions, pointers, or whatever else? Thanks in advance! Eduardo Ochs http://anggtwu.net/eev-maxima.html |