Kitonum

13347 Reputation

24 Badges

11 years, 66 days

MaplePrimes Activity


These are answers submitted by Kitonum

restart;
randomize():
A:=[1,1.732,1.23,4.42,9,6.45,3.45,8.428,9.1,12];
r:=rand(1..nops(A)):
seq(A[r()], i=1..3);


Since each time a number is chosen randomly from the entire list (a sample with a return), it can happen that the same number will be selected during the re-selection. It is also not difficult to implement a non-refund sample.

restart;
test := -2+exp(theta)+exp(-theta);
subs(exp(theta)=1/exp(-theta), test);
factor(%);

The final result:       (exp(-theta)-1)^2/exp(-theta)


Edit.

First write these data as a list of lists, then use the  plot  command as in this toy example:

XY:=[[1,2],[2,4],[3,5],[4,4]]:
plot(XY);

 

In the list of options for  pdsolve  command (with  numeric  option), the option  output = listprocedure  does not exist. See help on  ?pdsolve/numeric


 

Sol:=dsolve({diff(g(r),r,r)- r/R*g(r)=0, g(2*R)=0, D(g)(0)=R}) assuming R>0;
plot(eval(rhs(Sol),R=1), r=0..4, -2..2);

     
 

 

eq:=(-2*cos(x)^2+2*sin(x+(1/4)*Pi)^2-1)/sqrt(-x^2+4*x) = 0:
[solve(eq, x, allsolutions)];
subsindets(%, suffixed(_Z, integer), t->k);
map(t->unapply(t,k), %);
seq(`if`(evalf(p(0))>0 and evalf(p(0))<4,p(0),`if`(evalf(p(1))>0 and evalf(p(1))<4,p(1),NULL)), p=%);

  The final result:                      (1/2)*Pi,  (1/4)*Pi,  5*Pi*(1/4)

I remind that the original question was how to get a solution in the form  k*Pi and -Pi/48 + k*Pi/8
This form of the answer is based on a well-known identity  sin(a)-sin(b)=2*sin((a-b)/2)*cos((a+b)/2) . I don’t know a simple way to get this identity automatically in Maple, so I wrote it manually:

restart;
eq := sin(9*x-(1/3)*Pi) = sin(7*x-(1/3)*Pi):
a:=9*x-(1/3)*Pi:
b:=7*x-(1/3)*Pi:
solve(2*sin((a-b)/2)*cos((a+b)/2), allsolutions):
subsindets([%],suffixed(_Z, integer), t->k)[];

                               

I replaced these assignments  x[0]:=1  and so on, due to which all your troubles:

Optimal_control_new.mw

plots:-implicitplot3d(`if`(y<x and z<y,cos(x-y)*cos(y-z)*cos(x-2*z)^3-0.6, NULL), x=0..5, y=0..5, z=0..2, style=surface, color=green, numpoints=500000, axes=normal);

 

remove~(is, S);

# Or (for old versions of Maple)

map(t->remove(is, t), S);
 

f1 := [12.5, 16, 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000]:
x:= 23:
y:= 36:
Lp:= t->8-10*log[10]((1+(t/(2*x))^2.5)*(1+(y/(2.*t))^1.7));
[seq(Lp(t), t=f1)];

or use element-wise operator ~:

f1 := [12.5, 16, 20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000]:
x:= 23:
y:= 36:
Lp:= t->8-10*log[10]((1+(t/(2*x))^2.5)*(1+(y/(2.*t))^1.7));
Lp~(f1);

Obviously the last is the shortest way.

Edit.

Here is another way that will also work in older versions of Maple, which do not have the output = permutation option.

Two examples:

# Example 1 - sort rows in descending order of elements of the 3rd column
A:=LinearAlgebra:-RandomMatrix(4, generator = -10 .. 10);
sort(convert(A, listlist), (x,y)->x[3]>=y[3]);
Matrix(%);

# Example 2 - how many elements in the 3rd column are 5? 
`+`(seq(`if`(A[i,3]=5,1,0), i=1..4));

 


 

pde1 := k*(diff(u(x, t), x, x)) = diff(u(x, t), t)

k*(diff(diff(u(x, t), x), x)) = diff(u(x, t), t)

(1)

iv1 := u(0, t) = 0, u(L, t) = 0, u(x, 0) = 2;

u(0, t) = 0, u(L, t) = 0, u(x, 0) = 2

(2)

pdsolve([pde1, iv1], u(x, t))

u(x, t) = Sum(-4*(-1+(-1)^(_Z4*csgn(1/L)))*sin(Pi*_Z4*x/L)*exp(-k*Pi^2*_Z4^2*t/L^2)/(Pi*_Z4), _Z4 = 1 .. infinity)

(3)

lprint(%);

u(x, t) = Sum(-4*(-1+(-1)^(_Z4*csgn(1/L)))*sin(Pi*_Z4*x/L)*exp(-k*Pi^2*_Z4^2*t/L^2)/(Pi*_Z4), _Z4 = 1 .. infinity)

 

subs(_Z4 = n, %);

u(x, t) = Sum(-4*(-1+(-1)^(n*csgn(1/L)))*sin(Pi*n*x/L)*exp(-k*Pi^2*n^2*t/L^2)/(Pi*n), n = 1 .. infinity)

(4)

 

 


 

Download evaluate_a_sum_new.mw

printlevel := 2; M1 := 3; M2 := 3; nu := 1;
for k1 from 0 while k1 <= M1-1 do
for k2 from 0 while k2 <= M2-1 do
GP[k1+1, k2+1] := simplify(sum((-1)^(k1-i1)*GAMMA(k1+i1+2*nu)*GAMMA(nu+1/2)*x^i1*(sum((-1)^(k2-i2)*GAMMA(k2+i2+2*nu)*GAMMA(nu+1/2)*y^i2/(GAMMA(i2+nu+1/2)*factorial(k2-i2)*factorial(i2)*GAMMA(2*nu)), i2 = 0 .. k2))/(GAMMA(i1+nu+1/2)*factorial(k1-i1)*factorial(i1)*GAMMA(2*nu)), i1 = 0 .. k1));
end do; end do;
<seq(seq(GP[i,j],j=1..M2), i=1..M1)>;
# if a is just a symbol then
<seq(seq(a[i,j],j=1..M2), i=1..M1)>;

 

But you calculate completely different integrals, so the results are different.

V = Int(N, T__2 = 0 .. infinity)<>IntegrationTools:-Parts(V, exp(sigma-delta*(T__2-T__F)-(T__2-T__F)^2/T__p^2), T__2)

Using the option  T__2  you change the source integral. See the help on the  IntegrationTools:-Parts  command.


Take a look at a simple example in which we see that adding a third parameter in the  IntegrationTools:-Parts  command completely changes the original integral:

V:=Int(x^2*sin(x), x);
IntegrationTools:-Parts(V,x^2);
IntegrationTools:-Parts(V,x^2,x);

                

 

 

2 3 4 5 6 7 8 Last Page 4 of 208