From: Barton W. <wi...@un...> - 2024-08-26 11:34:49
|
The function changevar (defined in outmis) calls radcan. I'm pretty sure that radcan is responsible for the conversion from sqrt(1-sin(theta)^2) to a product of square roots; tracing radcan and running your example, I see: 1" Enter "radcan" "[cos(theta)*sqrt(1-sin(theta)^2)] 1" Exit "radcan" "cos(theta)*sqrt(1-sin(theta))*sqrt(sin(theta)+1) (nexpr) integrate(cos(theta)*sqrt(1-sin(theta))*sqrt(sin(theta)+1),theta) (nexpr) integrate(cos(theta)*sqrt(1-sin(theta)^2),theta) If you like to experiment, try removing the call to radcan in changevar and run the testsuite. How many testsuite failures are due to incorrect answers and how many of them just alter the answer syntactically? Could this call to radcan be replaced by some other simplification function that gives "better" results? If you do some such experiments, please let us know the results. --Barton ________________________________ From: Eduardo Ochs <edu...@gm...> Sent: Sunday, August 25, 2024 17:58 To: <max...@li...> <max...@li...> Subject: [Maxima-discuss] A question about how changevar expands roots Caution: Non-NU Email 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<https://urldefense.com/v3/__http://anggtwu.net/eev-maxima.html__;!!PvXuogZ4sRB2p-tU!EPbpSTLszRTO4xFiCejowLJ2GdDUDkHewQm2Jyehs1oQKftxn5m3sypLu8cx48xpQUIZWWbW0o0XSSFdPfk$> |