Kitonum

21830 Reputation

26 Badges

17 years, 220 days

MaplePrimes Activity


These are answers submitted by Kitonum

Specify the range for  x  variable explicitly:

with(DocumentTools):
A := [plot(sin(x)/x, x = -2*Pi .. 2*Pi, legend = sinc(x)), Sum(f(i), i = 1 .. N), plot3d(y^2*sin(x), x = -Pi .. Pi, y = -2 .. 2)]:
Tabulate(A, width = 60):


 

Download Tab.mw

Maximize (or Minimize) command only guarantees a local extremum, not a global one (see help for details). To get a global maximum, first plot a graph, and then narrow the range for the variable  x , that contains the maximum:


 

restart;
with(Optimization):
app := x->0.14546e-1*sin(3.141592654*x)+(-1)*0.50512e-2*sin(6.283185308*x)+0.19918e-2*sin(9.424777962*x);
ex :=x->-AiryAi(2^(2/3)*x)*(5*3^(5/6)-9*AiryBi(2^(2/3))*GAMMA(2/3))/(8*AiryAi(2^(2/3))*3^(5/6)-8*AiryBi(2^(2/3))*3^(1/3))-AiryBi(2^(2/3)*x)*(9*AiryAi(2^(2/3))*GAMMA(2/3)-5*3^(1/3))/(8*AiryAi(2^(2/3))*3^(5/6)-8*AiryBi(2^(2/3))*3^(1/3))+(1/4)*x^3+3/8;
plot(100*abs(app(x)-ex(x)), x = 0 .. 1);
Maximize(100*abs(app(x)-ex(x)), x=0.8..1);

proc (x) options operator, arrow; 0.14546e-1*sin(3.141592654*x)-0.50512e-2*sin(6.283185308*x)+0.19918e-2*sin(9.424777962*x) end proc

 

proc (x) options operator, arrow; -AiryAi(2^(2/3)*x)*(5*3^(5/6)-9*AiryBi(2^(2/3))*GAMMA(2/3))/(8*AiryAi(2^(2/3))*3^(5/6)-8*AiryBi(2^(2/3))*3^(1/3))-AiryBi(2^(2/3)*x)*(9*AiryAi(2^(2/3))*GAMMA(2/3)-5*3^(1/3))/(8*AiryAi(2^(2/3))*3^(5/6)-8*AiryBi(2^(2/3))*3^(1/3))+(1/4)*x^3+3/8 end proc

 

 

[HFloat(0.1838471711423484), [x = HFloat(0.9230341609253242)]]

(1)

 


 

Addition. In order to immediately get the global extremum, you can use DirectSearch  package, which should be downloaded from the Maple Application Center and installed on your computer

https://www.maplesoft.com/applications/view.aspx?sid=101333

 

Download Max.mw

First you need to open your file, then  ctrl+ p

Another way: menu file -> print  or  print preview

Probably a double for loop is meant for summing such terms, if  i  runs from  0  to  m  and  runs from  0  to  n . A simple procedure named  Bxy  solves the problem:

Bxy:=proc(m::nonnegint,n::nonnegint)
local S, i, j;
S:=0;
for i from 0 to m do
for j from 0 to n do
S:=S+binomial(m,j)*binomial(n,i)*x^i*(1-x)^(m-i)*y^j*(1-y)^(n-j);
od; od;
S;
end proc:

Example of use:

Bxy(3,2);

                  

 

Here is the numerical solution:

restart;
pde:=diff(u(x,t), t$2)+diff(u(x,t), x$4)=0;
bc:=u(0,t)=-12*t^2, u(1,t)=1-12*t^2, D[1,1](u)(0,t)=0, D[1,1](u)(1,t)=12;
ic:=u(x,0)=x^4, D[2](u)(x,0)=0;
sol:=pdsolve(pde, {ic,bc}, u(x,t), numeric);
sol:-plot3d(t = 0 .. 1, x = 0 .. 1, axes = boxed);

 

Use  %.  or  %*  instead of  :

sum(i %. a, i=1..3);
                                               


Another option is to use  ``(...)  construction to avoid the summation of similar terms. Then all the individual terms of the series are enclosed in parentheses, and it is convenient to compare:

sum(``(i*a), i=1..3);
                                               

 This construction is often useful in other cases. For example, if you need to clearly show the definition of the number  10!  then it can be done in 3 ways:

``(10)!=product(``(k), k=1..10);
# or
``(10)!=`%.`(seq(k, k=1..10));
# or
``(10)!=`%*`(seq(k, k=1..10));
                                          

 

Edit.                                   

Try this:

simplify(-sqrt((r-2*M)*(-r/(-r+2*M))^eta/r)*X*sqrt(-((r-2*M)/r)^eta*r/(-r+2*M))/f) assuming r>0, r-2*M>0, eta::real;


Edit.

 

In fact, Maple knows this, but this syntax  convert(sin(alpha), radical)  is required for output. Maple can express in real radicals trigonometric functions of any angle multiple of 3 degrees:


 

for k from 3 to 87 by 3 do
%sin(k*Pi/180)=convert(sin(k*Pi/180), radical);
od;

%sin((1/60)*Pi) = (-(1/16)*2^(1/2)-(1/8)*(5+5^(1/2))^(1/2)+(1/16)*2^(1/2)*5^(1/2))*3^(1/2)-(1/16)*2^(1/2)+(1/8)*(5+5^(1/2))^(1/2)+(1/16)*2^(1/2)*5^(1/2)

 

%sin((1/30)*Pi) = (1/8)*2^(1/2)*3^(1/2)*(5-5^(1/2))^(1/2)-1/8-(1/8)*5^(1/2)

 

%sin((1/20)*Pi) = -(1/4)*(5-5^(1/2))^(1/2)+(1/8)*2^(1/2)*(5^(1/2)+1)

 

%sin((1/15)*Pi) = (1/8-(1/8)*5^(1/2))*3^(1/2)+(1/8)*2^(1/2)*(5+5^(1/2))^(1/2)

 

%sin((1/12)*Pi) = (1/4)*2^(1/2)*(3^(1/2)-1)

 

%sin((1/10)*Pi) = -1/4+(1/4)*5^(1/2)

 

%sin((7/60)*Pi) = ((1/8)*3^(1/2)+1/8)*(5-5^(1/2))^(1/2)-(1/16)*2^(1/2)*(5^(1/2)+1)*3^(1/2)+(1/16)*2^(1/2)*(5^(1/2)+1)

 

%sin((2/15)*Pi) = -(1/8)*2^(1/2)*(5-5^(1/2))^(1/2)+(1/8+(1/8)*5^(1/2))*3^(1/2)

 

%sin((3/20)*Pi) = (1/8)*2^(1/2)+(1/4)*(5+5^(1/2))^(1/2)-(1/8)*2^(1/2)*5^(1/2)

 

%sin((1/6)*Pi) = 1/2

 

%sin((11/60)*Pi) = (-(1/16)*2^(1/2)+(1/8)*(5+5^(1/2))^(1/2)+(1/16)*2^(1/2)*5^(1/2))*3^(1/2)-(1/16)*2^(1/2)-(1/8)*(5+5^(1/2))^(1/2)+(1/16)*2^(1/2)*5^(1/2)

 

%sin((1/5)*Pi) = (1/4)*2^(1/2)*(5-5^(1/2))^(1/2)

 

%sin((13/60)*Pi) = (-(1/8)*3^(1/2)+1/8)*(5-5^(1/2))^(1/2)+(1/16)*2^(1/2)*(5^(1/2)+1)*3^(1/2)+(1/16)*2^(1/2)*(5^(1/2)+1)

 

%sin((7/30)*Pi) = (1/8)*2^(1/2)*3^(1/2)*(5+5^(1/2))^(1/2)+1/8-(1/8)*5^(1/2)

 

%sin((1/4)*Pi) = (1/2)*2^(1/2)

 

%sin((4/15)*Pi) = ((1/8)*5^(1/2)-1/8)*3^(1/2)+(1/8)*2^(1/2)*(5+5^(1/2))^(1/2)

 

%sin((17/60)*Pi) = ((1/8)*3^(1/2)+1/8)*(5-5^(1/2))^(1/2)+(1/16)*2^(1/2)*(5^(1/2)+1)*3^(1/2)-(1/16)*2^(1/2)*(5^(1/2)+1)

 

%sin((3/10)*Pi) = 1/4+(1/4)*5^(1/2)

 

%sin((19/60)*Pi) = ((1/8)*(5+5^(1/2))^(1/2)+(1/16)*2^(1/2)-(1/16)*2^(1/2)*5^(1/2))*3^(1/2)+(1/16)*2^(1/2)*5^(1/2)-(1/16)*2^(1/2)+(1/8)*(5+5^(1/2))^(1/2)

 

%sin((1/3)*Pi) = (1/2)*3^(1/2)

 

%sin((7/20)*Pi) = -(1/8)*2^(1/2)+(1/4)*(5+5^(1/2))^(1/2)+(1/8)*2^(1/2)*5^(1/2)

 

%sin((11/30)*Pi) = (1/8)*2^(1/2)*3^(1/2)*(5-5^(1/2))^(1/2)+1/8+(1/8)*5^(1/2)

 

%sin((23/60)*Pi) = (-1/8+(1/8)*3^(1/2))*(5-5^(1/2))^(1/2)+(1/16)*2^(1/2)*(5^(1/2)+1)*3^(1/2)+(1/16)*2^(1/2)*(5^(1/2)+1)

 

%sin((2/5)*Pi) = (1/4)*2^(1/2)*(5+5^(1/2))^(1/2)

 

%sin((5/12)*Pi) = (1/4)*2^(1/2)*(1+3^(1/2))

 

%sin((13/30)*Pi) = (1/8)*2^(1/2)*3^(1/2)*(5+5^(1/2))^(1/2)+(1/8)*5^(1/2)-1/8

 

%sin((9/20)*Pi) = (1/4)*(5-5^(1/2))^(1/2)+(1/8)*2^(1/2)*(5^(1/2)+1)

 

%sin((7/15)*Pi) = (1/8)*2^(1/2)*(5-5^(1/2))^(1/2)+(1/8+(1/8)*5^(1/2))*3^(1/2)

 

%sin((29/60)*Pi) = (-(1/16)*2^(1/2)+(1/8)*(5+5^(1/2))^(1/2)+(1/16)*2^(1/2)*5^(1/2))*3^(1/2)+(1/8)*(5+5^(1/2))^(1/2)+(1/16)*2^(1/2)-(1/16)*2^(1/2)*5^(1/2)

(1)

 


 

Download sine.mw

You can do this using  plots:-textplot  and  plot  commands as follows:

The code:

restart;
with(plots):
T:=[[0,0.9, "2*5+8 = 2*5+8"], font=[times,20]]:
T1:=textplot(op(T)):
Line:=plot([[t,0.87,t=-0.56..-0.28],[t,0.87,t=0.1..0.38]], color=black):
display(T1, Line, size=[300,70], view=[-1..1,0.6..1.3], axes=none);

Output:
                                            


You can even make an animation of this. For the animation we used the technique from this post .

The code:

A:=animate(textplot,subsop(1=[T[1,1..2][],T[1,3][1..round(i)]],T), i=0..length(T[1,3]), frames=40, paraminfo=false, view=[-1..1,0.6..1.3], size=[300,70], axes=none):
B1:=animate(plot,[[t,0.87,t=-0.56..a], color=black], a=-0.56..-0.28, frames=10, paraminfo=false):
B2:=animate(plot,[[t,0.87,t=0.1..a], color=black], a=0.1..0.38, frames=10, paraminfo=false):
display([A, display(op([1,-1,1],A),B1), display(op([1,-1,1],A),op([1,-1,1],B1),B2)], insequence);

  Output: 

                       

Premature calculation occurs, before the substitution of values  i  into the series. This is easy to see if you write down it as an inert sum:

Sum(0^i/i!, i=0..infinity);
                                                      

 
For correct calculation use  eval  command:

eval(sum(x^i/i!, i=0..infinity), x=0);
                                                             
1
 

I also did not understand exactly what you want to plot. You have a system of 5 unknown functions of the variable  t . Below I showed how you can plot the graph  V  vs  t. For other functions, everything is the same.

DEplot({diff(C(t), t) = rho*lambda*S(t)+rho*epsilon*lambda*V(t)+(1-q)*eta*I(t)-(mu+beta+chi)*C(t), diff(I(t), t) = (1-rho)*lambda*S(t)+(1-rho)*epsilon*lambda*V(t)+chi*C(t)-(mu+alpha+eta)*I(t), diff(R(t), t) = beta*C(t)+q*eta*I(t)-(mu+delta)*R(t), diff(S(t), t) = (1-p)*pi+phi*V(t)+delta*R(t)-(mu+lambda+vartheta)*S(t), diff(V(t), t) = p*pi+vartheta*S(t)-(epsilon*lambda+mu+phi)*V(t)}, {C(t), I(t), R(t), S(t), V(t)}, t = 0 .. 300, number = 5, stepsize = .1, [[S(0) = 8200, V(0) = 2800, C(0) = 200, I(0) = 210, R(0) = 200]], linecolour = t, axes = BOXED, scene = [t, V(t)]);

 

In fact, you study the monotonicity of the function  x-> (3*x-1)/(x^3+2*x+1)  in some intervals (for example for  x>0). For this instead  is  and  assume  command, I would just have used a plot, and to refine the intervals of increase and decrease, I would use the derivative:

restart;
f := x-> (3*x-1)/(x^3+2*x+1):
plot(f, 0..10, size=[700,300]);
R1:=solve({diff(f(x), x)>0, x>0});
R2:=solve({diff(f(x), x)<0, x>0});
evalf([R1, R2]);

 

I successfully restarted your worksheet and saved it again. Probably the cause of the problem was in the absence of any delimiters between the individual lines of your code (I had put them).

Plot_Diff_Temperature_new.mw

local D:
with(LinearAlgebra):
A:=RandomMatrix(1,1);
B:=RandomMatrix(1,5);
C:=RandomMatrix(5,1);
D:=RandomMatrix(5,5);
Matrix(2,2,{(1,1)=A,(1,2)=B,(2,1)=C,(2,2)=D});


Another way:

local D:
with(LinearAlgebra):
A:=RandomMatrix(1,1);
B:=RandomMatrix(1,5);
C:=RandomMatrix(5,1);
D:=RandomMatrix(5,5);
Matrix(2,2, ['A', 'B', 'C', 'D']):
M:=%;


Edit.

1. cutin  and  cutout  commands work only in 3D. If you try to run them in 2D, you receive an error message.

2. Yes,  project  command allows you to get shadows from some objects in 2D and 3D, but only with orthogonal projection. For an arbitrary projection, you can use  plottools[transform]  command.

with(plots): with(plottools):
P:=polygon([[0,0],[0,1],[1,1]], color=blue):
P1:=polygon([[0,0,1],[0,1,1],[1,1,1]], color=blue):
Q1:=polygon([[0,0,1],[0,1,1],[1,1,1]], color=grey):
display(cutin(P,1/2), axes=normal);  # An error
display(cutin(P1,1/2), axes=normal, view=[0..1,0..1,0..2]);
display(cutout(P,1/2), axes=normal);  # An error
display(cutout(P1,1/2), axes=normal, view=[0..1,0..1,0..2]);
display(cutout(P1,1/2), project(cutout(Q1,1/2), [[0,0,0],[1,0,0],[0,1,0]]), view=[0..1,0..1,0..2], axes=normal);  # Getting an shadow 

 

First 127 128 129 130 131 132 133 Last Page 129 of 292