Kitonum

21435 Reputation

26 Badges

17 years, 24 days

MaplePrimes Activity


These are answers submitted by Kitonum

You are probably interested in calculating the area of the region bounded by a red closed curve below (this is not an ellipse of course).
It's easy to do numerically:


 

restart;
A:=plots:-implicitplot(y^2 = x^3 - 3*x - 1, x=-2..0, y=-1..1):
B:=plot(x^3 - 3*x - 1, x=-2..0,-1..1):
plots:-display(A,B, color=[red,blue]);
R:=[fsolve(x^3 - 3*x - 1, x=-2..0)];
2*int(sqrt(x^3 - 3*x - 1), x=R[1]..R[2], numeric);

 

[-1.532088886, -.3472963553]

 

1.848519838

(1)

 


 

Download int.mw

 

To solve your example, it is enough to know the simplest definitions related to the joint distribution of two random variables  X  and  Y . Let's introduce the notations:  f__XY  is the density function of the joint distribution of  X  and  Yf__X  is the density function of  X ,  f__Y  is the density function of  Y ,  f__X_Y  is the density function of the conditional distribution of  X  given  ,   f__Y_X  is the density function of the conditional distribution of  Y  given  .


 

restart;
f__XY:=(x,y)->piecewise(x>0 and x<y and y<1, 2, 0);
f__X:=x->int(f__XY(x,y), y=0..1);
f__Y:=y->int(f__XY(x,y), x=0..1);
f__X_Y:=(x,y)->f__XY(x,y)/f__Y(y);
f__X_Y(x,y); # The answer to question 1
f__X_Y(0.3,0.7);  # Example of use
f__Y_X:=(x,y)->f__XY(x,y)/f__X(x);

f__XY := proc (x, y) options operator, arrow; piecewise(0 < x and x < y and y < 1, 2, 0) end proc

 

f__X := proc (x) options operator, arrow; int(f__XY(x, y), y = 0 .. 1) end proc

 

f__Y := proc (y) options operator, arrow; int(f__XY(x, y), x = 0 .. 1) end proc

 

f__X_Y := proc (x, y) options operator, arrow; f__XY(x, y)/f__Y(y) end proc

 

piecewise(0 < x and x < y and y < 1, 2, 0)/(2*y*piecewise(y < 0, 0, 1)-2*piecewise(y < 1, 0, 1)*y)

 

1.428571429

 

proc (x, y) options operator, arrow; f__XY(x, y)/f__X(x) end proc

(1)

int(f__X_Y(x,0.7), x=0.5..1);  # The answer to question 2

.2857142857

(2)

 


 

Download XY.mw

You have chosen too narrow a range of values for the contours. If we increase it, we get more interesting pictures, for example:

restart;
randomize():
a, b, c_3, c_4, A_5:='rand(-5..5)'()$5;
A := a*(A_5)^3-b; B := 3*a*(A_5)^2-3*b/(A_5); C := (c_3)*(A_5)-(c_4);
u:=3*y^2+2*x^3*B/A+3*x^2*C/A;
plots:-contourplot(u, x=-2.25..2.25, y=-2.25..2.25, axes=boxed, contours=[seq(-10..10,1)],grid=[200,200], coloring=["Blue","Red"], size=[500,500]);

                                

Below are 2 solutions to the problem. In the first one, we randomly set all the necessary parameters. In the second one, we use  Explore  command for this:


 

``

restart;
randomize():
a, b, c_3, c_4, A_5:='rand(-5..5)'()$5;
A := a*(A_5)^3-b; B := 3*a*(A_5)^2-3*b/(A_5); C := (c_3)*(A_5)-(c_4);
u:=3*y^2+2*x^3*B/A+3*x^2*C/A;

-5, 4, -4, 5, 2

 

-44

 

-66

 

-13

 

3*y^2+3*x^3+(39/44)*x^2

(1)

plots:-contourplot(u, x=-2.25..2.25, y=-2.25..2.25, axes=boxed, contours=[seq(-2.5..-1.3,0.1)], grid=[80,80], coloring=["Blue","Red"], size=[500,500]);

 

 

restart;
P:=[a, b, c_3, c_4, A_5]:
A := a*(A_5)^3-b; B := 3*a*(A_5)^2-3*b/(A_5); C := (c_3)*(A_5)-(c_4);
u:=3*y^2+2*x^3*B/A+3*x^2*C/A;
Explore(plots:-contourplot(u, x=-2.25..2.25, y=-2.25..2.25, axes=boxed, contours=[seq(-2.5..-1.3,0.1)], grid=[80,80], coloring=["Blue","Red"], size=[500,500]), parameters= (P=~ -5..5));

A_5^3*a-b

 

3*a*A_5^2-3*b/A_5

 

A_5*c_3-c_4

 

3*y^2+2*x^3*(3*a*A_5^2-3*b/A_5)/(A_5^3*a-b)+3*x^2*(A_5*c_3-c_4)/(A_5^3*a-b)

(2)

``


MaplePrime did not display the result of the last command. See the attached file for this.

 

Download contour_new.mw


 

restart;

eq9_30 := T__e_n = 2*(s/s_hat) / ((1+r*s/s_hat)^2+(s/s_hat)^2);

T__e_n = 2*s/(s_hat*((1+r*s/s_hat)^2+s^2/s_hat^2))

(1)

eq9_31 := solve(diff(rhs(eq9_30), s)=0,s);

s_hat/(r^2+1)^(1/2), -s_hat/(r^2+1)^(1/2)

(2)

eq9_32a :=  T__e_np = simplify(subs(s=eq9_31[1] , rhs(eq9_30))) assuming r::real;

T__e_np = (r^2+1)^(1/2)/(r^2+(r^2+1)^(1/2)*r+1)

(3)

Desired := T__e_np = 1/(sqrt(r^2 + 1) + r);

T__e_np = 1/((r^2+1)^(1/2)+r)

(4)

simplify(algsubs(r^2+1=t^2,eq9_32a)) assuming t>0;

T__e_np = 1/(r+t)

(5)

subs(t=sqrt(r^2+1), %);

T__e_np = 1/((r^2+1)^(1/2)+r)

(6)

 


Addition - another way:

T__e_np := sqrt(r^2+1)/(r^2+sqrt(r^2+1)*r+1);
numer(T__e_np)*sqrt(r^2+1)/expand(denom(T__e_np)*sqrt(r^2+1));
simplify(%);

                      

 

Download Q20201208_new.mw

Maple simply doesn't know what it should return if  k  is a symbol. Therefore, we must provide for this in the body of the procedure. Below is a possible solution to the problem:
 

restart;

divide5_new := proc(g, k)
  local x, r;
  if type(k,numeric) then if k < 3 then return 0 else return unapply((1/5)*g(i, x), i, x) fi;
else return piecewise(k<3,0,unapply((1/5)*g(i, x),i,x)) fi;
end proc:

# Examples

f :=  (i,x) -> x^2+i :

f1 := divide5_new(f, i);
f2 := divide5_new(f, 2);
f3 := divide5_new(f, 4);

piecewise(i < 3, 0, proc (i, x) options operator, arrow; (1/5)*x^2+(1/5)*i end proc)

 

0

 

proc (i, x) options operator, arrow; (1/5)*x^2+(1/5)*i end proc

(1)

 


 

Download divide5_new.mw

  BrettKnoss I have simplified  Carl's code a bit. I think this will make it clearer for you. To study the convergence at the ends of the convergence interval, we used the n-th term test: If , then the series diverges  (from wiki)  . Since the results are not 0, the series diverges at both ends.

restart;
f:= (x-1)/(x+2);
s:= convert(f, FormalPowerSeries);
c:= unapply(op([2,1],s), k);
L:= limit(abs(c(k+1)/c(k)), k= infinity);
solve(L < 1, x);
``;
# Investigation on the ends
RealDomain:-limit(eval(c(k),x=-2),k=infinity); 
RealDomain:-limit(simplify(eval(c(k),x=2)),k=infinity);

                       

 

 

Download ic.mw

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

First 45 46 47 48 49 50 51 Last Page 47 of 289