tomleslie

13876 Reputation

20 Badges

15 years, 177 days

MaplePrimes Activity


These are replies submitted by tomleslie

I should read the original question more carefully - but

Just for my own education, I generated all possible 4*4 matrices, and then used the LinearAlgebra:-Rank() command to work out how many had rank 3 or 4. Many ways to do the latter. A couple are shown in the attached. But the answer is always 58560 (see the attached)

The very early response posted by Kitonum in this thread used a very similar method to the above, with a slightly different way of generating the relevant matrices. This also counts 58560 matrices with rank 3 or 4 (again see the attached).

The methods proposed by JoeRiel/CarlLove are also implemented in the attached - and I freely admit that I don't really ubderstand these algorithms. However they always produce 57960 matrices with rank 3or4

ranks.mw

So are there 58560 or 57960 such matrices

Could someone smarter than me explain the discrepancy?

When e=9 (there may be other cases) you are trying to assign the matrix entry M[0,0] whihc doesn't exist, becuase matrix indices start at 1. See the attached, where I have added a printf() statement to show the problem

KoordinatRuang2.mw

PS you really shouldn't be accessing matrix elements using round brackets '()' - should be square, ie'[]'

  1. You define h:=evalf(Pi/6) before using N:=solve(h*p = 12*Pi/6, p). That is you have  forced 'h' to be a floating-point number, in which case you will get a floating point answer. Maple's solve() command will return an "exact" answer whenever possible - which you could do with N:=solve( eval(h*p = 12*Pi/6, h=Pi/6), p); This return the integer 12 - because it can!
  2. Your problem with getting the "maximum of all the errors in the column 10 and 12 of the displayed table of results" arises from your use of the commands

err1[c] := abs(evalf(res[i]-exy1)):
err2[c] := abs(evalf(res[i+4]-exy3)):

This gives each entry of err1 (or err2) as the sum of a float (res[1] or res[2]) and a list (exy1 or exy3). If I change these to use the appropriate elements of the lists exy1 and exy3 (as in)

err1[c] := abs(evalf(res[i]-exy1[c])):
err2[c] := abs(evalf(res[i+4]-exy3[c])):

then the final print statements retrun the maximum values in columns 10 and 12 of the displayed table. You probably want to put a '\n' in the first of these print statements just to tidy up the output.

 

  1. You get a value for 'N' usingthe command N:=solve(h*p = 12*Pi/6, p): However the latter return a floating point number, and you cannot initialise a Vector() dimension with a 'float'. Simple solution would be to use err1:=Vector(round(N)): and err2:=Vector(round(N)): (although you may want to consider trunc(N). It depends a little on what values the original solve() command is likely to produce and how you want to set the length of the vectors.
  2. If I use round(N) as the vectore initialiser, I still get errors from the final two print statements. This occurs because you are attempting to evaluate max(err1) and max(err2). However both err1 and err2  are a list of lists, and in fact each sublist consist of an expression of the form number1+[number2, number3...number23]. Maple cannot interpret this requirement of adding a number to a list with a simple '+', and certainly cannot compute the 'maximum' of this listlist structure. If I had any idea of what value you wanted to extract from this lists of lists, then I could (probably) produce it. However, as your code stands the arguments you are providing to the max() commands in the final two expression in your worksheet just don't make much sense (to me or Maple!)

Firstly, you must adopt Carl's suggestion and use '.' as a decimal separator, not ','

Having done this, there seem to be two expressions to be plotted. Earl has made this possible by encolsing them in a list, using '[]'

However these two surfaces have such different 'z-values' that if you plot both on the same graph, then all you will see is two flat planes. You can see a little more detail if you plot these two surface separately (see the attached)

surfPlots.mw

Did you really intend to plot two surfaces??

On my machine this code takes 75secs to run and produces 56088(?) 4x4 binary matrices.

The "quick and dirty" answer I provided earlier runs in 2secs and produces 65536, 4x4 binary matrices (as well as 512 3x3 binary matrices)

The back of my cigarette packet says that there should be 2^(4*4)=65536, 4*4 binary matrices. So why does this "rather complicated" method only produce 56088 - which ones does it "miss", and why?

So far as I can tell, it is painfully slow and gets the wrong answer. Please don't hesitate to tell me if i'm getting this wrong

No-one here is going to retype your code.

No-one here can tell what your data is

Use the big green up-arrow in the MaplePrimes toolbar to upload a worksheet which exhibits the problem

Use the big green up-arrow in the MaplePrimes toolbar to upload the datafile KoordinatRuang2.txt, so we can test

I received an Email suggesting that an update has been posted on this thread, with the (abbreviated) title

after your sevaral attempts on chosen right parame...

However I can find  no sign of this update.

If anyone posted this update, then please check this thread and if necessary repost

If someone posted this update and then deleted it - please don't do that. If you post an update and subsequently decie is wrong, irrelevant whatever, then just post a further "OOps" message stating that the update should be ignored. THat way way I won't waste my time looking for stuff which doesn't exist!!

@hmagii

If you check my previous response, you will see that I did use the laplace transform method to solve both of your problems

It is not my problem if these solutions do not fulfil your homework requirements

The command sequence I posted, ie

restart;
sys := {z = 4, x-y = 5, x+y = 10};
map(rhs, solve(sys, [x, y, z])[]);
rhs~(solve(sys, [x, y, z])[]);
evalf[2]~(rhs~(solve(sys, [x, y, z])[]));

only produces three outputs. The first two, ie

map(rhs, solve(sys, [x, y, z])[]);
rhs~(solve(sys, [x, y, z])[]);

produces *exact*, rational outputs, so both generate [15/2, 5/2, 4].

The third command, using evalf[2], evaluates these outputs to floating-point approximations comprising two significant digits, so it produces [7.5, 2.5, 4.].

Now the OP's original question does not produce the output listed by the OP, because

restart;
sys := { z = 4, x+y= 10, x-y = 5 };
L:=solve(sys, {x,y,z} );

generates L := {x = 15/2, y = 5/2, z = 4} - again exact rationals, rather that the floating point approximations which the OP claims are produced.

Now I have no idea what you mean by your question. The assignment

N := [7.5000000000, 2.5000000000, 4.0000000000]

generates a list of three floating point numbers with 11 significant digits. If you want these as floating point numbers with only 2 significant digits, one obvious question is why define them with 11 significant digits in the first place!! Or you coudl just consider

restart;
N:=[7.5000000000, 2.5000000000, 4.0000000000];
N:=evalf[2]~(N);

So what, exactly, is your problem?

 

Terms like 'ugly' and 'beautiful' don't mean very much. Do either of the following qualify?
 

  restart;
  fq := piecewise( p < -5, 0.,
                   p < -3, .161711971*(p+5.)^3,
                   p < -1, -1.798464149*p^2-.544033315*p+7.541565235-.3076373305*p^3,
                   p < 1, 0.809338641e-1*p^3-.6327505649*p^2+.6216802691*p+7.930136430,
                   p < 3, 0.7445052690e-1*p^3-.613300552*p^2+.602230257*p+7.936619768,
                   p < 5, 0.19182821e-2*p^3+0.39489651e-1*p^2-1.35614035*p+9.894990378,
                   p < 7, -0.256603524e-2*p^3+.106754411*p^2-1.69246414*p+10.45553002,
                   p < 9, -0.254356370e-2*p^3+.106282509*p^2-1.68916084*p+10.44782231,
                   p < 11, -0.2031067084e-1*p^3+.585994401*p^2-6.00656786*p+23.40004343,
                   p < 13, 0.4137545813e-1*p^3-1.449647855*p^2+16.38549696*p-58.70419431,
                   p < 15, -0.273325019e-1*(p-15.)^3,
                   15 <= p, 0.
                 ):
  m := piecewise( p < 1, undefined,
                  p < 9, fq,
                  undefined
                ):
  simplify(m);
#
# or
#
  fq:=unapply(fq,p):
  mm:=unapply(piecewise( p < 1, undefined,
                     p < 9, fq(p),
                     undefined
                   ),p
             ):
  simplify(mm(p));

 

restart;
sys := {z = 4, x-y = 5, x+y = 10};
map(rhs, solve(sys, [x, y, z])[]);
rhs~(solve(sys, [x, y, z])[]);
evalf[2]~(rhs~(solve(sys, [x, y, z])[]));


I mean - what is supposed to be difficult about this?

Sorry, had a 'senior' moment

What I should have said was

sys := {z = 4, x-y = 5, x+y = 10};
sol:=map(rhs, solve(sys, [x, y, z])[]);

If I get to pick my own example, then how about the following

   restart;
#
# Test equation containing parameter 'i'
#
   expr:={x + i*y + z = 2, 2*x + y = 3, z=1};
#
# Simple way to get solutions for multiple values
# of parameter 'i'
#
   [ seq( solve( expr,[x,y,z] )[],i=1..2 ) ];
#
# Harder(?) way to get the same solutions
#
   mySolve:=proc(sys)
                            return [ seq( solve( eval(sys, i=j),[x,y,z] )[],j=1..2 ) ]
                   end proc:
   mySolve(expr);

 

It would seem that your system of equations is

sys:= [diff(y,t) = data[i+t+1], diff(x,t) = data[i+t+1]]

Since you plan on "solving" for x, y, these must be 'names' (ie they do not immediately evaluate to a function of t). Since, as written, 'x' and 'y' are not functions of 't', then both diff(y,t)=0 and  diff(x,t)=0 - which I assume you don't want! So your example should probably read

sys:= [diff(y,t) = data[i+t+1], diff(x,t) = data[i+t+1]]

However this implies that 't' is the continuous, independent variable. However as a continuous variable, 't' cannot then be used to calculate the value of the indexable quantity data[]. SO the above system still does not make any sense. Maybe(?) you mean

sys:= [diff(y,t) = data[i+1], diff(x,t) = data[i+1]]

However this still does not make much sense since it implies diff(y(t),t)=diff(x(t),t), so you still dont have a 'system'. Maybe(?) you mean

sys:= [diff(y,t) = data[i+1], diff(x,t) = 2*data[i+1]^2]

This is *starting* to look like a system which can be solved. However, since this is a system of ODEs, you cannot use 'solve' to get a solution (as in your procedure func1)., you have to use dsolve(). So

dsolve( [diff(y,t) = data[i+1], diff(x,t) = 2*data[i+1]^2], [x(t, y(t)] )

makes some kind of sense.

If I wanted to produce solutions for this, for a range of values for 'i', then the simplest(?) way would be something like

seq( dsolve( [diff(y,t) = data[i+1], diff(x,t) = 2*data[i+1]^2], [x(t, y(t)] ), i=1..100)

Like I said, if the above does not cover what you aret trying to achieve, then you are going to have to provide a better example

First 122 123 124 125 126 127 128 Last Page 124 of 207