## 3053 Reputation

19 years, 191 days

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu`

## .mw files are XML files...

Maple worksheets are, in fact, XML files.

If you want to see what I mean, open a .mw file with a text editor. Note, you should not try to make changes to a worksheet by editing the XML code.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## plots[odeplot]...

Look at the odeplot command in the plots package.

If you have

`ode := diff( H(z), z\$z ) = ...;ics := H(0)=1, D(H)(0)=-1;sol := dsolve( {ode, ics}, H(z), numeric );`

then you can generate your plot with

`plots[odeplot]( sol, [z,1-(2/H(z))*diff(H(z),z)], z=0..1 );`

You will need to finish filling in the ODE, the initial conditions, and the interval on which you want this plot.

The odeplot is one of my favorite plotting functions. See the online help for more examples of what you can do with this command.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## single equation in 28 variables...

Well, you can't do either (in a meaningful way) without some more information.

For example, if you had 26 more equations then you could, in theory, reduce the system of 27 equations in 28 unknowns to a single equation.

Since your single equation is linear, maybe you want all of the solutions to this single equation. If that's the case, you can choose 27 of the 28 variables however you want, and then the equation can be used to solve for the last variable (provided it is not x(8), which is completely unconstrained as a result of your equation). This would give you 28 equations. Is this what you want?

Maybe it would help us if you told us where your equations comes from, and what you want to do with its "solution".

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## First step: plot...

I'm not sure exactly what you are expecting, but a first step might be to plot the curve. That might give you some ideas. To say more, I would need to know why you want to know (homework?) and what tools you know and are expected to use.

Here's how I would plot this curve:

`with( plots ):eq := x^2+x*y+y^2=2010;                       2          2                             x  + x y + y  = 2010implicitplot( eq, x=-55..55, y=-55..55 );`

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu`

## What have you tried so far?...

What have you tried so far?

What do you want from the solution? Do you expect an explicit formula for y(t)? Is an implicit formula OK? Numeric?

Show us what you have tried, and what you hope to obtain, and we'll try to give you some pointers.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## how did you define p and q?...

How did you define p and q? As functions? As expressions?

You are on the right path but the results depend upon exactly how you defined p and q. Rather than show you how I would do this, why don't you show us what you've tried so far.

Also, depending on the specifics of your course, you might want to replace parfrac with fullparfrac. The main difference this will factor terms like x^2+1 as (x+I)*(x-I).

Good luck on your test later today.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## crash confirmed, with additional data...

I am using Maple 14.

I had no problem with n=10000, n=20000, or n=40000. But, n=80000 did crash Maple.

The times required for each test increased faster than the size of the problem.

`  n    time10000  3.14120000 11.78140000 45.094`

From these times, I would say the algorithm used in Median is quadratic in the size of the problem.

Note: I issued a soft restart (restart;) between each test.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## Windows "Locale" setting...

This sounds like something that depends upon the "locale" setting within Windows (I presume).

The locale is generally set through the Control Panel. Look for a resource called "Regions" or "Regional and Language Options" or "Clock, Language, and Region".

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## Re: piecewise function definition...

Here is how I would define such a function:

`u  := x -> piecewise( x<-h, 0, -h<x and x<h, 1, 0 );`

Note that you do not write u(x,0) := ..., rather you use the arrow operator to create a function.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## Plots with different colors (setcolor())...

Maple maintains a list of colors to use in plots through the setcolors command in the plots package:

`with( plots ):C := setcolors();`

Since there are not 11 colors in this list, you might want to cycle through these colors. Here is how this can be done:

`for i from 0 to 10 do  y := i/2;  f := 2*x + y;  plot( f, x, color=setcolors()[i mod nops(C) + 1] );end do;`

I'm guessing that your next question will be to put all 11 plots in one picture. You can do this with a loop and the display command, but Maple makes this much easier:

`plot( [ seq( 2*x+i/2, i=0..10 ) ], x=-1..1 );`

Note that I restricted the domain to the interval [-1,1] as this gives more vertical separation between the curves in the graph. If you don't like this domain, change it to what is most appropriate. (The default is [-10,10].)

Notice that Maple automatically cycles through the 6 colors in its default color list. You can extend (or modify) this list of colors through the setcolors command. For example:

`setcolors( ["Red", "LimeGreen", "Goldenrod", "Blue", "MediumOrchid", "DarkTurquoise",                "Brown", "Magenta", "Cyan", "Pink", "Gold"] );   ["Red", "LimeGreen", "Goldenrod", "Blue", "MediumOrchid", "DarkTurquoise"]`

Note that the output from setcolors is the previous set of colors. If you follow this with a call to setcolors, you will see the current setting:

`setcolors(); ["Red", "LimeGreen", "Goldenrod", "Blue", "MediumOrchid",    "DarkTurquoise", "Brown", "Magenta", "Cyan", "Pink", "Gold"]`

Then, the combined plot looks like:

`plot( [ seq( 2*x+i/2, i=0..10 ) ], x=-1..1 );`

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## Extracting points from a PLOT data struc...

To exatract the matrix of points used in an implicitplot, I would use:

`P := implicitplot( x^2+y^2=1, x=-1..1, y=-1..1 ):pts := op([1,1],P);`

When I did this pts was a matrix with dimensions 167x2. To force Maple to display the contents of this matrix (and not just a placeholder showing the size and type of the elements) it's necessary to change the rtablesize parameter:

`interface( rtablesize=200 ):pts;`

This approach will work for any plot, 2-d or 3-d. But, for a 3-d plot, the structure of the points data structure is different.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## customized restart command - first ideas...

Here's an idea that I hope somewill can turn into a viable answer.

What I envision is a procedure that captures the list of loaded packages, executes the restart, and then reloads the packages.

The packages command provides the list of currently loaded packages. So, what you want to execute is, essentailly:

`restart; map( with, packages() );`

where the value of packages() is determined before the restart is executed.

Here's my naive attempt to implement this idea:

`MyRestart := proc()  local _CMD;  _CMD := sprintf( "restart; map( with, %a );", packages() );  parse( _CMD );  return NULL;end proc;`

Usage would be:

`MyRestart();`

This does not work because parse executes only one command each time it's called. So, the offset option has to be used, maybe something like this:

`MyRestart := proc()   local _CMD;   _CMD := sprintf( "restart; map( with, %a );", packages() );   parse( _CMD, 'offset'=0, statement );   parse( _CMD, 'offset'=10, statement );   return NULL; end proc;`

(There's no need for lastread because we know there are exactly 2 statements in this string.

This has several problems. First, restart can be executed only at the top level, not in a proc.

That's as far as I got with this tonight. I'll bet by the time I wake up someone will have a way to do this. I just hope my ideas are helpful in getting to that point.

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## nested display...

The display command without the insequence=true combines frames from each animation. So, to put the frames of a and b together you would use display( [a,b] ). Then, to append the frames of c to the end, you need to use a second display, this one with insequence=true.

I'll illustrate with an example, with some generic plots in the frames.

`a := animate( plot, [sin(k*x),x=-Pi..Pi,color=blue], k=0..5 ):b := animate( plot, [cos(k*x),x=-Pi..Pi,color=red], k=0..5 ):c := animate( plot, [sin(k+x),x=-Pi..Pi,color=green], k=0..5 ):A := display( a,b ):display( A, c, insequence=true );`

The same result can be obtained in one line with

`display( display( a,b ), c, insequence=true );`

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu`

## You are on the right track. The problem ...

You are on the right track. The problem arises because your ccc does not contain a product. What Maple sees is a function, sin, and its arguments, x. In this case, the select/remove functions apply the binary test on the arguments of the function - this explains the output your showed:

`ccc:= sin(x);S:= select(has,ccc,x);R:=remove(has,ccc,x);                                                                     sin(x)                                   sin(x)                                    sin()`

But, if you give Maple a product:

`ccc:= 2*sin(x);S:= select(has,ccc,x);R:=remove(has,ccc,x);                                                                    2 sin(x)                                   sin(x)                                      2`

Your procedure goes a long way towards creating a procedure that does what you want. Here's the way I would implement it (to avoid the local variables):

myselectremove := proc(a,x)
if has(a,x) then
if type(a,`*`) then
return [selectremove(has,a,x)];
else
return [a,1];
end if;
else
return [1,a];
end if;
end proc;

Others might offer more sophisticated implementations, possibly even with some checks on the arguments to be sure you handle odd situations that you have not otherwise considered.

I hope all of this is of use to you,

Doug

```---------------------------------------------------------------------
Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.edu
Phone:  (803) 777-6183         URL:    http://www.math.sc.edu
```

## for .. do as requested, and seq and map...

Here is how I would do this with the for (do) statement:

`pts := NULL:for new from min(x) to max(x) by stepsize do  pts := pts, [new,min(y)];end do:b2 := [pts];[[2, 1], [2.5, 1], [3.0, 1], [3.5, 1], [4.0, 1], [4.5, 1], [5.0, 1], [5.5, 1],   [6.0, 1], [6.5, 1], [7.0, 1], [7.5, 1], [8.0, 1]]`

Then the plot would be created with

`pointplot(b2,symbol=circle,color=blue)`

If I were to write this on my own, I would use the seq and map commands as follows:

`b3 := map( a -> [a,min(y)], [step] );[[2, 1], [2.5, 1], [3.0, 1], [3.5, 1], [4.0, 1], [4.5, 1], [5.0, 1], [5.5, 1],   [6.0, 1], [6.5, 1], [7.0, 1], [7.5, 1], [8.0, 1]]`

I hope these are useful,

Doug

`---------------------------------------------------------------------Douglas B. Meade  <><Math, USC, Columbia, SC 29208  E-mail: mailto:meade@math.sc.eduPhone:  (803) 777-6183         URL:    http://www.math.sc.edu`
 First 7 8 9 10 11 12 13 Last Page 9 of 44
﻿