Kitonum

21550 Reputation

26 Badges

17 years, 125 days

MaplePrimes Activity


These are answers submitted by Kitonum

ConvIntoIneq  procedure solves the problem:

ConvIntoIneq:=proc(Rel)

local t, R, x, y;

t:=indets(Rel)[];

R:=solve(Rel);

x, y:=op(1,R), op(2,R);

if x=-infinity then if type(y,realcons) then return cat(t, "<=", y) else

cat(t, "<", op(1,y)) fi else

if type(x,realcons) then return cat(t, ">=", x) else

cat(t, ">", op(1,x)) fi; fi;

end proc:

 

Examples of use:

ConvIntoIneq(not x<100), ConvIntoIneq(not x>100), ConvIntoIneq(not x>=100), ConvIntoIneq(not x<=100), ConvIntoIneq(x>100), ConvIntoIneq(x<100), ConvIntoIneq(x>=100) ;

                       

 

 

 Addition. Unfortunately, if we want to get a "nice" output, the name of variable can appear on the right side of the inequality:

map(parse, [ConvIntoIneq(not x<100), ConvIntoIneq(not x>100), ConvIntoIneq(not x>=100), ConvIntoIneq(not x<=100), ConvIntoIneq(x>100), ConvIntoIneq(x<100), ConvIntoIneq(x>=100)])[] ;

                   

I added 2 options into your code: axes=normal and orientation=[15,50]  and used user lighting :

               

 

 Addition. The plot was saved in Paint as png - file.

 

Another variant. Additionally I added  color=khaki ,  style=surface , numpoints=20000  and changed  user lighting  :

              

 

 

 

 

 

plot([[0,0.36],[5,0.38],[10,0.3],[15,0.18],[20,0.96],[25,0.18],[30,0.16],[35,0.96]], style=line, thickness=5, color=red, view=[0..35,0..1], axis[1] = [gridlines = [7, thickness = 1, subticks = false, color = grey]], axis[2] = [gridlines = [6, thickness = 1, subticks = false, color = grey]], tickmarks=[[0=1,5=5,10=10,15=50,20=250,25=1000,30=10000,35=50000], spacing(0.2,0)], size=[650,350], font=[COURIER,ROMAN,14]);

             

 

 

 Edited.

 

 

P := (L, a, b) ->plot(L, x = a .. b, color = [seq(`if`(i::odd, red, black), i = 1 .. nops(L))]):   # L is a list of functions

 

Example of use:

P([sin(x), cos(x), 2, 3-x], 0, 5);

 

First, you can find the indices of columns that must be deleted, and then delete them.

Example:

A:=<0,1,0,3; 0,-2,0,4>;

ListTools[SearchAll](0, convert(A[1], list));

LinearAlgebra[DeleteColumn](A, [%]);

                                                             

 

 

 

Your syntax is wrong there. Below is the text of the procedure called  P  that solves the problem for any  Time  and  solution:

P:=proc(Time, solution)

local n;

n:=nops(Time);

piecewise( seq( op([t>=Time[i] and t<Time[i+1], solution[i]]), i = 1..n-1));

end proc:

 

Solution of above example:

P([0,1,2,3], [t^2, 1, 3-t]);

plot(%, t=0..3, scaling=constrained);

 

Edited.

Example:

F:=piecewise(t>=0 and t<1, t^2, t>=1 and t<2, 1, t>=2 and t<3, 3-t);

plot(F, t=0..3, scaling=constrained);

                                

Addition:  outside the interval t=0..3  the function  F by default considered to be equal to

 

 

Examples of plotting  4 basic trigonometric functions:

 

F1 := sin(x): F2 := cos(x): F3 := tan(x): F4 := cot(x): R := x = -Pi .. 2*Pi: C := [red, blue, green, brown]: c := scaling = constrained:

v1 := plot(F1, R, color = C[1]):

v2 := plot(F2, R, color = C[2]):

v3 := plot(F3, R, -3 .. 3, color = C[3], discont):

v4 := plot(F4, R, -3 .. 3, color = C[4], discont):

 

plot([F1, F2, F3, F4], R, -3 .. 3, color = C, discont, c);  # All together in one plot

                    

 

 plots[display](< v1, v2; v3, v4 >, c, size = [300, 300]);  # Matrix of the plots

          

 

 plots[display](< v1 | v2 | v3 | v4 >, c);  # Vector-row of the plots

 

 plots[display](< v1, v2, v3, v4 >, c, size = [100, 100]);  # Vector-column of the plots

                                           

 

 

If you want the tickmarks are not lost while reducing the size of the plot, reduce the font size:

  

 

 

 

combine(y(x) = (1/3)*exp(x)+_C1/(exp(x))^2);

                                     y(x) = 1/3*exp(x)+_C1*exp(-2*x)

 

Example with other powers not exp:

combine(y(x) = 1/3/2^x+_C1/(3^x)^2);

                                      y(x) = 1/3*2^(-x)+_C1*3^(-2*x)

 

@Rules,  in its solution  you are using  diff  command. Unfortunately during the second differentiation is obtained an incorrect result. D command corrects the situation:

restart;

eq:=z(x,y)^2+y^3+x^4 - ln(x+y+z(x,y)):

F:=(x,y)->z(x,y)^2+y^3+x^4 - ln(x+y+z(x,y)):

D[1](F)(x,y);

D_x:=solve(%,(D[1](z))(x,y));

D[2](F)(x,y);

D_y:=solve(%,(D[2](z))(x,y));

D[1,2](F)(x,y);

D_xy:=simplify(eval(solve(%, (D[1,2](z))(x,y)),{(D[1](z))(x,y)=D_x,(D[2](z))(x,y)=D_y}));

D[2,1](F)(x,y);

D_yx:=simplify(eval(solve(%, (D[2,1](z))(x,y)),{(D[1](z))(x,y)=D_x,(D[2](z))(x,y)=D_y}));

is(D_xy=D_yx);

 

 Addition. Above I wrote "Unfortunately during the second differentiation is obtained an incorrect result" .  In fact, when used properly,  diff  command also gives the correct result:

restart;

Eq:=z(x,y)^2+y^3+x^4 - ln(x+y+z(x,y)):

diff(Eq,x);

D_x:=solve(%,diff(z(x,y),x));

diff(Eq,y);

D_y:=solve(%,diff(z(x,y),y));

diff(Eq,x,y);

D_xy:=simplify(eval(solve(%,diff(z(x,y),x,y)),{diff(z(x,y),x)=D_x,diff(z(x,y),y)=D_y}));

diff(Eq,y,x);

D_yx:=simplify(eval(solve(%,diff(z(x,y),y,x)),{diff(z(x,y),x)=D_x,diff(z(x,y),y)=D_y}));

is(D_xy=D_yx);

M.Hirnyk, please check this code in Maple 5 R4 .

 

@Rules, кстати, вы можете задавать свои вопросы по-русски на форуме по Maple на exponenta.ru

plots[inequal]  command for non-linear inequalities works only in the latest versions of Maple. For earlier versions, you can use  plots[implicitplot]  command with option  filledregions :

A := plots[implicitplot]([x^2+y^2-1, (x-1)^2+y^2-1], x = -2 .. 3, y = -2 .. 2, color = [red, blue], linestyle=3, thickness = 2, gridrefine = 3):

B := plots[implicitplot](max(x^2+y^2-1, (x-1)^2+y^2-1) < 0, x = -2 .. 3, y = -2 .. 2, filledregions, coloring = [yellow, white], gridrefine = 3):

plots[display](A, B, scaling = constrained);

                            

 

 

Edited.

 

 

 

I think the solution of your equation can not be expressed explicitly. Therefore, you can solve it immediately automatically, without using explicit integration (but using implicit option):

restart;

eq:=(exp(x)+y(x))+(2+x+y(x)*exp(y(x)))*diff(y(x),x)=0;  # Replaced  dy/dx=diff(y(x),x)

dsolve({eq, y(0)=1}, y(x), implicit):

Sol:=subs(y(x)=y,%);

plots[implicitplot](Sol,x=-10..10,y=-10..10, gridrefine=3);

                     

 

 

 Addition. I wonder what is the cause of the left branch, which is not visually goes through the point  (0, 1) ?

You forgot colon in assigning L. Also evalb command can be omitted:

f:={1,2,3,4}:

h:={1,2,4,5}:

L:=seq(i,i=1..4):

for i in L do

if  f[i]=h[i]  then

print(f[i]);

end if;

end do;

One way, you can do some calculations in for loop and in each step assign a name to your result.

An example:

for a from 0 to 3 by 0.5 do  # For each value of parameter a we find the list of roots of the equation  x^3-a*x+1=0

R[a]:=[fsolve(x^3-a*x+1)];

od;

                                          

 

 

Another way to use  seq  command (a solution of the same problem):

R:=seq([fsolve(x^3-a*x+1)], a=0..3, 0.5);

              

 

Reference to these results you have in different ways: in the first case, the indices coincide with the values of the parameter a, in the second case as the index, you just specify the number of the solution.

 

Edited.

 

 

First 184 185 186 187 188 189 190 Last Page 186 of 290