vv

14242 Reputation

20 Badges

10 years, 344 days

MaplePrimes Activity


These are answers submitted by vv

You should use lists instead of sets, otherwise the order of the elements is unpredictable.

f:=[1,2,3,4]:
h:=[1,2,4,5]:
select(i->f[i]=h[i], [seq(1..4)]);

maybe:

f[%];

or

select(i->i=h[i], f);

You must have a mistake somewhere because your analytic solutions satisfy the system only when C=0 or J=0, i.e. the trivial case.

pdesys := {diff(C(x,t),t)-phi*epsilon*J(x,t)*C(x,t), diff(J(x,t),x)-epsilon*J(x,t)*C(x,t)}:
Jsol := (x,t)-> J__0*exp(J__0*epsilon*phi*t)/(exp(J__0*epsilon*phi*t)+exp(C__0*epsilon*phi*x)-1):
Csol := (x,t) -> C__0*exp(C__0^epsilon*phi*x)/(exp(J__0*epsilon*phi*t)+exp(C__0*epsilon*phi*x)-1):
subs({J=Jsol,C=Csol},  pdesys): simplify(%);

X := -0.6356560300e-1*ln(Y+200.+17.54410643*Y^(2/3)+102.5985568*Y^(1/3))/a+
         0.6356560300e-1*ln(Y+200.)/a-.2201977080*arctan(.1974510146*Y^(1/3)
         -.5773502693)/a+.1096187623/a:

vx := <1500, 1340.00, 1135.00, 982.00, 884.15, 704.72, 520.00, 287.00, 70.00, 0.>:
vy := <0., 4.28, 7.77, 7.30, 9.00, 13.00, 25.85, 28.91, 38.48, 50.00>:

Statistics:-Fit(X, vy, vx, Y,output=parametervalues);
    [a = 0.115891288738057e-3]

f:=Statistics:-Fit(X, vy, vx, Y):
p1:=plot(vx,vy,style=point):  p2:=plot( [f,Y,Y=0..50],color=red):
plots:-display(p1,p2);



In Maple 2016.1 (64 bit)  I obtain the correct answer:

[12, [x = 1, y = 2]]

This is normal because verify does a kind of syntactic check (extended by some options).

I am a bit surprised that the probabilistic check testeq also fails.

It would have been nice if j:=16117;N:=3;  were provided in the code.
Even nicer if the unknowns had reasonable names (for an outsider).
So, with a simple subs your system is:

sysX := [x6,
 x20-x23,
 x21-0.3505865589e-5,
 x22-0.5304364281e-5,
 x5-x14,
 x24*(-0.3915554290e-1*x12-0.1903748329e-1*x6+0.8260795999e-1)-3.876387504,
 x24*(-0.3860115660e-1*x12-0.1876793978e-1*x6+0.7836678184e-1)-2.040147478*10^6*x23,
 x24*(-0.1876794098e-1*x12-0.9892449327e-2*x6+0.3810204607e-1)-2.040147478*10^6*x9,
 x25*(-0.3915554290e-1*x13-0.1903748329e-1*x7+0.8260795999e-1)-3.876387504,
 x26*(-0.3915554290e-1*x14-0.1903748329e-1*x8+0.8260795999e-1)-3.876387504,
 x1-.9724029753*x6-x12,
 x10-.9724029753*x7-x13,
 x11-.9724029753*x8-x14,
 x3-x12+x10,
 x3-.25*x18-.25*x16,
 x4-x13+x11,
 x25*(-0.3860115660e-1*x13-0.1876793978e-1*x7+0.7836678184e-1)+2.040147478*10^6*x20-7.152482840,
 x25*(-0.1876794098e-1*x13-0.9892449327e-2*x7+0.3810204607e-1)+1.983845478*10^6*x20-5.221405977,
 x26*(-0.3860115660e-1*x14-0.1876793978e-1*x8+0.7836678184e-1)+2.040147478*10^6*x21-10.82168541,
 x26*(-0.1876794098e-1*x14-0.9892449327e-2*x8+0.3810204607e-1)+1.983845478*10^6*x21-8.751240594,
 x15-0.7006679273e-1*x12-.2484955248*x6-1.002451672,
 x16-0.7006679273e-1*x13-.2484955248*x7-1.002451672,
 x17-0.7006679273e-1*x14-.2484955248*x8-1.002451672,
 x18-0.7006679273e-1*x12+.1803623678*x6-1.002451672,
 x19-0.7006679273e-1*x13+.1803623678*x7-1.002451672,
 x2-0.7006679273e-1*x14+.1803623678*x8-1.002451672]:

To solve it with fsolve, Digits must be increased (the system seems to be ill-conditioned).

Digits:=20:
fsolve(sysX,indets(sysX));
{x1 = 1.0112518604279113366, x10 = .50079130545073703755, x11 = -0.42400685353282833597e-1, x12 = 1.0112518604279113366, x13 = .87282458350900007716, x14 = .26867164104671288780, x15 = 1.0733068465024293527, x16 = .96853537340626784353, x17 = .94178275674200828459, x18 = 1.0733068465024293527, x19 = 1.1326128306517202960, x2 = 1.0789746676418324408, x20 = 0.17374637467959646823e-5, x21 = 0.35058655890000000000e-5, x22 = 0.53043642810000000000e-5, x23 = 0.17374637467959646823e-5, x24 = 90.123721949337849443, x25 = 69.574517142133632373, x26 = 49.584072102670758903, x3 = .51046055497717429906, x4 = .91522526886228291076, x5 = .26867164104671288780, x6 = 0., x7 = -.38259166982030833324, x8 = -.31990063204406129237, x9 = 8.4475741104335797627*10^(-7)}

Note that being "almost" linear, using solve instead of fsolve is not a bad idea.

 

 

Q:=proc(a,b,c,d,x,y) local t;
   x^2-x+y^2-5*y - evalf(Int(5*exp(sin(t+x)),t=0..b)) end:

Optimization:-NLPSolve('Q(1, Pi/2, 5, 2, x,y)', x= 0 .. 5, y = 0 .. 4);
       [-25.8258678143110600, [x = .750451348084492, y = 2.50000000432642]]



 

In Maple 2016,

N  := 2:
F  := add(P||k * x^k, k=0..N):
G := [seq(P||k=-1.0 .. 1.0, k=0..N)]:
Explore(plot(F, x=0..1), parameters=G)
;

works as expected. What version do you use?

Also,

F := a*x:
Explore(plot(F, x=0..1), parameters = [a=0..1]);

works, after replacing (of course) F = a*x with F:= a*x.

But note that you should use [a=0.0 .. 1.0]  otherwise a will take only the two integer values 0 and 1.

In principle,

hyp:=a>0,b>0,c>0,d>0,e>0,f>0,g>0,a>c,a>e,a>g:
is(expr>0) assuming hyp;

should work. But practically, it works only if expr is simple enough.

Unfortunately,

is(exp(a-1)-exp(g-1)>0) assuming hyp;   # ==> FAIL
is((a-1)^3-(g-1)^3>0) assuming hyp;      # ==> FAIL

is(a+b>e) assuming hyp;  # true    (finally!)

 

 

 

 

You have two issues here.

1. Your definition
f := unapply(rsolve({f(0) = 0, f(1) = 1, f(n) = f(n-1)+n*f(n-2)}, f(n)), n);
is recursive.

2. Maple cannot find a closed form for f(n).

A numeric summation is possible:

g:=rsolve({f(0) = 0, f(1) = 1, f(n) = f(n-1)+n*f(n-2)}, f(n), 'makeproc');
evalf(Sum('g(n)/factorial(n)', n = 0 .. infinity));
    2.929012921


 

A:=Matrix(20,2, (i,j)->`if`(j=1,i,(i-10)^2)):
B:=Matrix(20,2, (i,j)->`if`(j=1,i,0.75*(i-10)^2)):

PLOT(CURVES(A,LEGEND("1st"),COLOR(RGB,1,0,0)),
          CURVES(B,LEGEND("2nd"),COLOR(RGB,0,1,0))    );

or

pA:=PLOT(CURVES(A,LEGEND("1st"),COLOR(RGB,1,0,0))):
pB:=PLOT(CURVES(B,LEGEND("2nd"),COLOR(RGB,0,1,0))):
plots:-display(pA,pB);

Implicitplot algorithm needs sign changes in order to determine the points.
Mathematically, in this case, all the points of the surface (x+y+z)^2=0 are singular.

Of course, you can use the equivalent implicitplot3d(x+y+z=0, x=-5..5,y=-5..5,z=-5..5) to obtain the plane.

Each of n dancers placed at random positions on the dance-floor randomly chooses one "friend" and one "enemy".
    At each step, every dancer:
        - moves 0.5% closer to the centre of the floor
        - takes a large step towards his friend
        - and a small step away from his enemy.
    At random intervals the dancers re-choose their friends and enemies.

mu = number of steps between frames
rechoose = probability (%) to rechoose friends and enemies after mu*numframes steps.

n:=1000: numframes:=200: mu:=10: rechoose:=10:
x,y:='LinearAlgebra:-RandomVector(n,generator=-1.0 ..  1.0,datatype=float[8])' $2:
FE:=proc() global F,E; #friend,enemy
  F,E:='LinearAlgebra:-RandomVector(n,generator=1..n,datatype=integer[4])' $2;
end:
FE():
step:=proc(x::Vector(datatype=float[8]),y::Vector(datatype=float[8]),
      E::Vector(datatype=integer[4]),F::Vector(datatype=integer[4]))
option autocompile;
local i::integer[4],ex::float[8],ey::float[8],ed::float[8],
                    fx::float[8],fy::float[8],fd::float[8];
to mu do
for i to n do
  ex:=x[E[i]]-x[i];ey:=y[E[i]]-y[i]; ed:=sqrt(ex^2+ey^2);
  fx:=x[F[i]]-x[i];fy:=y[F[i]]-y[i]; fd:=sqrt(fx^2+fy^2);
  x[i] := 0.995*x[i] - 0.01*ex/(ed+0.01) + 0.02*fx/(fd+0.01);
  y[i] := 0.995*y[i] - 0.01*ey/(ed+0.01) + 0.02*fy/(fd+0.01);
od; od;
end:
for k to numframes do
  p[k]:=plot(x,y);
  step(x,y,E,F);
  if rand(1..100)()<=rechoose then FE() fi;
od:
plots[display](seq(p[k],k=1..numframes),style=point,axes=none,insequence=true);


Edited. Added definition, comments and a few changes in code.

 

Your system is incompatible. You have posted a similar system recently and you were told how to see this (e.g. remove the last equation).

allcomp:=proc(F, n)
local M:=Iterator:-CartesianProduct(F$n);
[seq(`@`(entries(u,nolist)), u=M)];
end;

allcomp([sin, cos, t->t^2], 3)(x);  #example

 

For Maple<2016 use:
allcomp2015:=proc(F,n)
local T:=combinat:-cartprod([F$n]),r:=NULL;
while not T[finished] do r:=r,`@`(op(T[nextvalue]()))  end do;
[r]
end;


First 107 108 109 110 111 112 113 Last Page 109 of 122