Kitonum

21440 Reputation

26 Badges

17 years, 36 days

MaplePrimes Activity


These are answers submitted by Kitonum

a:=sqrt(2)*T*I/sqrt(L*(k+2)*C):

simplify(exp(-a)*k^2+4*exp(-a)*k+exp(a)*k^2+4*exp(a)*k+4*exp(a)+4*exp(-a));

 

 

e^a  should be coded as  exp(a), because  in Maple  e  is just a symbol. 

C:=proc(x, E)

local i, n;

n:=nops(E);

if is(x<=E[1]) then return 1 else

for i from 1 to n do

if is(x<=E[i]) and is(x>E[i-1]) then return i  fi;

od; fi;

n+1;

end:

 

Examples of use:

E:=[0,2,7,15,26,40]:

C(-1, E),  C(3, E),  C(15, E),  C(41, E);

                      1, 3, 4, 7

 

Addition: another way

C1:=proc(x, E)

local F, y;

uses ListTools;

y:=evalf(x);

F:=sort([y, op(E)]);

Search(y, F);

end:

 

For any graph it is easy to check in Maple. The graph given by its adjacency matrix.

Example: 

A:=<0,1,1,1,1; 1,0,1,0,1; 1,1,0,1,1; 1,0,1,0,0; 1,1,1,0,0>;

d:=sort([seq(add(A[i,j], j=1..5), i=1..5)], `>`);

# Checking of all the conditions

type(add(d[i], i=1..5), even);

for k to 5 do

if add(d[i], i=1..k)<=k*(k-1)+add(min(d[i], k), i=k+1..5) then print(true); fi;

od;

 

 

a := [x+1, x+2, x+3, x+4]:

remove(i -> i=x+2, a);

               [x+1, x+3, x+4]

 

To generate a random number between -1 and 1, first you generate from 0 to 2, and then this number decreased by 1.

Example: the sequense 20 random numbers from -1 to 1:

seq(RandomTools[Generate](float(range=0..2, digits=5, method=uniform)) - 1, n=1..20);

    .2143, -.73336, -.50076, -.7856e-1, -.14992, -.46077, .5519, -.4999e-1, -.14926, -.57465, .8858, -.27223, -.4630e-1,    -.66349, .2290, .1925, .2208, .5704, .2130, -.15558

The penultimate line of code  

M[1..6,1..6]:=Matrix(3,3,shape=identity)

is not evaluated because it is written in text mode.

Yes, it's possible. Use the formula of differentiation of parametric function  Diff(y(x), z)=Diff(y(x), x)/Diff(z(x), x)

Example:

y:=x->sin(x): z:=x->x-y(x):

diff(y(x), x)/diff(z(x), x);

 

 

f:=x->piecewise(x>=2 and x<=6, sqrt(x), undefined);

D(f)(1);

plot(f, 0..7, 0..3, scaling=constrained);

 

 

restart;

Dist := proc (A::list, B::list)

sqrt((A[1]-B[1])^2+(A[2]-B[2])^2)

end proc:  # Procedure for calculation of the distance between two points defined by lists

A := [1, 1]: B := [x1, 2]: C := [x2, y2]:  # The centers of the circles

solve({Dist(A, B) = 3, Dist(A, C) = 1+y2, Dist(B, C) = 2+y2}, useassumptions) assuming x1 > 0, x2 > 0, y2 > 0;

assign(%);

Circle1 := (x-1)^2+(y-1)^2 = 1;

Circle2 := (x-x1)^2+(y-2)^2 = 4;

Circle3 := (x-x2)^2+(y-y2)^2 = expand(y2^2);

plots[implicitplot]([Circle1, Circle2, Circle3], x = -1 .. 6, y = -1 .. 5, thickness = 2, color = [blue, green, red], scaling = constrained, numpoints = 10000);

 

 

 

For older versions (at least for <=12)  ~  command doesn't work. The adjustment will be

seq( x^3-3*x^2-24*x+8, x=[-2,4,6,9]);

                             36, -72, -28, 278

 

In new versions this variant works also.

 

M:=3:  N:=3:

H:=1/N*Matrix(M,{seq((i,1)=t[f]^i/i, i=1..M)}):

E:=1/N*Matrix(M, {seq((i,i+1)=1/i, i=1..M-1)}):

P:=<seq(`<|>`(Matrix(M) $ M-1-k,E,H $ k),k=M-1..0,-1)>;

 

 

restart;

N := 8:

a := -Pi:

b := 3 * Pi:

data := []:

for n from 0 to N do

x[n] := a + n * (b - a)/N;

data := [op(data), [x[n], sin(x[n])]];

od:

data;

plot(data);

 

 

If the list is long better to write the following equivalent but more effective variant:

restart;

N := 1000:

a := -Pi:

b := 3 * Pi:

for n from 0 to N do

x[n] := a + n * (b - a)/N;

data[n] := [x[n], sin(x[n])];

od:

data := convert(data, list):

plot(data);

 

 Addition:  Instead a loop  shorter to use  seq  command:

restart;

a:=-Pi: b:=3*Pi:

N:=1000:

data := [seq([k, sin(k)], k=[a + n * (b - a)/N $ n=0..N])]:

plot(data);

Because we already know that  sum(1/n^2, n=1..infinity)=Pi^2/6 , the same can be written slightly shorter:

floor(fsolve(sum(1/n^2, n= N..infinity)=.001));

                              1000

It looks better if only one parameter is changed.

For thickness (every value of the thickness takes about 2 seconds):

plots[display]([seq(plot(exp(-x^2)*sin(Pi*x), x = -2 .. 2, color = red, thickness = t, caption = typeset("Thickness =  ", t), titlefont = [TIMES, BOLD, 16]) $ 20, t = 1 .. 15)], insequence = true);

 

The same for colors (7 colors of the rainbow):

 

plots[display]([seq(plot(exp(-x^2)*sin(Pi*x), x = -2 .. 2, color = c, thickness = 4, caption = typeset("Color =  ", c), titlefont = [TIMES, BOLD, 16]) $ 20, c = [red, orange, yellow, green, blue, "Indigo", violet])], insequence = true);

 

Of course, these simple examples easier to solve by hand. 

Solution with Maple:

solve(3*x-5>=0);

solve(x+2<0 or x+2>0);

 

 

First 231 232 233 234 235 236 237 Last Page 233 of 289