Kitonum

21840 Reputation

26 Badges

17 years, 226 days

MaplePrimes Activity


These are answers submitted by Kitonum

You must specify the rule that you are going to compare the real and imaginary numbers.

Example:

sort([1+3*I, 2-I, 3], (a,b)->is(abs(a)<=abs(b)));

                        [2-I, 3, 1+3*I]

 

Read help on  sort  command.

restart;

Lines:=[y, x, x+y-3, x-y+7]:

Points:={[1,1],[4,3],[1,11],[-2,9],[-1,5],[-2,2],[-8,4],[-9,-1],[-3,-3],[3,-3],[6,-1]}:

Points1:=map(t->op([[t[1]-0.5,t[2]],[t[1]+0.5,t[2]]]), Points):

Packs:=combinat[choose](Points1,4):

k:=0:

for p  in Packs do

if convert([seq(add(sign(eval(Lines[i],[x=p[j,1],y=p[j,2]])),j=1..4)=0,i=1..4)],`and`) then

k:=k+1; Teams[k]:=p fi;

od:

Teams:=convert(Teams,list):

L:=ListTools[Categorize]((t1,t2)->convert([seq([seq(sign(eval(Lines[i],[x=t1[j,1],y=t1[j,2]])),j=1..4)]=[seq(sign(eval(Lines[i],[x=t2[j,1],y=t2[j,2]])),j=1..4)],i=1..4)],`and`),Teams):

n:=nops([L]);

Confs:=[seq(L[i,1], i=1..n)]; 


                                                                             n := 13

Confs := [{[-9.5, -1], [-8.5, -1], [3.5, 3], [4.5, 3]}, {[-9.5, -1], [-8.5, 4], [3.5, 3], [5.5, -1]}, {[-9.5, -1], [-3.5, -3], [.5, 11], [3.5, 3]}, {[-9.5, -1], [-2.5, 2], [.5, 11], [5.5, -1]}, {[-9.5, -1], [-2.5, 9], [.5, 1], [5.5, -1]}, {[-9.5, -1], [-2.5, 9], [2.5, -3], [3.5, 3]}, {[-9.5, -1], [-1.5, 5], [.5, 11], [2.5, -3]}, {[-8.5, 4], [-7.5, 4], [5.5, -1], [6.5, -1]}, {[-8.5, 4], [-3.5, -3], [.5, 11], [5.5, -1]}, {[-8.5, 4], [-2.5, 9], [2.5, -3], [5.5, -1]}, {[-3.5, -3], [-2.5, -3], [.5, 11], [1.5, 11]}, {[-3.5, -3], [-2.5, 9], [.5, 11], [2.5, -3]}, {[-2.5, 9], [-1.5, 9], [2.5, -3], [3.5, -3]}]

 

Visualization:

A:=plots[implicitplot](Lines,x=-10..7,y=-5..12, thickness=3, color=blue):

B:=[seq([seq(plottools[disk](Confs[i,j],0.2,color=red), j=1..4)],i=1..13)]:

plots[display](Matrix(3,4,[seq(plots[display](A,op(B[i]), axes=none), i=1..12)]));

plots[display](A,B[13], axes=none);



Lines:=[y, x, x+y-3, x-y+7]:

Points:=[[1,1],[4,3],[1,11],[-2,9],[-1,5],[-2,2],[-8,4],[-9,-1],[-3,-3],[3,-3],[5,-1]]:

Packs:=combinat[choose](Points,4):

k:=0:

for p  in Packs do

if convert([seq(add(sign(eval(Lines[i],[x=p[j,1],y=p[j,2]])),j=1..4)=0,i=1..4)],`and`) then

k:=k+1; Teams[k]:=p fi;

od:

Teams:=convert(Teams,list);  nops(%);

Teams := [[[1, 11], [4, 3], [-3, -3], [-9, -1]], [[1, 11], [-2, 9], [-3, -3], [3, -3]], [[1, 11], [-8, 4], [-3, -3], [5, -1]], [[1, 11], [3, -3], [-1, 5], [-9, -1]], [[1, 11], [-9, -1], [5, -1], [-2, 2]], [[4, 3], [-2, 9], [3, -3], [-9, -1]], [[4, 3], [-8, 4], [-9, -1], [5, -1]], [[-2, 9], [-8, 4], [3, -3], [5, -1]], [[-2, 9], [1, 1], [-9, -1], [5, -1]]]

                                                                                      9

 

Visualization of all the 9 solutions:

A:=plots[implicitplot](Lines,x=-10..6,y=-4..12, thickness=3, color=blue):

B:=[seq([seq(plottools[disk](Teams[i,j],0.2,color=red), j=1..4)],i=1..9)]:

plots[display](Matrix(3,[seq(plots[display](A,op(B[i]), axes=none), i=1..9)]));

 

One equation  a = sin(w*t1 + phi)  is equivalent to an infinite number of linear equations  w*t1 + ph=(-1)^n*arcsin(a)+Pi*n , n is an integer. I take only n=0

The exact solution of the first two equations:

restart;

solve({w*t1 + phi=arcsin(a), w*t2 + phi=arcsin(b)}, {w,phi});

                   {phi = -(arcsin(a)*t2-t1*arcsin(b))/(t1-t2), w = 1/(t1-t2)*(arcsin(a)-arcsin(b))}

 

If the data obtained as a result of the experiment, the overdetermined system can be solved by the method of least squares.  Maple finds a solution for which the sum of the squares of the differences of the left and right parts is minimal.

LinearAlgebra[LeastSquares]({w*t1 + phi=arcsin(a), w*t2 + phi=arcsin(b), w*t3 + phi=arcsin(c)}, {w,phi}) assuming t1::real,t2::real,t3::real;

{phi = -1/2*(arcsin(a)*t1*t2+arcsin(a)*t1*t3-arcsin(a)*t2^2-arcsin(a)*t3^2-arcsin(b)*t1^2+arcsin(b)*t1*t2+arcsin(b)*t2*t3-arcsin(b)*t3^2-arcsin(c)*t1^2+arcsin(c)*t1*t3-arcsin(c)*t2^2+arcsin(c)*t2*t3)/(t1^2-t1*t2-t1*t3+t2^2-t2*t3+t3^2), w = 1/2*(2*t1*arcsin(a)-arcsin(a)*t2-t3*arcsin(a)-t1*arcsin(b)+2*t2*arcsin(b)-t3*arcsin(b)-t1*arcsin(c)-t2*arcsin(c)+2*t3*arcsin(c))/(t1^2-t1*t2-t1*t3+t2^2-t2*t3+t3^2)}

 

otat := proc(a::`=`, b::list)

     local q;

     q := isolate(a, y);

seq(eval(q, b[i]), i=1..nops(b));   # returns values of  y  for all values of  x  in the list  b    

end proc:

 

Example:

otat(x-y = 1, [x = 10, x = 11, x=14]);

                  y = 9, y = 10, y = 13

 

Addition:  The line  seq(eval(q, b[i]), i=1..nops(b));   can be written shorter  eval~(q, b)[];   with the same output

Boundary problems can rarely be solved symbolically. And your task even has  a parameter K. Such problems are solved numerically for a particular value of the parameter:

K:=1:

Eq := diff(y(x), x, x) = -(x^2+1)*y(x)+K;

sol:=dsolve({Eq, y(-1) = 0, y(1) = 0}, y(x),numeric);

plots[odeplot](sol,[x,y(x)], x=-1..1, color=red, thickness=2);

                         

Here are another 6 ways (from the shortest to the longest) for the same list  L:=[7, 9, 13, evalf(Pi), a, b]:

L^~2;

`^`~(L,2);

map(`^`,L,2);

[seq(t^2, t=L)];

[L[i]^2 $ i=1..nops(L)];

[seq(L[i]^2, i=1..nops(L))];

restart:

with(plots):

f:=2*x:

g:=x^2: 

h:=unapply(piecewise( 0<=x and x<= 5, f, 5<x and x <= 10, g ), x):

A:=[1,2,8]:

h_table_A:=map(h,A);

                                         h_table_A := [2, 4, 64]

 

Addition: another way (without  unapply)

restart:

with(plots):

f:=x->2*x:

g:=x->x^2:

h:=x->piecewise( 0<=x and x<= 5, f(x), 5<x and x <= 10, g(x) ) :

A:=[1,2,8]:

h_table_A:=map(h,A);

Or:

ans:=solve({alpha = (1/2)*lambda*alpha*Pi, beta = (1/2)*lambda*beta*Pi}, lambda);

assign(ans);

lambda^6,  lambda^8;

                    

 

 

local Prime:

Prime:= proc (a, b)

local i, p, r;

p := {};

r :={} ;

for i from a to b do

   if isprime(i) then p := p union {i} ;

     if type(sqrt(p[-1]-1), integer) then r := r union {p[-1]} end if; end if;

end do;

p, r;

end proc:

 

Your example:

Prime(1, 10);

                       {2, 3, 5, 7}, {2, 5}

 

Another example:

Prime(1, 100);

   {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97}, {2, 5, 17, 37}

I guess that you are interested only real solution:

RealDomain[solve](convert({0.001=x*exp(0.6/(n*0.026)), 0.01=x*exp(0.68/(n*0.026))}, fraction),{x,n});

evalf(%);

 

 

n[1] := 1.5:  n[2] := 1:

sin(theta[g]):='n[2]'/'n[1]' = cat(convert(n[2], symbol)/convert(n[1], symbol), `=`, `0`, n[2]/n[1]);

                                

 

 

Also, the initial value for  P  should be   instead of  1.

 

I think it is more natural to use a formula instead of loops, for example as in Wiki

restart;

f:=x->2^x:

M:={-2,-1,0,1,2}: n:=nops(M):

L:=(i,x)->normal(mul((x-j)/(M[i]-j), j=M minus {M[i]})):

P:=add(f(M[i])*L(i,x), i=1..n);

plot([f(x), P], x=-2..2, color=[red,blue]);

 

 

 

We see that the approximation is very good (the graphics are almost identical).

You can prevent the calculation of  ln(1.5)  just treating  1.5  as a symbol:

diff(`1.5`^x,x);

                   

y:=sin(x):  y1:=x*sin(x):

maximize(y, x=0..Pi);

evalf(maximize(y1, x=0..Pi));

Optimization[Maximize](y1, x=0..Pi);

                                             1

                                   1.819705741

        [1.81970574115965, [x = 2.02875783126017]]

First 203 204 205 206 207 208 209 Last Page 205 of 292