Kitonum

21435 Reputation

26 Badges

17 years, 22 days

MaplePrimes Activity


These are replies submitted by Kitonum

@nm  There are 2 problems with this example:
1. The  indets  command for some reason does not consider  sqrt  as a function.
2. Maple unusually returns the result if any real number is the solution. It just returns  x  instead of  RealRange(-infinity,infinity) .

The following code handles these situations:

restart;
ode:=diff(y(x),x)-y(x) = x*y(x)^(1/2);
ic:=y(0)=4;

#this below code from https://www.mapleprimes.com/questions/231328-How-To-Make-Solve-Obtain-All-Values

sol:=dsolve([ode,ic],y(x));
res:=odetest(sol,ode);
F:=indets(res, function); # The function sqrt is missing
F:=F union indets(res,sqrt);
R:=[solve(`and`(seq(`or`(F[i]>0, F[i]<0, F[i]=0), i=1..nops(F))))];
if R=[x] then R:=[RealRange(-infinity,infinity)] fi;
solve(res) assuming `or`(seq(x in R[i],i=1..nops(R)));

 

@nm  Take a look at the update to my answer above. This same way solves your last example:

restart;
ode:=diff(y(x),x)=2*(x*sqrt(y(x))-1)*y(x):
ic:=y(0) = 1:
sol:=dsolve([ode,ic],y(x));
res:=odetest(sol,ode);
F:=indets(res, function);
R:=[solve(`and`(seq(`or`(F[i]>0, F[i]<0, F[i]=0), i=1..nops(F))))];
solve(res) assuming `or`(seq(x in R[i],i=1..nops(R)));

 

@nm  Very often you have to help Maple to achieve your goal. In this example, the assumption  x>0   is natural, since  x>0  is the domain for the function  ln(x)  in the real domain.

@DanishMapleFan  If the polynomials  h  and  g  are given, then you can use the method of undefined coefficients to reduce the problem to solving a system of linear equations.

The same example (without compoly):

restart;

g:=unapply((x+1)^2, x);
f:=unapply(2*x^2+x+3, x);
h:=expand((f@g)(x));
F:=unapply(a*x^2+b*x+c, x);
Eq:=expand((F@g)(x))=h;

Sys:={seq(coeff(lhs(Eq),x,n)=coeff(rhs(Eq),x,n), n=0..4)};
solve(Sys);
assign(%);

is(F(x)=f(x));

   

@nm  I do not understand at all what is the point of applying the  solve  command to a differential equation. Below are two very simple examples (which essentially mean the same thing). The output of the second example seems to me incorrect:

solve(y(x)+diff(y(x),x)=0, y(x)); # example 1
solve(y(x)+D(y)(x)=0, y(x)); # example 2

  

@AHSAN   depends on the width of the plot and is controlled by Maple automatically (see 2 examples below). Try playing with the options  size  for the plot  and  font  for legends. I don't know how to control  the width of legends box programmatically:

restart;
v := a+2*H*Q/T; 
v := subs(H = T*x, v);

plot([subs(a = 0.1, Q = 0.5, v), subs(a = 0.2, Q = 0.4, v)], x = 1 .. 10, style = pointline, colour = [black, red], symbol = [solidcircle, asterisk], symbolsize = 15, axes = boxed, numpoints = 20, legend=["a = 0.1, Q = 0.5 ", "a = 0.2, Q = 0.4"], legendstyle=[location=top],size=[400,400]); #example 1

plot([subs(a = 0.1, Q = 0.5, v), subs(a = 0.2, Q = 0.4, v)], x = 1 .. 10, style = pointline, colour = [black, red], symbol = [solidcircle, asterisk], symbolsize = 15, axes = boxed, numpoints = 20, legend=["a = 0.1, Q = 0.5 ", "a = 0.2, Q = 0.4"], legendstyle=[location=top],size=[250,400]); #example 2

 

@AHSAN  As you yourself mentioned, only  4 positions are available (in the example below, all the legends on the right). Therefore, if none of these options suits you, then this problem cannot be solved using the  legend  option.

restart;
v := a+2*H*Q/T; 
v := subs(H = T*x, v);

plot([subs(a = 0.1, Q = 0.5, v), subs(a = 0.2, Q = 0.4, v), subs(a = 0.3, Q = 0.35, v), subs(a = 0.4, Q = 0.3, v)], x = 1 .. 10, colour = [black, red, blue, green], axes = boxed);
 
plot([subs(a = 0.1, Q = 0.5, v), subs(a = 0.2, Q = 0.4, v)], x = 1 .. 10, style = pointline, colour = [black, red], symbol = [solidcircle, asterisk], symbolsize = 15, axes = boxed, numpoints = 20, legend=["a = 0.1, Q = 0.5", "a = 0.2, Q = 0.4"], legendstyle=[location=right]);

 

@AHSAN  Below the example of legends for the second plot. The same can be used for the first plot:

restart;
v := a+2*H*Q/T; 
v := subs(H = T*x, v);

plot([subs(a = 0.1, Q = 0.5, v), subs(a = 0.2, Q = 0.4, v), subs(a = 0.3, Q = 0.35, v), subs(a = 0.4, Q = 0.3, v)], x = 1 .. 10, colour = [black, red, blue, green], axes = boxed);
 
plot([subs(a = 0.1, Q = 0.5, v), subs(a = 0.2, Q = 0.4, v)], x = 1 .. 10, style = pointline, colour = [black, red], symbol = [solidcircle, asterisk], symbolsize = 15, axes = boxed, numpoints = 20, legend=["a = 0.1, Q = 0.5", "a = 0.2, Q = 0.4"]);


Edit.

@tomleslie Thank you! I did not know about it. The good workaround.

@lcz  Yes, I know, but this is the simplest solution to the problem for older versions of Maple. I think that this is quite possible to put up with. `3`!  is not calculated because  `3`  is not an integer but just a symbol. 

@mmcdara  I didn't understand where this error came from. I saved my worksheet again and downloaded it. Everything seems to be working correctly now.

@nm  OP just missed the  seq  command when copying.

@Preben Alsholm  Thanks for this observation. But this is only an intermediate result (not final one). We want to get the right side of the identity below:

is(x+y-2*sqrt(x*y)=-(sqrt(-x)+sqrt(-y))^2) assuming negative;

                                          true

@mmcdara  It doesn't surprise you that

plots:-implicitplot(g, x = -2..2, y= -2..2);

doesn't return any plot. Maple is right here, since the equation  g = 0  has no solutions. And here 

[solve(g, y)];

the command  solve  is not working correctly. It just formally expresses  y  through  x (these formulas can also be obtained manually by sequential squaring) , without worrying about any equivalence. It is very easy to check by simply substituting the found solution into the equation:

restart;
assume(x::real, y::real):
z := x+I*y:
g := abs(z-I)-abs(z+1)-2;
sol := [solve(g, y)];
simplify(eval(g,y=sol[1]));
simplify(eval(%, x=-1));  # Check - should be 0

             

Here's another example with an obvious bug:

restart;
solve(sqrt(x+y)+sqrt(x-y)=-2);


I'm going to update my answer below shortly where I explain in detail that there is no solution for the equation  

abs(z-I)-abs(z+1)=2 , where z=x+I*y  for real x and y

  

@acer  Thanks. There has been some progress after Maple 2018, but some bugs still remain. For some reason, some roots are skipped. In these examples, the  real  option should not be required because inequalities in the real domain are included  x>=-7*Pi/2, x<=-2*Pi   and so on. 

First 16 17 18 19 20 21 22 Last Page 18 of 132