tomleslie

13876 Reputation

20 Badges

15 years, 176 days

MaplePrimes Activity


These are answers submitted by tomleslie

to me - rather than a 'matrix' problem. So if you are just looking for a 'fast' way to write this equation, how about

restart;
add( mul(k)*add(k), k in combinat:-choose([i1,i2,i3,i4], 3));

 

with the definition of your equations.

If I guess what is intended in various places in you code, fix various typos etc, I can reduce your system to four equations in four unknowns, but cannot obtain a solution for these - suggesting that the equations are inconsistent, or that one or more of my guesses was wrong.

Examine the following, in which fsolve() does not succeed in obtaining a solution

eqProb.mw

your problem, since code will not execute without values for all of the parameters.

I have guessed values for these parameters, and fixed a couple of typos. This code now executes for one iteration through the loop. I don't really undertand why you are generating/plotting lots of points (all of which are almost exactly the same), or whta the point of updating values for the initial conditions (for subsequent loop iterations).

Anyhow, starting from the following, where do you want to go?

odeloop.mw

restart;
myInt:=n-> int( (2*sin(x/2)/x)^(2*n),
                           x=0..infinity
                        );
mySum:= n-> 2*n*Pi*sum( ((-1)^j*(n-j)^(2*n-1))/(j!*(2*n-j)!),
                                              j=0..n
                                            );
seq( `if`(myInt(p)=mySum(p), true, false), p=1..4);

 

In Maple, one only uses square brackets, ie '[]', when creating/accessing an indexable quantity. You seem to be using these more or less at random. You can't. In Maple '()' and '[]' mean two entirely different things

Maple is case-sensitive, so (for example), 'table' and 'Table' are two entirely different things, and only the former is defined within Maple. There are mulitple other occurences of such random capitalization

There are various 'commands', eg 'FindRoot', 'Interpolation' which I don't recognize as Maple commands at all: I guess you may be loading these as part of your maple.ini file

 

There is no consistent, workable method of finding Greek characters/words in a Maple worksheet if you have elected to use 2D-input mode.

Obviously it trivial to do this, if you use 1D-input mode

Maple does not generate anythig in touchstone format

If memory serves (and at my age it generally doesn't!), touchstone was an ASCII file format which comprised a header, followed by a lot of "matrices". The header consisted of simple information describing the subsequent data so would contain things like

  1. whether the data was in the form of S-parameters, Y-parameters, Z-parameters (whatever)
  2. whether the data was given in single-ended or differential form
  3. format for the data - ie real+imaginary, magintude+"wrapped" phase, magnitude+absolute phase etc
  4. probably also some kind of port count and port definitions

The following matrices comprised one of  S-parameters, Y-parameters, Z-parameters (maybe a few others) at specified frequencies.

As such it wouldn't be particularly difficult to come up with a few "fprintf()" statements which would generate a valid touchstone file. However given that touchstone now seems to be a "deprecated" format, one would need a seriously good reason to produce files in this format

the following.

NB you will have to change the file path/name to something relevant for your machine.

I have inserted a blank row between blocks in the Excel spreadsheet. If you don't want this, then use the "commented-out" line instead

 

restart;
with(LinearAlgebra):
with(ExcelTools);
startInd:=1;
for i from 1 by 1 to 4 do
     A:=RandomMatrix(11,6);
     Export( A,
                  "C:/Users/TomLeslie/Desktop/exData.xlsx",
                  "worksheet1",
                  cat("A", startInd)
               ):
 #   startInd:=startInd+op([1,1],A):
    startInd:=startInd+op([1,1],A)+1:
od:

 

as in

DCT(signal) # will perform the discrete cosine transform

Threshold( DCT(signal), options)  #will allow you to 'threshold' the DCT according to the options you supply

InverseDCT( Threshold( DCT(signal), options)  ) # will perform the inverse DCT of the "thresholded" DCT

Obviously since you do not supply a "signal", then it is difficult for me to verify that this will work in your case - but the operations involved are pretty trivial - so I wold be deeply surprised if this does not work

when one exists within the geometry package?

the following seems to work for all coordinate combinations supplied, ie no diveide-by-zero error, and generates a "polite" message whenever the points are collinear

  restart;
  getOrtho:= proc( x1, y1, x2, y2, x3, y3)
                                uses geometry;
                                local ps:= [ point(A,x1,y1),
                                                    point(B,x2,y2),
                                                    point(C,x3,y3)
                                                 ]:
                                try
                                           triangle(ABC, ps):
                                           orthocenter(H, ABC):
                                           return coordinates(H);
                                catch "The three given points are AreCollinear":
                                           printf("  **Don't supply collinear points!**")
                                end;
                      end proc:
  getOrtho(  1, 1, 3, 4,  5, 3);
  getOrtho( -3, 3, 1, 3, -3, 0);
  getOrtho(  0, 0, 0, 3,  4, 1);
  getOrtho(  1 ,1, 2, 2,  3, 3);

Obviously this could be trivially modified for any other method of supplying the coordinates, such as

[x1,y1], [x2, y2], [x3,y3],

or

[[x1,y1], [x2, y2], [x3,y3]]

or whatever

Your first problem is that when you define 'Q' as a passed argument to the procedure, then you cannot reassign 'Q' within the procedure. The standard way around this is to assign a local variable to the passed value of 'Q' and then update the value of the local variable as required.

The second problem I see with this code, is that it is not obvious what you want to be returned when the procedure exits. By default, Maple will return the value of the last executed statement. As a (purely personal) preference, I like to include an explicit 'return' statement, so that I can always specify exactly what will be returned.

Without knowing the definition of the function FN(), it is difficult to be more specific about your problem. If I define some arbitrary function FN(), then the following code will work

restart;
FN:=(v,u,w,x,y)->[v+y, u, w, x, y]:
Bucklingload:= proc( a,b,c,d,Q,pr)
                                     local Qloc:=Q:
                                     while FN(a, b, c, d, Qloc)[1] >0 do
                                               Qloc:= Qloc+pr ;
                                     end do;
                                     return [a, b, c, d, Qloc, pr];
                           end proc:
Bucklingload(5,1,1,1,1,-1);

 

 

One would normally use combine() and expand() to use trigonometric sum and difference formulas. These can be applied to matrices in an elementwise fashion using combine~() and expand~(), as in

restart;
A:= Matrix( [ [ cos(x)*cos(y)-sin(x)*sin(y), cos(x)*cos(y)+sin(x)*sin(y)],
                      [ sin(x)*cos(y)+cos(x)*sin(y), sin(x)*cos(y)-cos(x)*sin(y)]
                    ]
                );
B:= combine~(A);
C:= expand~(B);

I'm not sure what the matrix in your question actually represents.

 

But these two approaches take about the same time/memory on my machine

restart;
with(LinearAlgebra):
with(ListTools):
nr:=10000:
nc:=5:
A:=RandomMatrix(nr, nc);
B:=RandomMatrix(nr,nc);
M:=CodeTools:-Usage( Matrix
                                        ( [ seq
                                            ( [A[..,k], B[..,k]][],
                                              k=1..op([1,2],A)
                                            )
                                          ]
                                        )
                                     );
P:=CodeTools:-Usage( Matrix
                                        ( Interleave
                                          ( [Column(A,[1..op([1,2],A)])],
                                            [Column(B,[1..op([1,2],B)])]
                                          )
                                        )
                                     );

 

of the imaginary unit by using, eg

interface(imaginaryunit=j);

Now 'j' will be square root of -1, and you can use 'I' for anything you want

to adjust your worksheet so that an "answer" can be obtained - see the attached

odeProb.mw

However all of my attempts to evaluate this answer fail at very small values of the  independent variable 't'. Without much justifciation, I would suggest that this failure occurs because the supplied initial conditions are not compatible with the supplied ODEs

First 150 151 152 153 154 155 156 Last Page 152 of 207