5984 Reputation

17 Badges

7 years, 266 days

MaplePrimes Activity

These are answers submitted by mmcdara

Maybe this will suit you if the term "tensor" stands for "a 4 dimensional table"

H := Array(seq(1..3, k=1..4)):
H[1, 1, 1, 1] := 10:
H[1, 2, 2, 1] := 20:

But if you want to use "true" tensors you can have a look to the Physics or DifferentialGeometry packages


Please see my other replies.
I've posted 
dsolve({ic, odes, odex}, type = numeric, range = 0 .. 1, events = [[s(tau)-1, halt]])

instead of 
dsolve({ic, odes, odex}, type = numeric, range = 0 .. 1, events = [[s(tau)-const, halt]])


About your original question
 [ [ [s(t), a*arcsinh(2/a) < s(t)], halt] ] means : halt dsolve when s(t) = 0 AND a*arcsinh(2/a) < s(t)]

I don't know what is the error Maple returned, but there could be potential conflict between these two conditions.

Is "a" a numerical value ?
If not it can't work until you have used the option parameters (see my first reply)
... or given "a" some value...
Look to attached file after thet "EXTRA MATERIAL" title

a := 3.0:
dsolve({ic, odes, odex}, type = numeric, range = 0 .. 1, events = [ [ [s(tau), s(tau) > a*arcsinh(2/a)] , halt]] )


Where does this problem come from ?

I suppose u is a function of r and z ?
Is P a constant or not ?
Why do you write r=h(z) and not r=H (H being constant) ? Is the radius r a function of z ? If so some terms seem to be missing in the equations (1) 

Even in the simlest case P is a constant, u a function of r alone and h(z) is a constant H, and provided I did no mistakes in my worksheet, there is no solution to this problem unless P or H = 0 ...


1/ Isaac Newton (1687)

Philosophiae naturalis principia mathematica, Sir Isaac Newton, Londres 1687.


French version
Livre Troisième (=Third Book)

pp 120-122


2/ Joseph Louis de Lagrancge (1795)

"Leçons élémentaires sur les mathématiques données à l'École Normale en 1795" p.183-288

Leçon cinquième pp 284-286

For a more detailed historical approach of interpolation I recommend you to read the book (in french)
Histoire d'algorithmes, du caillou à la puce
Jean-Luc Chabert et al.
Belin ed. 1994
chapter 10

It seems it has been translated in english under the title
Chabert, A History of Algorithms. From the Pebble to the Microchip, 1999.


First solution : click on the hand right to the exclamation point (it should be red)

Sometimes this doesn't work if the build in function (here fsolve) has run some child process.
In this case the only thing to do is wait, hopping the command will stop correctly ... or to kill the process itself.

Second solution: use kernelopts(cputime=.....).
For instance kernelopts(cputime=15) will stop your active worksheet as soon as the cpu time reaches 15s.
Watch out: kernelopts(cputime=15) is global to the worksheet: if 10 s has already been used for some computations, the remaining ones have to be executed in less than 5 s  to complete entirely.
When cpulimit is reached (I cannot guarantee it'd the same thing on all platforms or systems), you may receive a "kernel connection lost" message. If it so, you will not be able to do any other thing within your worksheet (other worksheets are still operational) and the only thing tou will be able to do is to save the active worksheet, to close it and to open it again.


I don't know if Maple offers a softer mechanism to kill a command programatically. 

The first part of the attached file is essentially a corrected version of yours
In the second part you will find some improvements that could help you to do the same things in a simpler way



x := max(%) - 1:
`if`(convert(x, fraction)::integer, n>=round(x), n>floor(x))

8 < n


x := max(%) - 1:
`if`(convert(x, fraction)::integer, n>=round(x), n>floor(x))

4 <= n





If I concentrate on your sentence "I am trying to generate a binomial sample", and if you want to use the student package, then the solution is obvious:

N := 50:
P := 0.1:
X := BinomialRandomVariable(N,P):

# S is a sample of size M 
M := 10:
S := Sample(X, M);

But maybe, as Carl Love sugegsted, you want to do something different ?

PS : for my own I prefer to use the Statistics package.
In this case :

N := 50:
P := 0.1:
X := RandomVariable(Binomial(N, P)):
M := 10:
S := Sample(X, M);

WATCH OUT: here S is a vector of floats (not integers as with Student[Statistics]): be aware of this when you use S! 


M := 5;
A := Matrix(M+1, M+1, (r,s) -> `if`(type(r+s, odd), 2^(k+1)*sqrt((2*r-1)*(2*s-1)), 0))



R := ((n1-n2)/(n1+n2))^2:
simplify(subs(n1=xi*n2, R));
plot(%, xi=-1..2, labels=[n1/n2, 'R']);


If you want a symbolic solution just use
dsolve({ode, bcs}, f(x))

But your second bc is not correctly stated : you should write f((4*10^(-8)-rho)^.5)= "some value"

Unfortunately, dsolve will return no result because the ode is not tractable symbolically.

Then you can try dsolve({ode, bcs}, numeric).
In which case you need to fix initial conditions, not "noundary" ones.
More of this, you need to fix the value of rho (unless you use paramerized dsolve : dsolve({ode, bcs}, numeric, parameters=[rho]) )

the correct syntax is a:=a+1  not (a=a+1) (idem for b, c, d)

First remark :
I loaded your file and got this error
Error, recursive assignment

It comes from the line "eqs := eqs, ....  " and tells you that "eqs" has not been already defined.

Second remark
In : solve operates on a single equation or a set of equation (at least until MAPLE 2016 ... I do not have more recent versions).
The syntax of your last line is not correct and should be 
Array(1 .. 9, rhs~(convert( solve(eqs, {seq(T[k], k = 1 .. 9)}) , list)))

In effect, eqs has a lot of indeterminates and you must tell MAPLE what are the ones it has to solve for, this is the meaning of {seq(T[k], k = 1 .. 9)}.

Now a computational issue: even if you execute this command you will be very disappointed by the result you'll get. I'm not even sur that you will obtain a solution (I can't).
Do not forget you have several fourth order equations to solve: the result will be amazingly huge if you look for a formal one.
To convince you, replace all the "4" in the fourth power by "m" in your eqyuations and execute 

Array(1 .. 9, rhs~(convert( solve( subs(m=1, eqs), {seq(T[k], k = 1 .. 9)}) , list)))

(ok, this is not the correct exponent, but just look to the result)

Now do the same thing for m=2 and observe what happens.

Some hints

  1. If a numerical solution satisfies you, I suggest to fix the values of all the quantities, but the T[1..9], in eqs and use fsolve instead of solve.
    Syntax    Array(1 .. 9, rhs~(convert( solve(eqs) , list)))
  2. If you need want a formal solution of this advection problem, MAPLE proposes you the procedure "pdsolve". Please have a look to it and let me know if it could suit you.
  3. It's likely that someone here will have other(and better) ideas

But for the moment I'm affraid that yout problem, in the way you stated it, is untractable (?)



And a third one :

1 +~ Statistics:-CumulativeSum(X)

You see here that MAPLE has many overlapping feature: look to Carl Love's answer.

BTW : I didn't know the procedure PartialSums of the ListTools package

@Rouben Rostamian  @acer  @Mariusz Iwaniuk 

Some of the solutions are based on some arbitrary cutoff and I do not consider they are correct.

Rouben's cutoff-free solution is far better ... if we accept a zero gravity of course !!!

You will find in the attached file another solution free of any trick  (excepted the instruction in pink used here to prevent null time ranges).
The solution is piecewise constructed (a strategy I use to use for more complex situations than the bouncing ball test case).

Make a zoom around the 16th rebound (t=4.2425543703...) for a detailed comparison between Rouben's solution and mine's


First 47 48 49 50 51 Page 49 of 51