Kitonum

21525 Reputation

26 Badges

17 years, 74 days

MaplePrimes Activity


These are answers submitted by Kitonum

You have not specified the version of your Maple. Perhaps in the latest versions everything works as you would like. In my Maple 2018, everything is the same as yours.
I don't see any other way how to code the desired legend using the  plot, plots:-textplotplottools:-rectangle  commands. Of course, this is quite troublesome.
Look at an example below:

restart;
interface(version);
``;
p1:=plot(x^2,x=-2..2,color=red, style=pointline,symbol=asterisk,symbolsize=14,adaptive=false,numpoints=20):
p2:=plot([[1,-0.9],[1.4,-0.9]],color=red):
p3:=plots:-textplot([1.6,-0.8,x^2],font=[times,16]):
p4:=plot([[1.2,-0.9]],style=point,color=red,symbol=asterisk, symbolsize=14):
p5:=plottools:-rectangle([0.9,-0.6],[1.7,-1.1], style=line):
plots:-display(p1,p2,p3,p4,p5, size=[500,500]);

                       

 

restart;
R:=Uo/sqrt(Go*Ho)=Fr;
subs(Uo=solve(R,Uo), Go*Ho/Uo^2);

                                      


The equality  Uo=solve(R,Uo)  is equivalent to the equality  .

Here is a more direct and shorter solution. I used multiple assignment for all constants, removed indices  m  and  n  that were not used in any way, specified the matrix  S  and vector  V  of the system in a shorter way, and used the  LinearAlgebra:-LinearSolve  command. The result is returned as a vector  Sol , the entries of which we can give any names, for example  A  and  B :

restart;
h, C, rho, omega := 0.03, 1, 7800, 222:
S := <rho*h*omega^2+100,200; 280,rho*h*omega^2+444>;
V := -C*<555, 6665>;
Sol := LinearAlgebra:-LinearSolve(S, V);
A, B := seq(Sol);   

 

restart;
L:=proc(P,v)
if P=x then  x*y elif 
P=y then  1 elif
P=z then  z^2 elif
nops(P)=1 and not (P in v) then  0 elif
type(P,`+`) then  map(L,P,v) elif
type(P,`*`) or type(P,`^`) then if type(P,`^`) then  op(2,P)*op(1,P)^(op(2,P)-1)*L(op(1,P),v)  else  `+`(seq(`*`(({op(P)} minus {p})[])*`if`(p::numeric,0,`if`(p in v,L(p,v),op(2,p)*op(1,p)^(op(2,p)-1)*L(op(1,p),v))),p={op(P)})) fi; fi;
end proc:

# Examples
L(x*y + y*z,[x,y,z]);
L(x*y*z,[x,y,z]);
L(1/2*x*y^2+3*y^3*z, [x,y,z]);                               

                      


More complex examples can be easily generated using the  randpoly  command, for example:

P:=randpoly([x,y,z], dense, degree=3);
L(P,[x,y,z]);

 

Edit.

See Help on  inttrans:-laplace  command and  dsolve,inttrans  help page. 

Your function should be defined as  piecewise  function:

f:=t->piecewise(t>=0 and t<5,exp(-2*t),t>=5,-t);
inttrans:-laplace(f(t), t, s);

 

restart;
# Define i1(t) and i2(t) as symbolic variable

# Given differential equation
ode1 := diff(i1(t),t) = 0.5*i1(t)-3*i2(t)+5*exp(-2*t);
ode2 := diff(i2(t),t) = 2*i1(t) - 6*i2(t);
odes := {ode1, ode2};

# Define initial conditions
cond1 := i1(0) = 1;
cond2 := i2(0) = -1;
conds := {cond1, cond2};

# Solution of system of differential equations
Sol := dsolve(odes union conds);

plot(eval([i1(t), i2(t)], Sol), t=0..5, color=[red,blue], legend=["i1(t)","i2(t)"]);

 

To plot one or more points, the simplest way will be to use the syntax  plot([A, B, ...], style=point) , where A, B, ...  are points given by lists of their coordinates. To specify the color, size and shape of symbols representing points, use the options  color =... ,  size = ...  and  symbol = ...  . To label points we use  plots:-textplot  command. Note that the function  y=x^2  is defined as a procedure  f:=x->x^2 . This is convenient when calculating the values of both the function itself and its derivative at specific points.

Below, as an example, we solve the problem:

Given the curve  y=x^2  and 2 points  A(-1,1) B(2,4)  .
1. Check that these points lie on this curve.
2. Find the point on the curve  y=x^2 and the equation of the tangent line to this curve (at this point)  such that the tangent is parallel to the chord  AB .
3. Draw all the objects in one plot.

Solution:

restart;
f:=x->x^2:  A:=[-1,1]:  B:=[2,4]:

# Calculations
#
x1, x2, y1, y2 := A[1], B[1], A[2], B[2];
is(f(x1)=y1), is(f(x2)=y2); # Checking that points A and B lie on the curve y=x^2
Eq := D(f)(x0)=(f(x2)-f(x1))/(x2-x1);  # Mean value theorem
x0:=solve(Eq, x0);
y0:=f(x0);
k:=D(f)(x0); # The slope of the tangent
Tangent:=y=y0+k*(x-x0); # The equation of the tangent 
C:=[x0,y0];  # The point of tangency

# Plotting
#
Lines:=plot([f(x), [A,B], rhs(Tangent)], x=x1-1..x2+0.5, color=[blue,green,red]): # The plot of all the lines
Points:=plot([A,B,C], style=point, color=blue, symbol=solidcircle, symbolsize=12): # The plot of all the points
Labels:=plots:-textplot([[A[],"A"],[B[],"B"],[C[],"C"],[-1,3.5,y=f(x)],[-1,-1.5,Tangent]], font=[times,16], align={left,above}): # All the labels
plots:-display(Lines,Points,Labels, scaling=constrained, view=[x1-1..x2+0.5,-2..5], size=[500,500]);

                              

                          

 

 

 

When you apply thу  simplify  command to some equality, it is separately applied to the left and right sides, i.e.  simplify(A=B)  is equivalent to  simplify(A)=simplify(B)  (that's the design). 
To check some equality (an identity) use the  is  command instead of simplify:

restart;
simplify((a^2-b^2)/(a-b)=a+b);
is((a^2-b^2)/(a-b)=a+b);


If you really want to simplify your expression  f  to the expression  g , there is a workaround. We make simple substitutions, after which the numerator and denominator will be polynomials, then simplify. I wonder if the Mathematica can directly simplify  f  to  g  without such tricks.

restart;
f:=(9*(x^(-2/3*a))^2*exp(6/a*(x^(-2/3*a))^(1/2))^2*_C0^2-6*(x^(-2/3*a))^(3/2)*exp(
6/a*(x^(-2/3*a))^(1/2))^2*_C0^2*a+x^(-2/3*a)*exp(6/a*(x^(-2/3*a))^(1/2))^2*_C0^
2*a^2+18*(x^(-2/3*a))^2*exp(6/a*(x^(-2/3*a))^(1/2))*_C0-2*x^(-2/3*a)*exp(6/a*(x
^(-2/3*a))^(1/2))*_C0*a^2+6*(x^(-2/3*a))^(3/2)*a+x^(-2/3*a)*a^2+9*(x^(-2/3*a))^
2)/(3*_C0*exp(6/a*(x^(-2/3*a))^(1/2))*(x^(-2/3*a))^(1/2)-exp(6/a*(x^(-2/3*a))^(
1/2))*_C0*a+3*(x^(-2/3*a))^(1/2)+a)^2:
g:=x^(-2/3*a):
Subs:=[x^(-2*a*(1/3))=A^2,exp(6*sqrt(x^(-2*a*(1/3)))/a)=B];
f1:=subs(Subs, f);
f2:=simplify(f1) assuming A>0;
subs(A=sqrt(x^(-2*a*(1/3))), f2);
is(%=g);


 

restart;
A:=Matrix(3, [$1..9]);
L:=[indices(A, pairs)];
L1:=(rhs=lhs)~(L);
T:=table(L1);
T[7];

              

Eq:=a^(5/2)*s^2*(D(f))(eta)^2*sqrt(nu)/(R*sqrt(a)*sqrt(nu)+eta*nu) = a^(5/2)*s^2*(D(P(s, eta*sqrt(nu)/sqrt(a))))(eta)/sqrt(nu);
Term:=select(has,rhs(Eq),P);
solve(Eq, Term);

             

       

It's better to implement  this as a procedure so that  Digits  is set automatically:

restart;
Evalf:=proc(x::realcons,n::posint)
local m;
m:=ilog10(evalf(x));
Digits:=m+n+3;
printf(cat("%.",n,f),x);
end proc:

Examples of use:

Evalf(123456789/123,6);
``;
Evalf(123456789/123,15);
``;
Evalf(Pi,3);

     

 

If I understood everything correctly, then your surfaces can be plotted according to the following scheme:
1. We define the parametric equations of the curve:  x = R*cos(phi),  y = a - R*(1 - sin(phi)) (phi is the parameter) in the plane  xOy , setting the corresponding constants  a  and  R .
2. Both surfaces are obtained by rotating these curves around the axis  Ox .

In the picture in 3D below, the orientation of the axes  x, y, z  roughly matches your original drawing ( x  is down, y  is back, z  is right):

 

restart;
a:=3: R:=8:  # For the curve A 
a1:=2: R1:=-8:  # For the curve B
x:=R*cos(phi); y:=a-R*(1-sin(phi)); x1:=R1*cos(phi); y1:=a1-R1*(1-sin(phi));
A:=plot([x, y, phi=Pi/3..2*Pi/3], title="The plot A"):
B:=plot([x1, y1, phi=Pi/3..2*Pi/3], title="The plot B"):
plots:-display(< A | B >, scaling=constrained, view=[-4..4,-4..4], labels=["x","y"], labelfont=[times,bold,16], titlefont=[times,16]);

         


 

A1:=plot3d([x,y*cos(alpha),y*sin(alpha)], phi=Pi/3..2*Pi/3, alpha=0..2*Pi, axes=normal, title="The plot A1"):
B1:=plot3d([x1,y1*cos(alpha),y1*sin(alpha)], phi=Pi/3..2*Pi/3, alpha=0..2*Pi, axes=normal, title="The plot B1"):
plots:-display(< A1 | B1 >, scaling=constrained, view=[-4.5..4.5,-4.5..4.5,-4.5..6.5], labels=["x","y","z"], labelfont=[times,bold,16], titlefont=[times,16],  orientation=[-10,-3,70]);

    

 

As an addition - animation of  A1 :

plots:-animate(plot3d,[[x,y*cos(alpha),y*sin(alpha)], phi=Pi/3..2*Pi/3, alpha=0..'a', axes=normal], 'a'=0..-2*Pi, frames=90, scaling=constrained, view=[-4.5..4.5,-4.5..4.5,-4.5..4.5], labels=["x","y","z"], labelfont=[times,bold,16], orientation=[-10,-3,70]);

                                     

 

You can use the  subs  command if you notice that  Zs / Z_AB = K_S  is equivalent to  Zs=Z_AB*K_S :

restart;
eq_5 := x = -(K_i*Zs - Z_AB - Zs)/(K_i*Z_AB);
eq_5_m5 := x = expand(rhs(eq_5));
eq_5_m6 := x = subs(Zs=Z_AB*K_S, rhs(eq_5_m5 ));

                          

 

I usually use the following way:

restart;
u:=<-2+m,3+m>;

u:=eval(u, m=5);
# or
u1:=eval(u, m=5);

 

Such equations are easily reducible to ordinary differential equations with derivatives. In the example below, we solve the equation  p*dx-q*dy=1/2*d(y^2-x^2)  by taking  p=3, q=2  and plotting several integral curves and 2 asymptotes:

restart;
d:=z->diff(z,x)*dx:
p:=3: q:=2:
p*d(y(x))-q*dx=1/2*d(y(x)^2-x^2);
dsolve(%);
plot([seq(eval(y(x),%[1]),_C1=-8..3),seq(eval(y(x),%[2]),_C1=-8..3),-(x-2)+3,x-2+3], x=-4..8, color=[green$24,red$2], scaling=constrained);

                 

 

First 42 43 44 45 46 47 48 Last Page 44 of 290