tomleslie

13876 Reputation

20 Badges

15 years, 165 days

MaplePrimes Activity


These are replies submitted by tomleslie

@Lilith 

From current Maple help for Empriical()

The probabilities option was introduced in Maple 16.

Since you are using Maple 15, this option presumably does not exist. SInce I don't have access to the help for Maple 15, (waaaaay too old), I'm not sure how the same functionality would have been achieved. Suggest that you check the help at

?EmpiricalDistribution

If that doesn't help then consider my previous post where I compared the ProbabilityTable() and Empirical() approach - and maybe use the former if it is appropriate

 

@JAMET 

which now works for cubes

Download cubeSum.mw

@Carl Love 

the former is a "piecewise continuous" distribution, whereas the the latter is discrete, these will agree at some points and not others.

Consider

  restart;
  with(Statistics):
#
# This is a "piecewise" continuous definition
#
  X:= RandomVariable
      ( ProbabilityTable
        ([1/2, 1/4, 1/8, 1/16, 1/32, 1/32])
      ):
#
# Whereas this is a "discrete" distribution
#
  Y:= RandomVariable
      ( Empirical( [1,2,3,4,5,6],
        'probabilities'= [1/2, 1/4, 1/8, 1/16, 1/32, 1/32])
      ):
#
# So these will agree on some points
#
  ProbabilityFunction(X, 3);
  ProbabilityFunction(Y, 3);
#
# But not on others
#
  ProbabilityFunction(X, 2.5);
  ProbabilityFunction(Y, 2.5);

which will produce   1/8, 1/8, 1/4, 0

So actually plotting ProbablilityFunction(), as the OP does, can get "interesting"

The "best I have come up with so far is to use ProbabilityTable() and subtract 1 from all the samples, as in

  restart;
  with(Statistics):
  prx:=[1/2, 1/4, 1/8, 1/16, 1/32, 1/32]:
  X:=RandomVariable(ProbabilityTable(prx)):
  A:=Sample(X,1000)-~1:
  Q:=Histogram(A,binwidth=1,range=0..numelems(prx)):
  P:=plot(ProbabilityFunction(X,h+1), h=0..numelems(prx),color=red):
  plots[display](P,Q);

which produces

 

I do wish someone could fix the inline worksheet upload!

 

@Anthrazit 

Hmmm, the quoted phrase

  " work as I would expect from a rounding function, like it is implemented in the software I named previously."

NO it is not like the software you named previously, because it fundamentally disagrees with the round() function in python, which of course fundamentally disagrees with the ROUND() function in EXCEL.

You appear to believe that the round() function in Pythin and the ROUND() function in EXCEL are equivalent.

THEY ARE NOT.

Try very hard to accept that rounding functions are often (subtly?) different in different software languages. You also state that

"But that is common knowledge, the last digit is the one you can't always trust."

which is also incorrect. You can trust the last digit in either pythion or EXCEL, provided you appreciate that the rounding operations in the two programs are different and what the difference is. It isn't exactly difficult. EXCEL will always round half-integers away from zero. python will always round half-integers to the "even" option. Both are consitent - they just happen to disagree (sometimes)

@Anthrazit 

Try reading the wikipedia page at https://en.wikipedia.org/wiki/Rounding for a start.

You may have a clear idea about how a "structural engineer" wants a 'round' function to work, but it is dangerous to assume that your requirement will match that of scientists/accountants/mathematicians/even_other_engineers (of which I am one)

You should also be careful about making statements such as

Excel btw. does it exactly the same way as Python,

because this isn't true: they differ on the half-integers

  1. The EXCEL ROUND() function always 'rounds' away from zero - so ROUND(1.5) returns 2, and ROUND(2.5) returns 3, although you can control the "rounding" direction explicitly by using ROUNDUP() and ROUNDDOWN() instead
  2. According to its language reference manual (https://docs.python.org/3/library/functions.html?highlight=round#round) python "rounds" to the "even" choice so round(1.5) returns 2, ie it rounds away from zero, but round(2.5) also returns 2, because it rounds towards zero!!

I don't have the time/energy to check other languages - but I'd be really surprised if they were all exactly the same

It is trivial to write a rounding function which operates pretty much any way you want (see the attached for a couple of possibilities). This only gets complicated if you want to deal with things like complex numbers etc, which I haven't bothered with

You can place such definitions in your init file, so that these are always available


Inline display of worksheets still seem to be broken!
 

Download rnd.mw

 

 

@dharr 

with this approach is that it works for selecting all terms which contain a power of (say) cos(x) - however if you want to select only a specific power - say cos(x)^7?

NB this distinction may (or may not) be relevant for the OP's problem

@mary120 

and then upload the resulting output here using the big green up-arrow in the Mapleprimes toolbar, because as I provided it, the outputs for

epsilon^(5/2)
epsilon^2
epsilon^(3/2)
epsilon^1
epsilon^(1/2)
epsilon^(0)

are correct.

You are going to have provide evidence of this worksheet producing something which "doesn't work".

This might be asociated with Maple versions, whatever so specifyign Maple version would also be helpful.

But when I provide a worksheet which demonstrably works and you state

it does not work for integer power of epsilon

some evidence is necessary.

I need to know if Maple is producing an "error", an "incorrect" answer, whatever. - Your statement "it does not work" is not informative or helpful

 

It would be helpful if you used the big green up-arrow in the Mapleprimes toolbar to upload your worksheet

@Anthrazit 

using a DataFrame

@JAMET 

is  shown in the attached  trivial update to my original.

I still haven't done anything about the fact that every target number can be constructed as a sum of squares in mulitple ways - mainly because you have give no indication about what should be done in such a case.

And this worksheet still cannot be displayed here because the incompetent idiots who maintain this site still cannot/willnot test simple uploads whenever they make some kind of  "change/improvement" 

Download sqSum2.mw

 

 

You state that

the system we want to solve is:

 

p(x,t)=p(y,t)                            (5)

 

v(x,t)=v(y,t)

Rather obviously, the solution for this system is x=y ..... and the definition of the functions p() and v() is irrelevant, as is any value of the variable 't'

command is provided in order to

solve the linear equations A . x = b

which is a quotation from the help page for this command.

So why isn't this sufficient?

If you happen to know stuff about the coefficient matrix 'A', then it is possible to provide options for the basic command which may make the solution process more (or less!!??) efficient

@Kitonum 

because I can't reproduce your problem in anything from Maple 18 onwards -see attachments

restart; with(Optimization); kernelopts(version); LPSolve(5*x1+2*x2+7*x3+6*x4+x5+6*x6+8*x7+6*x8, {10*x1+9*x2+15*x3+3*x4+11*x5+6*x6+3*x7+4*x8 <= 22}, assume = {integer, nonnegative}, maximize = true)

`Maple 18.02, X86 64 WINDOWS, Oct 20 2014, Build ID 991181`

 

[56, [x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 7, x8 = 0]]

(1)

Download int18opt.mw

 

restart; with(Optimization); kernelopts(version); LPSolve(5*x1+2*x2+7*x3+6*x4+x5+6*x6+8*x7+6*x8, {10*x1+9*x2+15*x3+3*x4+11*x5+6*x6+3*x7+4*x8 <= 22}, assume = {integer, nonnegative}, maximize = true)

`Maple 2015.2, X86 64 WINDOWS, Dec 20 2015, Build ID 1097895`

 

[56, [x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 7, x8 = 0]]

(1)

 

Download int2015opt.mw

 

restart; with(Optimization); kernelopts(version); LPSolve(5*x1+2*x2+7*x3+6*x4+x5+6*x6+8*x7+6*x8, {10*x1+9*x2+15*x3+3*x4+11*x5+6*x6+3*x7+4*x8 <= 22}, assume = {integer, nonnegative}, maximize = true)

`Maple 2016.2, X86 64 WINDOWS, Jan 13 2017, Build ID 1194701`

 

[56, [x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 7, x8 = 0]]

(1)

 

Download int2016opt.mw

 

restart; with(Optimization); kernelopts(version); LPSolve(5*x1+2*x2+7*x3+6*x4+x5+6*x6+8*x7+6*x8, {10*x1+9*x2+15*x3+3*x4+11*x5+6*x6+3*x7+4*x8 <= 22}, assume = {integer, nonnegative}, maximize = true)

`Maple 2017.3, X86 64 WINDOWS, Sep 13 2017, Build ID 1262472`

 

[56, [x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 7, x8 = 0]]

(1)

 

Download int2017opt.mw

 

restart; with(Optimization); kernelopts(version); LPSolve(5*x1+2*x2+7*x3+6*x4+x5+6*x6+8*x7+6*x8, {10*x1+9*x2+15*x3+3*x4+11*x5+6*x6+3*x7+4*x8 <= 22}, assume = {integer, nonnegative}, maximize = true)

`Maple 2018.2, X86 64 WINDOWS, Nov 16 2018, Build ID 1362973`

 

[56, [x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 7, x8 = 0]]

(1)

``

NULL

Download int2018opt.mw

 

restart; with(Optimization); kernelopts(version); LPSolve(5*x1+2*x2+7*x3+6*x4+x5+6*x6+8*x7+6*x8, {10*x1+9*x2+15*x3+3*x4+11*x5+6*x6+3*x7+4*x8 <= 22}, assume = {integer, nonnegative}, maximize = true)

`Maple 2019.2, X86 64 WINDOWS, Nov 26 2019, Build ID 1435526`

 

[56, [x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 7, x8 = 0]]

(1)

 

Download int2019opt.mw

 

restart; with(Optimization); kernelopts(version); LPSolve(5*x1+2*x2+7*x3+6*x4+x5+6*x6+8*x7+6*x8, {10*x1+9*x2+15*x3+3*x4+11*x5+6*x6+3*x7+4*x8 <= 22}, assume = {integer, nonnegative}, maximize = true)

`Maple 2020.0, X86 64 WINDOWS, Mar 4 2020, Build ID 1455132`

 

[56, [x1 = 0, x2 = 0, x3 = 0, x4 = 0, x5 = 0, x6 = 0, x7 = 7, x8 = 0]]

(1)

 

Download int2020opt.mw

@MapleUser09 

Maybe the attached?

for i from 1 to 20 do:
    printf("new variable=%2d\n", i)
end do;

new variable= 1
new variable= 2
new variable= 3
new variable= 4
new variable= 5
new variable= 6
new variable= 7
new variable= 8
new variable= 9
new variable=10
new variable=11
new variable=12
new variable=13
new variable=14
new variable=15
new variable=16
new variable=17
new variable=18
new variable=19
new variable=20

 

 


ownload prStuff2.mw

@Kros 

Your original request was to resolve

restart;
PDE := diff(u(x, t), t) - Laplacian(u(x, t), [x]) - u(x, t) + x - 2*sin(2*x)*cos(x) = 0;

 

IBC := D[1](u)(Pi/2, t) = 1, u(0, t) = 0, u(x, 0) = x;

 

pds := pdsolve(eval(PDE), {IBC}, type = numeric);
Error, (in pdsolve/numeric/process_PDEs) number of dependent variables and number of PDE must be the same

and several responders herw showed you how the above problem could be solved.

Perhaps unfortunately, someone pointed out that this particular problem could also be solved analytcally, so that a numerical solution wasn't really either necessary or desirable.

However you were unable to reproduce the analytical solution because you were (for whatever reason) unable to update the necessary solution packages within Maple. Then possibly(?) you were able to to perform a simple software update? Although no-one here actually knows, because you have never stated whether or not you were able to reproduce the behaviour ( ie an analytical solution for your original problem) which everyone else can achieve

Having failed to provide this information on your original problem, you then moved on to other PDEs, with the complaint that these could not be solved analytically in the same way. I simply have no idea what your objective is here so I will make a few statements, which you should consider

  1. Can Maple provide an analytic solution for any PDE/BC problem which you supply? Answer -NO
  2. Can Maple provide an analytic solution for a given PDE/BC just because you think it looks "similar" to a problem whcy MAple can solve? Answer - No
  3. Can Maple be guaranteed to provide an analytic solution for a a PDE/BC problem, for which you already "know" the analytic solution? Answer - No
  4. Can any other mathematical software ( eg Mathematica/Macsyma/whatever) do better on a given PDE/BC problem? Answer- maybe. All of these have strengths and weaknesses
First 52 53 54 55 56 57 58 Last Page 54 of 207