Kitonum

21495 Reputation

26 Badges

17 years, 57 days

MaplePrimes Activity


These are answers submitted by Kitonum

restart;

with(DEtools): with(plots): Nsols := 5; Ntstep := 10;

 k := 0; A := 0.37e-1; B := 0.2e-6;

ode0 := diff(U(t), t) = -(A+B*U(t))*U(t);

 ic[1] := U(365*k) = 1000;

sol[0] := dsolve({ode0, ic[1]}, U(t), range = 365*k .. 365*k+365, numeric);

p[0] := odeplot(sol[0], [[t, U(t)]], t = 365*k .. 365*k+365, colour = blue, legend='p[0]'):

display(p[0]);

ode1 := diff(U(t), t) = -(A+r(t)+B*U(t))*U(t);

R := RandomTools:-Generate(distribution(Normal(-0.2e-1, 0.4e-1)), makeproc = true);

r := proc (t) if not type(t, numeric) then return 'procname(args)' end if; R() end proc;

 

for i to Nsols do

sol[i] := dsolve({ode1, ic[1]}, numeric, known = r(t), method = classical[foreuler], stepsize = 0.1e-1):

p[i] := odeplot(sol[i], [[t, U(t)]], t = 365*k .. 365*k+365, colour = red)

 end do:

display(seq(p[i], i = 1 .. Nsols));

 

for j to Ntstep do

 for i to Nsols do

x[i] := proc (t) options operator, arrow; rhs(sol[i](t)[2]) end proc;

y[i] := x[i](j):

end do:

ymaxval[j] := max([seq(y[i], i = 1 .. Nsols)]):

end do:

S1:=[seq(ymaxval[j], j=1..Ntstep)];

 

for j to Ntstep do

 for i to Nsols do

x[i] := proc (t) options operator, arrow; rhs(sol[i](t)[2]) end proc;

y[i] := x[i](j):

end do:

yminval[j] := min([seq(y[i], i = 1 .. Nsols)]):

end do:

S2:=[seq(yminval[j], j=1..Ntstep)];

 

plotofmax:= plot([seq(j, j=1..Ntstep)], S1, color=red, legend="plotofmax"):

plotofmin:= plot([seq(j, j=1..Ntstep)], S2, color=black, legend="plotofmin"):

 

display(plotofmax, plotofmin, p[0], view=[1..Ntstep, min(S2, rhs(sol[0](10)[2]))..max(S1, rhs(sol[0](0)[2]))]);

Now all works:


restart;

with(DEtools): with(plots):

 

k := 0; A := 0.37e-1; B := 0.2e-6;

 

ode1 := diff(U(t), t) = -(A+r(t)+B*U(t))*U(t);

ic[1] := U(365*k) = 1000;

 

R := RandomTools:-Generate(distribution(Normal(-0.2e-1, 0.4e-1)), makeproc = true);

r := proc (t) if not type(t, numeric) then return 'procname(args)' end if; R() end proc;

 

for i to 5 do

sol[i] := dsolve({ode1, ic[1]}, numeric, known = r(t), method = classical[foreuler], stepsize = 0.1e-1):

p[i] := odeplot(sol[i], [[t, U(t)]], t = 365*k .. 365*k+365, colour = red) end do:

 

display(seq(p[i], i = 1 .. 5));

 

for i to 5 do x[i] := proc(t) options operator, arrow; rhs(sol[i](t)[2]) end proc:

y[i] := x[i](2) end do:

 

seq(y[i], i=1..5);

max(seq(y[i], i=1..5));

If you want a vector to be argument in your function, you can use the  unapply  command:

F:=unapply(6*x[1]^2 + 3*x[2]^2 - 1.5*x[3]^3, x::Vector):

 

Examples:

F(<1,2,3>);

H:=unapply(Student[VectorCalculus][Hessian](F(<X[1], X[2], X[3]>), [X[1], X[2], X[3]]), X::Vector):

H(<x,y,z>);

H(<1,2,3>);


To draw a phase curve, you must:

1) Set the value of the parameter  k .
2) Specify the initial condition.

If you interested of changing of the curve in response to changes  k , you can make animation with the parameter  k .

Example (for greater clarity, the ranges of  k  and  t  are reduced):

with(DEtools):
for k from 1 to 2 by 0.01 do
DE := diff(x(t), t) = x(t):
DF := diff(y(t), t) = k*y(t):
A[k]:=phaseportrait([DE, DF], [y, x], t = 0 .. 0.5, [[y(0)=1, x(0)=1]], color=black, linecolor = red):
od:
plots[display](seq(A[k], k=1..2, 0.01), insequence=true);

 

To construct the phase curves you need:

1) Increase the range for the variable t .

2) Set the initial conditions.


Example (plotting of two phase curves):

with(DEtools):
sys := diff(x(t), t) = y(t), diff(y(t), t) = x(t)*(1-x(t)*x(t))+y(t);
DEplot([sys], [x(t), y(t)], t = 0 .. 3, x = -3 .. 3, y = -3 .. 3, [[x(0)=1, y(0)=2], [x(0)=-2, y(0)=1]],color = black);

P:=combinat[powerset]({a, b, c, d, e}):

m:=0:  n:=0:  k:=0:

for i in P do

for j in P do

if nops(i union j)=5 and nops(i intersect j)=3 then m:=m+1: fi:

if nops(i union j)=5 and nops(i intersect j)=4 then n:=n+1: fi:

if nops(i union j)=5 and nops(i intersect j)=5 then k:=k+1: fi:

od: od:

binomial(30, 5)*(m+n*binomial(4, 3)+k*binomial(5, 3))*2^(30-3);

                                                     1721414839173120

Your code has 3 errors:

1) Instead posint should be positive.

2) The condition a+b>c is only necessary but not sufficient for a, b, c to be lengths of a triangle. Should be

a+b>c and a+c>b and b+c>a

3) Conditions of the type  a+b>c  should be given in the form  is(a+b>c)  

limit(exp(-a*x), x = infinity) assuming a>0;

                              0

x[n]:=e[n]+w;

f(w):=0;

fxn:=convert(series(f(x[n]), e[n]=0, 10), polynom);

subs(seq(((D@@i)(f))(w) = c[{i}], i = 2 .. 9), fxn);

To build a contourplot you need to specify the range for the second variable  y . It's better  to output  both  graphics separately.

with(plots):

F:= x^2+2*y^3+Q:

Q:=1:  contourplot( F, x=0..1, y=0..1,color=red);

Q:=2:  contourplot( F, x=0..10, y=0..10,color=blue);

 

Done in Maple 14 Classic Worksheet.

A:=plottools[curve]([[1,-1], [1,1], [-1,1], [-1,-1], [1,-1]], style=line, thickness=5):

B:=plottools[circle]([0,0], 1, thickness=5):

A1:=plottools[homothety](A, sqrt(2)/2):

A2:=plottools[homothety](A, 1/2):

A3:=plottools[homothety](A2, sqrt(2)/2):

B1:=plottools[homothety](B, sqrt(2)/2):

B2:=plottools[homothety](B1, sqrt(2)/2):

U:=plots[display](A, A1, A2, A3, B, B1, B2):

C:=plot([1,-1], x=-1..1, filled=true, color=yellow, numpoints=10000):

C1:=plot([cos(t), sin(t), t=0..2*Pi], filled=true, color=white):

E:=plot([1/sqrt(2),-1/sqrt(2)], x=-1/sqrt(2)..1/sqrt(2), filled=true, color="DarkOrange", numpoints=10000):

E1:=plot([cos(t)/sqrt(2), sin(t)/sqrt(2), t=0..2*Pi], filled=true, color=white):

F:=plot([1/2,-1/2], x=-1/2..1/2, filled=true, color="HotPink", numpoints=10000):

F1:=plot([cos(t)/2, sin(t)/2, t=0..2*Pi], filled=true, color=white):

X:=plots[display](F1, F, E1, E, C1, C):

G:=plot([cos(t), sin(t), t=-Pi/4..Pi/4], filled=true, color=gold):

G1:=plottools[rotate](G, Pi/2):

G2:=plottools[rotate](G, Pi):

G3:=plottools[rotate](G, 3*Pi/2):

H:=plot([cos(t)/sqrt(2), sin(t)/sqrt(2), t=-Pi/4..Pi/4], filled=true, color="IndianRed"):

H1:=plottools[rotate](H, Pi/2):

H2:=plottools[rotate](H, Pi):

H3:=plottools[rotate](H, 3*Pi/2):

K:=plot([cos(t)/2, sin(t)/2, t=-Pi/4..Pi/4], filled=true, color="Crimson"):

K1:=plottools[rotate](K, Pi/2):

K2:=plottools[rotate](K, Pi):

K3:=plottools[rotate](K, 3*Pi/2):

Y:=plots[display](G, G1, G2, G3, H, H1, H2, H3, K, K1, K2, K3):

V:=plottools[polygon]([[sqrt(2)/4,sqrt(2)/4], [-sqrt(2)/4,sqrt(2)/4], [-sqrt(2)/4,-sqrt(2)/4], [sqrt(2)/4,-sqrt(2)/4]], color="DarkMagenta"):

plots[display](V, Y, X, U, axes=none);

The answer to the question b) is quite simple (the area of the yellow square is 8 ), as each next smaller square has an area of ​​two times less than the previous one.

To answer to the question a) it takes a bit of work.

S:= A*cos(m*x)*sin(n*z) + B*cos(k*z)*sin(q*x) + sin(s*z) + C*cos(p*z)+E*sin(t*z)^2: 

L:=[]:

for i in [op(S)] do

if (nops(i)=1 and (is(op(0,i)=sin) or is(op(0,i)=cos))) or

(nops(i)=2 and (is(op([-1,0],i)=sin) or is(op([-1,0],i)=cos)) and

(type(op(1,i),constant) or type(op(1,i),symbol))) then

if nops(i)=1 then L:=[op(L), [1,i]] else L:=[op(L), [op(1, i),i]]: fi:

fi:

od: 

L;

                                          [[1, sin(s*z)], [C, C*cos(p*z)]]


A:=Array([1,1,1,0,0,3,2,4]):
n:=ArrayNumElems(A):
mean:=add(A[i], i=1..n)/n;
variance:=add((A[i]-mean)^2, i=1..n)/n;
                     mean := 3/2
variance := 7/4

Good question!

We will consider the integers from 0 to 10^23 -1. We assume that each of them is written by 23 digits (from 0 to 9). If the integer is less than 10 ^ 22, then write forward the required number of zeros.
Procedure   Total(N)  finds the total number of numbers in the specified range  0 .. 10^23 -1 , whose sum of the digits is equal to .

Total:=proc(N::nonnegint)

local L, i, j, k, l, m, n, a, b, M, s, S, T;

if N>207 then return 0 else

 

L:=[seq([i,0], i=0..54)]:

for i from 0 to 9 do

for j from 0 to 9 do

for k from 0 to 9 do

for l from 0 to 9 do

for m from 0 to 9 do

for n from 0 to 9 do

a:=i+j+k+l+m+n:

L:=subsop(a+1=[a,L[a+1,2]+1], L):

od: od: od: od: od: od:

 

M:=[seq([i,0], i=0..45)]:

for i from 0 to 9 do

for j from 0 to 9 do

for k from 0 to 9 do

for l from 0 to 9 do

for m from 0 to 9 do

b:=i+j+k+l+m:

M:=subsop(b+1=[b,M[b+1,2]+1], M):

od: od: od: od: od:

 

s:=0:

for i from 0 to 54 do

for j from 0 to 54 do

for k from 0 to 54 do

for m from 0 to 45 do

if i+j+k+m=N then s:=s+1; S[s]:=[i, j, k, m]; fi;

od: od: od: od:

S:=[seq(S[t], t=1..s)]:

 

T:=0;

for i in S do

T:=T+L[i[1]+1,2]*L[i[2]+1,2]*L[i[3]+1,2]*M[i[4]+1,2];

od;

fi;

 

T;

end proc:


Solution of the initial problem:

add(Total(N), N=10..99);

add(Total(N), N=100..207);

38645951372988192979800
61354048627011778971400


First 268 269 270 271 272 273 274 Last Page 270 of 290