Kitonum

17135 Reputation

24 Badges

13 years, 18 days

MaplePrimes Activity


These are answers submitted by Kitonum

Procedure  P  returns the list of  N  pairs of such numbers  [p, q] :


 

restart;

P:=proc(N::posint)
local k, n, p, m, q, u;
uses NumberTheory;
k:=0;
for n from 1 do
p:=ithprime(n);
for m from 1 to n do
q:=ithprime(m);
if pi(p)=q-pi(q) then k:=k+1; u[k]:=[p,q]; break fi;
od;
if k=N then return convert(u,list) fi;
od;
end proc:

 

# Example of use
P(100);

[[2, 2], [13, 11], [17, 13], [29, 17], [31, 19], [43, 23], [67, 29], [71, 31], [97, 37], [107, 41], [109, 43], [131, 47], [157, 53], [181, 59], [191, 61], [223, 67], [233, 71], [239, 73], [269, 79], [281, 83], [313, 89], [359, 97], [379, 101], [383, 103], [401, 107], [409, 109], [431, 113], [503, 127], [523, 131], [569, 137], [571, 139], [619, 149], [631, 151], [659, 157], [691, 163], [719, 167], [751, 173], [787, 179], [797, 181], [857, 191], [859, 193], [881, 197], [883, 199], [971, 211], [1039, 223], [1061, 227], [1063, 229], [1091, 233], [1117, 239], [1123, 241], [1201, 251], [1231, 257], [1279, 263], [1301, 269], [1303, 271], [1361, 277], [1381, 281], [1399, 283], [1453, 293], [1549, 307], [1567, 311], [1571, 313], [1597, 317], [1693, 331], [1723, 337], [1789, 347], [1801, 349], [1831, 353], [1873, 359], [1931, 367], [1979, 373], [2003, 379], [2027, 383], [2069, 389], [2113, 397], [2137, 401], [2207, 409], [2273, 419], [2281, 421], [2347, 431], [2351, 433], [2383, 439], [2399, 443], [2441, 449], [2521, 457], [2543, 461], [2549, 463], [2579, 467], [2671, 479], [2707, 487], [2719, 491], [2777, 499], [2797, 503], [2837, 509], [2927, 521], [2939, 523], [3083, 541], [3137, 547], [3217, 557], [3257, 563]]

(1)

 


Edit.

Download P1.mw

In fact, we have a nonlinear inequality with the parameter . Maple usually cannot solve such inequality in a closed form. But it is easy to write a procedure  (named  F  below) that, for each value of the parameter , finds the corresponding range for  r . Now you can use this procedure by specifying values for c:

restart;
F:=c->solve({-r+c+1 + sqrt(r^2 - 2*r*c -r +2*c )<1, 0<r, r<1}, r):


Examples of use:

F(0.1), F(0.5), F(0.9);

             {r <= .2000000000, .1900000000 < r}, {.7500000000 < r, r < 1.}, {.9900000000 < r, r < 1.}

Using the  rand  command, we give your parameters some random values from the appropriate ranges:


 

NULL

restart;
with(DETools):
randomize():
a_1:=rand(1..5)():
b_1:=rand(2..7)():
c:=rand(1..8)():
d:=rand(0..4)():
e:=rand(0..10)():
A := a_1*c^3-b_1; B := 3*a_1*c^2-3*b_1/c; C := c*d-e;
sys := {diff(x(t), t) = y(t), diff(y(t), t) = (B*x(t)^2+C*x(t)-e)/A};
initialdataset:={seq(seq([x(0) = f, y(0) = g], f = -5 .. 5), g = -5 .. 5)}:
DEplot(sys, [x, y], t = -3 .. 3, initialdataset, x = -6 .. 6, y = -6 .. 6, colour = black, thickness = 2, style = line, linestyle = 1, axes = boxed, linecolor = red, scaling = constrained, arrows = medium);

622

 

1866/5

 

-5

 

{diff(x(t), t) = y(t), diff(y(t), t) = (3/5)*x(t)^2-(5/622)*x(t)-5/311}

 

 

 


If you want your initial parameters to take not only integers, but also fractional values in float format, then write  a_1:=rand(1...5.)() and so on. I have not set values for  f  and  g  parameters, so Maple builds not one, but a whole family of curves. Of course, you yourself can set these parameters in the same way.

Download rand.mw

Example:

A:=<1,"2"; "3","4">;
map(t->`if`(type(t,string),parse(t),t), A);

                                  

 

Edit.

 

The command  plots:-implicitplot  for plotting an implicit curve  F(x,y)=0  works by calculating the values ​​of a function of two variables  F(x,y)  on a rectangular grid  x = a .. b , y = c .. d . It is based on the property of a continuous function: if at points  A(x1,y1)  and  B(x2,y2)  the function  F(x,y)  takes values ​​of different signs, then on the segment  AB  there is a point  (x0,y0)  at which F(x0,y0)=0 . Typically, the curve  F(x,y)=0  separates the plane  R^2  into 2 regions in which  F(x,y)<0  and  F(x,y)>0  . The grid should be small enough (by default  grid=[26,26]. This can be achieved either by decreasing the ranges (as dharr does) or by reducing the grid cells (see an example below). In those rare examples where the function  F(x,y)  does not change sign, the command  plots:-implicitplot  fails even with a very small grid (example below):

Examples:


 

restart;

with(plots, implicitplot):
eqn := (1 + ln(x))/x = 0;
implicitplot(eqn, x = -10 .. 10, y = -10 .. 10, grid=[50,50]); # OK

(1+ln(x))/x = 0

 

 

# abs(x-y)=0 is equivalent to x-y=0, but for abs(x-y) there is no sign change  
implicitplot(abs(x-y)=0, x = -10 .. 10, y = -10 .. 10, grid=[100,100]); # it fails - no any plot
implicitplot(x-y, x = -10 .. 10, y = -10 .. 10); # OK

 

 

 


 

Download implicitplot.mw

 

restart;
A:=int(diff(u(x,t),x),x=-infinity..infinity,continuous);

simplify(A, {Limit(u(_X, t),_X=infinity)=0,Limit(u(_X, t),_X=-infinity)=0});

# Or

simplify(A, {Limit(u(_X, t),_X=infinity)=Limit(u(_X, t),_X=-infinity)});

                    

Of course the shortest solution would be:

restart;
A:=int(diff(u(x,t),x),x=-infinity..infinity, continuous);
simplify(A, {%});

                       

 

Edit.

 


 

restart;

eq9_13_m3 := 2*R__R*s*omega__s*L__sigma_S/(s^2*L__sigma_S^2*omega__s^2 + R__R^2);

2*R__R*s*omega__s*L__sigma_S/(s^2*L__sigma_S^2*omega__s^2+R__R^2)

(1)

aux2 := s_hat = R__R/(L__sigma_S*omega__s*s);
simplify(eq9_13_m3, {R__R/(L__sigma_S*omega__s*s)=s_hat});
numer(%)/s_hat^2/``(expand(denom(%)/s_hat^2));

 

s_hat = R__R/(L__sigma_S*omega__s*s)

 

2*s_hat/(s_hat^2+1)

 

2/(s_hat*``(1+1/s_hat^2))

(2)

 


IWe see that your desired expression is independent of s.

 

Download Q20201204_new.mw

I don't know what Maple Learn means. Use standard syntax to evaluate multiple integrals. Below is an example in which the double integral is reduced to an iterated integral and calculated in two ways:
 

restart;
plots:-inequal({y>=x^2,y<=1}, x=0..1, y=0..1); # The integration region

A:=Int(x*y^2, [y = x^2 .. 1, x = 0 .. 1]); # The first way
value(A);

B:=Int(x*y^2, [x = 0 .. sqrt(y), y = 0 .. 1]); # The second way
value(B);

 

Int(x*y^2, [y = x^2 .. 1, x = 0 .. 1])

 

1/8

 

Int(x*y^2, [x = 0 .. y^(1/2), y = 0 .. 1])

 

1/8

(1)

 


 

Download double_integral_(2).mw

If  n = 1  then you get  0  in the denominator of  c(n) , so I chose  n = 2 .. infinity . The method you use to find the convergence region is guaranteed to only give an open interval. Therefore, we must separately investigate the convergence at the ends of this interval:

 

restart;
c:=n-> 1/(n^2-1);
u:=n->c(n)*(x-2)^n; # The function of the general term of the series
S:=Sum(u(n), n=2..infinity);
limit(abs(u(n+1)/u(n)), n=infinity); # We use the ratio test (d'Alembert test) for a series of absolute values
solve(%<1); # We get the (open) convergence interval
x1,x2:=op(op(1,%)),op(op(2,%)); # The left and right ends of the convergence interval 

value(eval(S, x=x1)); # The series converges at the left end
value(eval(S, x=x2)); # The series converges at the right end

                                


Edit.

We will denote  U[n]=u(x[n])  for all  n=1..N


 

restart;
h:=0.01: r:=0.02: N:=10: f:=y->y^5: K:=(x,y)->sin(x)*y^5:
assign(seq(x[n]=sin(h*n), n=1..N));
assign(seq(y[m]=cos(r*m), m=1..N));
Sys:={seq(add(K(x[n],y[m])*U[n],n=1..N)=f(y[m]), m=1..N)};
solve(Sys);
assign(%);
plot([seq([x[n],U[n]], n=1..N)]);

{0.9041977446e-2*U[1]+0.1808214671e-1*U[2]+0.2711870069e-1*U[3]+0.3614983446e-1*U[4]+0.4517374631e-1*U[5]+0.5418863892e-1*U[6]+0.6319272033e-1*U[7]+0.7218420503e-1*U[8]+0.8116131509e-1*U[9]+0.9012228112e-1*U[10] = .9042278847, 0.9217561686e-2*U[1]+0.1843328007e-1*U[2]+0.2764531298e-1*U[3]+0.3685182042e-1*U[4]+0.4605096570e-1*U[5]+0.5524091660e-1*U[6]+0.6441984635e-1*U[7]+0.7358593478e-1*U[8]+0.8273736944e-1*U[9]+0.9187234656e-1*U[10] = .9217868940, 0.9377158775e-2*U[1]+0.1875244234e-1*U[2]+0.2812397660e-1*U[3]+0.3748988973e-1*U[4]+0.4684831323e-1*U[5]+0.5619738315e-1*U[6]+0.6553524110e-1*U[7]+0.7486003540e-1*U[8]+0.8416992218e-1*U[9]+0.9346306649e-1*U[10] = .9377471349, 0.9519961947e-2*U[1]+0.1903802012e-1*U[2]+0.2855227191e-1*U[3]+0.3806081695e-1*U[4]+0.4756175830e-1*U[5]+0.5705320364e-1*U[6]+0.6653326625e-1*U[7]+0.7600006627e-1*U[8]+0.8545173175e-1*U[9]+0.9488639979e-1*U[10] = .9520279281, 0.9645244800e-2*U[1]+0.1928856077e-1*U[2]+0.2892802026e-1*U[3]+0.3856169791e-1*U[4]+0.4818767181e-1*U[5]+0.5780402472e-1*U[6]+0.6740884511e-1*U[7]+0.7700022837e-1*U[8]+0.8657627792e-1*U[9]+0.9613510634e-1*U[10] = .9645566310, 0.9752366583e-2*U[1]+0.1950278292e-1*U[2]+0.2924929994e-1*U[3]+0.3898997090e-1*U[4]+0.4872285256e-1*U[5]+0.5844600637e-1*U[6]+0.6815749959e-1*U[7]+0.7785540643e-1*U[8]+0.8753780928e-1*U[9]+0.9720279972e-1*U[10] = .9752691664, 0.9840776929e-2*U[1]+0.1967958593e-1*U[2]+0.2951446027e-1*U[3]+0.3934343555e-1*U[4]+0.4916455091e-1*U[5]+0.5897585024e-1*U[6]+0.6877538326e-1*U[7]+0.7856120675e-1*U[8]+0.8833138568e-1*U[9]+0.9808399436e-1*U[10] = .9841104957, 0.9910019883e-2*U[1]+0.1981805799e-1*U[2]+0.2972213375e-1*U[3]+0.3962026895e-1*U[4]+0.4951048892e-1*U[5]+0.5939082379e-1*U[6]+0.6925930955e-1*U[7]+0.7911398932e-1*U[8]+0.8895291446e-1*U[9]+0.9877414571e-1*U[10] = .9910350219, 0.9959737274e-2*U[1]+0.1991748283e-1*U[2]+0.2987124616e-1*U[3]+0.3981903912e-1*U[4]+0.4975887715e-1*U[5]+0.5968878048e-1*U[6]+0.6960677527e-1*U[7]+0.7951089479e-1*U[8]+0.8939918065e-1*U[9]+0.9926968385e-1*U[10] = .9960069267, 0.9989671343e-2*U[1]+0.1997734498e-1*U[2]+0.2996102443e-1*U[3]+0.3993871556e-1*U[4]+0.4990842785e-1*U[5]+0.5986817559e-1*U[6]+0.6981597898e-1*U[7]+0.7974986542e-1*U[8]+0.8966787059e-1*U[9]+0.9956803967e-1*U[10] = .9990004334}

 

{U[1] = 43.01571534, U[2] = 2.129649377, U[3] = -.6317112735, U[4] = .3228390822, U[5] = -1.905151633, U[6] = 2.229722710, U[7] = 0.7779033052e-2, U[8] = 1.952960982, U[9] = 2.850101312, U[10] = .8287345356}

 

 

 


 

Download Sys.mw

Of course, the indefinite integral is calculated up to an additive constant. Here's a way to get the desired result.

NULL

restart

randomize

NULL

v := RandomTools:-Generate(choose({m, t, x, z}))

z

(1)

NULL

f := RandomTools:-Generate(polynom(integer(range = -10 .. 10, exclude = {0}), v, degree = 2))

z^2+3*z-1

(2)

fp := g(v)^4

g(z)^4

(3)

fd := diff(g(v), v)

diff(g(z), z)

(4)

NULL

fs := fd*g(v)^5

(diff(g(z), z))*g(z)^5

(5)

NULL

NULL

PE := Int(fs, v)

Int((diff(g(z), z))*g(z)^5, z)

(6)

PR := int(fs, v)

(1/6)*g(z)^6

(7)

subs(g(v)=f, PR);

(1/6)*(z^2+3*z-1)^6

(8)

``


 

Download QuestionInt_new.mw

You can use  combinat:-permute  for this:

restart;
S:=[1,2,3]:
combinat:-permute(map(`$`,S, 2), 2);

                   [[1, 1], [1, 2], [1, 3], [2, 1], [2, 2], [2, 3], [3, 1], [3, 2], [3, 3]]


or a little shorter

combinat:-permute(`$`~(S, 2), 2);


Edit. If you use  the  Iterator  package then the  CartesianProduct  command can be used.


 

restart;
V1 := Vector(8, [1, 2, 2, 1, 3, A, B, 1/(A + B)^2]);
V2 := Vector(8, [1, 2, 2, 1, 3, A, B, 1/(A^2 + 2*A*B + B^2)]);
V2:=simplify(V2);
LinearAlgebra:-Equal(V1[6 .. 8], V2[6 .. 8]);

Vector(8, {(1) = 1, (2) = 2, (3) = 2, (4) = 1, (5) = 3, (6) = A, (7) = B, (8) = 1/(A+B)^2})

 

Vector(8, {(1) = 1, (2) = 2, (3) = 2, (4) = 1, (5) = 3, (6) = A, (7) = B, (8) = 1/(A^2+2*A*B+B^2)})

 

Vector[column](%id = 18446746221073234750)

 

true

(1)

 


 

Download simplify.mw


 

restart

NULL

"f(x):=18*log10(x);"

proc (x) options operator, arrow, function_assign; 18*log10(x) end proc

(1)

"g(x):=1/(2) x^(3)-8*x^(2)+(69/(2))^()*x-27;"

proc (x) options operator, arrow, function_assign; (1/2)*x^3-8*x^2+(69/2)*x-27 end proc

(2)

plot([f(x), g(x)], x = -1 .. 11, -30 .. 25, size = [800, 500])

 

NULL

sort([RootFinding:-Analytic(f(x)-g(x), re = 0 .. 12, im = -1 .. 1)])

[0.372146548487319e-1, 1.00000000000000, 4.50616492819266, 10.0000000000000]

(3)

``


 

Download intersect_curve_new.mw

restart;
f:=unapply(int(diff(Y1(x), x), x)+C1, x);
solve({Y1(0) = f(0)}, {C1});

                                    f := x -> Y1(x) + C1
                                           {C1 = 0}

First 15 16 17 18 19 20 21 Last Page 17 of 259