Jarekkk

454 Reputation

13 Badges

19 years, 247 days

MaplePrimes Activity


These are answers submitted by Jarekkk

Here is another example how to do it. It depends on how you would like the complex numbers to be represented in the Excel file. I created two possibilities.

A := LinearAlgebra[RandomMatrix](2, 4, generator = rand(0 .. 5)+I*rand(-3 .. 5));


strings := map(x -> convert(x, string), A);

text := Array(1 .. 6, 1 .. 1, [["Real parts:"], [""], ["Imaginary parts:"], [""], [""], ["Complex numbers:"]]):
with(ExcelTools):
Export(text, "D:/example.xls", "Complex numbers", "A2"):
Export(Matrix([[Re(A)], [Im(A)]]), "D:/example.xls", "Complex numbers", "B2"):
Export(strings, "D:/example.xls", "Complex numbers", "B7"):

Excel file:


The problem is that 10 default digits are not enough to compute "precise enough" numerical values of the sol function. Set Digits to 15 (for example).

To have 3 real solutions the second order polynomial (x^2 - 2*m*x + 5*m - 6) has to have a positive discriminant. So you can use the discrim command.

Then you only need to eliminate those values of m (if any) for which some solutions are the same.

This

int(x*y*(x^2-y^2)/(3*(x^2+y^2)^3), [x = 0 .. 2, y = 0 .. 1]);

works.

That is because rsolve couldn't find any solution. You can set infolevel['rsolve'] := 2 to gain more information when trying to solve. See ?rsolve for more details.

I have created a simple example. If it doesn't help, you can upload your worksheet with excel sheet to see what is wrong.

You can also look at the quantities.xls first to see that the values are not there (in the "Errors" sheet) before running the maple worksheet. You would also need to change the path to the excel file (or place it like me).

example.mw

quantities.xls

You can use simplify commnand.

simplify(sqrt(16*y^6));

You can also add the assumptions, e.g.:

simplify(sqrt(16*y^6), assume = real);

For more information look at ?simplify.

It would be nice if you could titled differently your question and if your problem was better specified.

If I understand it correctly:

One boy eats 6 or 7 pieces of pizza, one girl eats 2 or 3 pieces of pizza. When we give them 4 pizzas (48 pieces) it is not enough for them, when we give them 5 pizzas (60 pieces), at least one piece of pizza remains. How many boys and girls are there?

Solution:

Let us denote x the number of boys and y the number of girls. Since 48 pieces are not enough, we can write the first inequality:

ineq1 := 6*x+2*y >= 49:

Since 60 pieces are more than enough we deduce the second inequality:

ineq2 := 7*x+3*y <= 59:

Now, there are several solvers for inequalities. In our case the isolve command for the integer solutions would suit it best. Unfortunately, it finds no solution. So we can use the general solve command instead.

solve({ineq1, ineq2});

There is also the possibility to use assumptions. Unfortunately again, it doesn't help. So now the one step by hand. From the obtained solution we see x has to be at least equal to 8 (since it is a whole number). On the other hand from the second inequality (ineq2) we see that x has to be less than 9 (since y is nonnegative), so x has to be equal to 8. And then it is easy to get the value of y with isolve.

x := 8: isolve({ineq1, ineq2});


You haven't specified the initial conditions (ic2) correctly. Namely the initial value for D(y), there has to be also a point, at which it holds, e.g.:

ic2 := x(0) = 1, (D(x))(0) = 0, y(0) = 0, (D(y))(0) = 1;

with(LinearAlgebra);
Id := Matrix(3, shape = identity):  # symbol I is reserved for the imaginary unit
X := LinearAlgebra[RandomVector][column](3, generator = 1 .. 9):
Y := LinearAlgebra[RandomMatrix](3, generator = 1 .. 9):
Z := LinearAlgebra[RandomMatrix](3, generator = 1 .. 9):
a := 2: b := 3: q := 5:

A := Matrix(8):
A[1 .. 3, 1 .. 3] := Id:
A[1 .. 3, 4 .. 6] := Y:
A[1 .. 3, 7] := -X:
A[1 .. 3, 8] := a*X:
A[4 .. 6, 1 .. 3] := b*Y:
A[4 .. 6, 4 .. 6] := Z:
A[7, 1 .. 3] := Transpose(X):
A[8, 8] := q:

A;

MatrixInverse(A);  # Inverse matrix to A (didn't look good after copy/paste)

 



restart;
with(geom3d):
point(A, 1, 2, -1):
point(B, 3, -2, 5):
line(l, [A, B]):
eq := Equation(l, 't');

new_eq := solve(x = eq[1], t) = solve(y = eq[2], t):
new_eq = solve(z = eq[3], t);

OK, we can transform the problem as follows. Let M be a 5x5 matrix

f :=(i, j)-> x[5*i-5+j]:
M := Matrix(5, 5, f);

where x[i] is in {0,1} for i=1..25. Let "1" mean "the cell is black". Then each 3x3 matrix has to have the sum of its elements equal to 5 and each 2x4 and 4x2 matrices have to have the sum of their elements equal to 4.

I wrote a simple procedure for summing the matrix elements:

with(MTM):
elem_sum := proc (Mat::Matrix) sum(sum(Mat, 2), 1) end proc:

Then we can compose the equations (for the earlier noted sums) and solve them:

eqs := seq(seq(elem_sum(M[i .. i+2, j .. j+2]) = 5, i = 1 .. 3), j = 1 .. 3), seq(seq(elem_sum(M[i .. i+3, j .. j+1]) = 4, i = 1 .. 2), j = 1 .. 4), seq(seq(elem_sum(M[i .. i+1, j .. j+3]) = 4, i = 1 .. 4), j = 1 .. 2):

res := isolve({eqs});

And we get for example:

                          x[13] = _Z1
                  x[14] = 4 - _Z1 + _Z2 + _Z3
                          x[23] = _Z2
                          x[24] = _Z3


Since x[i] is in {0,1} for i=1..25 the above equations can not hold. I tried it before also with

assume(seq((x[i] in {0, 1}), i = 1 .. 25));

and got the same result, so I was not sure if it is correctly computed. But it seems that Maple doesn't care on the assumptions in this case. :)

There are several possibilities. You can use ?Statistics[ScatterPlot] for example.

Simple example:

M := Vector([seq((1/32)*Pi*n, n = 0 .. 32)]):
N := LinearAlgebra[RandomVector](33):
Statistics[ScatterPlot](M, N);

Is this what you're looking for?

f := i -> theta[i]:
v := Vector(100, f):
x := cos~(v):
y := sin~(v):

x1dot := diff~(x, v);

y1dot := diff~(y, v);

x2dot := diff~(x, v$2);

y2dot := diff~(y, v$2);



The new one is easy and you almost don't need to count anything.

Since stdev>0 is a constant you need to maximize w1*E1+(1-w1)*E2, which is max(E1,E2). So you only need to find out which one from E1 and E2 is greater and w1 will be either 0 or 1 according to it.

3 4 5 6 7 Page 5 of 7