nm

11353 Reputation

20 Badges

13 years, 12 days

MaplePrimes Activity


These are questions asked by nm

applyrule is useful but seems limited. I can't do operation such as expand in the RHS of the rule.

For example, I wanted to applyrule that says to take sin(x::anything) and change it to cos(expand(x)), but it does not expand x. 

It seems because in the RHS of the rule, at the instance applyrule sees expand, x remains a symbol and not evaluated. So there is nothing to expand. It gets evaluated at later time, but by then too late for expand to do anything, it is gone. Just a guess.

But is there a trick to allow one to do more things in RHS of applyrule, such as expand or simplify? This would make applyrule much more useful. Otherwise, as it is, applyrule is of limited use. 

I know I can use evalindets ofcourse for this. 

#expand does not work in RHS of applyrule
e1:=sin(2*sqrt(a*b)*(t+mu));
applyrule( sin(x::anything) = cos(expand(x)), e1);

sin(2*(a*b)^(1/2)*(t+mu))

cos(2*(a*b)^(1/2)*(t+mu))

#but other operations worksheetdir
e1:=sin(2*sqrt(a*b)*(t+mu));
applyrule( sin(x::anything) = cos(x^2), e1);

sin(2*(a*b)^(1/2)*(t+mu))

cos(4*a*b*(t+mu)^2)

expand(2*sqrt(a*b)*(t+mu))

2*(a*b)^(1/2)*t+2*(a*b)^(1/2)*mu

#I could do this ofcourse
evalindets(e1,'specfunc'(sin),X->sin(expand(op(1,X))));

sin(2*(a*b)^(1/2)*t+2*(a*b)^(1/2)*mu)

 

 

Download apply_rule.mw


Using other software, there is no such problem using other operations on RHS of a rule

You see, expand worked on RHS of rule. 

I'd like to do same thing using applyrule in Maple. Is there a trick to allow this?

Maple 2024.1

I was trying to odetest one of my solutions to this ode when I got this internal Maple error I have not seen before.

Is this a legitimate error? my solution could be wrong ofcourse but strange to get internal error in this case.

Does this happen on earlier versions of Maple?

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1798 and is the same as the version installed in this computer, created 2024, August 29, 14:22 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

sol:=Intat(1/(u^n/((1/((a*g(x)+b)^n)/(f(x)^n)*diff(g(x),x)*f(x))^(-n-1))/((f(x)*diff(g(x),x))^(-2*n+1))/((1/((a*g(x)+b)^n)/(f(x)^n)*diff(g(x),x)*f(x)*(diff(f(x),x)*diff(g(x),x)+f(x)*diff(diff(g(x),x),x))-(-1/((a*g(x)+b)^n)/(f(x)^n)*diff(g(x),x)^2*f(x)*n*a/(a*g(x)+b)-1/((a*g(x)+b)^n)/(f(x)^n)*diff(g(x),x)*n*diff(f(x),x)+1/((a*g(x)+b)^n)/(f(x)^n)*diff(diff(g(x),x),x)*f(x)+1/((a*g(x)+b)^n)/(f(x)^n)*diff(g(x),x)*diff(f(x),x))*f(x)*diff(g(x),x)-f(x)*diff(f(x),x)/((a*g(x)+b)^n)/(f(x)^n)*diff(g(x),x)^2*n)^n)/(n^(-n))-u+1),u = a/f(x)/(a*g(x)+b)*y(x))-ln(a*g(x)+b)+_C1 = 0;

Intat(1/(u^n/(((diff(g(x), x))*f(x)/((a*g(x)+b)^n*f(x)^n))^(-n-1)*(f(x)*(diff(g(x), x)))^(-2*n+1)*((diff(g(x), x))*f(x)*((diff(f(x), x))*(diff(g(x), x))+f(x)*(diff(diff(g(x), x), x)))/((a*g(x)+b)^n*f(x)^n)-(-(diff(g(x), x))^2*f(x)*n*a/((a*g(x)+b)^n*f(x)^n*(a*g(x)+b))-(diff(g(x), x))*n*(diff(f(x), x))/((a*g(x)+b)^n*f(x)^n)+(diff(diff(g(x), x), x))*f(x)/((a*g(x)+b)^n*f(x)^n)+(diff(g(x), x))*(diff(f(x), x))/((a*g(x)+b)^n*f(x)^n))*f(x)*(diff(g(x), x))-f(x)*(diff(f(x), x))*(diff(g(x), x))^2*n/((a*g(x)+b)^n*f(x)^n))^n*n^(-n))-u+1), u = a*y(x)/(f(x)*(a*g(x)+b)))-ln(a*g(x)+b)+_C1 = 0

ode:=diff(y(x),x)-f(x)^(1-n)*diff(g(x),x)*y(x)^n/((a*g(x)+b)^n)-diff(f(x),x)*y(x)/f(x)-f(x)*diff(g(x),x) = 0;

diff(y(x), x)-f(x)^(1-n)*(diff(g(x), x))*y(x)^n/(a*g(x)+b)^n-(diff(f(x), x))*y(x)/f(x)-f(x)*(diff(g(x), x)) = 0

odetest(sol,ode,y(x));

Error, (in PDEtools/NumerDenom) invalid input: PDEtools/NumerDenom expects its 1st argument, ee, to be of type Or(algebraic,table,rtable), but received {Intat(1/(u^n*(f(x)^(1-n)*diff(g(x),x)*(a*g(x)+b)^(-n))^n*(f(x)*diff(g(x),x))^(2*n)*n^n-u*(a*g(x)+b)^n*f(x)^n*(a*n*f(x)^(2-n)*diff(g(x),x)^3*(a*g(x)+b)^(-n-1))^n+(a*g(x)+b)^n*f(x)^n*(a*n*f(x)^(2-n)*diff(g(x),x)^3*(a*g(x)+b)^(-n-1))^n),u = _Z) = Intat(1/(u^n*(f(x)^(1-n)*diff(g(x),x)*(a*g(x)+b)^(-n))^n*(f(x)*diff(g(x),x))^(2*n)*n^n-u*(a*g(x)+b)^n*f(x)^n*(a*n*f(x)^(2-n)*diff(g(x),x)^3*(a*g(x)+b)^(-n-1))^n+(a*g(x)+b)^n*f(x)^n*(a*n*f(x)^(2-n)*diff(g(x),x)^3*(a*g(x)+b)^(-n-1))^n),u = _Z)}

 

 

Download internal_error_PDEtools_NumerDenom_sept_4_2024.mw

Here is another ode solution by Maple, I am not able to get zero from odetest. 

If someone could come up with a trick or method to verify this, that will be great. I tried all sort of assumptions and not able to get zero. Even coulditbe() could not give zero. 

It is a Chini ode and also homogeneous, `class G`.

Solving using either method, odetest do not returns zero.  There are no initial conditions. I am sure the solutions are correct, but odetest need some help or may be this requires different method to verify not using odetest?

Worksheet below.

 

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

Physics:-Version();

`The "Physics Updates" version in the MapleCloud is 1796 and is the same as the version installed in this computer, created 2024, August 29, 14:22 hours Pacific Time.`

libname;

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

restart;

ode:=diff(y(x),x) = a*x^(n/(1-n))+b*y(x)^n;
DEtools:-odeadvisor(ode,y(x));

diff(y(x), x) = a*x^(n/(1-n))+b*y(x)^n

[[_homogeneous, `class G`], _Chini]

maple_sol:=dsolve(ode,y(x),[Chini],useInt,implicit); #explicit makes it take very long time
 

Intat(1/(_a^n/(b^(-n-1)*(a*x^(-n/(-1+n)))^(-2*n+1)*(-x^(-n/(-1+n)-1)*a*n*b/(-1+n))^n*n^(-n))-_a+1), _a = -y(x)/((-1+n)*x*a*x^(-n/(-1+n))))-(Int(-1/((-1+n)*x), x))+c__1 = 0

residual:=odetest(maple_sol,ode); #how to show this is zero?

n^n*(-y(x)*x^(1/(-1+n))/(a*(-1+n)))^n*(a*x^(-n/(-1+n)))^(2*n)*(-a*b*n*x^(-2*n/(-1+n)+1/(-1+n))/(-1+n))^(-n)*b^(n+1)-b*y(x)^n

coulditbe(residual=0) assuming real;

FAIL

#now solving as homog. (which gives simpler looking solution

maple_sol:=dsolve(ode,y(x),[homogeneous]);

Int(x^(n/(-1+n))/((b*x*(-1+n)*_a^n+_a)*x^(n/(-1+n))+a*x*(-1+n)), _a = _b .. y(x))-c__1 = 0

residual:=odetest(maple_sol,ode); #how to show this is zero?

-b*y(x)^n*n/(-1+n)-x^(-1-1/(-1+n))*a*n/(-1+n)+b*y(x)^n/(-1+n)+x^(-1-1/(-1+n))*a/(-1+n)-y(x)/(x*(-1+n))

coulditbe(residual=0) assuming real;

FAIL

 


 

Download challenge_odetest_sept_1_2024.mw

 

What is the correct syntax in Maple to do integration of variables on 

So that the new integration variable is using the mapping    u=y*x^(1/3) so that the result is 

The problems seems is that there is no option to tell Maple what the new integration variable is. So it does not know it should be y or x?

I looked at help and all my tries failed. Below is worksheet and also examples from another software as reference. The other software has argument to tell change of variable what is the new integration variable should be. But in Maple, there is no such option.,  Does this mean in Maple change of integration variables only works when the right hand side of the transformation has only one symbol and not two or more? i.e. this works   u=y, but not u=y*x

restart;

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

T:=Student:-MultivariateCalculus;
e:=Int(1/(3*u^4 + u + 3),u);
T:-ChangeOfVariables(e,[u=y*x^(1/3)]);
T:-ChangeOfVariables(e,[y=u*x^(-1/3)]);

Student:-MultivariateCalculus

Int(1/(3*u^4+u+3), u)

Error, (in Student:-MultivariateCalculus:-ChangeOfVariables) unable to complete the change-of-variables operation

Error, (in Student:-MultivariateCalculus:-ChangeOfVariables) unable to complete the change-of-variables operation

Student[Calculus1][IntTutor](); #did not help either

 

 

Download change_of_variables_integration_august_31_2024.mw

I searched help and see nothing specific to change of variable for integration, so I assumed the above is the command to use. Am I using the wrong command for integration change of variables in Maple?

For reference, I need to duplicate this in Maple:

Is one not supposed to make _Z local variable?  If not, then how to insure the global _Z do not have some value assigned to it?

In this example below, I build some integral. I used local _Z for upport limit. But now Maple generate internal error.

If I do not declare _Z as local, and leave it global, then no error is generated.

But if I also declare _Z inside the proc as global _Z, then the error also goes away.

So is one always supposed to use _Z as global? 

The strange thing _Z is protected, so I cant assign to it value from global space. Message says Try declaring `local _Z`; see ?protect for details. but when I do that, I still get an error. 

So is the bottom line here is that one should not declare _Z local to a proc, and just assume it is always global symbol that has no assigned value to it, and that will always be safe to do?  I do not assign value to _Z inside my proc. Just wanted to use it for upper limit, as symbol.

restart;

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

foo:=proc()
 local _Z;
 local F,G,H,n;
 F:=x;G:=x;G:=x;n:=4;
 -RootOf(Intat(F^(-n-1)*H^(-2*n+1)*(-G*F*n*H)^n*n^(-n)/(-
         tau*F^(-n-1)*H^(-2*n+1)*(-G*F*n*H)^n*n^(-n)+F^(-n-1)*H^(-2*n+1)*(-G*F
         *n*H)^n*n^(-n)+tau^n),tau = _Z)-Int(-G,x)+C1)/G*H;
end proc:

foo()

Error, (in RootOf) expression independent of, _Z

boo:=proc()
 local F,G,H,n;
 F:=x;G:=x;G:=x;n:=4;
 -RootOf(Intat(F^(-n-1)*H^(-2*n+1)*(-G*F*n*H)^n*n^(-n)/(-
         tau*F^(-n-1)*H^(-2*n+1)*(-G*F*n*H)^n*n^(-n)+F^(-n-1)*H^(-2*n+1)*(-G*F
         *n*H)^n*n^(-n)+tau^n),tau = _Z)-Int(-G,x)+C1)/G*H;
end proc:

boo();

-RootOf(Intat(x^3/(H^3*tau^4-tau*x^3+x^3), tau = _Z)-(Int(-x, x))+C1)*H/x

boo2:=proc()
 global _Z;
 local F,G,H,n;
 F:=x;G:=x;G:=x;n:=4;
 -RootOf(Intat(F^(-n-1)*H^(-2*n+1)*(-G*F*n*H)^n*n^(-n)/(-
         tau*F^(-n-1)*H^(-2*n+1)*(-G*F*n*H)^n*n^(-n)+F^(-n-1)*H^(-2*n+1)*(-G*F
         *n*H)^n*n^(-n)+tau^n),tau = _Z)-Int(-G,x)+C1)/G*H;
end proc:

boo2()

-RootOf(Intat(x^3/(H^3*tau^4-tau*x^3+x^3), tau = _Z)-(Int(-x, x))+C1)*H/x

_Z:=5;

Error, attempting to assign to `_Z` which is protected.  Try declaring `local _Z`; see ?protect for details.

local _Z;
foo();

Warning, A new binding for the name `_Z` has been created. The global instance of this name is still accessible using the :- prefix, :-`_Z`.  See ?protect for details.

_Z

Error, (in RootOf) expression independent of, _Z

 

 

Download using_Z_inside_proc_august_28_2024.mw

First 17 18 19 20 21 22 23 Last Page 19 of 199