MaplePrimes Questions

The following code works fine:

restart;
with(LinearAlgebra): with(MTM): with(StringTools): MultivariateNormalSample := proc (Sigma, V, N) local d; d := LinearAlgebra:-Dimension(V); LinearAlgebra:-LUDecomposition(Matrix(Sigma, datatype = float[8]), 'method' = 'Cholesky') . ArrayTools:-Alias(Statistics:-Sample(Normal(0, 1), d*N), [d, N])+ArrayTools:-Replicate(Vector[column](V, datatype = float[8]), 1, N) end proc: S := MultivariateNormalSample(`<,>`(`<|>`(1, 2), `<|>`(2, 5)), `<,>`(2, 3), 100):
W := ~int8(~round(S)):
K := convert(W, string):
K := Drop(K, 17):
K := Select(IsDigit, K):
M := seq(PadRight(K[i], 2), i = 1 .. Length(K)):
Z := M[1]:
for i from 2 to Length(K) do Z := cat(Z, M[i]); if `mod`(i, 2) = 0 then Z := cat(Z, "\n") end if end do:
Z;

but if I make a proc out of it then it breaks down on the line:

 W := ~int8(~round(S)):

There seems to be an issue with the elementwise tilde operator.

restart;
Generate:=proc()
local MultivariateNormalSample,S,W,K,M,Z,i;
with(LinearAlgebra): with(MTM): with(StringTools):
MultivariateNormalSample := proc (Sigma, V, N) local d; d := LinearAlgebra:-Dimension(V); LinearAlgebra:-LUDecomposition(Matrix(Sigma, datatype = float[8]), 'method' = 'Cholesky') . ArrayTools:-Alias(Statistics:-Sample(Normal(0, 1), d*N), [d, N])+ArrayTools:-Replicate(Vector[column](V, datatype = float[8]), 1, N) end proc: S := MultivariateNormalSample(`<,>`(`<|>`(1, 2), `<|>`(2, 5)), `<,>`(2, 3), 100):
W := ~int8(~round(S)):
K := convert(W, string):
K := Drop(K, 17):
K := Select(IsDigit, K):
M := seq(PadRight(K[i], 2), i = 1 .. Length(K)):
Z := M[1]:
for i from 2 to Length(K) do Z := cat(Z, M[i]); if `mod`(i, 2) = 0 then Z := cat(Z, "\n") end if end do:
return Z:
end proc;Generate();

I seem to have missed something. Any ideas?

Harry

hi.please see attached file and explain how i remove error

thanks alot

error3.mw

Maple 2015, Windows 7 Pro

Notice the printout of the following example.  The true/false Maple evaluations are incorrect because I do not know what TYPE command to put in the printf expression.  However, the format of the printout is what I want.

restart;
r:= [17=15,16<17,17>18]:
printf("%{}9a\n\n%{}9a\n\n", <r>,<type~(r,anything)>)



  17 = 15   16 < 17   18 < 17

     true      true      true

In this second example the Maple evaluations of the statements are correct, but I want the print format to flow accross the page rather than down the page.

restart;
for r in [17 = 15, 16 < 17,18 < 17]
do
printf("%{}9a\n\n%{}9a\n\n",<r>,<evalb(r)>)
end do;
  17 = 15

    false

  16 < 17

     true

  18 < 17

    false

Could someone show me how to modify the second example so that the printout will flow across the screen rather than down the screen.  Thanks in advance, Les  PS I'd like to keep the loop if possible.

I have y"+y=sinx

If I want to substitute y=sinx, how should I do it?

I tried subs(y=sin(x),f(y))(ofc after defining f:=y as above).

The most troubling thing is that it does not automatically apply double derivative.

I have the following code of a plot:

plot(
[
add(BS(bb[4], t, i, 3)*bb[1](i+1), i = 0..n),
add(BS(bb[4], t, i, 3)*bb[2](i+1), i = 0..n),
t = 0..1
],
color=red, axes=normal, scaling=constrained, numpoints=100, thickness=2
):

and I get the following error:

Error, (in BS) cannot determine if this expression is true or false: 0 <= t and t < .54901960784313725490196078431373

The problem is that, in the definition of BS, there are some conditions that depend on the variable t. It seems that Maple does not use a specific value of t when executing BS. My solution is to plot specific points, i.e., 

plot(
[
seq([add(BS(bb[4], h/5000, i, 3)*bb[1](i+1), i = 0..n),
add(BS(bb[4], h/5000, i, 3)*bb[2](i+1), i = 0..n)], h=0..5000)
],
color=red, axes=normal, scaling=constrained, numpoints=100, thickness=2
):

Can this be done in a more elegant way?

 

 

Hello maple experts,

please is there any other way of solving this problem Wht.mw

Some complained that the graphs do not satisfy the boundary conditions smoothly.

Thanks.

How can I display in Maple T.A. the content of a matrix as pure text?

Thus instead of

matrix([[1, 2], [3, 4]])

1 2

3 4

Is there a solution without using Mathml and hopefully without using StringTools?

And can I assign the rectangular text display to a variable (including line feeds)?

 

Harry

 

 

Dear Friends

I am trying to find determining system for variable coefficient KdV equation, this system is required to find relevant point symmetries for said equation. Following is set of command that I used to perform task:

This last cammand gives me determining system for PDE1.

Following is direct procedure to find determining system:

This last command give large expression from which determining system is obtained by equating coefficient to zero which does not matches with determining system obtained with first procedure.

What could be the possible error?

I have also attached relevant Maple18 file for analysis.

[411]_Determing_Equations_for_Variable_coefficient_KdV.mw

Here is one I have been struggling with lately:

I have a relatively large module with many procedures inside (plus some other data structures). In one of the procedures, it turns out that it would be convenient to have a subprocedure defined inside to both shorten the code by avoiding duplication as well as make it more error proof (once the subprocedure is debugged it'll be correct everywhere it is used). Here is the skeleton

Lattice:=module() option package;
export Track;   ...
   Track:=proc(arguments) uses LinearAlgebra;
   local trackElement;
      ...

      for ... do
         result:=trackElement(parms); # This does not work
         ...
      end do

      trackElement:=proc(arguments) uses LinearAlgebra;
         ...
      end proc; # trackElement

   end proc; # Track;

end module; # Lattice

The problem I have is that procedure trackElement is not recognized as i found out running the code in the debugger. I can make it work by taking trackElement out of Track and make it local to the Lattice module. While functionally this works (and it is how I have it now programmed), I do  not like it as every proc in the Lattice module can see trackElement. That should not be so, I want it local to procedure Track, which is where it belongs.

I really thought I could define procedures within procedures. Am I wrong? Or is there something else ging on?

TIA,

Mac Dude

PS: The whole module is more than 100 kB of Maple code sitting in a library. I refrain from uploading it here as it would be non-trivial to get going even for a simple test case.

So basic problem.

 

I want to create a list with undetermined size. I have some data, let's say these data objects are numbers for now (they can be expressions of variables, or even equations)

 

Here is a pseudocode,

 

for n=1:10

  list(n) = n+1;

end

 

So the above for loop will create a list of size 9, with objects being number 2 through 11.

 

I want the list to be in {} form

 

Now I awnt to take this further. Let's say my data objects aren't just numbers, but expressions. How would I create a list of expressions and turning them into an equation?

 

Example

 

e1 := a^2 + b

e2 := b + a*b

 

e3:= b*a + a*b^2

 

Pesudocode

 

for i = 1:3 do

list(i) = ei ~=0;

end

 

Output should look like

 

list = {a^2 + b = 0, b + a*b=0,b*a + a*b^2=0}

 

Notice the use of curly braces

 

hi

how can I download Fourier series package?

Hello Primers

I am doing some homework with the software Maple 2015 where I am supposed to design a lamp through creating some line segments and a circle in a 2d coordinate system. But my question is, how do I add a third dimension and rotate all these line segments around the y-axis, so I can get an idea of how it looks like in 3d?

Here is a picture

Thanks in advance

Dear Friends

I need to arrange legends from 2 to 1.2

Please hint me

Thanks

 

restart:
e := x*t*(E[c]-E[m])/((2*(x+2))*(x*E[c]+E[m])):
EZ := (E[m]-E[c])*((t-2*z-2*e)/(2*t))^x+E[c]:
assume(x > 0):
d := int(EZ*z^2/(-nu^2+1), z = -(1/2)*t-e .. (1/2)*t-e):
R := simplify(subs(E[c] = k*E[m], d/subs(x = 0, d))):
LS[1.2] := solid:LS[1.4] := longdash:LS[1.6] := dash:LS[1.8] := spacedash:LS[2.0] := dashdot:
for k from 1.2 by .2 to 2.0 do
p[k] := plot(R, x = 0 .. 5, color = black, axes = framed, font = [Times, 13], size = [650, 550], resolution = 1200, legendstyle = [location = right], legend = ['E[c]/E[m]' = k], linestyle = LS[k], thickness = 2, labels = ['n', 'P[FG]/P[Metallic]'], labelfont = [Times, 14], tickmarks = [10, 15])
end do:
with(plots):
display({`$`(p[1+.2*m], m = 1 .. 5)});

 

 

Hi,

Is it possible to use the command MatrixFunction with two matrices as:

with(LinearAlgebra):

A := Matrix([[-13, -10], [21, 16]]); B := Matrix([[3, 0], [21, 16]]);

BesselY(A,B) ?

In the maple help we can do the calculation only for one matrix as:

MatrixFunction(A, sin(x), x);

Thank you

First 1228 1229 1230 1231 1232 1233 1234 Last Page 1230 of 2428