1137 Reputation

13 Badges

4 years, 38 days

MaplePrimes Activity

These are answers submitted by mmcdara

I don't know what Maple version you use (in a previous thread you said tou used Maple 13?) but in Maple 2015 (and beyond.. but I can verify this right now) your code is not correct.
The line

should be replaced by 
V:= r -> piecewise(0<=r and r<=R, -VV, r>R, 0):

Here is your original code

A few points beyond the above correction

  1. Some lines are unnecessary:

  2. As Carl Love wrote, you need another IC/BC condition, dot instance D(u)(0) = something
    With, for instance, SYS2:={diff(u(r), r, r)+k^2*u(r) = V(r)*u(r), u(0) = 0, D(u)(0)=1} you should obtain this curve
    odeplot(sol, [r, u(r)], r = 0 .. 2);

The GB is reduced w.r.t the plex order (proof here)


It seems indeed that the help pages do not mention if th GB is reduced or not.



Use "randomize" to generate a random sed on each node


Samplor := proc(N) 
  local Seed:
  Sample(Uniform(0, 1), N); 
end proc:

Map(Samplor, [2, 2, 2, 2]);



# example
Y := Array(1..N, i -> i^2);
             [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
DY := map(u -> Y[u+1]-Y[u-1], [$2..N-1])
                [8, 12, 16, 20, 24, 28, 32, 36]



You will find some hints in the attached file.

There are basically 2 problems wiith your code:

  1. value is a reserved word in Maple
  2. You don't read teploty.txt, so the test fails because the "value" is not valuated.

A temporary solution until someone here will provide a clever one

M := `<|>`(`<,>`(1, 3, 2), `<,>`(4, 1, 3)):

# Structure of M

S := op(2, M);

 {(1, 1) = 1, (1, 2) = 4, (2, 1) = 3, (2, 2) = 1, (3, 1) = 2,  (3, 2) = 3}

# Reverse S

T := map(u -> rhs(u)=[lhs(u)], S);

 {1 = [1, 1], 1 = [2, 2], 2 = [3, 1], 3 = [2, 1], 3 = [3, 2],  4 = [1, 2]}

# A simple procedure to find a value "n"
# (should be improved to handle the case "n is not an element of M")

Find := proc(n) map(u -> if lhs(u)=n then rhs(u) end if, T); end proc:

                        {[1, 1], [2, 2]}
                            {[3, 1]}
                        {[2, 1], [3, 2]}


fsolve(f, omega=4)
               4.450852611 - 1.509500329*10^(-25)*I

fsolve(f, omega=5)
               4.450852611 - 5.580307451*10^(-24)*I

As you observe the solution is complex (even the smallness of the imaginary part can suggest it is a numerical effect).
But this info is usefull and give you a hint to search a solution in a given interval:

fsolve(f, omega=1, complex, {omega=1-I..5+I}  );  # search in the xomplex square [1, 5]x[-I, I]

By the way: Do not use simplify in fsolve to spare computational time.



Your integral is just the mathematical expectation of the random variable 0.3*p1+0.7*p2:


No need to look further

More than this :
memory used=101.54KiB, alloc change=0 bytes, cpu time=2.00ms, real time=19.00ms, gc time=0ns

... and finally:


If you don't want to use a 'procedurelist' output and keep using an Array, you can buid a piecewise approximation of the second derivative where each "piece" is a 3rd order polynomial in x.

Nevertheless, as tomleslie said elsewhere in this thread (Rouben Rostamian too), you can easily isolate this second derivative from the original ode... then I'm not sure my answer is of any help ?

A simpler way:

E1 := x*y^3+5*x^2*y+3*a^2+4*x*y+z^2+3*x-y+z+2:
_order := 2:           # truncation order
vars   := [x, y, z]:   # truncation variables
mtaylor(E1, vars, _order+1);




Question 1:
There exits a package RootFindind with a procedure NextZero you could use In the same package. In the same package the procedure Isolate is also very useful.

Question 2: the content of the attached file could help you to get started 

Kitonum is right when he says "I think first you need to specify the values of the parameters  lambda  and  ."

You will find in the attached file a workaround:

  1. solve
  2. once the roots known, select the regions where 

A lot of work is to be done "by hand".

I would be interested to recieve the critics from Kitonum.

Use of RunWorksheet:

  1. Load the file
  2. Put it in some directory "/..../"
  3. Open Maple In a new worksheet type the command 
    DocumentTools[RunWorksheet]( "/..../", [r = .1, c = 1, mu = 1, Lambda = .1, fe = 20, fg = 5] )

Be careful: from my own experience RunWorksheet is very touchy to use.
Here are some constraints to respect (at least with Maple <= 2016):

  1. Build your worsheet with its 2 sections "Inputs" and "calculation" BEFORE adding the attributes "InputSectionTitle" and "Calculation" (InputSectionTitle must have "Inputs" as  a value; Calculation has value "default").
  2. Write each input in the "Inputs" section on separate lines.
  3. For RunWorksheet either works and returns a result, eirther doesn't work and remains silent, use "writeto(SometextFile)" at the beginning of the "Calculation" section (have a look to the attached file).
    Pay attention to the ending ";" or ":" which are easily omitted for the last command of a block.

Lastly, RunWorksheet has some limitations: 

  • you can't run a same worksheet on different processors/nodes by using the Grid package,
  • some graphical functions are not supported (if my meory serves: dualaxisplot, plotdevice(SomeFormat, ...), ...




Unless for polynomial systems for which you can specify the "maxsols" number of solutions to find, fsolve returns only one.
And of course the solution you get depends on your starting point (see fsolve[details] help page) or on the search interval you set (same help page).

An alternative is to use the function "Isolate" from package RootFinding.

You will find a few results in the attached file.


Not knowing all the subtitlies of the way Maple works, my first reflex when the arrow operator doesn't return the expected result is to use "unapply".
It goes well here:

for i from 1 to 3 do
   f[i]:=unapply(P(i,1,1,x), x);
end do;

To Carl, vv and others: what are the pros and cons of all the solutions proposed here ?


First 7 8 9 10 11 12 13 Page 9 of 13