Maple 12 Questions and Posts

These are Posts and Questions associated with the product, Maple 12

second has rsolve solution

compare original sequence

accsum(ListTools[Reverse]([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])),

with rsolve solution , it start from third number wrong, some number are wrong but correct at next number, 

but i just want to guess next number is 1 or 2

[seq(subs(k=kk, sol), kk=0..(lengthofsequence+1))],

with(SumTools):
with(gfun):
accsum := proc(xx)
local result,mm:
result := []:
for mm from 1 to nops(xx) do
temp := Summation(xx[k], k = 1 .. mm):
result := [op(result), temp]:
od:
return result:
end proc:


patterngroup := [2, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 1]: # left is latest, 2,1,1..
lengthofsequence := 5:
for mm from 1 to 12 do
if guessgf(accsum(Reverse([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])), x) = FAIL then
print(patterngroup[mm]):
else
sol := rsolve(listtorec(accsum(ListTools[Reverse]([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])), u(n))[1], u(k)):
acxxc := accsum(ListTools[Reverse]([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])):
olist := [seq(patterngroup[k], k=(mm)..(mm+5))]:
#start from 0
print(patterngroup[mm], olist, accsum(ListTools[Reverse]([seq(patterngroup[k], k=(mm)..(mm+lengthofsequence))])), [seq(subs(k=kk, sol), kk=0..(lengthofsequence+1))], sol, subs(k=(lengthofsequence+1), sol), subs(k=(lengthofsequence+1), sol)-acxxc[nops(acxxc)]):
end if:
od:
 

How to pdsolve(diff( f(a,b), a+b) = diff( f(a,b),a))?

buy := proc(ss,windowlength,syseq1,syseq2a,syseq2b)
try:
p := dualaxisplot(listplot(ma, color = red), listplot(me, color = blue), style = line, gridlines = false);
catch:
p := dualaxisplot(listplot(me, color = red), listplot(me, color = blue), style = line, gridlines = false);
end try:
return p:
end proc:


CheckGraph := proc(text,graphparam1,graphparam2)
  local maplet, choice:
  maplet := Maplet(
    [
      [Plotter['PL1'](graphparam1)],
      [Plotter['PL2'](graphparam2)],
      #[Plotter['PL2'](graphparam2)],
      [text, ComboBox['CoB1']("No Refund", sort(["Jackpot"], lexorder))],
      [Button("OK", Shutdown(['CoB1'])), Button("Cancel", Shutdown())]
    ],
  ):
  choice := Maplets[Display](maplet):
end proc:

graph1 := buy(0,100,rhs(sol[parse(result1[1])][1]),rhs(sol[1][1]),rhs(sol[2][1]));

>graph1
can show graph but after using Plotter['PL1'] , it can not show graph in dialog

CheckGraph("Has Jackpot?",graph1,graph2):

 

how to plot dualaxisplot in dialog?

would like to show a list system one by one and ask question and wait for answer and then plot graph and ask question and wait for answer and then show next system ask question and contiune this for loop

but my script show all system at once but can not one by one and no pop up dialog and no wait for answer

how to do?

 

restart:
interface(prettyprint=2):
with(ListTools):
with(StringTools):
with(ExcelTools):
with(SumTools):
with(Maplets[Elements]):
count := 1:

RR := Import("C:\\Users\\ohungyeeel\\Documents\\EquationsLists.xls", "Candidate", "A1:Q65535"):

for mm from 2 to 20 do

try:
if RR[count,13] = "Complex" or RR[count,13] = "Beautiful system but no result" then
dummy := 0:
else
print(RR[count,1],RR[count,2]):
sol := solve(RR[count,2]):
print("Source:",RR[count,3]):
print("Solution:",sol):

choosesystem := Maplet(InputDialog['ID1']("Choose system?", 'Yes1' = Shutdown(['Yes']), 'No1' = Shutdown(['No']))):
Maplets[Display](maplet):

if choosesystem = "Yes" then
RR[count,15] := "SystemChosenAndSolutionCorrect":
else
RR[count,15] := "NotChosenAndSolutionWrong":
end if:

plot(sol):

choosesystem := Maplet(InputDialog['ID1']("Like and it works?", 'Yes1' = Shutdown(['Yes']), 'No1' = Shutdown(['No']))):
Maplets[Display](maplet):

if choosesystem = "Yes" then
RR[count,16] := "Best":
else
RR[count,16] := "NotSelected":
end if:

end if:

catch:
print("error at ",RR[count,1],RR[count,2]):
end try:

count := count + 1:
od:
Export(RR, "C:\\Users\\ohungyeeel\\Documents\\EquationsLists10092020.xls", "Candidate", "A1"):

interface(prettyprint=2):
with(ListTools):
with(StringTools):
for xx from 1 to 2 do
xx := 1:
Source := FileTools[Text][ReadFile](cat("C:\\hello\\probability1-200-26042020\\home\\probability",xx,"\\probability",xx,".txt")):
openindex := [SearchAll("[",Source)]:
endindex := [SearchAll("]",Source)]:
beforefiltered := []:
for mm from 1 to nops(openindex) do
if mm > 27 then
beforefiltered := [op(beforefiltered), Chop(substring(Source, openindex[mm]..endindex[mm]))]:
end if:
od:
afterfiltered := []:
for mm in beforefiltered do
if Has(mm,"--") or Has(mm,"|") or Has(mm,"{") or Has(mm,"}") then
dummy := 0:
elif Has(mm,"Root") then
dummy := 0:
else
afterfiltered := [op(afterfiltered),mm]:
end if:
od:
afterfiltered[1];

however after chop still has new line, can not make a beautiful csv format, 

"[b(t,k)+ a
(t,k)*
x(t,k)]"

# I try to export to text first and then use Excel to use "|" as delimiter instead comma as delimiter,
#because b(t,k) has comma "," will separate to open a new column

appendto("C:\\Users\\Student\\Documents\\IQ1-200csv.txt"):
for mm in afterfiltered do
AA := parse(mm):
lprint(xx,"|","hello := [","|",AA[1],"|",AA[2],"|","]:");
od:
od:

Expect csv in format
1,b(t,k)+a(t,k)*x(t,k)
2,a(t,k)+s(t,k)*z(t,k)

There are 3 lists of data 

how to plot 3 lines with x axis represent time 1,2,3...

 

P1 := x^2+y^2-4:
P2 := y^2-2*x+2:

Original question is find CAD of (some y)[P1 <0 and P2 <0]

how to use maple 12 and maple 2015 to find Q1,Q2,Q3 which are projection of P1 and P2

my book show sample points are [-4,-1-sqrt(7),-3,-2,0,1,3/2,-1+sqrt(7),9/5,2,3]
but FindSamples result is not the same with my book, is it my book wrong or FindSamples function wrong?
I find result of my script is the same as book's quantifier position at 7,8,9 though sample points has little different

how to generalize my following script to multiple variables x, y, z, and more ?

and

I compare with maple 2015 result are different from my book solution, is maple 2015 more advanced version CAD? 

with(ListTools):

P1 := x^2+y^2-4:
P2 := y^2-2*x+2:

Q1 := x^2 + 2*x - 6;
Q2 := x^2 - 4;
Q3 := x - 1;

sourcesamples := sort(evalf([solve(Q1), solve(Q2), solve(Q3)]),`<`);

FindSamples:=proc(sourcesamples)
local N, P;
N:=nops(sourcesamples);
P:=proc(a,b)
local a1, b1, m1, n, m;
if a=b then error "Should be a<>b" fi;
a1,b1:=op(convert(sort([a,b],(x,y)->evalf(x)<evalf(y)),rational));
count := 0:
for n from 1 do
m1:=a1*n;
m:=`if`(type(m1,integer),m1+1,ceil(m1));
count := count + 1:
if is(m/n>a1) and is(m/n<b1) then return m/n fi;
od;
print("count=",count);
end proc:
[ceil(sourcesamples[1])-1, seq(op([sourcesamples[i],P(sourcesamples[i],sourcesamples[i+1])]), i=1..N-1),sourcesamples[N],floor(sourcesamples[N])+1];
end proc:

RemoveComplex := proc(yy)
local result, k:
result := []:
for k in yy do
if Im(k) = 0 then
result := [op(result), k]:
end if:
od:
if result = [] then
result := []:
end if:
return result:
end proc:

Joinsolution := proc(param1, param2group)
local result, k:
result := []:
for k in param2group do
result := [op(result), [param1, k]]:
od:
return result:
end proc:

CADsamples := FindSamples(sourcesamples):
CADresult1 := []:
for mm in CADsamples do
#print(mm):
if MakeUnique(RemoveComplex([solve(subs(x=mm, P1)), solve(subs(x=mm, P2))])) = [] then
CADresult1 := [op(CADresult1), op(Joinsolution(mm,[0]))];
else
CADresult1 := [op(CADresult1), op(Joinsolution(mm,FindSamples(sort(evalf(MakeUnique(RemoveComplex([solve(subs(x=mm, P1)), solve(subs(x=mm, P2))]))),`<`))))];
end if:
od:
CADresult1;

for mm in CADresult1 do
if subs(x=mm[1],subs(y=mm[2], P1)) < 0 and subs(x=mm[1],subs(y=mm[2], P2)) < 0 then
print("solution ", mm, SearchAll(mm[1],CADsamples), evalf(mm)):
end if:
od:

Compare with

with(RegularChains):
with(ChainTools):
with(MatrixTools):
with(ConstructibleSetTools):
with(ParametricSystemTools):
with(SemiAlgebraicSetTools):
with(FastArithmeticTools):
R := PolynomialRing([x,y]):
sys := [x^2+y^2-4,y^2-2*x+2]:
N := []:
P := []: 
H := [x]:
dec := RealTriangularize(sys,N,P,H,R):
proj := Projection(sys, N, P, H, 1, R);
Display(dec, R);

P := SamplePoints(sys, R);
Display(P, R);
cad := CylindricalAlgebraicDecompose(sys, R);
 

is there easy way to simulate lines rotation like robotic arm following point P moving by adjusting angle q1 and q2?

i feel point two lines and simulate static two lines in animate is also not easy.

with(plots):
with(geometry):
#Joint at (5,5)
#length a  2, y=7, x, solve(subs(y=7,2^2 = (y-5)^2+(x-5)^2), x)[1];
#length b 2, y=1, x, solve(subs(y=4,2^2 = (y-5)^2+(x-5)^2), x)[1];
point(A, 5, 5), point(B, solve(subs(y=7,2^2 = (y-5)^2+(x-5)^2), x)[1], 7):
point(C, 5, 5), point(D, solve(subs(y=4,2^2 = (y-5)^2+(x-5)^2), x)[1], 4):
line(L1, [A, B]);
line(L2, [C, D]);
_EnvHorizontalName := x;
_EnvVerticalName := y;
Equation(L1);
Equation(L2);
solve(Equation(L1), y);
solve(Equation(L2), y);
plot([solve(Equation(L1), y),solve(Equation(L2), y)], x = 1 .. 2);
animate(plot, [Equation(L1),Equation(L2), x = 0 .. 2], A = -3 .. 3);

Angle Reference from below

angle of L2 , q1a

angle of L1,  q2a

 

p1 := vector([a*cos(q1), a*sin(q1)]);
P := evalm(p1 + b*vector([cos(q1+q2), sin(q1+q2)]));
Pe := map(expand, P);
A := {cos(q1) = c1, sin(q1) =s1, cos(q2)=c2, sin(q2)=s2};
P := subs(A, op(Pe));
F1 := [x - P[1], y - P[2], s1^2+c1^2-1, s2^2+c2^2-1 ];
F2 := subs({a=1, b=1}, F1);
with(Groebner):
g1 := Basis(F2, plex(c2, s2, c1, s1, y, x));
g1 := [-4*x^2+x^4+2*x^2*y^2+y^4-4*y*x^2*s1-4*y^3*s1+4*s1^2*x^2+4*s1^2*y^2, 2*y*s1+2*x*c1-x^2-y^2, 4*x-x^3-y^2*x+2*y*x*s1-2*y^2*c1-4*s1^2*x+4*y*s1*c1, s1^2+c1^2-1, x*s1-y*c1+s2, -y^2+2-x^2+2*c2];
map(indets, g1);
 

g2 := Basis(F2, plex(c2, s2, c1, s1));
 

assume point x = 1, y = 0.5
g2spec := subs({x=1, y=1/2}, [g2[1],g2[3]]);
S1 := [solve(g2spec[1])];
q1a := evalf(arcsin(S1[1]));
q1b := evalf(arcsin(S1[2]));

S2 := [solve(subs(s1=S1[1], g2spec[2])), solve(subs(s1=S1[2], g2spec[2])) ];
q2a := evalf(arcsin(S2[1]));
q2b := evalf(arcsin(S2[2]));

q2a := subs({a=2,b=2}, q2a);
if q2a < 0 then
 q2a_pi := evalf(eval(-q2a-Pi));
else
 q2a_pi := evalf(eval(Pi-q2a));
end if:
q2a_pi;

q2b := subs({a=2,b=2}, q2b);
if q2b < 0 then
 q2b_pi := evalf(eval(-q2b-Pi));
else
 q2b_pi := evalf(eval(Pi-q2b));
end if:
q2b_pi;

I follow below question to generate binary sequence
but number of sequence is 6 not 5, why 011001 is wrong?

number of sequence should be catalan number.

how to generate this kind of sequence correctly?

For ecah positive integer n, how many 2n-digit binary sequence
 b1,b2,b2n with n "0" and n "1" are there such that
for each i=1,2,...2n, the number of "0" is larger than or equal 
to the number of "1" in the subsequence b1,b2,...bi?


with(combinat):
with(ListTools):
with(SumTools):
source := permute(Flatten([seq([0,0,0,1,1,1], k=1..1)]), 6);
aavxa := []:
for z in source do
if Summation(z[k], k = 1 .. nops(z)) = 3 then
if z[nops(z)] = 1 and z[1] = 0 then
if Reverse(z) in aavxa then
else
aavxa := [op(aavxa), z];
end if:
end if:
end if:
od:
nops(aavxa);
aavxa;
 

y(t)/diff(y(t),t)

 

how to dsolve when highest derivative at denominator?


For a from 1 to 2 do

convert(cat("k",a),symbol) := a;

od;

Error : can not do assignment 

how to do ?


Eigenvector result is changing every time it run.

How to make eigenvectors result the same every time it run?

 

1.1 * 10^2

but export text become two lines

               2

1.1 *   10

pretty printing = 3 

but still two lines

 

how to export in one line such as 10^2 ?

               

If A then B After clustering B , how to find a set of A in machine learning topic and fuzzy topic?

Du plot two lines but overlapped 

how to set color of each line and choose each line plot on top of layer to confirm overlapped?

1 2 3 4 5 6 7 Last Page 1 of 30