Maple 2016 Questions and Posts

These are Posts and Questions associated with the product, Maple 2016
restart;
Digits:=30:

f:=proc(n)
	x[n]-y[n];
	
end proc:


e1:=y[n] = (15592/1575)*h*f(n+5)+(35618816/99225)*h*f(n+9/2)-(4391496/15925)*h*f(n+13/3)-(2035368/13475)*h*f(n+14/3)-(212552/121275)*h*f(n+1)+(10016/11025)*h*f(n+2)-(31672/4725)*h*f(n+3)+(19454/315)*h*f(n+4)-(351518/1289925)*h*f(n)+y[n+4]:
e2:=y[n+1] = -(34107/22400)*h*f(n+5)-(212224/3675)*h*f(n+9/2)+(92569149/2038400)*h*f(n+13/3)+(82333989/3449600)*h*f(n+14/3)-(568893/1724800)*h*f(n+1)-(459807/313600)*h*f(n+2)+(1189/22400)*h*f(n+3)-(50499/4480)*h*f(n+4)+(32951/6115200)*h*f(n)+y[n+4]:
e3:=y[n+2] = (69/175)*h*f(n+5)+(1466368/99225)*h*f(n+9/2)-(13851/1225)*h*f(n+13/3)-(60507/9800)*h*f(n+14/3)+(43/3675)*h*f(n+1)-(3509/9800)*h*f(n+2)-(6701/4725)*h*f(n+3)+(871/420)*h*f(n+4)-(247/396900)*h*f(n)+y[n+4]:
e4:=y[n+3] = -(31411/201600)*h*f(n+5)-(745216/99225)*h*f(n+9/2)+(13557213/2038400)*h*f(n+13/3)+(9737253/3449600)*h*f(n+14/3)-(20869/15523200)*h*f(n+1)+(36329/2822400)*h*f(n+2)-(202169/604800)*h*f(n+3)-(100187/40320)*h*f(n+4)+(14669/165110400)*h*f(n)+y[n+4]:
e5:=y[n+13/3] = -(3364243/1322697600)*h*f(n+5)-(134364928/651015225)*h*f(n+9/2)+(19955023/55036800)*h*f(n+13/3)+(5577703/93139200)*h*f(n+14/3)-(910757/101847715200)*h*f(n+1)+(1336457/18517766400)*h*f(n+2)-(2512217/3968092800)*h*f(n+3)+(31844549/264539520)*h*f(n+4)+(690797/1083289334400)*h*f(n)+y[n+4]:
e6:=y[n+14/3] = -(29107/10333575)*h*f(n+5)+(7757824/651015225)*h*f(n+9/2)+(180667/429975)*h*f(n+13/3)+(342733/2910600)*h*f(n+14/3)-(7253/795685275)*h*f(n+1)+(42467/578680200)*h*f(n+2)-(19853/31000725)*h*f(n+3)+(993749/8266860)*h*f(n+4)+(22037/33852791700)*h*f(n)+y[n+4]:
e7:=y[n+9/2] = -(115447/51609600)*h*f(n+5)-(21389/198450)*h*f(n+9/2)+(231041241/521830400)*h*f(n+13/3)+(43797591/883097600)*h*f(n+14/3)-(32833/3973939200)*h*f(n+1)+(48323/722534400)*h*f(n+2)-(91493/154828800)*h*f(n+3)+(1220071/10321920)*h*f(n+4)+(24863/42268262400)*h*f(n)+y[n+4]:
e8:=y[n+5] = (1989/22400)*h*f(n+5)-(61184/99225)*h*f(n+9/2)+(1496637/2038400)*h*f(n+13/3)+(2458917/3449600)*h*f(n+14/3)+(73/5174400)*h*f(n+1)-(31/313600)*h*f(n+2)+(359/604800)*h*f(n+3)+(1079/13440)*h*f(n+4)-(179/165110400)*h*f(n)+y[n+4]:



h:=0.01:
N:=solve(h*p = 8/8, p):
#N := 10:
#n:=0:
#exy:= [seq](eval(i+exp(-i)-1), i=h..N,h):
c:=1:
inx:=0:
iny:=0:

mx := proc(t,n):
   t + 0.01*n:
end proc:

exy := (x - 1.0 + exp(-x)):

vars := y[n+1],y[n+2],y[n+3],y[n+4],y[n+13/3],y[n+14/3],y[n+9/2],y[n+5]:

printf("%6s%20s%20s%20s\n", "h","numy1","Exact", "Error");
#for k from 1 to N/8 do
for c from 1 to N do

	par1:=x[n]=map(mx,(inx,0)),x[n+1]=map(mx,(inx,1)),
		x[n+2]=map(mx,(inx,2)),x[n+3]=map(mx,(inx,3)),
		x[n+4]=map(mx,(inx,4)),x[n+5]=map(mx,(inx,5)),
		x[n+13/3]=map(mx,(inx,13/3)),x[n+14/3]=map(mx,(inx,14/3)),
		x[n+9/2]=map(mx,(inx,9/2)):
	par2:=y[n]=iny:
	res:=eval(<vars>, fsolve(eval({e||(1..8)},[par1,par2]), {vars}));
	
	printf("%7.3f%22.10f%20.10f%17.3g\n", 
		h*c,res[8],(exy,[x=c*h]),abs(res[8]-eval(exy,[x=c*h]))):
		#c:=c+1:
	
	iny:=res[8]:
	inx:=map(mx,(inx,5)):
end do:

Dear all,

Please Kindly help to correct or modify the code above

Thank you and best regards
 

 

 

The rational expression at the beginning of the code is approximant. p1-p5 are conditions imposed on t, and are to be solved simultaneously to obtain a[0]-a[4] which are then substituted into t to obtain Cf. S1-S4 are to be obtained from Cf and its derivative.

However, I observed that Cf is not providing the desired results. What have I done wrong? Please Can someone be of help?

Thank you and kind regards

 

restart:
t:=sum(a[j]*x^j,j=0..2)/sum(a[j]*x^j,j=3..4):
F:=diff(t,x,x):
p1:=simplify(eval(t,x=q))=y[n]:
p2:=simplify(eval(t,x=q+h))=y[n+1]:
p3:=simplify(eval(F,x=q))=f[n]:
p4:=simplify(eval(F,x=q+h))=f[n+1]:
p5:=simplify(eval(F,x=q+2*h))=f[n+2]:
vars:= seq(a[i],i=0..4):
Cc:=eval(<vars>, solve({p||(1..5)}, {vars}));
for i from 1 to 5 do
	a[i-1]:=Cc[i]:
end do:
Cf:=t;
M:=diff(Cf,x):
s4:=y[n+2]=collect(simplify(eval(Cf,x=q+2*h)),[y[n],y[n+1],f[n],f[n+1],f[n+2]], recursive);
s3:=h*delta[n]=collect(h*simplify(eval(M,x=q)),{y[n],y[n+1],f[n],f[n+1],f[n+2]},factor);
s2:=h*delta[n+1]=collect(h*simplify(eval(M,x=q+h)),{y[n],y[n+1],f[n],f[n+1],f[n+2]},factor):
s1:=h*delta[n+1]=collect(h*simplify(eval(M,x=q+2*h)),{y[n],y[n+1],f[n],f[n+1],f[n+2]},factor):

 

Hi dear community!

 

The following code produces a table, however it always has the text "Tabulate0" as an output as well. Is it possible to supress that? Ordinary : dont work unfortunately.

 

with(DocumentTools):
with(ArrayTools):
nUnten:=2:
nOben:=8:
InitialisierungDF:=Vector[column](nOben-nUnten+1, fill=oE): #Erstellen der auszugebenden Tabelle
InitialisierungSpalte:=Vector[row](nOben-nUnten+1, i->n=nUnten-1+i):
DF:= DataFrame( Concatenate( 2, InitialisierungDF $ 10),
                   columns = [ GKAbs, GKRel, PZPAbs, PZPRel, PZMAbs, PZMRel, PYAbs, PYRel, DAbs, DRel],
                   rows = InitialisierungSpalte);
print(Tabulate(DF));

 

Thank you very much!

Hi there!

The first time I compile the following code, I get the error message

"Error, cannot split rhs into multiple assignment."

when trying to solve an issue with the procedure. I then have to compile the procedure over and over again, until it finally works (which it does eventually, without changing the code.) The problematic line is

Knoten, Eigenvektoren := Eigenvectors(evalf[15](M));

it is one of the last lines within the code below. Is it possible to get rid of that issue? It is annoying and unprofessional to have to compile a code over and over again until it finally works.

 

 

 

GaußKronrodQuadraturKurz:= proc(Unten, Oben, f,G,n)::real;
 
  #Unten:= Untere Intervallgrenze; Oben:= Obere Intervallgrenze; G:= Gewicht;
  #f:= zu untersuchende Funktion; n:= Berechnung der Knotenanzahl mittels 2*n+1
local
A,B,P,S,T, #Listen
a,b,p,s,t, #Listenelemente
i,j,k, #Laufvariablen
M, #werdende Gauss-Kronrod-Jacobi-Matrix
m, #Matrixeinträge
u,l, #Hilfsvariablen Gemischte Momente
RekursivesZwischenergebnis,Gewichte,Knoten,Eigenvektoren,AktuellerNormierterVektor,Hilfsvariable,Endergebnis;

with(LinearAlgebra):
 
A := [seq(a[i], i = 0 .. n)];
B := [seq(b[i], i = 0 .. n)];
P := [seq(p[i], i = -1 .. ceil(3*n/2)+1)];  
S := [seq(s[i], i = -1 .. floor(n/2))];
T := [seq(t[i], i = -1 .. floor(n/2))];
p[-1]:= 0;
p[0]:=1;
for i from -1 to floor(n/2) do
  s[i]:=0;
  t[i]:=0
end do;
for j from 1 to 2*n+1 do
  RekursivesZwischenergebnis:= x^j;
  for i from 0 to j-1 do
    RekursivesZwischenergebnis:= RekursivesZwischenergebnis -
    (int(x^j*p[i],x=Unten..Oben)/int(p[i]*p[i],x=Unten..Oben))*p[i]                  #Gram-Schmidt algorithm
  end do;
  p[j]:=RekursivesZwischenergebnis;
end do;
a[0]:=-coeff(p[1],x,0);

  #p[0+1]=(x-a[0])*p[0]-b[0]*p[0-1] -> p[1]=x*p[0]-a[0]*p[0]-b[0]*p[-1] ->
  #p[1]=x*1-a[0]*1-0 -> a[0]=x-p[1] -> a[0]= -coeff(p[1],x,0), da p[1] monisch ist und von Grad 1    #ist
 
b[0]:=int(p[0]^2, x=Unten..Oben); #by definition
for j from 1 to ceil(3*n/2) do
 
  #Genau genommen muss a nur bis floor(3/(2*n)) initialisiert werden, allerdings wird der Wert       #ohnehin für die Berechnung von b gebraucht. Die Initialisierung schadet nicht.
    
                                     
  a[j]:= coeff(p[j],x,j-1)- coeff(p[j+1],x,j);
    
    #p[j+1]=(x-a[j])*p[j]-b[j]*p[j-1] -> p[j+1]=x*p[j]-a[j]*p[j]-b[j]p[j-1] ->
    #coeff(p[j+1],x,j)=coeff(x*p[j],x,j)-coeff(a[j]*p[j],x,j)
      #(da b[j]*p[j-1] vom Grad j-1 ist) ->
    #coeff(p[j+1],x,j)=coeff(x*p[j],x,j)-a[j], da p[j] monisch ist ->
    #coeff(p[j+1],x,j)=coeff(p[j],x,j-1)-a[j]->
    #a[j]=coeff(p[j],x,j-1)-coeff(p[j+1],x,j)
 
  b[j]:=  quo((x-a[j])*p[j]-p[j+1],p[j-1],x);
    

     #p[j+1]=(x-a[j])*p[j]-b[j]*p[j-1] -> -p[j+1]+(x-a[j])*p[j]= b[j]*p[j-1]
     #b[j]=((x-a[j])*p[j]-p[j+1])/p[j-1]

end do;    
t[0]:=b[n+1]; #t[0]:= /hat{b}[0], Beginn der ostwärtigen Phase
for i from 0 to n-2 do # n-2 ist die Anzahl der zu berechnenden Diagonalen
  u:=0;
  for k from floor((i+1)/2) to 0 by -1 do # aufgrund des diagonalen Vorgehens ist nur bei jedem
                                          # zweiten Schleifendurchlauf eine Inkrementierung
                                          # vorzunehmen
    l:=i-k;
    u:=u+(a[k+n+1]-a[l])*t[k]+b[k+n+1]*s[k-1]-b[l]*s[k]; # Ausrechnen gemischter Momente über die
                                                         # fünfgliedrige Rekursion
    s[k]:=u
  end do;
  for j from -1 to floor(n/2) do  # Durchrotieren der Werte der gemischten Momente, da ein                                           # jeweiliges gemischtes Moment beim zweiten auf die Generierung                                    # folgenden
                                  # Schleifendurchlauf das letzte mal benötigt und danach über-
                                  # schrieben wird. Die am Ende vorliegenden Werte sind gerade
                                  # die, die bei der südwärtigen Phase benötigt werden.
    Hilfsvariable:=s[j];
    s[j]:=t[j];
    t[j]:=Hilfsvariable
  end do;
end do;
for j from floor(n/2) to 0 by -1 do
    s[j]:=s[j-1]
end do;
for i from n-1 to 2*n-3 do #entspricht der Anzahl der restlichen Diagonalen
  u:=0;
  for k from i+1-n to floor((i-1)/2) do #berechnet die gemischten Momente innerhalb einer
                                        #Diagonalen, von oben rechts nach unten links.
    l:=i-k;
    j:=n-1-l;
    u:=u-(a[k+n+1]-a[l])*t[j]-b[k+n+1]*s[j]+b[l]*s[j+1];
    s[j]:=u
  end do;
  if i mod 2 = 0 then #Ausrechnen eines fehlenden Koeffizienzen über die fünfgliedrige Rekursion                         #am Eintrag (k,k)
    k:= i/2;
    a[k+n+1]:=a[k]+(s[j]-b[k+n+1]*s[j+1])/t[j+1]
  else                #Ausrechnen eines fehlenden Koeffizienzen über die fünfgliedrige Rekursion                         #am Eintrag (k,k-1)
    k:=(i+1)/2;
    b[k+n+1]:=s[j]/s[j+1]
  end if;
  for j from -1 to floor(n/2) do #Erneutes Durchrotieren der Werte der gemischten Momente
    Hilfsvariable:=s[j];
    s[j]:=t[j];
    t[j]:=Hilfsvariable
  end do;
end do;
a[2*n]:=a[n-1]-b[2*n]*s[0]/t[0]; #Berechnung des letzten fehlenden Koeffizienten über die                                           #fünfgliedrige Rekursion am Eintrag (n-1,n-1)

M:=Matrix(2*n+1, shape=symmetric);#definieren der werdenden Gauß-Krondrod-Matrix
M(1,1):=a[0];
for m from 2 to (2*n+1) do #generieren der Gauss-Kronrod-Matrix
  M(m-1,m):= sqrt(b[m-1]);
  M(m,m-1):= sqrt(b[m-1]);
  M(m,m):= a[m-1];
end do;
Knoten, Eigenvektoren := Eigenvectors(evalf[15](M));# "Die gesuchten Knoten sind die Eigenwerte #dieser Matrix, und die Gewichte sind proportional zu den ersten Komponenten der normalisierten #Eigenvektoren"

 

for m from 1 to 2*n+1 do
  AktuellerNormierterVektor:= Normalize(Column(Eigenvektoren,m),Euclidean);
 
 
  Gewichte[m]:=AktuellerNormierterVektor[1]^2*b[0]

end do;

Endergebnis:=Re(add(Gewichte[i]*eval(f*diff(G,x),x=Knoten[i]),i=1..2*n+1));

 

end proc

 

An example of an application of the procedure is

 

GaußKronrodQuadraturKurz(-2, 1, 3*x*3*x^2*sin(x),x,3)

 

Thank you very much!

 

HI all, I obtained a solution to a system solved by Maple but it seems not to be correct. And I couldn't detect where the mistake lies!

 

solution_bug_or.....mw

Hello everyone!

I want to construct column vector which elements should be square matrices (m x n each one). So, i use cycle "for" to set such construction.

My question is: what is the fastest way to construct matrices if each matrix elements are independent from each other and also they are results of numerical integration, like is shown in attached file?

Acceleration.mw

Good day, all. I hope we are staying safe.

Please I need help with the regard to the following codes.

The major issue is with rho:=x[n]/h. The rho needs to change values as x[n] changes in the computation. This I think I have gotten wrong. Your professional modifications or/and corrections to the code would be appreciated.

Thank you and kind regards.

restart;
Digits:=20:
#assume(alpha>0,alpha < 1):
f:=proc(n)
	-y[n]-x[n]+(x[n])^2+(2*(x[n])^(2-alpha))/GAMMA(3-alpha)+((x[n])^(1-alpha))/GAMMA(2-alpha):
end proc:

e2:=y[n+2] = y[n]+(1/2)*((alpha^2-alpha)*rho^2+(2*alpha^2-2)*rho+(4/3)*alpha^2-(2/3)*alpha)*(rho*h)^alpha*GAMMA(2-alpha)*f(n)/rho-alpha*GAMMA(2-alpha)*((-1+alpha)*rho^2+(2*alpha-2)*rho+(4/3)*alpha-8/3)*(h*(rho+1))^alpha*f(n+1)/(rho+1)+(1/2)*((alpha^2-alpha)*rho^2+2*(-1+alpha)^2*rho+(4/3)*alpha^2-(14/3)*alpha+4)*(h*(rho+2))^alpha*f(n+2)*GAMMA(2-alpha)/(rho+2):
e1:=y[n+1] = y[n]+(1/4)*((alpha^2-alpha)*rho^2+(alpha^2+3*alpha-4)*rho+(1/3)*alpha^2+(4/3)*alpha)*GAMMA(2-alpha)*f(n)/((rho*h)^(-alpha)*rho)-(1/2)*GAMMA(2-alpha)*((alpha^2-alpha)*rho^2+(alpha^2+alpha-2)*rho+(1/3)*alpha^2+(1/3)*alpha-2)*f(n+1)/((h*(rho+1))^(-alpha)*(rho+1))+(1/4)*((-1+alpha)*rho^2+(-1+alpha)*rho+(1/3)*alpha-2/3)*alpha*GAMMA(2-alpha)*f(n+2)/((h*(rho+2))^(-alpha)*(rho+2)):


alpha:=0.25:
inx:=0:
iny:=0:
#x[0]:=0:
h:=1/20:
N:=solve(h*p = 1, p):
n:=0:
c:=1:
rho:=x[n]/h: 
err := Vector(round(N)):
exy_lst := Vector(round(N)):

for j from 0 to 2 do
	t[j]:=inx+j*h:
end do:
vars:=y[n+1],y[n+2]:

step := [seq](eval(x, x=c*h), c=1..N):

printf("%4s%15s%15s%16s\n", 
	"h","Num.y","Ex.y","Error y");
st := time():
for k from 1 to N/2 do

	par1:=x[n]=t[0],x[n+1]=t[1],x[n+2]=t[2]:
	par2:=y[n]=iny:
	res:=eval(<vars>, fsolve(eval({e||(1..2)},[par1,par2]), {vars}));

	for i from 1 to 2 do
		exy:=eval(-c*h+(c*h)^2):
		printf("%5.3f%17.9f%15.9f%15.5g\n", 
		h*c,res[i],exy,abs(res[i]-exy)):
		
		err[c] := abs(evalf(res[i]-exy)):
		exy_lst[c] := exy:
		numerical_y1[c] := res[i]:
		c:=c+1:
		rho:=rho+1:
	end do:
	iny:=res[2]:
	inx:=t[2]:
	for j from 0 to 2 do
		t[j]:=inx + j*h:
	end do:
end do:
v:=time() - st;
printf("Maximum error is %.13g\n", max(err));

numerical_array_y1 := [seq(numerical_y1[i], i = 1 .. N)]:

time_t := [seq](step[i], i = 1 .. N):

with(plots):
numerical_plot_y1 := plot(time_t, numerical_array_y1, style = [point], symbol = [asterisk],
				color = [blue,blue],symbolsize = 15, title="y numerical",legend = ["Numerical"]);
exact_plot_y1 := plot(time_t, exy_lst, style = [line], symbol = [box], 
				color = [red,red], symbolsize = 10, title="y exact",legend = ["Exact"]);

display({numerical_plot_y1, exact_plot_y1}, title = "Exact and Numerical Solution of Example 1 ");

 

Hello, everyone!

I have a problem. Colleague send me a figure in maple-file – .mw. How to export data from this plot? I usually use "plottools:-getdata" command, but what strategy should I apply in case of attached file?

 

Test-example.mw

I am currently struggling with a piecewise functions. Seeing as this function is defined over a large number of breakpoints, it would seem that Maple is unable to execute a certain integration (over a particular interval). Since the first derivatives match up at all breakpoints and the piecewise function looks perfectly smooth to my eyes, I figured that I might obtain a sensible result approximating the function by means of a polynomial and integrating based on the resulting approximation. When I try to use minimax from numapprox, however, I just receive an error message to the effect that:

Error, (in evalf/int/CreateProc) function does not evaluate to numeric

I'd very much appreciate it if anyone had any pointers on how I might find a reasonably precise (not necessarily polynomial) approximation for a seemingly smooth piecewise function with a large number of breakpoints.

Many thanks.

Edit: Please find attached my worksheet: worksheet.mw. My goal is to approximate the function Z over the interval 5/3 to 5 by something that is not defined in a piecewise manner.

 

 

I am trying to run this code but this error message is coming up "Error, (in fprintf) number expected for floating point format
". What have I done wrong and how do I correct it.

Thank you and best regards.

 

restart;
Digits:=30:

f:=proc(n)
	-((sin(x[n]))/(2-sin(x[n])))*(2+sin(x[n]-Pi)):
end proc:

e1:=y[n+1]=h*delta[n]-(1/2)*h^2*(-u^2*sin((1/2)*u)+2*cos((1/2)*u)*u-2*cos(u)*u-4*sin((1/2)*u)+2*sin(u))*f(n)/(u^2*(2*sin((1/2)*u)-sin(u)))+(1/2)*h^2*(u^2*sin((1/2)*u)+2*cos((1/2)*u)*u-4*sin((1/2)*u)+2*sin(u)-2*u)*f(n+1)/(u^2*(2*sin((1/2)*u)-sin(u)))-(1/2)*h^2*(u*sin(u)+2*cos(u)-2)*f(n+1/2)/(u*(2*sin((1/2)*u)-sin(u)))+y[n]:
e2:=h*delta[n+1]=h*delta[n]+h^2*(u*sin((1/2)*u)+cos(u)-1)*f(n)/(u*(2*sin((1/2)*u)-sin(u)))+h^2*(u*sin((1/2)*u)+cos(u)-1)*f(n+1)/(u*(2*sin((1/2)*u)-sin(u)))-h^2*(u*sin(u)+2*cos(u)-2)*f(n+1/2)/(u*(2*sin((1/2)*u)-sin(u))):
e3:=y[n+1/2]=(1/2)*h*delta[n]-(1/8)*h^2*(-u^2*sin((1/2)*u)+4*cos((1/2)*u)*u-4*cos(u)*u-16*sin((1/2)*u)+8*sin(u))*f(n)/(u^2*(2*sin((1/2)*u)-sin(u)))+(1/8)*h^2*(u*sin((1/2)*u)+4*cos((1/2)*u)-4)*f(n+1)/(u*(2*sin((1/2)*u)-sin(u)))-(1/8)*h^2*(u^2*sin(u)+4*cos(u)*u+16*sin((1/2)*u)-8*sin(u)-4*u)*f(n+1/2)/(u^2*(2*sin((1/2)*u)-sin(u)))+y[n]:
e4:=h*delta[n+1/2]=h*delta[n]-(1/2)*h^2*(-u*sin((1/2)*u)+4*cos((1/2)*u)-2*cos(u)-2)*f(n)/(u*(2*sin((1/2)*u)-sin(u)))+(1/2)*h^2*(u*sin((1/2)*u)+4*cos((1/2)*u)-4)*f(n+1)/(u*(2*sin((1/2)*u)-sin(u)))-(1/2)*h^2*(u*sin(u)+2*cos(u)-2)*f(n+1/2)/(u*(2*sin((1/2)*u)-sin(u))):


inx:=0:
ind:=1:
iny:=2:
h:=Pi/4:
n:=0:
omega:=1:
u:=omega*h:
N:=solve(h*p = 8*Pi, p):

c:=1:
for j from 0 to 1 by 1/2 do
	t[j]:=inx+j*h:
end do:

vars:=y[n+1/2],y[n+1],delta[n+1/2],delta[n+1]:

step := [seq](eval(x, x=c*h), c=1..N):
printf("%6s%15s%15s%16s%15s%15s%15s\n", 
	"h","Num.y","Num.z","Ex.y","Ex.z","Error y","Error z");
#eval(<vars>, solve({e||(1..4)},{vars}));


st := time():
for k from 1 to N do

	par1:=x[0]=t[0],x[1/2]=t[1/2],x[1]=t[1]:
	par2:=y[n]=iny,delta[n]=ind:
	res:=eval(<vars>, fsolve(eval({e||(1..4)},[par1,par2]), {vars}));

	for i from 1 to 2 do
		exy:=eval(2+sin(c*h/2)):
		exz:=eval(-sin(c*h/2)+10*epsilon*cos(10*c*h)):
		printf("%6.5f%17.9f%15.9f%15.9f%15.9f %13.5g%15.5g\n", 
		h*c,res[i],res[i+2],exy,exz,abs(res[i]-exy),
		abs(res[i+2]-exz)):
		
		c:=c+1:

	end do:
	iny:=res[2]:
	ind:=res[4]:
	inx:=t[1]:
	for j from 0 to 1 by 1/2 do
		t[j]:=inx + j*h:
	end do:
end do:

 

In this code, there are 8 vectors, each vector has 5 points except vectors 7 and 8 with 4 points. I made their  (7 and 8) respective fifth point a string. However, this error statement pops up "Error, invalid input: log[10] expects its 1st argument, x, to be of type algebraic, but received 2.51E-10".

Can someone help me with the correction?

Thank you all and kind regards

 

restart;

B:=<<601,1201,2401,4801,9601>|<2.87E-19,7.94E-21,7.94E-23,1.03E-24,5.91E-26>|
    <2001,4001,8001,16001,32001>|<3.30E-2,5.37E-4,8.47E-6,1.33E-7,2.08E-9>|
    <183,365,728,1476,2910>|<4.58E0,7.54E-8,2.20E-11,4.95E-14,9.15E-15>|
    <1621,3020,6166,12022,"2222">|<2.95E-3,8.51E-6,3.39E-8,2.51E-10,"2.51E-10">>:

for i from 1 to 5 do
   B[i, 2] := log[10](B[i, 2]):                      
   B[i, 4] := log[10](B[i, 4]):         
   B[i, 6] := log[10](B[i, 6]):         
   B[i, 8] := log[10](B[i, 8]):

   B[i, 1] := log[10](B[i, 1]):                      
   B[i, 3] := log[10](B[i, 3]):         
   B[i, 5] := log[10](B[i, 5]):         
   B[i, 7] := log[10](B[i, 7]):

end do:  # computing the log of the max-error
B: # This is the table of values we'll plot.

T:=plot([B[..,[1, 2]],B[1..1,[1, 2]], B[.., [3, 4]],B[1..1,[3, 4]], 
     B[..,[5, 6]],B[1..1,[5, 6]],B[.., [7, 8]],B[1..1,[7, 8]]], 
    legend = ["","BFFM","", "BNM","", "BHM","", "ARKN"],
    #title="Efficiency Curve for Example 5",
    style = ["pointline","point","pointline","point","pointline","point","pointline","point"], 
    symbolsize = 15,axes = framed, 
    symbol = [box,box, circle,circle,solidbox, solidbox,solidcircle, solidcircle],
    color=[ red, red, gold,gold, blue, blue,black, black], 
    axis = [gridlines = [colour = green, majorlines = 1,linestyle = dot]], 
    labels = [typeset(log__10(`NFE`)), typeset(log__10(`Max Err`))]);

Hi!

 

Is there a way to use the profiling function for procedures within a procedure? I have this code as an example:

Test:=proc(a,b)::real;

local c;Ergebnis;

Test2:= proc(d,e) #Prozedur zum Schreiben der Ausgaben

    f:=d+e;
    g:=f*d;
    5+3;
    3/0;
end proc:
 c:=a+b;
 Ergebnis:=Test2(a,c)
 end proc:

infolevel[Test]:= 2:
CodeTools:-Profiling:-Profile(Test):
Test(3,4);
CodeTools:-Profiling:-PrintProfiles(Test);

just profiling Test2, the subprocedure, doesn't do anything. Obviously, in this example, the division by zero is the problem, however, I am interested in a general solution to detect more complicated problems within a sub-procedure. Is there a way to also profile it, and thus see where the computation stops?

Hi!

 

I am trying to construct multiple math plots within one procedure, however, only one is displayed at a time, and it is always at the end of the outputs. I searched for that peculiar behaviour and eventually found on

https://de.maplesoft.com/support/help/Maple/view.aspx?path=DataFrame/Tabulate

the line

This command inserts the assembly of Tables and Embedded Components into the worksheet using the InsertContent facility. The inserted content is placed after any usual output of the Execution Group in which this command is called. Each Execution Group allows for only one inserted result to exist at any given time. Multiple calls to commands which utilize the InsertContent facility made within the same Execution Group will result in each successive inserted assembly replacing any assembly inserted earlier for that Execution Group.

 

Is there a workaround for this issue? I cannot find one, e.g. on

https://de.maplesoft.com/support/help/Maple/view.aspx?path=DocumentTools%2fInsertContent

Thank you in advance. :)

Hi!

I have trouble using ArrayTools, specifically Extend, to create a DataFrame. DF1 and DF2 are, even though awkwardly, created correctly, DF 3 does not work. My code is this:

with(ArrayTools):

with(DocumentTools):

nOben:=10;

nUnten:=3;

InitialisierungDF:=Vector(nOben-nUnten+1); #Initialisierung des Dataframes für die Tabelle
InitialisierungSpalte:=Vector[row](nOben-nUnten+1);
for i from 1 to nOben-nUnten+1 do
 InitialisierungDF(i):=oE;
 InitialisierungSpalte(i):=n=i;
end do;
print(InitialisierungDF);
print(InitialisierungSpalte);
DF1:= DataFrame( < InitialisierungDF | InitialisierungDF | InitialisierungDF | InitialisierungDF>,
            columns = [ GK, PZP, PZM, PY],
            rows = InitialisierungSpalte);  
DF2:= DataFrame( < InitialisierungDF | InitialisierungDF | InitialisierungDF | InitialisierungDF>,
            columns = [ GK, PZP, PZM, PY],
            rows = InitialisierungSpalte);
Tabulate(DF1);

print(InitialisierungSpalte);
print(Extend(InitialisierungDF,[oE]));
print(Extend(InitialisierungSpalte,[RMSE]));
InitialisierungDF:=Extend(InitialisierungDF,[oE]);
InitialisierungSpalte:=Extend(InitialisierungSpalte,[RMSE]);  
DF3:= DataFrame( < InitialisierungDF | InitialisierungDF | InitialisierungDF | InitialisierungDF>,
            columns = [ GK, PZP, PZM, PY],
            rows = InitialisierungSpalte);

 

The result is supposed to be a math table of the form

           GK   PZP    PZM   PY

n=1     oE     oE       oE     oE

n=2     oE     oE       oE     oE

...

RMSE  oE    oE      oE       oE

 

I have run into multiple problems, potentially bugs. First, I have to initialize awkwardly with

 

InitialisierungDF:=Vector(nOben-nUnten+1); #Initialisierung des Dataframes für die Tabelle
InitialisierungSpalte:=Vector[row](nOben-nUnten+1);
for i from 1 to nOben-nUnten+1 do
 InitialisierungDF(i):=oE;
 InitialisierungSpalte(i):=n=i;
end do;

 

because InitialisierungDF:=Vector(1..nOben-nUnten+1,oE) doesn't work and produces entries like oE(1) for whatever reason.

Then, creating the data frame DF3 does not work at all with the above mentioned code.

 

InitialisierungDF:=Vector(nOben-nUnten+1); #Initialisierung des Dataframes für die Tabelle
InitialisierungSpalte:=Vector[row](nOben-nUnten+1);
for i from 1 to nOben-nUnten+1 do
 InitialisierungDF(i):=oE;
 InitialisierungSpalte(i):=n=i;
end do;
print(InitialisierungDF);
print(InitialisierungSpalte);
DF1:= DataFrame( < InitialisierungDF | InitialisierungDF | InitialisierungDF | InitialisierungDF>,
            columns = [ GK, PZP, PZM, PY],
            rows = InitialisierungSpalte);  
DF2:= DataFrame( < InitialisierungDF | InitialisierungDF | InitialisierungDF | InitialisierungDF>,
            columns = [ GK, PZP, PZM, PY],
            rows = InitialisierungSpalte);

print(InitialisierungSpalte);
print(Extend(InitialisierungDF,[oE]));
print(Extend(InitialisierungSpalte,[RMSE]));
 
DF3:= DataFrame(<Extend(InitialisierungDF,[oE])|Extend(InitialisierungDF,[oE])|Extend(InitialisierungDF),[oE]|Extend(InitialisierungDF,[oE])>,
            columns = [ GK, PZP, PZM, PY],
            rows = Extend(InitialisierungSpalte,[RMSE]));  


doesn't work either, however, this time a different error occurs. Looking at the vectors the dimensions seem to be correct in each case, though. Any suggestions on how to fix these things?

Good evening,

is it possible to construct a math table with Maple just with Code? Something like

      test_1    test_2

a       9,6        5,6

b     pending  8,4     

to be able to print it? There is

https://de.maplesoft.com/support/help/Maple/view.aspx?path=worksheet/documenting/table            and

https://de.maplesoft.com/support/help/Maple/view.aspx?path=worksheet%2freference%2ftableproperties   

, however, I do not understand how to just get any table going and assign calculated values within a procedure as is possible with a matrix for example. Thank you in advance! :)

3 4 5 6 7 8 9 Last Page 5 of 60