John Fredsted

2238 Reputation

15 Badges

20 years, 170 days

MaplePrimes Activity


These are replies submitted by John Fredsted

Once again it has proven rewarding to read these threads:
  • I did not know that _B1, _B2, etc., meant binary variables taking on values 0 and 1 only, as Robert writes.
  • I did not know that _EnvAllSolutions must be assigned true in order that solve returns all solutions to some trigonometric equation, as Georgios writes.
Thanks, guys!
That is one obvious drawback of rolling back from Maple 11 to Maple 9.5, doing ones own work in Maple 9.5, and then on attending this forum occasionally forgetting to also test ones suggestions in Maple 11.
That is one obvious drawback of rolling back from Maple 11 to Maple 9.5, doing ones own work in Maple 9.5, and then on attending this forum occasionally forgetting to also test ones suggestions in Maple 11.
It was my intention this morning to reply to your post which I saw yesterday evening just before being visited by two close friends of mine. However, due to the time difference between the two sides of the mighty Atlantic (as the Scottish band Runrig sings), many appropiate replies have already been provided by others. However, Jakubi made me wonder because I have never been able to have the <maple>-tag properly format an output containing an assignment, i.e., something of the form LHS := RHS. Looking at Scott's post, in which he explicitly writes the code, I find the reason: an innocent looking, but all decisive, terminating semicolon. That would be quite alright, was it not for the following:
  • It seems that this terminating semicolon must be inserted by hand, as it is not part of the copy-pasted output from the worksheet.
  • For a non-assignment without a terminating semicolon, like <maple>[Matrix([[0, 1], [1, 0]]), Matrix([[1, 1], [1, 0]]), Matrix([[0, 1], [1, 0]])]</maple>, it formats properly.
It was my intention this morning to reply to your post which I saw yesterday evening just before being visited by two close friends of mine. However, due to the time difference between the two sides of the mighty Atlantic (as the Scottish band Runrig sings), many appropiate replies have already been provided by others. However, Jakubi made me wonder because I have never been able to have the <maple>-tag properly format an output containing an assignment, i.e., something of the form LHS := RHS. Looking at Scott's post, in which he explicitly writes the code, I find the reason: an innocent looking, but all decisive, terminating semicolon. That would be quite alright, was it not for the following:
  • It seems that this terminating semicolon must be inserted by hand, as it is not part of the copy-pasted output from the worksheet.
  • For a non-assignment without a terminating semicolon, like <maple>[Matrix([[0, 1], [1, 0]]), Matrix([[1, 1], [1, 0]]), Matrix([[0, 1], [1, 0]])]</maple>, it formats properly.
That is one of those functions that you either know exists, or don't have the fantasy (at least I don't) to envisage the existence of.
That is one of those functions that you either know exists, or don't have the fantasy (at least I don't) to envisage the existence of.
I know this is a bit of a tangent, but I do not find it difficult to copy-paste a Matrix from a worksheet to mapleprimes. One just has to use the <maple>-tag instead of the <pre>-tag. Taking as an example Matrix(3,3,(i,j) -> i*j), the copy-pasted output becomes
                           [1  2  3]
                           [       ]
                           [2  4  6]
                           [       ]
                           [3  6  9]
using the <pre>-tag, and Matrix([[1, 2, 3], [2, 4, 6], [3, 6, 9]]) using the <maple>-tag.
I know this is a bit of a tangent, but I do not find it difficult to copy-paste a Matrix from a worksheet to mapleprimes. One just has to use the <maple>-tag instead of the <pre>-tag. Taking as an example Matrix(3,3,(i,j) -> i*j), the copy-pasted output becomes
                           [1  2  3]
                           [       ]
                           [2  4  6]
                           [       ]
                           [3  6  9]
using the <pre>-tag, and Matrix([[1, 2, 3], [2, 4, 6], [3, 6, 9]]) using the <maple>-tag.
Here is a solution that works for multidimensional Arrays, giving two lists of indices for the minimal and maximal entries, respectively, allowing the minimal and maximal values to be multiple present (degenerate) in the Array. Define an indexing function:
`index/makeIndex` := proc(Idx::list,Arr::Array,Ent::list)
	if nargs = 2 then Arr[op(Idx)]
	else Arr[op(Idx)] := (Idx = op(Ent))
	end if
end proc:
Then, for the Array you provide (note the degeneracy for the minimum value 2):
L := ListTools:-Flatten(convert(Array(makeIndex,A),listlist)):
AMin := min(map(rhs,L)[]);
AMax := max(map(rhs,L)[]);
AMinInd := map(lhs,select(x -> evalb(rhs(x) = AMin),L));
AMaxInd := map(lhs,select(x -> evalb(rhs(x) = AMax),L));
                           AMin := 2
                           AMax := 27
                  AMinInd := [[1, 4], [4, 4]]
                      AMaxInd := [[2, 3]]
If subs and eval uses information from dismantle to perform their jobs, then the former ones should not work for matrices, compare the blog post Matrices and dismantle. And indeed they do not as the following simple example shows:
expr := [Matrix(2,2,(i,j) -> i*j),y];
subs(Matrix([[1,2],[2,4]]) = x,expr);
eval(expr,Matrix([[1,2],[2,4]]) = x);
I think the best you can do is to locally expand the polynomial:
split := proc(p::polynom(anything,[x,y]))
	local q;
	q := expand(p);
	if type(q,`+`) then map(split,q)
	else select(type,q,freeof([x,y])) * INT(degree(q,x),degree(q,y))
	end if
end proc:
I reckoned that. I hope that you have received a useful answer from the others, because these postings of mine surely are of no help :-).
I reckoned that. I hope that you have received a useful answer from the others, because these postings of mine surely are of no help :-).
You are quite right, which is why I withdraw my post. I apologize.
First 46 47 48 49 50 51 52 Last Page 48 of 68