nm

10229 Reputation

19 Badges

12 years, 150 days

MaplePrimes Activity


These are answers submitted by nm

which then uses the value of the variable in the saved filename

Maple automatically converts integer to string when conctentating. I found this myself by accident sometime ago.  i.e. there is no need to do special conversion of variable to string, which simplifies the code.

So all you have to do it

file_name:=cat("my_file_",0,"_",200,".txt")

Or

n:=99;
file_name:=cat("my_file_",n,"_",n+1,".txt")

or

for n from 1 to 5 do
    file_name:=cat("my_file_",n,".txt");
od;

Now you can use the file_name for creating file with that name.

but have received the root of.

You can't hope to remove RootOf of this as it stands. 

But you could evaluate the solution for specific numerical values of your parameters A,Br, beta, k, m and then solve numerically.

Something like this

lambda[0] := k/(k + 1):

P := -6*x*((x - 1)^4*(A + (-1/3 - (4*Br)/21)*m)*k^8 - 4*(((A*beta + (15*Br*m)/56)*lambda[0]^3 + (-(9*A*beta)/5 - (15*Br*m)/28)*lambda[0]^2 + (4*A*beta*lambda[0])/3 + (-(7*beta)/18 + 5)*A - 20*(Br + 7/4)*m/21)*x + (-2*A*beta - (15*Br*m)/28)*lambda[0]^3 + ((18*A*beta)/5 + (15*Br*m)/14)*lambda[0]^2 - (8*A*beta*lambda[0])/3 + (7*A*beta)/9)*(x - 1)^3*k^7/5 + (12*(x - 1)^2*(((A*beta + (15*Br*m)/56)*lambda[0]^3 + (-(9*A*beta)/5 - (5*Br*m)/7)*lambda[0]^2 + (4*A*beta*lambda[0])/3 + (-(14*beta)/27 + 5/2)*A - 10*(Br + 7/4)*m/21)*x^2 + ((-A*beta - (15*Br*m)/56)*lambda[0]^3 + ((9*A*beta)/5 + (15*Br*m)/14)*lambda[0]^2 - (4*A*beta*lambda[0])/3 + (7*A*beta)/9)*x + (-(4*A*beta)/3 - (5*Br*m)/14)*lambda[0]^3 + ((12*A*beta)/5 + (5*Br*m)/28)*lambda[0]^2 - (16*A*beta*lambda[0])/9 + (7*A*beta)/54)*k^6)/5 - 12*(((A*beta + (5*Br*m)/28)*lambda[0]^3 + (-(9*A*beta)/5 - (15*Br*m)/14)*lambda[0]^2 + (8*A*beta*lambda[0])/9 + (-(7*beta)/9 + 5/3)*A - 20*(Br + 7/4)*m/63)*x^3 + (5/14*m*Br*lambda[0]^3 + 15/14*Br*m*lambda[0]^2 + 16/9*A*beta*lambda[0] + 7/9*A*beta)*x^2 + ((-A*beta - (45*Br*m)/56)*lambda[0]^3 + ((9*A*beta)/5 + (15*Br*m)/28)*lambda[0]^2 - 4*A*beta*lambda[0] + (7*A*beta)/18)*x - 2*lambda[0]*((A*beta + (5*Br*m)/56)*lambda[0]^2 - (9*A*beta*lambda[0])/5 + (4*A*beta)/9))*(x - 1)*k^5/5 + ((((4*A*beta)/5 - (3*Br*m)/7)*lambda[0]^3 + (-(72*A*beta)/25 - (12*Br*m)/7)*lambda[0]^2 - (32*A*beta*lambda[0])/15 + (1 - (56*beta)/45)*A - 4*(Br + 7/4)*m/21)*x^4 + (((15*Br*m)/7 + (4*A*beta)/5)*lambda[0]^3 + ((6*Br*m)/7 + (144*A*beta)/25)*lambda[0]^2 + (32*A*beta*lambda[0])/3 + (28*A*beta)/45)*x^3 + ((-(15*Br*m)/14 + (4*A*beta)/5)*lambda[0]^3 + (-(396*A*beta)/25 + (9*Br*m)/7)*lambda[0]^2 - (16*A*beta*lambda[0])/3 + (14*A*beta)/15)*x^2 + 4*((-(75*Br*m)/56 + A*beta)*lambda[0]^2 + (81*A*beta*lambda[0])/5 - (20*A*beta)/3)*lambda[0]*x/5 - (32*A*lambda[0]^2*(-27/40 + lambda[0])*beta)/5)*k^4 + ((((4*A*beta)/5 + (9*Br*m)/14)*lambda[0]^3 + ((3*Br*m)/7 + (108*A*beta)/25)*lambda[0]^2 + (16*A*beta*lambda[0])/5 + (14*A*beta)/45)*x^4 + ((-4*A*beta - (9*Br*m)/14)*lambda[0]^3 + (-(324*A*beta)/25 + (3*Br*m)/7)*lambda[0]^2 - (16*A*beta*lambda[0])/5 + (14*A*beta)/45)*x^3 + 8*lambda[0]*((A*beta - (3*Br*m)/28)*lambda[0]^2 + (27*A*beta*lambda[0])/25 - (8*A*beta)/15)*x^2 - 8*A*lambda[0]^2*(lambda[0] - 27/25)*beta*x - (16*A*beta*lambda[0]^3)/5)*k^3 - (12*x*lambda[0]*(((A*beta + (5*Br*m)/56)*lambda[0]^2 + (9*A*beta*lambda[0])/5 + (4*A*beta)/9)*x^3 + ((-3*A*beta + (5*Br*m)/56)*lambda[0]^2 - (9*A*beta*lambda[0])/5 + (4*A*beta)/9)*x^2 + 2*A*lambda[0]*(lambda[0] - 6/5)*beta*x + 2*A*beta*lambda[0]^2)*k^2)/5 + (12*x^2*A*((lambda[0] + 3/5)*x^2 + (-lambda[0] + 3/5)*x - (4*lambda[0])/3)*lambda[0]^2*beta*k)/5 - (4*A*x^3*beta*lambda[0]^3*(x + 1))/5)*(x - 1)*(k - 1)/(k^4*(k + 1)*((x - 1)*k - x)^6):

Pre_prime := diff(P, x):

critical_points := solve(Pre_prime = 0, x, real):

sol:=expand(eval(Pre_prime,[A=1,Br=2, beta=3, k=4, m=5]));

-(819872388/21875)*x^2/(3*x-4)^6+(338029344/21875)*x/(3*x-4)^6+(87875118/21875)*x^5/(3*x-4)^6-(89829324/4375)*x^4/(3*x-4)^6+(885207852/21875)*x^3/(3*x-4)^6-(41842368/21875)/(3*x-4)^6+(4919234328/21875)*x^3/(3*x-4)^7-(3042264096/21875)*x^2/(3*x-4)^7-(263625354/21875)*x^6/(3*x-4)^7+(1616927832/21875)*x^5/(3*x-4)^7-(3983435334/21875)*x^4/(3*x-4)^7+(753162624/21875)*x/(3*x-4)^7

solve(sol=0,x);

RootOf(4556250*_Z^5-26043039*_Z^4+60067458*_Z^3-69517416*_Z^2+40248992*_Z-9298304, index = 1), RootOf(4556250*_Z^5-26043039*_Z^4+60067458*_Z^3-69517416*_Z^2+40248992*_Z-9298304, index = 2), RootOf(4556250*_Z^5-26043039*_Z^4+60067458*_Z^3-69517416*_Z^2+40248992*_Z-9298304, index = 3), RootOf(4556250*_Z^5-26043039*_Z^4+60067458*_Z^3-69517416*_Z^2+40248992*_Z-9298304, index = 4), RootOf(4556250*_Z^5-26043039*_Z^4+60067458*_Z^3-69517416*_Z^2+40248992*_Z-9298304, index = 5)

map(X->evalf(X),[%])

[.8354684271, 1.053165735+.2330961086*I, 1.387046718+.4189727818*I, 1.387046718-.4189727818*I, 1.053165735-.2330961086*I]

 

 

Download remove_rootof_numerically_nov_9_2024.mw

I tried converting an outupt to a string which removed all the backslashes in the file path. Maybe there is a dedicated command that I overlooked.

Here is a proc that removes the user name from libname. You can test more to see if it works for you

restart;

clean_my_libname:=proc(the_libname::list)
local item::string;
local n::integer,m::integer;
local new_libname::list:=[];

for item in the_libname do
   n:=StringTools:-Search("\\Users",item);
   m:=StringTools:-Search("\\maple\\toolbox",item);
   if n<>0 and m<>0 then
      cat(item[1..n+5],item[m..]);
      new_libname:=[ op(new_libname), %];
   else      
      new_libname:=[ op(new_libname), item];
   fi;
od;
op(new_libname);
end proc:

my_new_libname:= clean_my_libname([libname]);

"C:\Users\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

libname

"C:\Users\Owner\maple\toolbox\2024\Physics Updates\lib", "C:\Program Files\Maple 2024\lib"

 


 

Download clean_libname.mw

on my PC, windows 10, Maple 2024.2 has maple.mla of size 268 MB.

You can sort its content by size of each m file inside the mla. This is result of first top 10 entries by size

The 4th column, according to help under LibraryTools:-ShowContents  is the size in bytes of the m file.

Here is worksheet which displays all entries in Maple.mla sort by size.

interface(version);

`Standard Worksheet Interface, Maple 2024.2, Windows 10, October 29 2024 Build ID 1872373`

restart;

library := FileTools:-JoinPath(["lib", "maple.mla"], base=mapledir):

the_content:=LibraryTools:-ShowContents(library):

#sort by large size to small size
the_content:=ArrayTools:-SortBy( convert(the_content,Matrix) ,'column', 4,'descending', 'inplace' ):
the_content[1..10];

Matrix(10, 4, {(1, 1) = "evalf/int/GaussLaguerreQuadratureTable.m", (1, 2) = [2024, 3, 1, 8, 35, 48], (1, 3) = 154783114, (1, 4) = 2376962, (2, 1) = "casesplit/K.m", (2, 2) = [2024, 3, 1, 8, 30, 34], (2, 3) = 57860403, (2, 4) = 159362, (3, 1) = "subtype.m", (3, 2) = [2024, 3, 1, 8, 52, 29], (3, 3) = 62029141, (3, 4) = 139356, (4, 1) = "RegularChains.m", (4, 2) = [2024, 3, 1, 8, 31, 30], (4, 3) = 173035257, (4, 4) = 100337, (5, 1) = "inttrans/mellin/bessel/table.m", (5, 2) = [2024, 3, 1, 8, 49, 53], (5, 3) = 60561441, (5, 4) = 88741, (6, 1) = "context/defaultconfig.m", (6, 2) = [2024, 3, 1, 8, 49, 23], (6, 3) = 25630911, (6, 4) = 77254, (7, 1) = "ifactor/PollardP1/tree.m", (7, 2) = [2024, 3, 1, 8, 26, 13], (7, 3) = 83287450, (7, 4) = 74717, (8, 1) = "inttrans/invmellin/bessel/table.m", (8, 2) = [2024, 3, 1, 8, 49, 47], (8, 3) = 138871406, (8, 4) = 68185, (9, 1) = "evalf/int/GaussLegendreQuadratureTable.m", (9, 2) = [2024, 3, 1, 8, 35, 48], (9, 3) = 139687979, (9, 4) = 60871, (10, 1) = "convert/Sum/from.m", (10, 2) = [2024, 3, 1, 8, 33, 51], (10, 3) = 80273108, (10, 4) = 57302})

the_table :=Array(1..0):
the_table ,= ["m file name","size in bytes (4th column)","cummulative size in bytes"]:
total_size := 0:
for N from 1 to  LinearAlgebra:-RowDimension(the_content) do    
    current_size:=the_content[N,4]:
    total_size:= total_size+current_size:
    the_table ,= [the_content[N,1],current_size,total_size]:
    if N>20 then #remove this check to see all, as table becomes too large to show
       break;
    fi;
od:
the_table:=convert(the_table,listlist):
DocumentTools:-Tabulate(the_table,width=40,weights = [2, 1, 1]);

"Tabulate1"

 


Download lib_size_nov_5_2024.mw

Updated to add 2 columns , exact and approx solutions. ps also changed x values list. Note at x=1 we have division by zero in exact solution.

restart;

exact_sol:=1/(1-x);
approx_sol:=1 + x + 37/60*x^5 + 2/3*x^4 + 1/3*x^3 + x^2 + 2351/7560*x^9 + 781/1680*x^8 + 101/210*x^7 + 53/120*x^6 + 1/7*x^10 + 1091/23100*x^11 + 11/15600*x^13 + 11/1200*x^12;

1/(1-x)

1+x+(37/60)*x^5+(2/3)*x^4+(1/3)*x^3+x^2+(2351/7560)*x^9+(781/1680)*x^8+(101/210)*x^7+(53/120)*x^6+(1/7)*x^10+(1091/23100)*x^11+(11/15600)*x^13+(11/1200)*x^12

the_table :=Array(1..0):
the_table ,= [x,"exact solution", "approximate solution","Abs Error","Relative Error"]:
data:=[seq(i,i=0..1,0.1)];
for item in data do
    current_exact_sol:=evalf(eval(exact_sol,x=item));
    current_approx_sol:=evalf(eval(approx_sol,x=item));
    current_error := abs(current_exact_sol-current_approx_sol);
    current_relative_error := current_error/current_exact_sol;
    the_table ,= [item,current_exact_sol,current_approx_sol,current_error ,current_relative_error]:
od:
the_table:=convert(the_table,listlist):
DocumentTools:-Tabulate(the_table,width=60):

[0, .1, .2, .3, .4, .5, .6, .7, .8, .9, 1.0]


Download error_table_nov_5_2024.mw

igcd(45,63)

     9

So it is (A)

 is there a way to generate solutions to an ODE by producing specific parameters?

May be I am not answering the correct question. Why not do something similar to you question How-I-Can-Give-Assumption-To-A-ODE-Equation  where you setup the values in list and iterate over them?

btw, I assumed m->1^{-} means limit as m->1 from left.   some of these values when substituted into the ode and m is replaced by 1, give same ode!. You can add more parameters as needed.

restart;

data:=[ [P=m^2,Q=-(1+m^2),R=1],
        [P=1,Q=-(1+m^2),R=m^2],
        [P=-m^2,Q=2*m^2-1,R=1-m^2],
        [P=1,Q=2*m^2-1,R=-m^2*(1-m^2)],
        [P=1/4,Q=(m^2-2)/2,R=m^2/4],
        [P=m^2/4,Q=(m^2-2)/2,R=m^2/4]
        ]:
the_result :=Array(1..0):
the_result ,= [P,Q,R,"current ode","solution"]:
ode:=diff(F(xi),xi)^2=P*F(xi)^4+Q*F(xi)^2+R:
for item in data do
    current_ode:=limit(eval(ode,item),m=1,'left'):
    sol:=[dsolve(current_ode)]:
    the_result ,= [rhs(item[1]),rhs(item[2]),rhs(item[3]),current_ode,sol]:        
od:
the_result:=convert(the_result,listlist):
DocumentTools:-Tabulate(the_result,weights=[10,20,20,45,45],width=60):


 

Download ode_answer_oct_26_2024.mw


 

interface(version);

`Standard Worksheet Interface, Maple 2024.1, Windows 10, June 25 2024 Build ID 1835466`

data:=[[A,B],[0,B],[A,0],[0,0]]:
the_result :=Array(1..0):
ode:=diff(G(xi),xi)=G(xi)^2+A*G(xi)+B:
the_result ,= ["A","B","solution"]:

for item in data do
    eval(ode,[A=item[1],B=item[2]]):
    sol:=dsolve(%):
    the_result ,= [item[1],item[2],sol]:
od:
the_result:=convert(the_result,listlist):
DocumentTools:-Tabulate(the_result,weights=[10,10,100],width=30):
 

Download dsolve_oct_25_2024.mw