MaplePrimes Questions

I'm trying to make a table of values as a data table.  The problem is that it's making more rows than loops, I'm not able to make an empty DataFrame, and that I have to add an extra row to align the values, so I need to remove a row, and change the indexes.  Any help with making data tables work properly, would be greatly appreciated.

```

newt := x -> evalf(x - f(x)/D(f)(x));

f:= x -> x^6-2; # function to analyze

rt[0] := 1.5; #x0 value


n_error[0]:=1.5-newt(1.5): #error of first estimate
     

DF := DataFrame( <x|n_error>):# create a dataframe to store estimates, and error rates
for count from 0 to 10 do; nerror[count]:=abs(x[count]-x[count-1]);    rt[count]:=x[count-1];
x[count + 1] := newt(x[count]); DF:=Append(DF,DataSeries(<rt[count]|nerror[count]>),mode=row);    
end do:

NewtonData:=DataFrame(Remove( DF, 2, mode=row)):
NewtonData


```

In the below paper 

ODEs are solved by using Matlab Software

Is it possible to solve this in Matlab software?  [I think you mean Maple!--Carl Love]

I have attached the Article

j.physa.2019.123959.pdf

I am trying to run a Groebner Basis computation below in a for loop a few times to get an average running time.

start := time[real]():
gb := Groebner[Basis](polynomials, tdeg(op(vars)), characteristic=2^29-3):
finish := time[real]() - start:

Because Maple apparently caches the result, i was wondering if there is a way to undo this caching? Or better yet, is there a built-in tool taht would do this time measurement multiple times?

I am trying use convert(46,ordinal) to generate ordinals such as 46th. However the command produces "46th". How may I remover the double quotes so that I get 46th? I've tried using parse but it often generates an error.

I have the following link with data that I want to import to Maple and plot... any ideas how I can do that? Thanks.

https://www.gw-openscience.org/GW150914data/P150914/fig1-observed-H.txt

restart;
N := 10;
h := 0.1e-1;
print(??); # input placeholder
r := 0.2e-1;
for n to 10 do xn := sin(h*n) end do;
print(`output redirected...`); # input placeholder
                         0.009999833334
                         0.01999866669
                         0.02999550020
                         0.03998933419
                         0.04997916927
                         0.05996400648
                         0.06994284734
                         0.07991469397
                         0.08987854920
                         0.09983341665


for m to 10 do ym := cos(r*m) end do;
print(`output redirected...`); # input placeholder
                          0.9998000067
                          0.9992001067
                          0.9982005399
                          0.9968017063
                          0.9950041653
                          0.9928086359
                          0.9902159962
                          0.9872272834
                          0.9838436928
                          0.9800665778
eq := sum(sin(xn)*ym^5*u(x) = y, x = 1 .. 10);
print(`output redirected...`); # input placeholder
0.09012228112 u(1) + 0.09012228112 u(2) + 0.09012228112 u(3)

   + 0.09012228112 u(4) + 0.09012228112 u(5) + 0.09012228112 u(6)

   + 0.09012228112 u(7) + 0.09012228112 u(8) + 0.09012228112 u(9)

   + 0.09012228112 u(10) = 10. y
 

I do not know what the mistake is, help to solve please

 

I have a piece of code that solves a differential equation numerically and plots the solution, but I also want to store my values for the solution so that I can later call them easily. I want to be able to save my values for xphi for all t from 0 to 11 - not necessarily with the same variable name, it could be some k(t) - so that later when I type eg k(10) Maple gives me the value of xphi at t=10. I assume the code only requires a slight modification, but still I haven't been able to find a way to do this. Here is the corresponding piece of code. Thank you in advance.

xodephi := {diff(x(t), t) = 16250.25391*(1 - (487*x(t))/168 + 4*Pi*x(t)^(3/2) + (274229*x(t)^2)/72576 - (254*Pi*x(t)^(5/2))/21 + (119.6109573 - (856*ln(16*x(t)))/105)*x(t)^3 + (30295*Pi*x(t)^(7/2))/1728 + (7.617741607 - 23.53000000*ln(x(t)))*x(t)^4 + (535.2001594 - 102.446*ln(x(t)))*x(t)^(9/2) + (413.8828821 + 323.5521650*ln(x(t)))*x(t)^5 + (1533.899179 - 390.2690000*ln(x(t)))*x(t)^(11/2) + (2082.250556 + 423.6762500*ln(x(t)) + 33.2307*ln(x(t)^2))*x(t)^6)*x(t)^5, diff(xphi(t), t) = 5078.204347*x(t)^(3/2), x(0) = 0.03369973351, xphi(0) = a}:  #xphi(10.92469316) = 0}:

sol := dsolve(xodephi, parameters=[a], numeric):

ff:=proc(A)
  sol(parameters=[A]);
  eval(xphi(t), sol(10.92469316))
end:

A:=fsolve(ff);
sol(parameters=[A]);
sol(10.92469316);

-467.1843838

 

[a = -467.1843838]

 

[t = 10.92469316, x(t) = HFloat(0.061040830524973895), xphi(t) = HFloat(1.6909911249030074e-9)]

(1)

plots:-odeplot(sol, [t,xphi(t)], t=0..11);

 

plots:-odeplot(sol, [t,x(t)], t=0..11);

 

 

 

restart;
with(plots);
with(plottools);
k := disk([0, 0], 3, color = white)

k1 := polygon([[0, 0], [3, 4], [3, 1]])
display({k, k1});
Error, (in plots:-display) expecting plot structures but received: {k1}
 

Dear people in mapleprims,

I haven't used maple for a long time.
By the way, I tried to modify a denominator part in an fractional expression, but I couldn't.

Original expression is 

a:=-(I__22-X__2)/(I__11*I__22-I__11*X__2-I__12*I__21-I__22*X__1+X__1*X__2);

#And, I want to change this to the form

b:=(X__2-I__22)/((x__1-I__11)*(X__2-I__22)-I__12*I__21);

How can I do this?

Thank you in advance.

taro yamada

 

Hi,

how to display the primitive in the form f^n/n . ith the command int, the response is always developed. ( i try different commands "factor",...without results) 

Thanks

QuestionInt.mw

This seems like a serious limitation of Maple module, unless I am missing something.

I am trying to refactor one of my module, putting some code in separate .mpl file, say B.mpl,  and then do, from the main module

   $include  "B.mpl"; 

 But Maple complain now that, since B.mpl has export in it, that I can't do that. 

But the code inside B.mpl works fine if I copy it back and paste it inside the module, in the same location where the $include  "B.mpl";  is

Here is an example. (Since I can't use $include  "B.mpl";  in worksheet, Maple does not like it, I replaced it in this example by read "B.mpl";

(btw, both the syntax  module A()   and A:=module() seem to be equivalent), the problem shows up with either form)

I also tried with ";" and witout ";" at the end of the $include , it still gives same error.

 

restart;

currentdir("....."); #set directory to where the folder is


module A()

read "B.mpl";

 export foo:=proc()
  0;
 end proc;
end module;

Where the file B.mpl is

export boo:=proc()
return 0;
end proc; 

How is one supposed to refactor long file to separate files if can't leave export on those proc's?  

If I put everything in one .mpl file, it works

module A()

#read "B.mpl";  

export boo:=proc()  #this proc was in B.mpl
return 0;
end proc; 

 export foo:=proc()
  0;
 end proc;
end module;

I did more testing, and found that this seems to be an issue in Maple 2020.2. Because I just tried the same thing in Maple 2019 and it worked there ! i.e. no error.

Any one knows what is going on? 

Maple 2020.2, Physics 884.   Windows 10.

Here is screen shot. Same code. Works OK in Maple 2019.2 but gives error in 2020.2

 

 

 

Hi,

How do I integrate with Units[Standard]?

For example:


 

restart

with(Units[Standard]):

I__RMS__T := int((18*Unit('A')+9*t*Unit('s')*Unit('A')/(.9*Unit('s')))^2, t = 0.1e-1*Unit('s') .. 10*Unit('s'))

Error, (in Units:-Standard:-+) the units `1` and `s` have incompatible dimensions

 

I__RMS__T := int((18*Unit('A')+9*t*Unit('A')/(.9*Unit('s')))^2, t = 0.1e-1*Unit('s') .. 10*Unit('s'))

Error, (in Units:-Standard:-+) the units `A` and `A/s` have incompatible dimensions

 

 

 

It doesn't seem like I can around this. Is there a way to ignore the units error and just calculate the value?
 

Download test.mw

What type of mathematics can perform the type of transformation seen in the uploaded worksheet?

Could it be done with the Maple plottools transform command?

Could it be a projective transformation using homogeneous coordinates?

Could it be a complex conformal transformation?

Transformation.mw

Hi, I would like to parallelize the double for loop. I am computing pairwise SPolynomials like so

for i from 1 to n-1 do

for j from i+1 to ndo

spol:=Spol(poly[i],poly[j], tdeg(op(vars))):

...

od:

od: 

I would like to parallelize this code, here is what I have done:

at_node:=proc(p1,p2,vars, polynomials)

spol:=SPolynomial(p1,p2,tdeg(op(vars))):

if NormalForm(spol, polynomials, tdeg(op(vars)))=0

return [1,0]:

fi:

end proc:

Grid[Setup]("local", num_nodes=4):

Grid[Set](at_node): # below is the main loop that fails

for idx from 1 to n-1 do

out:=Grid[Seq](at_node(polynomials[idx], polynomials[j], vars, polynomials) j=idx+1, n):

od:

The loop above fails due to the error when calling normal form. It seems that the at_node function accepts an incorrect input for p1, a list of polynomials instead of a single polynomial. Is there a way to parallelize double for-loop with Grid like that? I am not sure where my error is.

 

 

 

 

 

 

Hi!

I have the following code to calculate the optimal quadrature rule with preassigned nodes (within a list), while the number of nodes that are to be added is n. The calculated quadrature rule is then used to approximate an integral.

 

restart;
with(LinearAlgebra):     
with(ListTools):
with(PolynomialTools):
Erweiterung:= proc(Unten, Oben, f,g,Liste,n)::real;
  #Unten:= Untere Intervallgrenze; Oben:= Obere Intervallgrenze; f:= zu integrierende Funktion;
  #G:= Gewicht; Liste:= Liste der alten Knoten, n:= Anzahl hinzuzufügender Knoten;
  local Basenwechsel,p,i,c,d,e,Hn,Koeffizienten,a,s,j,M,V,S,K,nNeu,Em,Hnm,KnotenHnm,KoeffizientenHnm,h0,b,gxi,Gewichte,Delta,Ergebnis,Endergebnis,Koeffizient,Rest;
  uses LinearAlgebra, ListTools;
  Basenwechsel1:=proc(Dividend, m)::list; #stellt ein gegebenes Polynom über eine Linearkombination der orthogonalen Polynomen dar.
   local Basenwechsel;
 
  Koeffizient:=quo(Dividend, p[m],x);

  Rest:=rem(Dividend, p[m],x);
 
  if m=0 then
    Basenwechsel:=[Koeffizient*evalf(int(g*p[m]^2,x=Unten..Oben))];
  else

    Basenwechsel:=[Koeffizient*evalf(int(g*p[m]^2,x=Unten..Oben)),op(procname(Rest,m-1))];
   
  end if;
 
  end proc;
  Basenwechsel2:=proc(Dividend, m)::list; #stellt ein gegebenes Polynom über eine Linearkombination der orthogonalen Polynomen dar.
   local Basenwechsel;
 
  Koeffizient:=quo(Dividend, p[m],x);

  Rest:=rem(Dividend, p[m],x);
 
  if m=0 then
    Basenwechsel:=[Koeffizient];
  else

    Basenwechsel:=[Koeffizient,op(procname(Rest,m-1))];
   
  end if;
 
  end proc;
p[-1]:=0;
p[0]:=1;
for i from 1 to (numelems(Liste)+n)*2 do
  p[i]:=(x^i-add(evalf(int(x^i*p[j]*g,x=Unten..Oben))*p[j]/evalf(int(p[j]^2*g,x=Unten..Oben)),j=0..i-1)); #Berechnung einer Folge orthogonaler Polynome bezüglich der gegebenen Gewichtsfunktion und des gegebenes Intervalles
  pprint(p[i]);
c[i-1]:=coeff(p[i],x,i)/coeff(p[i-1],x,i-1); #Berechnung der dreigliedrigen Rekursion der errechneten orthogonalen Polynome
d[i-1]:=(coeff(p[i],x,(i-1))-c[i-1]*coeff(p[i-1],x,(i-2)))/coeff(p[i-1],x,(i-1));
if i <> 1 then
  e[i-1]:=coeff(p[i]-(c[i-1]*x+d[i-1])*p[i-1],x,i-2)/coeff(p[i-2],x,i-2);
else
  e[i-1]:=0;
end if;
end do;
pprint(Liste[1],numelems(Liste));
Hn:=mul(x-Liste[i],i=1..numelems(Liste));
pprint(Hn);
 Koeffizienten:=FromCoefficientList(Basenwechsel1(Hn,numelems(Liste)+1),x,termorder=reverse); #Die Koeffizienten der orthogonalen Polynome werden hier als Koeffizienten der Monome gespeichert.
pprint(Koeffizienten,HIER);

pprint(c,d,e);
a[0][0]:=1; #Beginn der Berechnung der orthogonalen Produkterweiterungen, die Koeffizienten der orthogonalen Polynome werden wieder über die Monome gespeichert (2*x^2+2 bedeutet bspw. [2,0,2,0,0...] für die Koeffizienten)
a[1][0]:=x;
a[1][1]:=-e[1]*c[0]/c[1]+(d[0]-d[1]*c[0]/c[1])*x+c[0]/c[1]*x^2;
for s from 2 to numelems(Liste)+n do
  a[s][0]:=x^s;
  a[s][1]:=-e[s]*c[0]/c[s]*x^(s-1)+(d[0]-d[s]*c[0]/c[s])*x^s+c[0]/c[s]*x^(s+1);
    pprint (coeff(a[s][1],x,s),as1s);
end do;
for s from 2 to numelems(Liste)+n do
  for j from 2 to s do
    
      pprint(c[j-1]*sum(coeff(a[s][j-1],x,k-1)/c[k-1]*x^k,k=abs(s-j)+2..s+j));  pprint(sum((d[j-1]-c[j-1]*d[k]/c[k])*coeff(a[s][j-1],x,k)*x^k,k=abs(s-j)+1..s+j-1));  pprint(c[j-1]*sum(e[k+1]*coeff(a[s][j-1],x,k+1)/c[k+1]*x^k,k=abs(s-j)..s+j-2));pprint(e[j-1]*sum(coeff(a[s][j-2],x,k)*x^k,k=s-j+2..s+j-2));

     a[s][j]:=c[j-1]*sum(coeff(a[s][j-1],x,k-1)/c[k-1]*x^k,k=abs(s-j)+2..s+j)+sum((d[j-1]-c[j-1]*d[k]/c[k])*coeff(a[s][j-1],x,k)*x^k,k=abs(s-j)+1..s+j-1)-c[j-1]*sum(e[k+1]*coeff(a[s][j-1],x,k+1)/c[k+1]*x^k,k=abs(s-j)..s+j-2)+e[j-1]*sum(coeff(a[s][j-2],x,k)*x^k,k=abs(s-j)+2..s+j-2);

      
   
    
  end do;
end do;
for s from 0 to numelems(Liste)+n do
  for j from 0 to s do
    pprint(a[s][j], Polynom[s][j]);
  end do;
end do;
M:=Matrix(n,n); #Beginn der Erstellung eines linearen Gleichungssystems, dessen Lösung die Koeffizienten der orthogonalen Polynome sind, deren Summe Em die hinzuzufügenden Knoten als Nullstellen hat.
V:=Vector(n);
 
  for s from 0 to n-1 do
    for j from 0 to s do
      M(s+1,j+1):=sum(coeff(a[s][j],x,k)*coeff(Koeffizienten,x,k),k=0..n);
      if s<>j then
        M(j+1,s+1):=M(s+1,j+1);
      end if;
      pprint(M,1);
    end do;
    pprint(testb1);pprint(coeff(a[n][s],x,2));pprint(coeff(Koeffizienten,x,2));
    pprint(testb2); pprint(Koeffizienten);
    M(s+1,n+1):=sum(coeff(a[n][s],x,k)*coeff(Koeffizienten,x,k),k=0..n);
    
    pprint(M,V);
  end do;
pprint(M,V);
S:=LinearSolve(M,V);
K:=evalindets(S,name,()->2);
pprint(K,LinSolve);

Em:=add(p[i]*K[i+1],i=0..n); #Erstellen von Em, dessen Nullstellen die hinzuzufügenden Knoten sind
Hnm:=Hn*Em; #Erstellen von Hnm, welches alle Knoten als Nullstelle besitzt
KnotenHnm:=fsolve(Hnm,complex); #Knotenberechnung

 


   
pprint(Hn,alt,Em,neu,Hnm);
pprint(Testergebnis,nNeu);
pprint(fsolve(Hnm),fsolve(nNeu));
KoeffizientenHnm:=Reverse(Basenwechsel2(Hnm,n+numelems(Liste)));  #Das Polynom Hnm wird über die orthogonalen Polynome dargestellt.
pprint(KoeffizientenHnm);
h0:=int(g,x=Unten..Oben); #Beginn der Berechnung der Gewichte
 pprint(h0,HO);
b[n+numelems(Liste)+2]:=0;
b[n+numelems(Liste)+1]:=0;
  for i from 1 to nops([KnotenHnm]) do
    for j from n+numelems(Liste) by -1 to 1 do
      pprint(test21,KnotenHnm,Hnm);
      b[j]:=KoeffizientenHnm[j+1]+(d[j]+KnotenHnm[i]*c[j])*b[j+1]+e[j+1]*b[j+2];
      pprint(b[j]);
    end do;
    pprint(test23);
    gxi:=quo(Hnm,x-KnotenHnm[i],x);
   pprint(gxi);
    Gewichte[i]:=c[0]*b[1]*h0/eval(gxi,x=KnotenHnm[i]);
    pprint(b);
   
    Delta[i]:=c[0]*b[1];
  end do;
print(DieKnoten,KnotenHnm);
print(DieGewichte, Gewichte);
Ergebnis:=add(eval(f,x=KnotenHnm[k])*Gewichte[k],k=1..nops([KnotenHnm]));
Endergebnis:=evalf(Ergebnis)
end proc


The problem is that the code takes very, very long to run if the weight function is not a polynomial.

Erweiterung(-1,1,2*x^2+2,1,[-0.906179845938664],4)

for example, is done immediately (1, the 4th entry, being the weight function), while

Erweiterung(-1,1,2*x^2+2,2/sqrt(1-x^2),[-.8660254037, 0, .8660254037],4)


takes ages to finish. Is there a tool for me to see what exactly is taking Maple so long? Is there an easy fix, such as evalf()'ing key calculations (other than using (2*x^2+2)*2/sqrt(1-x^2) as the integrand and 1 as the weight function, since the quadrature rules I am looking at are supposed to be good with certain weird weight functions)? Thank you in advance!

First 469 470 471 472 473 474 475 Last Page 471 of 2428