tomleslie

13876 Reputation

20 Badges

15 years, 163 days

MaplePrimes Activity


These are replies submitted by tomleslie

If you upload the matlab file (*.m) which produces the plot, together with any files which it calls (eg a data file?) so that I can run your basic problem in matlab, then I might be able to figure out how to run the same matlab from within maple.

If you cannot provide sufficient information for me to produce the necessary plot using matlab, then there is no hope that I will be able to do so from within maple.

File uploading is acieved with the big green up-arrow at thr rhs of the above toolbar

Posting images of equations so that they cannot be cut/paste/evaluated just demonstrates how lazy you are: do you really expect someone to retype these for you because you can't be bothered???

Now I actually have converted these to a format which can be evaluated within Maple: however it is difficult to interpret your original equations for a few reasons

      In the second equation for D

r,s

    is the symbol 'I' isinde the square root or outside? Can I assume that the symbol 'I' represents the square root of -1?
  1. the third equation contains a condition on the (uppercase) variable S, which does not occur anywhere else - is this a typo for (lowercase) s
  2. The first and third equations both define Fr,s so which is the definition of Fr,s, the first equation or the third?? So far as I can tell for any value r up to min((M', M+1) the two definitions are identical, gicv=ven 2 above, and thus require that k'=k+1. You need to seriously think about these and clarify whcih definition of Fr,s is correct and under which conditions

The difintion of your equations in Maple syntax, with the coirrection given in (2) above is

F1:=(r,s) -> piecewise( r::integer and
                                   s::integer and
                                   r>=2        and
                                   r<=M+1   and
                                   s>=1        and
                                   s<=r-1     and
                                   type(r+s,odd),
                                   2^(k+1)*sqrt((2*r-1)*(2*r-1)),
                                   0
                                 );
DD:=(r,s) -> piecewise( r::integer  and
                                    s::integer and
                                    r>=2        and
                                    r<=M       and
                                    s>=1        and
                                    s<=r-1     and
                                   type(r+s,odd),
                                   2^k*sqrt((2*r-1)*(2*r-1)*I),
                                   0
                                );
F2:=(r,s) -> piecewise( r::integer  and
                                   s::integer  and
                                   r>=2        and
                                   r<=Mp      and
                                   s>=1        and
                                   s<=r-1     and
                                   type(r+s,odd),
                                   2^kp*sqrt((2*r-1)*(2*r-1)),
                                   0
                                );


So you can play with these equations and determine exactly what question you want to ask

sqrt((1+x)/x) is complex in the open range (-1.0). It is infinite at x=0. So given that the integrand is real, complex or infinite depending on the value x, what would you expect the value of the integration to be???

@Wolff 

If you had mentioned the Monty Hall problem in your original post, I would probably never have posted a response. I used to point out "flaws" in the "simulation" of this problem in the early 90s, but rapidly gave up because the authors of such simulations could never grasp that

  1. if you switch your winning odds are 2/3
  2. if you don't switch, your winning odds are 1/3

These odds are determined by logic not software - if any program/simulation gives any other result, then that program is simply wrong.

Since your program requires so much user input at each step, it is simply too tedious to verify whether or not the correct answers are being obtained. Tests you should run

  1. for 1000 trials, pick door 1 every time and switch every time: if the answer is more than ~32 away from 667 wins be suspicious
  2. repeat the above: if the answer is exactly the same, then all your random number generators are being re-initialised to the same value (which they probably shouldn't be), so be suspicious
  3. repeat steps 1 and 2 for selections of door2, every time, door 3 every time
  4. repeat steps 1 and 2 for sequences such as picking doors in order 1,2,3,1,2,3.....
  5. repeat steps 1 and 2 for selecting random sequences of 1, 2 and 3
  6. If the answers are ever more than about 32 away from 667, then there is a sporting chance that your code is wrong/biased/whatever

I have run a few small checks on your code, the results of which made me slightly suspicious. Not saying it is incorrect, but just enough doubt to make me want to run some much lengthier examples - which is just too tedous to do

@MTata94 

For future reference, don't upload pdf, it means we can't cut/paste etc: always upload .mw/.mws

Your code is different from Carl's because you seem to be using 2-D math input, which he wasn't, so I am assuming something went wrong in the conversion process.

Looking at the pdf , the global and end proc are followed by semi-colons so ought to "echo" something to the screen - but neither do - very suspicious. It is as if these statements are not being "executed". In the case of the proc...end proc, this would mean that the procedure is not being defined, which would explain the output from the final statement. If Spd has not been defined then Maple will simply echo your final statement to the screen.

The attached worksheet shows my code (see above), and Carl's code both using 1-D input, and both working correctly.

I then tried to reproduce your code (ie 2D math) by using the convert to 2D math input option. This "executed" and produced incomplete output because the something went wrong with the global statement during the conversion process. I had to hand-edit to make it look like your code: it always executed (which your pdf doesn't seem to), but I could never make it execute properly with a global statement in the calling routine.

I'm putting this one down to yet another obscure issue with 2-D math

2Dmath.mw

Everything which has been said before is correct: however I believe the following is shorter, eliminates irrelevant stuff, and makes important stuff more obvious - but is I suppose essentially superfluous

restart;
a:=0.0065:
R0:=1.225:
T0:=273.16:
R:=287.04:
Spd:= proc(H, T1, IAS)
                   local gamma:= 1.4, T, SpdSnd;
                   global T0, R;
                   T:= T1+T0;
                   SpdSnd:= sqrt(gamma*R*T);
                   return IAS/SpdSnd;
          end proc:
Spd(5000, 15, 400);

The changes and the reasons for them

  1. I think that when a procedure relies on external (aka global) variables, then a global statement within the procedure should make this explicit. Otherwise one has to scan the code within the procedure for variables which must be externally defined: makes reuse more difficult
  2. Generally I prefer to use return statement(s): this makes explicit which value(s) are being returned, rather than having to analyse which is the last executed statement. Not really relevant for this simple procedure but when return values depend on (for example) the outcome of conditional statements, then a procedure can contain multiple return statements, and I find these useful as "markers" where a procdure may exit, so I think it is good practice to make these explicit
  3. In your particular example the original statements

EAS:= sqrt(rho*IAS^2/R0);
TAS:= EAS*sqrt(R0/rho);

will evaluate to IAS - so why do these calculations??? Superfluous calculations just make things harder to debug and make code mre difficult to reuse, so why do it???

@Wolff

Have to confess that I'm slightly surprised by these two comments: my original suggestion was made as a bit of a joke, but only because it seemed a relatively obscure way to achieve the OP's original "simple" request.

So to AJ:

"you have found a purpose to that broken Standard debugger window interface".

I am not a frequent debugger user. I tend  to start with inserting a couple of printf() statements when something isn't working the way I want. So I would regard myself as a casual/inexpert debugger user: however, when I do invoke it, I find it seems to do more or less what I need: I can stop/start execution, stepover, stepinto, query current variables, do sums on them, whatever. In fact pretty much what I would expect from a debugger. So I am curious: in what sense do you consider it "broken"?

and to Wolff

Since I only ever invoke the debugger on more complicated programs (and I find it useful/helpful) I am curious about your statement that it "doesn't work". All I can say is that it does for me! (I'm currently running Maple2015.1 and haven't found any debugger issues, and I didn't find any oin Maple18 either). If you have some code on which the debugger "doesn't work" then I would consider that a much more serious problem than your original post!!!

An example worksheet showing non-functionality would be great

rgds

@lham 

Suggest you study the following (especially the comments) to determine why I am still puzzled by your requrement

edq.mw

@lham 

You have told me two things that you don't want to do, ie

yep i didn't mean alpha(r)=alpha_0+alpha_1*r+alpha_2*r^2 or alpha(r)=alpha_0+alpha_1/r+alpha_2/r^2.

but you haven't specified exactlyy what you do want to do!!!!!

Please explictily write your approximation for alpha(r).

If I understand what you are trying to do then your fundamental problem is that each readline() command will produce strings such as "0.8 0.2". Before attempting to parse() this, you need to split it into individual components by using StringTools[Split](), and then map( parse, ()). So the basic command sequence that you need is

map( parse, StringTools[Split](readline(fn)))

where fn is the name of the file containing the data.

Exactly how you decide to store the output of this command depends very much on how you want to subsequently access it: the following is one of the most basic. If you create a text file containing

1
A    3
0.8 0.2
0.6 0.3
0.5 0.4
****
2
A   3
0.8 0.7
0.6 0.8
0.5 0.9
****

and store it as as testip.txt, then

with(StringTools):
fn:="testip.txt":
datArr:=Array():
for k from 1 while readline(fn)<>0 do
      for j from 1 by 1 to 4 do
          datArr(k,j):=map( parse, Split(readline(fn)));
      od;
      readline(fn);
od:

will put the four important lines of data as a row in the array dataArr, such as

[ [A, 3]  [.8, .2]  [.6, .3]  [.5, .4]
   [A, 3]  [.8, .7]  [.6, .8]  [.5, .9]
]

This data could be organised in many other ways -it isn't difficult, but since I can't guess what you want, this is aboout as far as I can go

You may think that

(D-f(x))@@2(g)(x)

is equal to

(D@@2)(g)(x)-(D((f(x))(g)))(x)-((f(x))(D(g)-(f(x))(g)))(x)

but it isn't. You are mixing operators are functions in a more or less random manner which I do not understand: after  all what is (D-f(x))?? a combination of an operator and a function- is that what you really want??? How doe one "apply" such a construct to any given argument

Now I have decide whether you want to know

  1. what the correct evaluation of the lhs of your expression is (enter it in Maple and you will get the correct result, but not the one you want - or
  2. what lhs would lead to the expansion on the rhs  So far I have failed.

So I am more or less guessing what you are trying to achieve. Applying my psychic powers, the closest I have been able to come up with (confirmed by Maple) is

((D-f)@@2)(g)(x)=((D@@2)(g))(x)-(D(f(g)))(x)-(f(D(g)-f(g)))(x)

 

In your worksheet, you state that

"I want to expand alpha and beta and sigma as alpha(r)=alpha_0+alpha_1(r)+alpha_2(r) and also for beta and sigma."

In other words you want to express the function alpha(r) in terms of a parameter alpha_0 and two new functions alpha_1(r) and alpha_2(r). Relpacing one unlnown function with two unknown functions and a parameter seems rather "unusual" as a "simplification". Before I give this any more thought, I'd just like to confirm that you don't mean something like

I want to expand alpha and beta and sigma as

alpha(r)=alpha_0+alpha_1*r+alpha_2*r^2,

or possibly

alpha(r)=alpha_0+alpha_1/r+alpha_2/r^2

Most of your problems are base around requirein an infinite sum, where maple seems incapable of findining a closed form. However one can approximate this infinite sum - just pretend infinity is 1000, 2000, 3000, whatever until you decide that the change in the answer is no longer significant. Then rewrite sum(f(x), x=l..infinity) as sum(f(x),x=1..infinity)-add(f(x), x=1..l). On this basis, try

restart;
sigma:=167:
t:= i -> evalf(exp(-i^2/(2*sigma^2))):
infsum:=2*add(evalf(t(j)), j=1..5000):
S:= l -> 1+infsum-2*add(evalf(t(j)),j=1..l):
plot(S, 20..50);

which seems to provide you want

Before we get into any more details, a couple of obvious things need fixing

  1. In your worksheet, the definition of PDE does not contain an "=" sign. It might be that you intend it to be equal to zero, but Maple will not assume this - needs fixing
  2. You need to give some serious thought to your boundary conditions. Respectfully suggest that you take a long hard look at the nature of boundary conitions on the pdsolve/numeric help page.

The condition r(z, 0) = r(z, 2*Pi) does define a "periodic" boundary condition. Unfortunately it does not give any indication of the periodic function required: perhaps you assumed that MAple would "know" that you meant one period of a sine wave, rather that 123 cycles of square wave - either of which would satisfy this condition. You need to define this BC much more tightly. For the other boundary condition, a comment in your worksheet states that r(z, theta) = constant, and that is what you want to express. As far as I know, for successful numeric solution of pdes, boundary conditions have to be expressed in the form

f(a_number, a_variable)=someFunctionOf(a_number, a_variable)

so r(z, theta) = constant just doesn't make it

Like I said, you need to give some serious thought to your boundary conditions. A useful, but not bulletproof guide is to consider your "time" variable, if you set this equal to zero, then do your boundary conditions evaluate to numbers for all possible values of the other variable???

@spark1631 
I'm also relatively new on this site (although I have been using Maple for a long time)

I'm very unimpressed by Maple bug reporting/tracking. I have only made 4 (I think) SCRs in the time I have been using this site. On the previous 3(or so), maplesoft eventually admitted that "It shouln't do that", but on none of these previous bugs have I been able to determine what is happening - fix/ignore/whatever

Hzving reported this particular bug  four days ago, so far I have not even received any notiffication from Maplesoft that a bug/SCR has been flagged. If my previous experience is aything to go by, then it will take another day or two before I get an email saying something like "It shouldn't do that".

However at that point, the bug report disappears  within maplesoft and (so far as I am aware) there is no way to track what if anyting is being done

Maplesoft (like most other suplpliers of non-professional products) care more about "adding features" than fixing bugs.

In a previous existence, where I used to use a significant number of professional-grade software products, I would simply suspend ongoing license payments until reported bugs had been fixed. Trust me, if you suspend this quarter's payment for 1000 licenses, you will get some attention. On the other hand as an individual (or a non-paying academic institution) , nobody cares about your problems. That's just the world we live in

 

First 191 192 193 194 195 196 197 Last Page 193 of 207