tomleslie

13876 Reputation

20 Badges

15 years, 170 days

MaplePrimes Activity


These are answers submitted by tomleslie

what else do you want/need

restart;
f:=x->cos(x); # function whose minimum is required
a:=0; # lower limit
b:=evalf(2*Pi); # upper limit
n:=50; # number of steps
min(seq( f(j), j=a..b, (b-a)/n)); # minimum value obtained

 

Your code, ie

restart;
f := proc (x) options operator, arrow; sqrt(x)+ln(.1*x) end proc;
xk := 5.0;
for k to 6 do
    xk1 := xk-f(xk)/(D(f))(xk);
    xk := xk1
end do;

works for me - at least for initial values between 1 and 10. I can see potential issues for initial values which are negative (or even large and positive).

Since I can't reproduce, I can only suggest

  1. make sure you have a 'restart' command at the start of the code snippet
  2. ensure that the initial value is a floating-point number - ie enter 5.0 rather than 5, which will essentially force all calculations to use floating-point rather than 'exact' arithmetic
  3. outside chance that it is a Maple version issue, although reading your code, I can't see any reason why this would be the case. But if (1) and (2) above do nt fix your problem, then specify Maple version
  1. When adding a small number of terms, it is generally a 'better' idea to use add() rather than sum()
  2. If you do decide to stick with sum() then you will need to adjust the range expression so that the first entry is less than the second. So sum(whatever, -2..0) will give the answer you (probably) want but sum(whatever, 0..-2) will not. Now sum(whatever, 0..-2)  will deliver a consistent answer, but probably not the one you want: see the ?sum/details page as suggested by vv
  3. Using the add() command, it does not matter whether the range is -2..0, or 0,,-2, provided that in the latter case one provides a third argument indicating the 'step'. By default this is '1'. But add(whatever, -2..0) will provide the same answer as add(whatever, 0..-2,-1)

DETools:-DEplot
         ( diff(x(t),t)-x(t), # ODE
            x(t),                # dependent variable
            t=-1..1,           # range of indepenent variable
            {x(0)=1}         # initial condition(s)
         );

as in

display(f1, g1, view = [.8 .. 1.2, 0 .. .4])

See the attached, where I have plotted

  1. f(x,y), at x=xVal, where I set xVal=1
  2. diff( f(x,y),y), at x=xVal, where I set xVal=1
  3. diff( f(x,y),y, y), at x=xVal, where I set xVal=1

You can set xVal to anything sensible with the pde solution space

pdeProb.mw

 

In order to see where you are now, then you need to include representative array 'P'. Also a value for 'N', (unless 'N' is just the range of the first index in 'P').

It is fairly easy to kill the gridlines in the example 'checkerboard' by using the 'style'  option in the polygonplot() command, as in

p := seq
       ( seq
         ( plots[polygonplot]
           ( [[i,j], [i+1,j], [i+1,j+1], [i,j+1] ],
             color=ColorTools:-Color([rand()/10^12,
             rand()/10^12,
             rand()/10^12]),
             style=polygon
           ),
           i=1..10
         ),
         j=1..10
       ):
plots[display]([p]);

 

Having read this question and the previous one where Kitonum supplied the 'Prefix()' procedure, I am still confused about what you are trying to achieve.

Simple example: the Prefix() procedure returns a single expression. It therefore makes absolutely no sense to apply any kind of 'zip()' comannd directly to the output of Prefix(), since the 'zip()' command requires two lists of 'data', as well as the function combining them.

So making a wild guess about converting between 'active' and 'inert' forms of expressions, I can come up with three possibilities, which are illustrated in the three execution groups of the attached worksheet.. If the information containeded does not cover your requirement then you are going to have to explain very clearly, precisely what you do want

inert.mw

there are several ways, but probably the simplest is with the code

restart;
t1:=time():
fr:=rand(0..499999):
M:=seq(fr(), i=1..500000):
t2:=time()-t1;

Don't feel inclined to do the same thing with your other tests - too much typing. In future consider uploading code rather then pictures

 

I'm not exactly sure what your problem is. Uploading pictures rather than code is never a good idea, because it gives responders too much typing to do. Also not a great idea to post partial code.

The following seems to work, and I think it is what you are trying to achieve

  restart;
  with(Statistics):
#
# Generate 1000 samples of a Uniform distribution
# with range -Pi..Pi
#
  NN:=Sample(Distribution(Uniform(-Pi, Pi)),1000):
#
# Compute OP's function (is this an 'arcsine
# distribution'?)
#
  NE:=[seq(1/2-1/2*cos(Pi*NN[i]), i=1..1000)]:
#
# Plot the histogram of NE with 20 bins
#
  Histogram(NE, bincount=20);

 

The code

restart;
checkInSet := proc(L, x)
                                local i:
                                if   nops(L) = 0
                                then return 0;
                                else for i from 1 to nops(L) do
                                             if   x = L[i]
                                             then return i
                                             fi;
                                       end;
                                end;
                      end proc:
M := { (a-2*b-2*c)^2*(2*a-b+2*c)^2,
          (a-2*b-c)^2*(a-b+2*c)^2,
          (a-2*b+c)^2*(a+b-2*c)^2,
          (a-2*b+2*c)^2*(2*a+b-2*c)^2,
          (a-b-2*c)^2*(2*a-b+c)^2,
          (a-b-c)^2*(a-b+c)^2,
          (a-b+c)^2*(a+b-c)^2,
          (a-b+2*c)^2*(2*a+b-c)^2,
          (a+b-2*c)^2*(2*a-b-c)^2
       }:
checkInSet(M, (a-2*b-2*c)^2*(2*a-b+2*c)^2);

returns 1 - which is what I would expect. What did it return for you? And what did you expect.?

which seems to affect only those with Nvidia graphics cards, and who updated their graphics drivers "recently".

Ignore the title and read the thread at

http://www.mapleprimes.com/questions/221001-How-Do-I-Remove-All-Files-Associated#comment236117

Basically the latest official set of Nvidia drivers doesn't seem to work with Maple!!

So if you have an Nvidia graphics card, and you downloaded a new set of drivers in the past month or so (either because you have set the Nvidia driver update to work automatically, or you manually downloaded a new set), then Maple 2016/Maple2015 will no longer work

If this does apply to you, then I recpmmend getting the 'patch' driver set referenced in the second from last entry in this thread. This cured the problem for me. Other solutions are posted in this thread (and they work), but I really can't recommend changing your Maple installation/configuration, just to fix a problem with graphics drivers

I revised some of your code for the "forced" system, just to make it a bit shorter/more efficient and easier for me to figure out exactly what was going on. The first plot in the attached is the same as in your post.

By "autonomous" system, I assume you mean the case where the forcing function is zero. The second half of the attached sheet also produces a plot for this case. I had to drastically shorten the timescale, because the system seems to spiral in to u(t)=1, v(t)=0, pretty quickly. I'm not sure if this is what you want because the Wikipedia article

https://en.wikipedia.or/wiki/Duffing_equation

suggests that the equibrium values can be stable or unstable and depend on the system parameters and initial conditions. So I'm guessing many other behaviours can be generated

duffing.mw

  1. Do you want to remove the first row - fairly simple, can be "hardcoded"
  2. Do you want to add a new first row - fairly simple, can be "hardcoded"
  3. Do you want to remove the last row - fairly simple, can be "hardcoded"
  4. Do you want to add a new last row - fairly simple, can be "hardcoded"
  5. Do you want to  remove an arbitrary row? - Well you will have to provide a facility to specify the row number
  6. Do you want to  add a row at an arbitrary point? - Well you will have to provide a facility to specify the row number

The code in the attached contains execution groups which will handle all of the above possibilities - you just have to figure out which you want (and maybe how to apply it)

addRemRow.mw

 

The following give all solutions for 2<=p<=500. Feel free to pick any maximum p-value you want

  restart;
  pMax:=500:
  seq
  ( `if`
     ( numelems(k)>1,
       k,
       NULL
     ),
     k in [ seq
              ( [ p=j,
                  msolve(x^2 = -1, j)
                ],
                j=2..pMax
              )
            ]
   );

First 171 172 173 174 175 176 177 Last Page 173 of 207