Kitonum

21530 Reputation

26 Badges

17 years, 94 days

MaplePrimes Activity


These are answers submitted by Kitonum


 

restart

"P(t):=(r*Q[inf])/(2+2 cosh(b-r*t));"

proc (t) options operator, arrow, function_assign; r*Q[inf]/(2+2*cosh(b-r*t)) end proc

(1)

"Q(t):=(∫)[0]^(t)P(t) ⅆt assuming real;"

proc (t) options operator, arrow, function_assign; `assuming`([int(P(t), t = 0 .. t)], [real]) end proc

(2)

value(Q(t))

(1/2)*Q[inf]*tanh((1/2)*b)-(1/2)*Q[inf]*tanh(-(1/2)*t*r+(1/2)*b)

(3)

 


 

Download Hubbert-new.mw

Maybe the following is what you want:


 

restart;
v := 145000;
thetavn := (1/6)*Pi;
omegac := .1;
x:=omegac*t;
s := cos(2*thetabn)*x+2*sin(thetabn)^2*sin(x);
plots:-implicitplot(s = 0, t = -200 .. 200, thetabn = 43*Pi*(1/180) .. 88*Pi*(1/180), tickmarks = ["decimalticks","piticks"], gridrefine = 4, size = [800, 600]);

145000

 

(1/6)*Pi

 

.1

 

.1*t

 

.1*cos(2*thetabn)*t+2*sin(thetabn)^2*sin(.1*t)

 

 

 


 

Download plot.mw

Edit.

I fixed only 1 line:

GAUSSIAN_new.mw

When calculating the derivative of a function at a point, it is better to use the differentiation operator  D  than  eval  command (simpler and more compact syntax). For example:

eval(diff(x^2,x), x=2.5);
D(x->x^2)(2.5);
                                                 
5.0
                                                 5.0


In your example, you are trying to differentiate the function at points where it is not defined. See:

restart;
y := x-> (1-Heaviside(x-0.10e-1))*(cos(9.0218219*x)-.99533285*sin(9.0218219*x)-.99999991*cosh(9.0218219*x)+.99533285*sinh(9.0218219*x))+(Heaviside(x-0.10e-1)-Heaviside(x-0.418e-1))*(.24369100*cos(7.7520047*x)-.36109859*sin(7.7520047*x)-.23739778*cosh(7.7520047*x)+.19615343*sinh(7.7520047*x))+Heaviside(x-0.418e-1)*(.95680995*cos(9.0218219*x)-.80884870*sin(9.0218219*x)-1.0381918*cosh(9.0218219*x)+1.1704059*sinh(9.0218219*x)):
convert(y(x), piecewise);
y(0.418e-1);
y(0.1e-1);

   

 

This bug occurs when using the palette in 2d math input. Instead, enter a vector or a matrix using angle brackets directly from the keyboard. It's much faster:

 

 

We can immediately (without even using  combinat  package) obtain all such sums for any (the list  L ) if we first construct the corresponding generating function (the polynom  P ).

Example:

n:=5:
P:=collect(expand(mul(x+~[a||(0..n-1)])), x);
L:=[seq(coeff(P,x,n-k), k=1..n)];

   

 

I guess that you are looking for real roots  (x1, y1) , and  t, b, n  are parameters. Your system has the form  {eq1, eq2} = {f(x1)=f(y1), g(x1)=g(y1)}  in which  f = x->t/(x-1)/x^2-b*n/6/x^2*x^(-n-1), g = x->t*(0.74/(x-1)/x^3-3*ln(x-1))+b/x^(n)*(1/2-0.74*n/6/x^4) . Obviously, this system always has an infinite number of solutions  (x1,y1) = (x,x) , in which x>1 . If  f  or  g  is monotonous, then there are no other solutions.

The  extrema  command allows in many cases to symbolically find local extremes of smooth multidimensional problems with smooth constraints. For the solution, the Lagrange multipliers method is used. We get a more accurate solution with less cost. Unfortunately, the exact symbolic result is quite cumbersome and its approximation is shown below:

Digits:=25:
min(extrema((x[1]-1)^2+(x[2]-1)^2+(x[3]-1)^2, x[1]*(x[2]^2+x[3]^2+1)=8, {x[1], x[2], x[3]}, 's')):
evalf(%);
evalf(s):
select(p->`and`(seq(eval(x[i], p)>=1 and eval(x[i], p)<=2, i=1..3)), %)[];
evalf[23](eval((x[1]-1)^2+(x[2]-1)^2+(x[3]-1)^2, %)); # Check

The output:
                                      0.69329028371527531623476
         {x[1] = 1.531665799394114675166437, x[2] = 1.453112437188548339089389, x[3] = 1.453112437188548339089389}
                                      0 .69329028371527531623477


From a geometrical point of view, we found the value of the objective function  (x[1]-1)^2+(x[2]-1)^2+(x[3]-1)^2  when its level surfaces  (x[1]-1)^2+(x[2]-1)^2+(x[3]-1)^2=С  (in your example these are ordinary spheres) touch the surface  x[1]*(x[2]^2+x[3]^2+1)=8  for the first time.

Addition. Since Optimization:-Minimize and extrema commands generally return local extremes (and extrema command - the critical points), it is useful to verify the result obtained using  DirectSearch:-GlobalOptima  command, which searches for the global extremum using a direct search without derivatives:

restart;
DirectSearch:-GlobalOptima((x[1]-1)^2+(x[2]-1)^2+(x[3]-1)^2, {x[1]*(x[2]^2+x[3]^2+1)>=8, seq(op([x[i]>=1,x[i]<=2]), i=1..3)});
     
[0.693290285423826, [x[1] = 1.53164167847983, x[2] = 1.45310861919799, x[3] = 1.45314455787912], 411]       

 


 

restart

a := Vector[row](1 .. 10)

Vector[row](%id = 18446745435669242694)

(1)

randomize()

for k to 10 do r := rand(1 .. 2); if r() < 1.5 then a[k] := "H" else a[k] := "T" end if end do

a

Vector[row](%id = 18446745435669242694)

(2)


 

Download CoinToss_new.mw

I don’t know how to extract the vector structures you are writing about, but just to simplify the trigonometric expression  applyrule command can help. First we apply  simplify command to your expression, and then applyrule command, and in the list we indicate the formulas that applyrule may need. The following is a simplified example of yours, in which I just replaced the names of the angles using simple indexing:

Expr:=cos(theta__a)*cos(theta__b)+sin(theta__a)*cos(phi__a)*sin(theta__b)*cos(phi__b)+sin(theta__a)*sin(phi__a)*sin(theta__b)*sin(phi__b):
# Simplification of Expr
applyrule([cos(t::anything)*cos(s::anything)+sin(t::anything)*sin(s::anything)=cos(t-s), cos(t::anything)*cos(s::anything)-sin(t::anything)*sin(s::anything)=cos(t+s), sin(t::anything)*cos(s::anything)+cos(t::anything)*sin(s::anything)=sin(t+s), sin(t::anything)*cos(s::anything)-cos(t::anything)*sin(s::anything)=sin(t-s)],simplify(Expr));

Output:       


In the code for  applyrule  I wrote down 4 well-known addition formulas for sine and cosine, but you can add formulas of multiple angles, etc.
The commands  applyop , subsindets  can also be useful for selective use.

Do not use a variable and an indexed variable with the same name, so I replaced  xi  with  xi_ :

restart;
l := -2;                             
m := 1;                             
k := sqrt(-1/(6*beta))/l;                      
w := (1/5)*alpha/(beta*l);                          
a[2] := -12*sqrt(-1/(6*beta))*alpha*m^2/(5*l*l);                   
a[0] := 0;                              
a[1] := 0;                              
F := -l*C[1]/(m*(C[1]+cosh(l*(xi_+xi[0]))-sinh(l*(xi_+xi[0]))));          
beta := -2;                              
alpha := 3;                               
C[1] := -1/1000;
xi[0] := 1;                               
xi_ := k*x-t*w;
u := a[0]+a[1]*F+a[2]*F*F;  
plot3d(u, x = -3 .. 3, t = -3 .. 3);

 

Do not use a variable and an indexed variable with the same name, so I replaced  f  with  . Also made a few more fixes. Now there are no errors:

restart

PDEtools[declare](f(x), prime = x)

` f`(x)*`will now be displayed as`*f

 

`derivatives with respect to`*x*`of functions of one variable will now be displayed with '`

(1)

H := 0; RE := 50; alpha := (1/180)*(5*3.14)

0

 

50

 

0.8722222222e-1

(2)

A[m] := unapply(-2*alpha*RE*(sum((diff(f[m-n](x), x))*f[n](x), n = 0 .. m))-(4-H)*alpha^2*(diff(f[m](x), x)), x)

proc (x) options operator, arrow; -8.722222222*(sum((diff(f[m-n](x), x))*f[n](x), n = 0 .. m))-0.3043086420e-1*(diff(f[m](x), x)) end proc

(3)

for i from 0 to 6 do A[i] := unapply(expand(subs(m = i, A[m](x))), x) end do

proc (x) options operator, arrow; -8.722222222*(diff(f[0](x), x))*f[0](x)-0.3043086420e-1*(diff(f[0](x), x)) end proc

 

proc (x) options operator, arrow; -8.722222222*(diff(f[1](x), x))*f[0](x)-8.722222222*(diff(f[0](x), x))*f[1](x)-0.3043086420e-1*(diff(f[1](x), x)) end proc

 

proc (x) options operator, arrow; -8.722222222*(diff(f[2](x), x))*f[0](x)-8.722222222*(diff(f[1](x), x))*f[1](x)-8.722222222*(diff(f[0](x), x))*f[2](x)-0.3043086420e-1*(diff(f[2](x), x)) end proc

 

proc (x) options operator, arrow; -8.722222222*(diff(f[3](x), x))*f[0](x)-8.722222222*(diff(f[2](x), x))*f[1](x)-8.722222222*(diff(f[1](x), x))*f[2](x)-8.722222222*(diff(f[0](x), x))*f[3](x)-0.3043086420e-1*(diff(f[3](x), x)) end proc

 

proc (x) options operator, arrow; -8.722222222*(diff(f[4](x), x))*f[0](x)-8.722222222*(diff(f[3](x), x))*f[1](x)-8.722222222*(diff(f[2](x), x))*f[2](x)-8.722222222*(diff(f[1](x), x))*f[3](x)-8.722222222*(diff(f[0](x), x))*f[4](x)-0.3043086420e-1*(diff(f[4](x), x)) end proc

 

proc (x) options operator, arrow; -8.722222222*(diff(f[5](x), x))*f[0](x)-8.722222222*(diff(f[4](x), x))*f[1](x)-8.722222222*(diff(f[3](x), x))*f[2](x)-8.722222222*(diff(f[2](x), x))*f[3](x)-8.722222222*(diff(f[1](x), x))*f[4](x)-8.722222222*(diff(f[0](x), x))*f[5](x)-0.3043086420e-1*(diff(f[5](x), x)) end proc

 

proc (x) options operator, arrow; -8.722222222*(diff(f[6](x), x))*f[0](x)-8.722222222*(diff(f[5](x), x))*f[1](x)-8.722222222*(diff(f[4](x), x))*f[2](x)-8.722222222*(diff(f[3](x), x))*f[3](x)-8.722222222*(diff(f[2](x), x))*f[4](x)-8.722222222*(diff(f[1](x), x))*f[5](x)-8.722222222*(diff(f[0](x), x))*f[6](x)-0.3043086420e-1*(diff(f[6](x), x)) end proc

(4)

"f[0](x):=(a*x^(2))/(2)+1;"

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

(5)

for m from 0 to 5 do f[m+1] := unapply(simplify(int(int(int(A[m](x), x), x), x)), x) end do

proc (x) options operator, arrow; -0.3634259259e-1*a^2*x^6-.3646938787*a*x^4 end proc

 

proc (x) options operator, arrow; 0.1761045381e-2*a^3*x^10+0.3408151129e-1*a^2*x^8+.1064013001*a*x^6 end proc

 

proc (x) options operator, arrow; -0.7384725559e-4*a^4*x^14-0.2118566073e-2*a^3*x^12-0.1491518225e-1*a^2*x^10-0.1663024406e-1*a*x^8 end proc

 

proc (x) options operator, arrow; a*x^10*(0.2876753716e-5*a^4*x^8+0.1095453285e-3*a^3*x^6+0.1240269629e-2*a^2*x^4+0.4102500165e-2*a*x^2+0.1617319522e-2) end proc

 

proc (x) options operator, arrow; -0.1070986563e-6*a^6*x^22-0.5086533018e-5*a^5*x^20-0.8017885754e-4*a^4*x^18-0.4712189945e-3*a^3*x^16-0.7979893843e-3*a^2*x^14-0.1072411871e-3*a*x^12 end proc

 

proc (x) options operator, arrow; a*x^14*(0.2200899762e-6*a^5*x^10+0.4465825411e-5*a^4*x^8+0.3857331795e-4*a^3*x^6+0.1305645586e-3*a^2*x^4+0.1167941967e-3*a*x^2+0.5157389599e-5+0.3866579693e-8*a^6*x^12) end proc

(6)

F := unapply(add(f[r](x), r = 0 .. 5), x)

proc (x) options operator, arrow; (1/2)*a*x^2+1-0.3634259259e-1*a^2*x^6-.3646938787*a*x^4+0.1761045381e-2*a^3*x^10+0.3408151129e-1*a^2*x^8+.1064013001*a*x^6-0.7384725559e-4*a^4*x^14-0.2118566073e-2*a^3*x^12-0.1491518225e-1*a^2*x^10-0.1663024406e-1*a*x^8+a*x^10*(0.2876753716e-5*a^4*x^8+0.1095453285e-3*a^3*x^6+0.1240269629e-2*a^2*x^4+0.4102500165e-2*a*x^2+0.1617319522e-2)-0.1070986563e-6*a^6*x^22-0.5086533018e-5*a^5*x^20-0.8017885754e-4*a^4*x^18-0.4712189945e-3*a^3*x^16-0.7979893843e-3*a^2*x^14-0.1072411871e-3*a*x^12 end proc

(7)

e1 := subs(x = 1, F(x)) = 0

.2249699361*a+1-0.1797425293e-1*a^2-0.828739687e-3*a^3-0.1540261131e-3*a^4+a*(0.2876753716e-5*a^4+0.1095453285e-3*a^3+0.1240269629e-2*a^2+0.4102500165e-2*a+0.1617319522e-2)-0.1070986563e-6*a^6-0.5086533018e-5*a^5 = 0

(8)

s := {e1}; s := evalf(solve(s, {a}))

{.2249699361*a+1-0.1797425293e-1*a^2-0.828739687e-3*a^3-0.1540261131e-3*a^4+a*(0.2876753716e-5*a^4+0.1095453285e-3*a^3+0.1240269629e-2*a^2+0.4102500165e-2*a+0.1617319522e-2)-0.1070986563e-6*a^6-0.5086533018e-5*a^5 = 0}

 

{a = 12.88012130}, {a = 3.801204750+16.02081577*I}, {a = -18.78808144+20.06115404*I}, {a = -3.539486758}, {a = -18.78808144-20.06115404*I}, {a = 3.801204750-16.02081577*I}

(9)

"F(x):=subs(a=-3.539486758,F(x));"NULL

-1.769743379*x^2+1-.8319047756*x^6+1.290829154*x^4-.2649461846*x^10+.4858345607*x^8-0.2158750698e-1*x^14+0.9432224648e-1*x^12-3.539486758*x^10*(0.4515063372e-3*x^8-0.4857521569e-2*x^6+0.1553805638e-1*x^4-0.1452074501e-1*x^2+0.1617319522e-2)-0.2105841952e-3*x^22+0.2825682275e-2*x^20-0.1258406727e-1*x^18+0.2089506199e-1*x^16

(10)

 

``

Download ADMTRY1_new.mw

Just use the  convert(x, float)  command or  evalf  command  for the finish result.

Use  CodeTools:-Usage  command for this. For ease of comparison, I increased the size of the array:
 

restart; FF := proc (xx::Array, nn::integer) local gg, i, j; gg := 0; for i by 3 to nn do for j from i+3 by 3 to nn do gg := gg+evalf(1/((xx[i]-xx[j])^2+(xx[i+1]-xx[j+1])^2+(xx[i+2]-xx[j+2])^2)) end do end do; return gg end proc; CodeTools:-Usage(FF(Array(1 .. 9999, [seq(i^2, i = 1 .. 9999)]), 9999))

memory used=1.75GiB, alloc change=8.00MiB, cpu time=22.66s, real time=22.12s, gc time=1.72s

 

0.1661350362e-2

(1)

NULL

restart; FF := proc (xx::Array, nn::integer) local gg, i, j; gg := add(add(1/((xx[i]-xx[j])^2+(xx[i+1]-xx[j+1])^2+(xx[i+2]-xx[j+2])^2), j = i+3 .. nn, 3), i = 1 .. nn, 3); return gg end proc; XX := Array(1 .. 9999, [seq(i^2, i = 1 .. 9999)]); CodeTools:-Usage(evalf(FF(XX, 9999)))

memory used=58.28GiB, alloc change=59.49MiB, cpu time=2.65m, real time=2.43m, gc time=71.55s

 

0.1661398690e-2

(2)

``

``


 

Download procedure_new1.mw

I think the problem can be solved in different ways. Below is an example of visualization of coin tosses. CoinToss procedure returns the result of N coin tosses in the form of a list of coordinates of the vertices of the broken line. Each segment up means the fall of one side of a coin, down - the other one. As an example, a simulation of 20 tosses of 2 independent coins is given. Animation of this is also shown.


 

restart;
CoinToss:=proc(N::posint,h:=0)
local S, r, n, t;
S[0]:=[0,h];
r:=rand(0..1);
for n from 1 to N do
t:=r();
S[n]:=[n,S[n-1][2]+(-1)^t];
od;
convert(S, list);
end proc:

A:=CoinToss(20,0.1);
B:=CoinToss(20);

[[0, .1], [1, 1.1], [2, 2.1], [3, 3.1], [4, 2.1], [5, 3.1], [6, 2.1], [7, 1.1], [8, .1], [9, 1.1], [10, .1], [11, -.9], [12, -1.9], [13, -.9], [14, .1], [15, -.9], [16, .1], [17, -.9], [18, .1], [19, -.9], [20, .1]]

 

[[0, 0], [1, -1], [2, -2], [3, -3], [4, -4], [5, -3], [6, -2], [7, -1], [8, -2], [9, -1], [10, -2], [11, -1], [12, -2], [13, -3], [14, -2], [15, -1], [16, -2], [17, -3], [18, -4], [19, -5], [20, -4]]

(1)

F:=n->plot([A[1..n+1],B[1..n+1]],color=[red,blue], scaling=constrained, thickness=3, size=[1000,400], legend=["1st coin","2nd coin"]);
F(20);

proc (n) options operator, arrow; plot([A[1 .. n+1], B[1 .. n+1]], color = [red, blue], scaling = constrained, thickness = 3, size = [1000, 400], legend = ["1st coin", "2nd coin"]) end proc

 

 

plots:-animate(plots:-display,['F'(round(k))], k=0..20, frames=100, size=[1000,400], scaling=constrained);

 

 

 


 

Download CoinToss.mw

 

First 96 97 98 99 100 101 102 Last Page 98 of 290