# Items tagged with exampleexample Tagged Items Feed

### Procedure plot and return value...

November 26 2014
1 2

Hi,

I've encountered a problem with Maple.

Is it possible to create a procedure which both displays some plots and also returns a value?

When I write a simple example:

It plots a circle as expected.

It returns value 2, but no plot is displayed.

Is it possible to do both, display and return a value?

I used to write two copies of procedure, one for plotting and one for returning value.

But thats not "pretty" solution.

Thanks for help.

### What is the problem with this procedure?...

November 04 2014
0 0
`This is pretty similar to my last question. but I found this maple code on a website that is suppose to find a vertex coloring of a graph G. The output is is supposed to be a list for example like [3, table([y = 1, k = 2, c = 2, m = 3, h = 1, x = 1] where the first part (in this case 3) is the number of colors and 1,2,3 in the second part are the colors to which each vertex is assigned.  However, no matter what graph I run this on I get everything equal to 1. such as [1, table([y = 1, k = 1, c = 1, m = 1, h = 1, x = 1])]. Why is this happening?  `
```color:=proc(G)
local i, j, C, U, V, total_used;
V:=Vertices(G); total_used:=1;
C[V[1]]:=1;```
```  for i from 2 to nops(V) do
C[V[i]]:=0;
end do;```
```  for i from 2 to nops(V) do
U:={};
for j from 1 to nops(neighbors(V[i], G)) do
U:=U union C[neighbors(V[i], G)[j]];
end do;
j:=1;
while member(j, U) do
j:=j+1;
end do;```
```    C[V[i]]:=j;
if j>total_used then
total_used:=j;
end if;
end do;
[total_used, eval(C)];
end:```

### differential equation system...

October 23 2014
0 4

With your help I have a solution to a system of three equations:

(parameters are calculated on the basis of the data (for different values) - one example below)
A1=0.00002072968491, A2=0, A3=0.001946449287, A4=0.01946449287

B1=, B2=0, B3=0.0004773383613, B4=0.00004773383613

C1=, C2=0, C3=, C4=0.00009087604510

eqa1: = A1 * (diff (Tg (x), x, x)) + A2 * (diff (Tg (x), x)) + (A3 + A4) * tan (x) + A3 * Tg (x) + A4 * Tw (x) = 0;

eqa2: = B1 * (diff (Tw (x), x, x)) + B2 * (diff (Tw (x), x)) + (B3 + B4) * Tw (x) + B3 * Tg (x) + B4 * tan (x) = 0;

eqa3: = C1 * (diff (Tz (x), x, x)) + (C3 + C4) * Tg (x) + C3 * tan (x) + C4 * Tw (x) = 0;

indets ({eqa1, eqa2, eqa3}) minus {x};

res: = Dsolve (eval ({eqa1, eqa2, eqa3}) union {boundary conditions ??}, numeric);

for k from 0 to 20 evalf (res (k), 4); from;

c1:= 0.524:

c2:=0.05:

m: = 0;

for m from 0 to 20 and

T (m): = c1 * rhs (op (6, res (m))) + c2 * rhs (op (2, res (m))) + (1-c1-c2) * rhs (op (4, res (m))); print (m, T (m)); end to:

How and what type boundary conditions (I was thinking about the simplest or third type) to be able to determine the values on the y-axis on the graph. For example, the values started at -10, and ended at 10 (at a point (x, -10), (x, 10) in the coordinate system for a predetermined x, for example, from 0 to 20 which start at the point (0, -10 ) and stop at the point (20,10)). My main purpose is to collect these three solutions  to one equation T (x) = az * Tz (x) + and * Tw (x) + ag * Tg (x), and the ends of the graph, they should be in the above-mentioned points (0, -10 ) - start and (20,10) - stop.

Now thank you very much for the advice.

Ewa.

### Special Matrix from Vector Component...

September 28 2014
0 2

Hi all,

Assume that we have a vector, namely v:=[1,-2,3,-4] and we want to construct special matrix namely Z, from Vector v as follow:

first row is 1, secnond row is -2,..., the end row is -4 namely
Matrix([[1,1,1,1],[-2,-2,-2,-2],[3,3,3,3],[-4,-4,-4,-4]]);

in the other word every row of matrix is 4 times corresponding componet in vector.(for example v is (1*4))

how can we do this?

best wishes

Ph.D Candidate

Applied Mathematics Department

### How do I solve a complex multi-regression problem?...

September 25 2014
1 0

Hi all.  I have researched into this problem.  But I could not find a solution to this.

Here is an example.

I have a set of independent variables, say there are 5 of them.  They are 1. Gender 2. Age group 3. Full or part time 4. First language.

I have a set of dependent variables.  Let us consider for an example 6 of them.  They are (i) Develops breast cancer (ii) Develops skin cancer (iii) Develops lung cancer (iv) develops prostate cancer (v) Lives till 50 (vi) Lives till 60 ...

How do I perform the following prediction:

(A) If a person is male and above 50, what are the chances that he is likely to develop prostate cancer?

(B) If a person is female and works part time, what are the chances that she is likely to develop breast cancer and lives till 60?

I need to develop a code and formula to do this?  Can someone please advise?

Many thanks.

Kind regards,

Kris

### How to make the rows of a matrix into a sequence...

August 25 2014
0 12

I am trying to find a way to take the rows of a matrix and put them in a sequence.  For example if i have the matrix

M:=Matrix(3,[[1,1,1],[2,2,2],[3,3,3]]);

I want to rewrite it as S:= {111222333}.

Sorry if this is not clear.  I know how to create a sequence, but I want to be able to use the Matrix and output a sequence without manually inputing the numbers.

### Stem and Leaf Plot...

July 04 2014 Maple
1
0

Following @acer 's challenge to create some more examples for the Rosetta Code project, I've put together some code that constructs Stem-And-Leaf plots here.

I've also attached a new mathapp ( StemAndLeafDisplay.mw ) that contains the code as well as an interactive example for Stem-Plots. This MathApp is also viewable online at the following mobius project page.

This older post may also be of interest for anyone looking to make a stem and leaf plot with decimals.

### Compound Inequalities in Maple 18...

June 12 2014
2 2

Here's an example compound inequality I'm working on.

Working it out manually....

Compound Inequality
4477.25 <= 4477.25+.25*(t-32450) <= 16042.25;

Distribute the coefficient
4477.25 <= 4477.25+.25*t - 8112.50 <= 16042.25;

Combine like terms
4477.25 <= -3635.25+.25*t <= 16042.25;

8112.50 <= .25*t <= 19677.50;

Divide all sides by .25
32450 <= t <= 78710;

How can I ask Maple to simplify this compound inequality? Obviously this is not the correct syntax, It seems Maple doesn't understand what I want it to do.

4477.25 <= 4477.25 + .25 * (t-32450) <= 16042.25;

0.00 <= 0.25 t - 8112.50 and 0.25 t <= 19677.50                (112)

Also is there a way to ask Maple to only perform one step? In the above example, is it possible to ask Maple to "Distribute the .25", then show the result, next ask it to combine like terms, etc?

### operators in GRTENSORII...

June 05 2014
1 4

how gr operators work?

I tried to run example given there but it is not working,

where can I get more examples to understand working of Gr operators work?

specially for raychaudhuri equations.

### How can I animate given the lagrangian?...

April 13 2014
2 4

Given the lagrangian from the pendulum physics example on the help page,

or text format.

L := -sin(omega*t-phi(t))*(diff(phi(t), t))*a*l*m*omega+(1/2)*(diff(phi(t), t))^2*l^2*m+cos(phi(t))*g*l*m

### New features in Maple 18: SQlite support and Backg...

April 02 2014
3
0

In Maple 18, the Database package has been updated to include support for SQlite databases as well as a new option for plots to change the background images on plots.  To showcase both of these features, our engineering team put together an example that optimizes the flight path of a pan-US delivery drone.

This application extracts the latitude and longitude of those zip codes from an SQLlite database (the application includes the database, which cross-references US zip codes against their latitude, longitude, city and state). The application then performs a traveling salesman optimization and plots the shortest path on a map of the US.

### How does one override Maple's built-in ordering an...

March 13 2014
0 3

I have two equations that are valid under the substitution sin <-> cos, so a simple way to generate the second equation is to replace all occurrences of sin with cos. But Maple gets the wrong answer when I do this, because of its built-in simplification. Here is an example. Z1 and Y1 shows the problem; Z2 and Y2 shows that my attempt to overcome the problem doesn't work.  Z3 doesn't work either, proving that the problem is internally generated by Maple because Maple insists on ordering variables in its own way, no matter how I write them.

________simplified example from Maple 15

restart;
Z1:=sin(-a*x+b);
Z2:='sin(-a*x+b)';
Z3:=sin(b-a*x);

-sin(a x - b)
sin(-a x + b)
-sin(a x - b)
Y1:=subs(sin=cos,Z1);
Y2:=subs(sin=cos,Z2);

-cos(a x - b)
-cos(a x - b)
correct answer should be cos(-a*x+b) but the calculated results are off by a minus sign.

Ans1:=evalf(subs(a=1,b=2,x=3,[Y1,Y2,cos(-a*x+b)]));
[-0.5403023059, -0.5403023059, 0.5403023059]

Question: How do I override Maple's desire to stick the "-" sign outside the sin function?

### surfdata visual problems...

November 28 2013
0 1

по_альтернативной_ок.mw

Hi!

i have problems with surfdata command. I want to see beautifull surface, but see only few black lines.

and i dont know why, because i do all like in example.

Thank you vwry much for answers)

### Simple examples of projective geometry...

November 15 2013
0 3

Dear Mapleprimes members,

I am trying to understand some known classical theorems of geometry (thales intersection thm, ceva, menelaus ) from the perspective of affine geometry and projective geometry.(my paper/pencil work is ok.. But I would like to use  Maple to visualize -if possible - geometrically some theorems and properties in a graph)

How could I do it in maple? Where may I get some examples?

thank you,

JeanJ

### for loop for matrix...

October 28 2013
1 1

Find a loop do define these matrices, even for large values of n. Record the Matrix Mn

all i,j=1,2,13,..,n for example

N := `<|>`(`<,>`(1, 2), `<,>`(2, 2))

P := `<|>`(`<,>`(1, 2, 3), `<,>`(2, 2, 3), `<,>`(3, 3, 3))

Q := `<|>`(`<,>`(1, 2, 3, 4), `<,>`(2, 2, 3, 4), `<,>`(3, 3, 3, 4), `<,>`(4, 4, 4, 4))