Maple Questions and Posts

These are Posts and Questions associated with the product, Maple

In my expresions I have an integer, nx, which actually has values of only +1 and -1 but I do not specify which.

THe results come out as powers of nx, say nx^n, where n is a positive integer.

How do I reduce the expression nx^n,= 1 for n even and nx^n,= nx for n odd?

I have the following system

pendsys := { diff(x(t),t) = a * x(t) + y(t), diff(y(t),t) = -x(t) + a * y(t) }:

with critical point being (0,0). After plotting the phase portrait, I found out that (0,0) is (asymptotically) stable when a<0 and unstable when a>0. Also, (0,0) is a center when a = 0. Also, as initial condition, I have x(0)=0, y(0)=1. I was thinking we have Hopf bifurcation at a = 0. My question is, how do I plot the bifurcation diagram for this system?

 

tes_A.mwtes_A.mw

Maple 2018.2.1, using Physicsupdates 266.

I undertsand method=Fourier needs boundary conditions to work, but I do not think this error message is right. Compare

 

restart;
pde := diff(u(r, theta), r, r)+diff(u(r, theta), theta, theta) = 0;
iv := u(2, theta) = 3*sin(2*theta)+1;
pdsolve([pde,iv], u(r,theta), method = Fourier)

With

restart;
pde := diff(u(r, theta), r, r)+diff(u(r, theta), theta, theta) = 0;
pdsolve(pde, u(r,theta), method = Fourier)

Error, (in pdsolve/info) wrong extra arguments: {method = Fourier}
 

pdsolve should return no solution instead. The way it is above, I thought at first I had wrong syntax with the "method = Fourier" settings and I think this error message can be misleading to a user.
 

Why doesn't PlotVector plot the arrows all in one size?  (as seen in the Maple help page here)

 

Am pondering how to best provide user-configurable options for a few packages I've written. The easiest method is to use global variables, preassign their default values during the package definition (but don't protect them) and save them with the mla used for the package. A user could then assign new values, say in their Maple initialization file or in a worksheet.  For example

  FooDefaultBar := true:
  FooDefaultBaz := false:

That works for a few variables, but is unwieldy if there are many, as the names generally have to be long and verbose to avoid accidental collision. Better may be to use a single record

  FooDefaults := Record('Bar' = true, 'Baz' = false):

To change one or more values, the user could do

   use FooDefaults in
      Bar := false;
   end use:

A drawback of using a global variable or record is that the user can assign any type to the variable, so the using program will have to check it. While one could use a record with typed fields, for example,

  FooDefaults := Record('Bar' :: truefalse = true, 'Baz' :: truefalse := false):

that only has an effect on assignments if kernelopts(assertlevel) is 2, which isn't the default.

A different approach is to use a Maple object to handle configuration variables. The object should be defined separate from the package it is configuring, so that the target package doesn't have to be loaded to customize its configuration. I've created a small object for this, but am not satisfied with its usage. Here is how it is currently used

# Create configuration object for package foo
Configure('fooDefaults', 'Bar' :: truefalse = true, 'Baz' :: truefalse = false):

The Assign method is used to reassign one or more fields

Assign(fooDefaults, 'Bar' = false, 'Baz' = true):

If a value does not match the declared type, an error is raised. Values from the object are available via the index operator:

   fooDefaults['Bar'];

Am not wild about this approach, the assignment seems clunky and would require a user to consult a help page to learn about the existence of the Assign method, though that would probably be necessary, regardless, to learn about the defaults themselves. Any thoughts on improvements? Attached is the current code.

Configure := module()

option object;

local Default # record of values
    , Type    # record of types
    , nomen   # string corresponding to name of assigned object
    , all :: static := {}
    ;

export
    ModuleApply :: static := proc()
        Object(Configure, _passed);
    end proc;

export
    ModuleCopy :: static := proc(self :: Configure
                                 , proto :: Configure
                                 , nm :: name
                                 , defaults :: seq(name :: type = anything)
                                 , $
                                )
    local eq;
        self:-Default := Record(defaults);
        self:-Type    := Record(seq(op([1,1], eq) = op([1,2], eq), eq = [defaults]));
        self:-nomen   := convert(nm,'`local`');
        nm := self;
        protect(nm);
        self:-all := {op(self:-all), self:-nomen};
        nm;
    end proc;

export
    ModulePrint :: static := proc(self :: Configure)
    local default;
        if self:-Default :: 'record' then
            self:-nomen(seq(default = self:-Default[default]
                            , default = exports(self:-Default)
                           ));
        else
            self:-nomen();
        end if;
    end proc;

export
    Assign :: static := proc(self :: Configure
                             , eqs :: seq(name = anything)
                             , $
                            )
    local eq, nm, val;
        # Check eqs
        for eq in [eqs] do
            (nm, val) := op(eq);
            if not assigned(self:-Default[nm]) then
                error "%1 is not a default of %2", nm, self:-nomen;
            elif not val :: self:-Type[nm] then
                error ("%1 must be of type %2, received %3"
                       , nm, self:-Type[nm], val);
            end if;
        end do;
        # Assign defaults
        for eq in [eqs] do
            (nm, val) := op(eq);
            self:-Default[nm] := val;
        end do;
        self;
    end proc;

export
    `?[]` :: static := proc(self :: Configure
                            , indx :: list
                            , val :: list
                           )
    local opt;
        opt := op(indx);
        if not assigned(self:-Default[opt]) then
            error "'%0' is not an assigned field of this Configure object", indx[];
        elif nargs = 2 then
            self:-Default[opt];
        elif not val :: [self:-Type[opt]] then
            error "value for %1 must be of type %2", opt, self:-Type[opt];
        else
            self:-Default[opt] := op(val);
        end if;
    end proc;

export
    ListAll :: static := proc(self :: Configure)
        self:-all;
    end proc;

end module:

Later: Observing that this is just a glorified record with an assurance that the values match their declared types, but with less nice methods to set and get the values, I concluded that what I really want is a record that enforces types regardless the setting of . Maybe created with

   FooDefaults := Record[strict]('Bar' :: truefalse = true, 'Baz :: truefalse = false):

In the meantime, I'll probably just use a record and not worry about whether a user has assigned an invalid value.

Hi

Initially I tried to find pemutations of 1..9, ie [[1,2,3],[4,5,6],[7,8,9]],[[1,2,4],[3,5,6],[7,8,9]],...etc, But maybe not all of them?

I wonder if someone out there can change my code to reflect the following:

1/According to the pdf excerpt, there are a total of 199 unique sums, the smallest sum is 774 and the largest 2556.(From displaying 280 outcomes, the code got the 774).

2/Show which sums have the greatest probability (specifically, 1566, 1575, 1638, 1656, 1674, 1692, 1755, and 1764, each of which can be shown with effort to have a 3/280, or 1.07%, probability – the calculations to determine this probability is a brute-force computation, and requires enumerating all outcomes of the sample space within a computational software package). We then finally reveal the prediction, which of course is correct..(I don't get it)

predict_perfect.mw

 

I want to divide every element of A1 list by every element of list A2. Lists are unequal length.

Example:

A1:= [a1, a2, a3];

A2:= [b1, b2];

Output would be:

[a1/b1, a2/b1, a3/b1, a1/b2, a2/b2, a3/b2]

I managed to do this by this means:

LinearAlgebra:-OuterProductMatrix([a1, a2, a3], [1/b1, 1/b2]); convert(%, list)

My questions are:

  1. Is there a more succinct, practical method?
  2. How about if I want to use a different operation like say adding or just use a function f?

Thank you all in advanced.

I've been using the following syntax to set boundary condition which is a derivative, when passing it to pdsolve. Say we want to set u(r,theta,t) to have insulated boundary conditions at r=1. So the BC will be

For example, to set derivative of u w.r.t. "r" to zero when r=1

       eval(  diff(u(r,theta,t),r), r=1) = 0;  #(1)

or using this syntax

       D[1](u)(1, theta, t) = 0;  #(2)

But now I find, on one example below, that the above no longer works.  I have to use this syntax (which I did not know about) for it to work

        D[1]*u(1, theta, t) = 0;  #(3)

Has something changed? why when using (3) pdsolve now gives result, but when using (2) or (1) it returns unevaluated? are the three semantically equivalent? when to use which syntax?

I am using Physics updates 265, Latest Maple 2018.2 

Here is an example showing the (1,2)  syntax no longer works, but the (3) syntax works

#articolo example 6.9.2
restart;

#using (1) syntax
pde := diff(u(r, theta, t), t) = (diff(u(r, theta, t), r)+r*(diff(u(r, theta, t), r, r))+(diff(u(r, theta, t), theta, theta))/r)/(25*r);
bc_on_r := eval(diff(u(r,theta,t),r), r=1) = 0;
bc_on_theta:= u(r,0,t)=0, u(r,Pi,t)=0;
ic := u(r,theta,0)=(r-1/3*r^3)*sin(theta);
pdsolve([pde, bc_on_r,bc_on_theta,ic], u(r, theta, t), HINT = boundedseries(r = [0]))

does not solve it.

restart;

#using (2) syntax
pde := diff(u(r, theta, t), t) = (diff(u(r, theta, t), r)+r*(diff(u(r, theta, t), r, r))+(diff(u(r, theta, t), theta, theta))/r)/(25*r);
bc_on_r := D[1](u)(1, theta, t) = 0; 
bc_on_theta:= u(r,0,t)=0, u(r,Pi,t)=0;
ic := u(r,theta,0)=(r-1/3*r^3)*sin(theta);
pdsolve([pde, bc_on_r,bc_on_theta,ic], u(r, theta, t), HINT = boundedseries(r = [0]))

does not solve it.

restart;

#using(3) syntax
pde := diff(u(r, theta, t), t) = (diff(u(r, theta, t), r)+r*(diff(u(r, theta, t), r, r))+(diff(u(r, theta, t), theta, theta))/r)/(25*r);
bc_on_r := D[1]*u(1,theta,t)=0;
bc_on_theta:= u(r,0,t)=0, u(r,Pi,t)=0;
ic := u(r,theta,0)=(r-1/3*r^3)*sin(theta);
pdsolve([pde, bc_on_r,bc_on_theta,ic], u(r, theta, t), HINT = boundedseries(r = [0]))

I've used syntax (1) before many times and it works. Here is an example where all three syntax work

pde:=diff(u(x,t),t)=k*diff(u(x,t),x$2);
bc:=eval(diff(u(x,t),x),x=0)=0,u(L,t)=0;
ic:=u(x,0)=f(x);
sol:=pdsolve([pde,bc,ic],u(x,t));

pdsolve gives

 Using syntax (2)

pde:=diff(u(x,t),t)=k*diff(u(x,t),x$2);
bc:=D[1](u)(0,t)=0,u(L,t)=0;
ic:=u(x,0)=f(x);
sol:=pdsolve([pde,bc,ic],u(x,t));

gives same answer as (1) and using syntax (3)

pde:=diff(u(x,t),t)=k*diff(u(x,t),x$2);
bc:=D[1]*u(0,t)=0,u(L,t);
ic:=u(x,0)=f(x);
sol:=pdsolve([pde,bc,ic],u(x,t));

The answer also looks like different and simpler, but I assume they are equivalent for now without looking too much into it.

Which syntax should one use as now I am really confused.

It looks like (3) is the one that should be used? Why the others did not work on first example? i.e. pdsolve did not give an answer at all?  And if (1,2,3) syntax are supposed to be equivalent, whysecond example gives slightly different looking answer when using one syntax vs. the other?

 

And finally to make things more confusing, here is an example where syntax (3) does not work, but syntax 1 and 2 work:

#articolo example 8.4.3
restart;
pde := diff(u(x, t), t) = (1/20)*(diff(u(x, t), x, x))+t;
bc := u(0, t) = 5, (u(1, t)+ D[1](u)(1, t)) = 10;
ic:= u(x, 0) = -40*x^2*(1/3)+45*x*(1/2)+5;
pdsolve([pde, bc,ic], u(x, t))

gives answer.

restart;
pde := diff(u(x, t), t) = (1/20)*(diff(u(x, t), x, x))+t;
bc := u(0, t) = 5, (u(1, t)+eval(diff(u(x,t),x),x=1))  = 10;
ic:= u(x, 0) = -40*x^2*(1/3)+45*x*(1/2)+5;
pdsolve([pde, bc,ic], u(x, t))

gives same answer. But

restart;
pde := diff(u(x, t), t) = (1/20)*(diff(u(x, t), x, x))+t;
bc := u(0, t) = 5, (u(1, t)+ D[1]*u(1, t)) = 10;
ic:= u(x, 0) = -40*x^2*(1/3)+45*x*(1/2)+5;
pdsolve([pde, bc,ic], u(x, t))

does not work.

Clearly there is something I do not understand between these 3 syntaxes and when to use which.

Using 265 version

Physics:-Version()
 "C:\Maple_updates\Physics+Updates.maple", 2018, December 22, 

    10:41 hours, version in the MapleCloud: 265, version 

    installed in this computer: not installed


downloaded today.


 

In this code k=2 and Beta=2 has been cconsidered

Loading Optimization

Loading Student:-MultivariateCalculus

ISO ELASTIC DEM ADD ERROR

y := proc (p, e) options operator, arrow; alpha-beta*p+k*e end proc:

G := g(p):

NULL

g := proc (e) options operator, arrow; (1/2)*mu*e^2 end proc:

 

Lambda := proc (z) options operator, arrow; int((z-u)*phi(u), u = 0 .. z) end proc: 

``

``

NULL

Step 1  Integrated supply chain

THE EXPECTED total PROFIT FUNCTION w r t LINEAR DEMAND

 

PI := proc (p, e, z) options operator, arrow; (p-c)*(y(p, e)-z)-(p-v)*Lambda(z)-g(e) end proc

proc (p, e, z) options operator, arrow; (p-c)*(y(p, e)-z)-(p-v)*Lambda(z)-g(e) end proc

(1)

PI(p, e, z)

(p-c)*(-beta*p+e*k+alpha-z)-(p-v)*(int((z-u)*phi(u), u = 0 .. z))-(1/2)*mu*e^2

(2)

FIRST PUT ALL PARAMETER VALUES AND THEN GO FOR THE DIFFERENTIATION

RUN THE OPTIMALITY AND THE SUBROUTINES FOR DIFFERENT Beta and K values

CASE 1:   Put k = 2 and beta =2

beta

(3)

`` 
Int_Profit := simplify(eval(PI(p, e, z), [k = 2, beta = 2, alpha = 50, mu = 10, c = 5, v = 1, phi(u) = 1/2]))

-2*p^2+(1/4)*(-z^2+8*e-4*z+240)*p-5*e^2+(1/4)*z^2-10*e+5*z-250

(4)

Int_Profit[1][1]

(-2*p^2+(1/4)*(-z^2+8*e-4*z+240)*p-5*e^2+(1/4)*z^2-10*e+5*z-250)[1][1]

(5)

 

Optimization:-NLPSolve(Int_Profit, p = 0 .. 60, e = -1000 .. 30, z = -10000 .. 25, initialpoint = {e = 0, p = 10, z = 0}, maximize)

[230.512568949745969, [e = HFloat(2.274015113534025), p = HFloat(16.370075567375324), z = HFloat(-1.4795080892429795)]]

(6)

NULL

Int_Profit

-2*p^2+(1/4)*(-z^2+8*e-4*z+240)*p-5*e^2+(1/4)*z^2-10*e+5*z-250

(7)

Calculate the Value of q

``

q := z+y(p, e)

-beta*p+e*k+alpha+z

(8)

qopt := simplify(eval(q, [e = 2.27401511353403, p = 16.3700755673753, z = 1.47950808924298, k = 2, beta = 2, alpha = 50, mu = 10, c = 5, v = 1, phi(u) = 1/2]))

23.28738718

(9)

Step 2  Decentralized supply chain

Retailer's profit

 

`#msubsup(mi("&Pi;",fontstyle = "normal"),mi("R"),mi("d"))` := proc (p, e, q, w) options operator, arrow; (p-w)*(y(p, e)-z)-(p-v)*Lambda(z)-g(e) end proc

proc (p, e, q, w) options operator, arrow; (p-w)*(y(p, e)-z)-(p-v)*Lambda(z)-g(e) end proc

(10)

Re_Profit := simplify(eval(`#msubsup(mi("&Pi;",fontstyle = "normal"),mi("R"),mi("d"))`(p, e, q, w), [alpha = 50, beta = 2, k = 2, mu = 10, c = 5, v = 1, phi(u) = 1/2, w = 10]))

-2*p^2+(1/4)*(-z^2+8*e-4*z+280)*p-5*e^2+(1/4)*z^2-20*e+10*z-500

(11)

Optimization:-NLPSolve(Re_Profit, p = 0 .. 60, e = -1000 .. 30, z = -10000 .. 25, initialpoint = {e = 0, p = 10, z = 0}, maximize)

[129.081143396165999, [e = HFloat(1.7075918734530873), p = HFloat(18.537959441958364), z = HFloat(-0.9736548233351249)]]

(12)

 

``

``

Optimal q value for decentralized supply chain

 

qd_opt := simplify(eval(q, [e = 1.70759187345309, p = 18.5379594419584, z = .973654823335125, k = 2, beta = 2, alpha = 50, mu = 10, c = 5, v = 1, phi(u) = 1/2]))

17.31291969

(13)

Manufacture's Profit

 

`#msubsup(mi("&Pi;",fontstyle = "normal"),mi("M"),mi("d"))` := proc (p, e, q) options operator, arrow; (w-c)*qd_opt end proc

proc (p, e, q) options operator, arrow; (w-c)*qd_opt end proc

(14)

M_Profit := simplify(eval(`#msubsup(mi("&Pi;",fontstyle = "normal"),mi("M"),mi("d"))`(p, e, q), [qd_opt = 17.31291969, alpha = 50, beta = 2, k = 2, mu = 10, c = 5, v = 1, phi(u) = 1/2, w = 10]))

86.56459845

(15)

Total Wholesale Profit

`#msup(mi("&Pi;",fontstyle = "normal"),mi("d"))` := proc (p, e, q) options operator, arrow; M_Profit+R_Profit end proc

proc (p, e, q) options operator, arrow; M_Profit+R_Profit end proc

(16)

Whole_Profit := eval(`#msup(mi("&Pi;",fontstyle = "normal"),mi("d"))`(p, e, q), [M_Profit = 86.56459845, R_Profit = 129.08114339616599])

215.6457418

(17)

step 3 find the t value

t := (In_Profit-R_Profit)/(w-c)

(In_Profit-R_Profit)/(w-c)

(18)

 

topt := eval(t, [w = 10, c = 5, In_Profit = 230.512568949745969, R_Profit = 129.08114339616599])

20.28628510

(19)

 

Hence range of t is 17.31 to 20.28

 

 

 


 

Download Code_1.mw

I have
a:=-(diff(x(t), t))^2*h^2/(x(t)^2-2*d*x(t)+d^2+h^2)^(3/2);
                       

How do you collect the denominator to get

Hoping to get your very own copy of Maple for Christmas? 

No, I'm not about to announce a sale. No crass commercialism allowed on MaplePrimes!  But we have created this handy-dandy letter for Santa that students can use to try to convince him to put Maple under the tree this year*.

 

 

Happy holidays from Maplesoft!

 

*Results not guaranteed, but we hope you will agree we made a valiant attempt. :-)

 

 

When I try to install (as an example) physics update using Maple 2018.2.1 on windows 10, it keeps hanging in the middle as shown above.

I closed Maple, starting again and tried again, same thing happens. I waited for more than 10 minutes and nothing happens.  I click on the install button in the clouds windows from Maple itself to install it as I always did.

 

Do others have problem installing this?  I'll try again in few hrs, it might be the Maple server is having some issues but thought to ask.

 

 

Hello,

given is the lower, partial differential equation. I have solved this (hopefully) correctly. I was given the tip to do in Maple a simple control in which the solution is inserted into the original equation. Since I'm quite inexperienced in maple, I would like to ask you for help on how I do that best!

Thanks a lot!

Basis equation:

Solution:


Could anyone explain why Maple doesn't calculate the Killing vectors for the metric below?

Thanks in advance!

killing2.mw

I try to solve ODE with conditions, but it give answer only without conditions:

SOT.mw

Thank you.

First 607 608 609 610 611 612 613 Last Page 609 of 2097