acer

32333 Reputation

29 Badges

19 years, 325 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Hi Robert, This is equivalent to what I was did, I believe, although I assumed that the poster would see the rationale for himself. There are 12 equations in 2*4*4 unknowns (real and imaginary parts). And only when the 12x32 matrix has rank=12 will one know that the 12 rows (or 12 4x4 complex matrices) are linearly independent. What I had as the bigM Matrix looks equivalent to the Matrix G in what you posted (though possibly with columns out of order). One can form G without having to form eqs, though of course `solve` would use the latter. acer
Can you make a 12x32 Matrix, where the entries of each row are the real and imaginary components of the entries of one of the 4x4's? with(LinearAlgebra): for i from 1 to 12 do M[i] := LinearAlgebra:-RandomMatrix(4)+I*LinearAlgebra:-RandomMatrix(4); od: for i from 1 to 12 do m[i]:=ArrayTools:-Alias(M[i],[16]); od: for i from 1 to 12 do n[i]:=Vector[row](32,[Vector(16,ii->Re(\ m[i][ii])),Vector(16,ii->Im(m[i][ii]))]); od: bigM := Matrix(12,32,(i,j)->n[i][j]): Rank(bigM); m[7]:=(2*I)*m[1]-m[3]; for i from 1 to 12 do n[i]:=Vector[row](32,[Vector(16,ii->Re\ (m[i][ii])),Vector(16,ii->Im(m[i][ii]))]); od: bigM := Matrix(12,32,(i,j)->n[i][j]): Rank(bigM); m[7]:=(2)*m[1]-m[3]; for i from 1 to 12 do n[i]:=Vector[row](32,[Vector(16,ii->Re\ (m[i][ii])),Vector(16,ii->Im(m[i][ii]))]); od: bigM := Matrix(12,32,(i,j)->n[i][j]): Rank(bigM); I wonder if there's a super slick way to do this using LinearAlgebra[Generic] from Maple 11. acer
Given that m and n are integers, then is it only the cases where m=n that the result is not zero? And when m=n<>0, then is the result Pi? If so (and check that I'm not wrong about that), then Maple 11 gives me, > _EnvAllSolutions:=true: > int( cos(m*x) * cos(n*x) , x = 0..2*Pi) assuming n=m, n::integer, m::integer: > lprint(%); piecewise(m+n = 0,2*Pi,Pi) That looks close. The subcase m+n=0 combined with m=n implies that m=n=0, so 2*Pi is good there. But I couldn't get maple to simplify to that. Interestingly, I got it slightly differently below using assume instead of assuming, > _EnvAllSolutions:=true: > assume(m::integer,n::integer); > int( cos(m*x) * cos(n*x) , x = 0..2*Pi ): > lprint(%); piecewise(m-n = 0,Pi,0)+piecewise(m+n = 0,Pi,0) Using other incantations of assume(), I got a result similar to the first one above, using assuming. acer
Can you use the new parameter-processing for this? See the ?paramprocessing help-page. > are_these_numbers_equal := proc(a, b, {tol::{identical(none),realcons}:='none'}) > if a<>b then > if type(tol,realcons) and abs(a-b) else return "False"; > fi; > else > return "True"; > fi; > end proc: > are_these_numbers_equal(2.,3.,tol=0.3); "False" > are_these_numbers_equal(2.,2.2,tol=0.3); "True enough" > are_these_numbers_equal(2.,2.2); "False" > are_these_numbers_equal(2.,2); "True" > are_these_numbers_equal(2.,2.4,tol=0.3); "False" Also, the help-page ?`:=` says, 1. The left-hand side is evaluated to a name. (For more information, see the evaln function). I believe the intended meaning there is that the lhs of the `:=` assignment statement must be something that can evaluate as a name. See the ?evaln help-page. I interpret the meaning as saying that the object has to be such that it can be used as a name. Maybe I'm wrong. If lhs(T):=rhs(T) were to do anything (and I can understand that it does not) then my guess would have been more along the lines of assigning to a remember table. But lhs doesn't have such, that I know of. And it seems difficult to give one to such built-ins, without them not losing their functionality. acer
There are several claims put forward in this post which I find to be incorrect or surprising. It is a mistake to expect that `:=` can be used as a postfix operator, eg. by doing things like `:=`(T,7) and expecting T to be assigned the value of 7. Notice too that it's help-page, ?`:=` calls it the assignment statement, not the assignment operator, and shows usage to accord with this. It was claimed that this works, in the original post, for piped in TTY maple. Is it truly so, and if so then in which version of Maple? It is a mistake to expect evalb() to return true when asked to compare a global and local which use the same symbol. I would be surprised if evalb ever identified the two as being the same. It is a mistake to expect lhs(Q) to not produce the `a` from the higher level (in this case, the global), when Q is a procedure parameter which gets passed in as a=5 say. If one used the assign() command then a side-effect will be brought about on the inbound name/value rather than on some local using the same symbol. I'm not a big fan of using side-effects when coding in Maple, but I don't find this behaviour surprising. So, what buggy behaviour has truly been shown here? acer
I realized that I had a little bit of conditional probability in the code, according to how one looks at it. It hinges on the if..then..else..end if clause in the proc body. "if nops(montys_choices) = 1 then" means that Monty had no choice in how to show inside a losing door. That's because the player picked a loser. Monty can't show the winning door, and he can't show inside the player's picked door. So he has only one choice. This can be rephrased as, "Given that the user selects a losing door, then Monty will show the remaining losing door and the final unshown door will always be the winning door." That has just the sort of phrasing that conditional probabilities do, when spoken, I think. It says, "Given that the user selects a losing door, then switching will always win." Similarly, one can analyze the code fragment that occurs in the `else` portion. Given that the player picked the winning door then Monty has a choice of two doors. Hence, given that the player picked the winning door then switching will always lose. These are both conditional probability statements. The probability of the first parts ("that the user selects a losing door" and "that the player picked the winning door") are 2/3 and 1/3 respectively. What makes it a somewhat unusual conditional probability is that the other parts (subsequent chances of winning, upon switching) have probabilities of 1 and 0 respectively. ps. I initially responded that the coding would be straightforward. There is one place where I made it not so, very much on purpose. It's where the set montys_choices is converted to a list and sorted, prior to one entry of it being selected at random. I just wanted to be sure that I'd avoided any pitfall of the consequences of how maple might order sets (now, or in future). acer
I realized that I had a little bit of conditional probability in the code, according to how one looks at it. It hinges on the if..then..else..end if clause in the proc body. "if nops(montys_choices) = 1 then" means that Monty had no choice in how to show inside a losing door. That's because the player picked a loser. Monty can't show the winning door, and he can't show inside the player's picked door. So he has only one choice. This can be rephrased as, "Given that the user selects a losing door, then Monty will show the remaining losing door and the final unshown door will always be the winning door." That has just the sort of phrasing that conditional probabilities do, when spoken, I think. It says, "Given that the user selects a losing door, then switching will always win." Similarly, one can analyze the code fragment that occurs in the `else` portion. Given that the player picked the winning door then Monty has a choice of two doors. Hence, given that the player picked the winning door then switching will always lose. These are both conditional probability statements. The probability of the first parts ("that the user selects a losing door" and "that the player picked the winning door") are 2/3 and 1/3 respectively. What makes it a somewhat unusual conditional probability is that the other parts (subsequent chances of winning, upon switching) have probabilities of 1 and 0 respectively. ps. I initially responded that the coding would be straightforward. There is one place where I made it not so, very much on purpose. It's where the set montys_choices is converted to a list and sorted, prior to one entry of it being selected at random. I just wanted to be sure that I'd avoided any pitfall of the consequences of how maple might order sets (now, or in future). acer
It should be straightforward to write a program in maple that simulates the game. That would let you confirm whether it is better to always switch, or not. acer
It should be straightforward to write a program in maple that simulates the game. That would let you confirm whether it is better to always switch, or not. acer
Robert's suggestion to simply remove the square [] list brackets from equ1 and equ2 is better than my suggestion to do equ11:=w_1=op(rhs(...)). But you might still want to use the ideas about reducing the number of equations. Multivariable Newton's method has an easier time of it and a better chance for convergence, for smaller systems of fewer variables and equations. It might then make it faster a more likely to get a result, if you decide to go with a variety of values for delta, p, and T say. acer
Robert's suggestion to simply remove the square [] list brackets from equ1 and equ2 is better than my suggestion to do equ11:=w_1=op(rhs(...)). But you might still want to use the ideas about reducing the number of equations. Multivariable Newton's method has an easier time of it and a better chance for convergence, for smaller systems of fewer variables and equations. It might then make it faster a more likely to get a result, if you decide to go with a variety of values for delta, p, and T say. acer
The first problem is that some of the "equations" you were passing in the first set argument to fsolve were of the form, name = list It looks a lot like what you wanted instead was the inside of that right-hand-side list (rhs). So, you could get it like so, equ11 := w_1 = op(rhs(eval(equ1, [p = .3, T = .1, delta = .9]))) and, equ22 := w_2 = op(rhs(eval(equ2, [p = .3, T = .1, delta = .9]))) Now, moving on. You can re-substitute quite a few of the later equations back into the earlier ones, to get down to a 2- or 3-variable system that fsolve handles OK. Here's what I added, at the end of your document, mw1w2 := isolate(equ44, m); A1 := eval(eval(equ11, [equ66, equ77, equ55]), mw1w2); A2 := eval(eval(equ22, [equ66, equ77, equ55]), mw1w2); A3 := eval(eval(equ33, equ55), mw1w2); Note that now, I could isolate w_1 from equation A1, and re-substitute that into A2 and A3 to get a 2-variable system of 2 equations. I didn't bother. solution := fsolve({A1, A2, A3}, {l, w[1], w[2]}, w[1] = -10000 .. 10, w[2] = -10000 .. 10, l = 0.1e-3 .. 1.999); That gave the result, {l = 0.4787635963e-2, w[1] = -1.900353594, w[2] = -1.901837431} The equations equ66 and equ77 give q and o directly. eval(mw1w2,solution); # gives value for m eval(eval(equ55, mw1w2), solution); # gives j I can re-substitute that solution into the equations, and check that doing so produces a very small float. Eg, eval(A2,solution); # gives close to 0.0, same for A1,A3 acer
The first problem is that some of the "equations" you were passing in the first set argument to fsolve were of the form, name = list It looks a lot like what you wanted instead was the inside of that right-hand-side list (rhs). So, you could get it like so, equ11 := w_1 = op(rhs(eval(equ1, [p = .3, T = .1, delta = .9]))) and, equ22 := w_2 = op(rhs(eval(equ2, [p = .3, T = .1, delta = .9]))) Now, moving on. You can re-substitute quite a few of the later equations back into the earlier ones, to get down to a 2- or 3-variable system that fsolve handles OK. Here's what I added, at the end of your document, mw1w2 := isolate(equ44, m); A1 := eval(eval(equ11, [equ66, equ77, equ55]), mw1w2); A2 := eval(eval(equ22, [equ66, equ77, equ55]), mw1w2); A3 := eval(eval(equ33, equ55), mw1w2); Note that now, I could isolate w_1 from equation A1, and re-substitute that into A2 and A3 to get a 2-variable system of 2 equations. I didn't bother. solution := fsolve({A1, A2, A3}, {l, w[1], w[2]}, w[1] = -10000 .. 10, w[2] = -10000 .. 10, l = 0.1e-3 .. 1.999); That gave the result, {l = 0.4787635963e-2, w[1] = -1.900353594, w[2] = -1.901837431} The equations equ66 and equ77 give q and o directly. eval(mw1w2,solution); # gives value for m eval(eval(equ55, mw1w2), solution); # gives j I can re-substitute that solution into the equations, and check that doing so produces a very small float. Eg, eval(A2,solution); # gives close to 0.0, same for A1,A3 acer
Since the evalf[..](...) action is only an approximate floating-point computation then the results would likely never be identically equal. If you increase the working precision during the floating-point evaluation in Idea 3 (or 2) then you might see those scalar floating-point numbers get closer to each other. If they don't get closer, as the precision is increased, then they are likely not equal. The precision in the incantations that I gave is specified by the number in the indexing [..] brackets of the evalf call. So, evalf[50](...) uses a working precision of 50 decimal base-ten digits, while evalf[100](..) would use a working precision of 100 digits. Calling evalf in this indexed way is an alternative to setting the Maple environment variable Digits. If, as you raise the precision, the results for sol1 and either sol2 or sol3 keeps getting closer then it may be that the obtained formula which you are instantiating at specific a,b, and c does actually work. During the (Gaussian) elimination steps that happen while Maple computes the so-called LU decomposition of a Matrix, a "pivot" is found for each row reduction. The pivot is chosen as a leading non-zero entry in the current column. Sometimes a complicated expression in an entry might appear as a huge involved formula while in truth it is identically zero (upon simplification, or conversion to so-called "normal" form). The candidates for pivot selection are hit with the Normalizer function, in order to attempt to always recognize elements as being invalid on account of their being actually zero. One can override the Normalizer. The function x->x is a "no operation" action, which while fast won't do any simplification and is thus not a good zero-recognizer. The danger, then, is that a hidden zero might get used as a pivot. The default Normalizer, when not overridden, may have to work very hard, which is why there is such a performance speed difference. I ought to read Jacques' paper(s) on these subjects. In one (other?) thread he talked about doing the Gaussian elimination step by step, and taking account of the pivots one by one. I'm wondering now whether fraction-free elimination would be a more useful approach. After all, determinant calculation doesn't necessitate divisions... Now, back to your problem. If you evaluate the original Matrix at given numerical points for a and b, then the determinant will be a univariate expression in c, yes? You could solve or fsolve that expr=zero for c. So, if it was fast enough to compute the determinant of that univariate Matrix (after instantiating a and b) then you might be able to repeat this many times. If you were lucky, you might be able to repeat it enough times so as to get a mesh of values for c, based on all the different particular a and b pairs that you used. You could then plot those. You might even be able to get a smooth interpolating approximation function, if you had enough numeric sets. acer
Thanks, Paulina. The method of converting to Atomic Identifier we figured out, for non-1D-parsable 2D objects. But ?plots,typesetting also mentions using left-name-quotes to do this (in the same paragraph that it mentions atomic identifiers, for such problematic 2D objects). I couldn't get the left-quotes to do it. Could you give an example? acer
First 568 569 570 571 572 573 574 Last Page 570 of 592