Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

I currently do extensive modeling that involves Monte Carlo simulations. This kind of analysis seems idially suited to parallel computing. To begin the process I have been following the teachings of chapter 15 of the Programming Guide 2023. As a first excersize I copyied the code on pages 583-584 and attempted to run it on my system. My Maple program is a 2019  Student Version running on anHP laptop using Windows11. The code yields an error code "Error, invalid input: add_range uses a 1st argument, lo, which is missing"

This is an exact copy of the ccode in the guide. Is there posibly a probem with my installation? I am willing to update and upgrade as may be needed. Any suuggestions how to procced?

Thanks

Ray

Dear Maple experts

I face an issue in using ‘implicit plot’ or ‘inequal’ commands in the attached file.

I use three Maple procedures to make some simple calculations and draw an output. It is Firm Profit versus ‘alpha’. This graph is correct and makes perfect sense.

Then, I use ‘inequal’ command to compare the same outputs when ‘alpha’ and ‘delta’ change. There is a conflict between these plots and the above diagram. For example, P2 plot says

restartNULL

with(plots); with(RealDomain)

NULL

c := 1; cr := 0.3e-1*c; u := 1; sExp := 0.6e-1*c; s := .65*c; v := 3*cNULL

``

FirmModelPP := proc (alpha, beta, delta) local p0, xi0, q0, Firmpf0, G01, Recpf0, Unsold0, Environ0; xi0 := 1; p0 := min(s+sqrt((v-s)*(c-s)), delta*v+sExp); q0 := u*(v-p0)/(v-s); f(N) := 1/u; F(N) := N/u; G01 := int(F(N), N = 0 .. q0); Firmpf0 := (p0-c)*q0-(p0-s)*G01; Recpf0 := (sExp-cr)*xi0*q0; Unsold0 := G01; Environ0 := q0+Unsold0; return p0, q0, Firmpf0, Recpf0, Environ0, Unsold0 end proc

NULL

NULLNULLNULL

FirmModelFC := proc (alpha, beta, delta) local p00, xi00, q00, Firmpf00, G001, G002, Recpf00, Unsold00, Environ00, pr00; option remember; xi00 := 1; p00 := s+sqrt((v-s)*(c-s)); q00 := alpha*u*(v-p00)/(v-s); f(N) := 1/u; F(N) := N/u; G001 := int(F(N), N = 0 .. q00/alpha); G002 := int(F(N), N = 0 .. beta*xi00*q00/(1-alpha)); pr00 := p00-delta*v; Firmpf00 := (p00-c)*q00-alpha*(p00-s)*G001; Recpf00 := xi00*q00*(sExp-cr)+(pr00-sExp)*(beta*xi00*q00-(1-alpha)*G002); Unsold00 := alpha*G001; Environ00 := q00+Unsold00; return p00, q00, Firmpf00, Recpf00, Environ00, Unsold00 end proc

NULLNULL``

NULLNULL

NULL

FirmModelHmax := proc (alpha, beta, delta) local q, p, pr, FirmpfSiS, F1, G1, G2, G3, RecpfSiS, sol, UnsoldSiS, EnvironSiS, p0, OldSoldPrim, xi, h, ps, qs, prs, prof1m, prof2m; option remember; xi := 1; prs := ps-delta*v; prof1m := (ps-c)*qs+((1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))-(1/2)*(1+beta*xi)^2*qs^2/u)*(ps-s)+(prs-sExp)*(beta*xi*qs-(1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))); prof2m := (ps-c)*qs-(1/2)*(ps-s)*qs^2/(alpha*u)+(prs-sExp)*(beta*xi*qs-(1/2)*beta^2*xi^2*qs^2/(u*(1-alpha))); if alpha <= 1/(1+beta*xi) then p, q := (eval([ps, qs], solve({diff(prof1m, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps, qs < 2*u*(1-alpha)/(beta*xi)}, [ps, qs])[1]))[]; `h&Assign;`*(p-delta*v-sExp)/(p-delta*v); FirmpfSiS := eval(prof1m, [ps = p, qs = q, prs = p-delta*v]); RecpfSiS := (sExp-cr)*xi*q; UnsoldSiS := (1/2)*(1+beta*xi)^2*q^2/u-(1/2)*beta^2*xi^2*q^2/(u*(1-alpha)); EnvironSiS := q+UnsoldSiS else p, q := (eval([ps, qs], solve({diff(prof2m, qs) = 0, qs = alpha*u*(v-ps)/(v-s), c < ps, sExp+delta*v < ps, qs < 2*u*(1-alpha)/(beta*xi)}, [ps, qs])[1]))[]; h := (p-delta*v-sExp)/(p-delta*v); FirmpfSiS := eval(prof2m, [ps = p, qs = q, prs = p-delta*v]); RecpfSiS := (sExp-cr)*xi*q; UnsoldSiS := (1/2)*q^2/(alpha*u); EnvironSiS := q+UnsoldSiS end if; return p, q, FirmpfSiS, RecpfSiS, EnvironSiS, UnsoldSiS, h, OldSoldPrim, xi end proc

``

``

NULL

NULL

``

NULLNULL

NULLNULL

pltPP3A := plot('FirmModelPP(alpha, .35, .40)[3]', alpha = 0. .. 1.0, color = red, legend = "", style = pointline, labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], symbolsize = 10, axes = boxed, symbol = box, numpoints = 10, adaptive = false, thickness = 1.0, view = [0 .. 1, 0 .. .18])

NULL

pltPP3B := plot([[0., eval('FirmModelPP(0., .35, .40)[3]', alpha = 0.)]], color = red, legend = ["PP"], style = point, symbol = box, symbolsize = 10, axes = boxed, view = [0 .. 1, 0 .. .18])

NULL

pltFC3A := plot('FirmModelFC(alpha, .35, .40)[3]', alpha = 0. .. 1, linestyle = [solid], color = black, legend = "FC", labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], axes = boxed, adaptive = false, thickness = .7, view = [0 .. 1.0, 0 .. .18])

NULL

NULLNULLNULLNULLNULL

pltHmax3A := plot('FirmModelHmax(alpha, .35, .40)[3]', alpha = 0. .. 1.0, linestyle = [dashdot], color = brown, legend = [SiS(h__max)], labels = [alpha, "Firm Profit"], labeldirections = ["horizontal", "vertical"], symbolsize = 10, numpoints = 50, adaptive = false, thickness = 1.0, axes = boxed, view = [0 .. 1, 0 .. .19])

``

NULLNULLNULL

display([pltPP3A, pltPP3B, pltFC3A, pltHmax3A])

 

NULL

``

NULL

NULL

NULL

``

NULL

``

NULL

NULL

diffr2 := proc (alpha, delta) if not [alpha, delta]::(list(numeric)) then return ('procname')(args) end if; FirmModelFC(alpha, .35, delta)[3]-FirmModelHmax(alpha, .35, delta)[3] end proc

NULL

P2 := plots:-inequal(diffr2(alpha, delta) <= 0, alpha = 0 .. 1, delta = 0 .. 1, optionsfeasible = [[color = "Spring 1"]])

 

``

NULL

diffr3 := proc (alpha, delta) if not [alpha, delta]::(list(numeric)) then return ('procname')(args) end if; FirmModelHmax(alpha, .35, delta)[3]-FirmModelPP(alpha, .35, delta)[3] end proc

NULL

P3 := plots:-inequal(diffr3(alpha, delta) <= 0, alpha = 0 .. 1, delta = 0 .. 1, colour = "Orange")

 

``

Download ConflcitInequal.mw

SiS is superior to FC in small ‘alpha’s. But in the initial diagram, it is obvious that it should be the opposite!

Perhaps I am making a mistake in using commands. Would you please help me?

I was wondering whether it is possible to execute Python code into Maple. As an example, I give a fairly simple code:

Concentration_calculation(C_0, Q, V_r, m_b, rho, R, Gamma_i, delta_t=1):
t = np.arange(0, 360*60, delta_t)
C_i = [C_0]
for i in range(len(t)-1):
dC = -(Q/V_r)*(1-math.exp(-3*m_b*math.sqrt(Gamma_i/(rho*t[i+1]))/(math.sqrt(math.pi)*Q*R)))*C_i[i]
C_i.append(C_i[i] + dC*delta_t)
return t, C_i

Any help in tis respect would be highly appreciated.

How do I increase the Java Heapsize.

About once a year rarely, I get that maple writes too much output to the worksheet file and then cannot load it again.

In the past I had to hand edit the maple file in emacs to remove output to at least get my source code back.

This is really not practical.

Webwisdom states that the heapsize can be increased by

export JVM_ARGS="-Xms1024m -Xmx1024m"

Dont know why Maple do not have to option to just ignore the results during startup.

Maple22 runs here on a Linux 32-Core server with 256GB memmory.

Question 1) Anyone know how to increase heap size.

Exporting as above dd not work

Question 2) Anyone know how to load a worksheet with all output ignored.

It is the volumous output Maple saves in the file, which it cannot read again which causes the problem.

Files are not corrupt.

Else I have to hand edit the maple output out of the files again like I did before.

Thanks

This is not a critical situation. A solution was developed. However, I am interested in trying to understand and explain to a colleague why their function failed to plot. The colleague often works on problems involving large factorial values.

failed_plot.mw

I have tried to generate a phase-plot of a complex function with maple (phase is the argument).

For example f(z):=gamma(z) or f(z):=zeta(z).

I haven't found.

Another idea is to translate this Matlab-Code to Maple-Code to get this beautyfull coloured plots.

xmin = -0.5;
xmax = 0.5;
ymin = -0.5;
ymax = 0.5;
xres = 400;
yres = 400;
x = linspace(xmin, xmax, xres);
y = linspace(ymin, ymax, yres);
[x, y] = meshgrid(x, y);
z = i*y + x;
f = exp(1./z);
p = surf(real(z), imag(z), 0*f, angle(-f));
set(p, 'EdgeColor', 'none');
caxis([-pi, pi]), colormap*hsv(600)*view(0, 90), axis*equal, axis*off;

How I can solve the error in maple which is ( (in PDEtools:-DeterminingPDE) expected the number of infinitesimals (4) to be equal to the sum of the number of independent (2) and dependent (1) variables; received: 4 <> 2 + 1)

X is a real random matrix of dimension n; its entries are i.i.d. variables.

They follow the standard normal law N(0,1).

I want to write a big sample. For that, I use the following two lines:

roll := RandomVariable(Normal(0, 1))

X := Matrix(n, proc (i, j) options operator, arrow; (Sample(roll))(1)[1] end proc)

Is there a method that does the calculations faster ??

Thanks in advance.

How to plot the second order derivative and first oder derivatives plot in time dependent pde and vector plot of  theta(y,t), u(y,t) at y=0..10 and t=0..1

nowhere i found a vector plot of time-dependent pde 

how to plot give me suggestions.

in vector plots, flow patterns should show with arrow marks

  restart;
  inf:=10:
  pdes:= diff(u(y,t),t)-xi*diff(u(y,t),y)=diff(u(y,t),y$2)/(1+lambda__t)+Gr*theta(y,t)+Gc*C(y,t)-M*u(y,t)-K*u(y,t),
         diff(theta(y,t),t)-xi*diff(theta(y,t),y)=1/Pr*diff(theta(y,t),y$2)+phi*theta(y,t),
         diff(C(y,t),t)-xi*diff(C(y,t),y)=1/Sc*diff(C(y,t),y$2)-delta*C(y,t)+nu*theta(y,t):
  conds:= u(y,0)=0, theta(y,0)=0, C(y,0)=0,
          u(0,t)=0, D[1](theta)(0,t)=-1, D[1](C)(0,t)=-1,
          u(inf,t)=0, theta(inf,t)=0, C(inf,t)=0:
  pars:= { Gr=1, Gc=1, M=1, nu=1, lambda__t=0.5,
           Sc=0.78, delta=0.1, phi=0.5, K=0.5, xi=0.5
         }        

{Gc = 1, Gr = 1, K = .5, M = 1, Sc = .78, delta = .1, nu = 1, phi = .5, xi = .5, lambda__t = .5}

(1)

  PrVals:=[0.71, 1.00, 3.00, 7.00]:
  colors:=[red, green, blue, black]:
  for j from 1 to numelems(PrVals) do
      pars1:=`union`( pars, {Pr=PrVals[j]}):
      pdSol:= pdsolve( eval([pdes], pars1),
                       eval([conds], pars1),
                       numeric
                     );
      plt[j]:=pdSol:-plot( diff(u(y,t),y), y=0, t=0..2, numpoints=200, color=colors[j]);
  od:
  plots:-display( [seq(plt[j], j=1..numelems(PrVals))]);

 

PrVals := [.71, 1.00, 3.00, 7.00]; colors := [red, green, blue, black]; for j to numelems(PrVals) do pars1 := `union`(pars, {Pr = PrVals[j]}); pdSol := pdsolve(eval([pdes], pars1), eval([conds], pars1), numeric); plt[j] := pdSol:-plot(diff(u(y, t), y, y), y = 0, t = 0 .. 2, numpoints = 200, color = colors[j]) end do; plots:-display([seq(plt[j], j = 1 .. numelems(PrVals))])

 
 

 

Download badPDE.mw

I would like to create a database of component information. I have previously done this using a table which is indexed by the part number. Each element is a DataFrame, which includes several items with values and at least 2 DataFrames. The 2 DataFrames are extracted from a Spreadsheet with 2 tabs, that is stored in a Maple Workbook. Each DataFrame has an name for the row and 2 columns; Description and Value. The Description is text and the value is a single value or 3-element list with unit. Such at [9, 10, 11]*~Unit('ohm')

Anyway, I'm wondering if this is the most efficient way. I'm also wondering if there is a way to create such a database so it can be used with other software tools, primarily Mathcad and Excel.

Thanks

The code generting module C writes  result to screen. How to I get it to file?

Dear Users!

I hope everyone is fine here. I have the following functions:

f := cos(t)*sin(x)-sin(x)+(1/2)*sin(x)*t^2-(1/24)*sin(x)*t^4

I want to plot the contour plots with legends like given as (this is the countor plot just for reference):

I want the same coloring to fill the contour plots. Kindly help me to resolve my problem. Thanks in advances

(I would prefer a solution for Maple 2015, but answers relative to newer versions are welcome)

Is there a simple way to force the result -y(1) + y(2) without using one of these two tricks?

# how can I get the expression of
int(diff(y(x), x), x=1..2);
                      / d                  \
                   int|--- y(x), x = 1 .. 2|
                      \ dx                 /

# Trick 1
int(diff(y(x), x), x);
eval(%, x=2)-eval(%, x=1)
                              y(x)
                          -y(1) + y(2)

# Trick 2
J := Int(diff(y(x), x), x = 1..2): 
value(IntegrationTools:-Parts(J, 1));
                          -y(1) + y(2)

TIA

According to the help page for optimize

"The optimize function makes use of Maple's option remember facility to identify common subexpressions in linear time and space. This means, however, that only those subexpressions which Maple has simplified to be identical are found. For example, the expression 
                            "x + y"

 is not recognized as being common to  
                          "x + y + z"

. That is, optimize performs mainly "syntactic" optimizations."

Is there a way to more efficiently calculate a set of expressions that have common factors as in the example above?

First 161 162 163 164 165 166 167 Last Page 163 of 2217