tomleslie

13876 Reputation

20 Badges

15 years, 164 days

MaplePrimes Activity


These are replies submitted by tomleslie

@chiefjazzdiewltr 

As mentioned earlier the default ranges for smartplot are x=[-5..5] and y=[-5..5], so what would you expect to be plotted for (say) x=-1, y=1/2 - also known as the square root of -1.

If you insist on using the smartplot() then you have to ensure that any values over the domains x=[-5..5], y=[-5..5] evaluate "sensibly" - ie real, and not infinite

@chiefjazzdiewltr 

For smartplot3d() the manual says

"For three dimensional figures, a default grid of  [-5 .. 5, -5 .. 5] is used", which is exactly the x- and y-ranges which are being used.

The fundamental problem with this plot is that when y=0, the value of the function x/y is infinite. So you have to ask yourself a question - how do expect Maple to plot infinity???? It would seem that smartplot() is using something around 10^16 - not quite infinity - but getting that way :-)
Suggest you try an example where the function value is not infinite over the x,y-domain

Two suggestions

  1. Use the simple command to plot one cycle of  of the sine function, ie plot( sin(x), x=0..2*Pi); what do you get?? I've just tried this in Maple 18 and it works exactly as I would expect. A plot with x-range from 0 to 2*Pi and a y-range from -1 to 1.  What do you get????
  2. Post a maple worksheet, illustrating your problem: ie the command(s) execured and the output obtained, so that we can diagnose. You can upload Maple workheets using the big green up-arrow button at the right hand end of the lower toolbar in the MaplePrimes editor

Depends a lot on how complicated you want to get!! Consider the following

  restart;
  with(Statistics):
#
# Define the distribution - could be user-defined
# but I'm using a normal distribution for illustrative
# purposes (mean is 1 and standard deviation is 2, again
# just for illustrative purposes)
#
   X := RandomVariable(Normal(1, 2)):
#
# Specify the number of samples required
#
   npts:= 20:
#
# Initialise a sequence to store the required sample
# values
#
   sVals:= NULL:
#
# Specify the range of acceptable values
#
   rnge:= [-2, 0]:
#
# Loop until one has the required number of samples
#
   while numelems([sVals]) < npts do
        #
        # Generate sample
        #
           s:= Sample(X,1)[1];
        #
        # If sample is in the desired range then add
        # it to the sequence
        #
           if    `and`( s > rnge[1],
                            s < rnge[2]
                         )
           then sVals:= sVals, s
           fi;
   od:
#
# Display samples generated
#
   sVals;

This will generate "npts" following a normal ditribution, (mean=1, std dev=2), where all samples lie in the range [-2, 0]

The drawback with this simple approach is that it generates samples according to the given distribution and throws away those which do not fit the range criterion. This will be very inefficient if the range is such that a large number of samples have to be generated (and then thrown away). In such a case it would be better to define the probability distribution function using some kind of piecewise arrangement.

For example if one wanted samples between (say), +6*sigma and +7*sigma of a normal distribution then in "pseudocode" one would have

distrib:=piecewise( x<6*sigma, 0,
                             x>7*sigma,0,
                             sf*normalDistribution
                          )

where sf is a scale factor whose value is such that sf*int(normalDistribution, x=6*sigma..7*sigma)=1

@Carl Love 

Until I saw the code for your original response, it had never occurred to me that one could perform a substitution into the body of a procedure. When I thought about it two things struck me

  1. That's a very useful/powerful construction which I could see being useful in many places, so I have added it to my "armory", but
  2. it is a little "sophisticated", and I was sure that there was a simpler solution to the OP's problem. I admit my original response didn't care about how many times the limit() function was evaluated, because I did not assume it would be an issue

So if I want a less "sophisticated" solution which evaluates the limit only once (and gets the correct answer!) how about

  restart;
  f:= (x, y)-> sin((x+y)/y): # arbitrary function
  F:= (f,x,y,L)-> limit(f(x,y), y= L): # limit function
  G:= proc( a, b, n )
                 local l, ll, l2F:=F(f, a, b, l); # evaluate limit once at l
                 add( subs( l=ll, l2F), ll=1..n);
        end proc:
  G(a, b, 10);

@kjhuebner 

You are perfectly free to make this suggestion to the power-that-be at Maplesoft.

The SoftwareChangeRequest is *hidden* under the "More" tab on the MaplePrimes home page

Looking at your code, you already have discovered the different way Maple interprets the key sequences <Enter> (aka C/R) and <shift-Enter>. The first "executes" the preceding comand and generates a new execution group. The second, does not execute anything, produces no new execution group, just allows entry on a new line.

Now consider how Maple is supposed to interpret data which you cut-and-paste from somewhere else - which of the above two interpretations would you want Maple to use as default for the line terminators in your original data???

In Maple 2015.1 the extra command prompts don't cause a problem - they just make code look like crap, so I understand why you would want to remove them. Realistically I can only see two ways of doing this

  1. A "paste-without-formatting" option
  2. A much smarter Find/Replace function which would allow one to search/replace command prompts

Either of the above would mean that "tidy" code could be produced much more quickly, but presumably either would require significant work on the Maple interface - which probably isn't going to happen:-(

@rit 

A couple of posts ago, I gave you a solution to one method of solving your problem. You have chosen to ignore this: I have no idea why.

At the same time I told you I had no intention of debugging the second method of your problem, because it was so badly written (in particular with respect to variable scope) that debugging was essentially impossible

You have now chosen to post another method with even more procedures all of which are incredibly badly written and expect me to debug???? Not going to happen!

Until you show some sign of understanding the difference between local variables, global variables, restrictions on formal parameter reassignments etc, etc then I will be unable to help any further. Such understanding will require you to read one (possibly two) Maple help pages, and implement the given information

I am unable to understand why you are so reluctant to do this

@patient 

when you write

P[j]:=plot(<X|S>):
Q[j]:=plot(<X|U>):

what is j and how is it incremented???

The attached worksheet works for N=100, and saves every tenth iteration for plotting

pdeProb2.mw

@patient 

Using Maple 2015.1

Having played with this a little, the problem seemed to be occurring at the LinearSolve() command. Like you if I execute individual steps then everything seemed to work, but executing the loop, it stalls on k=2. By sheer luck I shifted the

with(LinearAlgebra)

command outside the loop - after all you only have to initialise this package once. This seems to fix the problem of the loop stalling although I cannot think why

I defined arrays to hold the plots and shifted the plot statements inide the loop, as Carl suggested above

Anyhow the loop now executes and produces 10 plots for each of Q and P, although the differences are pretty small. See the attached

pdeProb.mw

@patient 

The code

N:=2:
for k from 1 to N do

............

end do;

will execute the loop contents exactly twice, unless you are doing something obcure such as reassigning k or N within the loop itself).

Suggestions

  1. Post code using the big green up-arow so we can investigate the non-terminating behaviour
  2. set k= 1 and run the loop contents - see if that terminates,
  3. set k=2 and run the loop contents again- see if that terminates,
  4. if (2) and (3) work but (1) doesn't then you have some obscure problem for which we really need to see code. The big green up-arrow on the toolbar is your friend

@patient 

if irem(k, N/10)=0
then ........:
 fi;

Althugh if you aren't going to use data from the other steps, why generate them?

@mela 

There are many difficulties in persuading Maple to produce an expression which is in the exact form desired by the user. There are many reasons for this, but the most common is that the user is making some assumptions about the values which variables can take - for example that they are real. Maple does not make such assumptions unless instructed to do so.

This can be addressed by providing as much information as you can about all of your variables: for example if you know that nothing in your problem can ever be complex then it can be a good idea to place

with(RealDomain);

at the top of your worksheet, and then perhaps further restrictions on variable values using assume() commands,

If you *know* (for example) that K is a positive integer and tau is greater than 0, then use

assume(K, posint)
assume(tau>0)

The simplest(?) method of achieving the transformation you want is

combine( eq2a, power, symbolic);
combine( eq3a, power, symbolic);

Note the use of the option 'symbolic' is actually placing some assumptions on your variables - see the ?combine/power help page

The attached worksheet shows both of the above approaches

simpl.mw

@tobbie247 

The mathematics (not the code) in your worksheet

Download D.T.M.mw

is pretty terrifying. I have no idea what you are trying to do with this code  (and I do know what shooting methods are)  but consider the following

  1. You construct a couple of 12-th order polynomials in x
  2. You ask for the values of A,B which make the limits of these polynomials finite as x goes to infinity
  3. Rather obviously (2) can only be achieved if the coefficents of all powers of x are zero, whcih cannot be achieved for your polynomials.  So the required limit does not exist!!
  4. So you generate the Pade approximations of your polynomials as either a ratio of two quadratics or two tertiaries, and take the limits of these as x tends to infinity.
  5. Now this will give a finite limit, because lim(x-inf, (p+qx+rx2)/(a+bx+cx2) is r/c (and similarly for the teriary version) However the limits generated from these pade approximations bear no relation to the limits generated from the originating polynomials

So unless I've missed somthing subtle - this is mathematical garbage

On the plus side I see no real issues with your second worksheet

Download shooting_method.mw

 

@mela 

You still give a very unclear description of which quantities are variables and which are parameters: I am assuming that the three remaining variables in your final post are Y, w, and P.

The variable P can be eliminated by

s1:=isolate(eq1,P);
eq2a:=subs(s1,eq2);
eq3a:=subs(s1,eq3);

You say that "I tried to go further but it becomes messy ".

Well, that reflects your original equations - or did you think that starting wiith 10 (generally non-linear) equations in 10 variables (plus lots of parameters), and eliminating 8 variables, would result in a couple of "simple" expressions. Why would you expect the results to be anything other than "messy"????

The final equations depend on the original equations - live with it

First 187 188 189 190 191 192 193 Last Page 189 of 207