acer

32485 Reputation

29 Badges

20 years, 7 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

You can use a mix of the RootFinding:-Parametric package and the `solve` command here.

Perhaps someone could check this over and explain how to reliably obtain the cell boundaries from RootFinding:-Parametric's results, in the single-parameter case. I find the output from CellDescription to be opaque.

param.mw

I was unable to insert the above worksheet's contents directly into this post, getting error messages from Mapleprimes about maplenet.

acer

The first version of Maple supported for Vista by Maplesoft was 11.01.

See here.

acer

If you use the Sockets package, then yes it should be possible for maple to negotiate the SMTP port connection and actually send the email (without `system` calls).

Look here, and perhaps in particular at the example.

I know at least one person who has claimed in conversation to have successfully written such an animal.

acer

Please stop posting duplicates of this earlier post of yours. Just correct the original, if you made mistakes in it, or in its uploaded worksheet.

What makes you think that the exact symbolic inverse of a (pretty general, even if triangular)  6x6 Matrix is going to be anything useful?

Is the non-blocked version of your C.C^%T singular? Did you really intend on having non-invertible blocks, or did you make a mistake in the code that creates each of them? Did you instead want all those entries to be distinct symbols, rather than identical-per-subblock?

What do you intend on doing with any solution, anyway? Are you planning on pumping in values for the x's, at some later time? Because if that is so then why not consider purely numerical solving? (You never responded to an earlier suggestion to a similar question, BTW.)

acer

C:=LinearAlgebra:-LUDecomposition(A,'method'='Cholesky','output'='L');

C.C^%T;

The option output=L is not necessary, as it is the default form returned for method=Cholesky. See here for lots more detail.

acer

> L:=[[name,4,3,6,5],[3,5,name],[3,6,1,2,9,8]];
[[name, 4, 3, 6, 5], [3, 5, name], [3, 6, 1, 2, 9, 8]]

> map2(remove,`=`,L,name);
[[4, 3, 6, 5], [3, 5], [3, 6, 1, 2, 9, 8]]

> map2(remove,`=`,L,3);
[[name, 4, 6, 5], [5, name], [6, 1, 2, 9, 8]]
> map2(member,name,L); [true, true, false]

acer

You can use the Matrix constructor for this, since it provides for an operator initializer of the entries.

c:=Matrix(2,2,(i,k)->i+k):
b:=Vector(2,(i)->i+1):

M:=Matrix(2,2,(i,k)->`if`(i=k,b[i],c[i,k]));

You can replace the 2,2 above with something that returns the dimensions directly. For example, since c above is a Matrix,

> op(1,c);
                              2, 2

So in this case you could also do,

M:=Matrix(op(1,c),(i,k)->`if`(i=k,b[i],c[i,k]));

And of course you could also use your formulae directly,

M:=Matrix(2,2,(i,k)->`if`(i=k,i+1,i+k));

acer

Yes, it should be possible to call such an engine from Maple. But it's likely that it would only be done indirectly, via an intermediary layer written in C, say, to translate between Maple and Mosek data structures and do Mosek initialization.

acer

You can try things like this,

> discont(diff(tan(x),x),x);
                                {Pi*_Z1+(1/2)*Pi}

> discont(diff(abs(x),x),x);
                                       {0}

There is also fdiscont, which uses floating-point approximations.

You might also try your luck a bit with `is` and `coulditbe`, although those wouldn't tell you where (they're for functionals, in this context?).

You can pick apart a piecewise with `op`.

acer

Are you using a full colon, after the outermost `end do`, to suppress output?

acer

> restart:

> e:= G*(.7500000000*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))-.7500000000*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*a+.7500000000*a*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2))) + (1-G)*(-6.250000000*10^(-12)*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*(5.833333333*10^9*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))-7.500000000*10^9)*(4.*a-3.*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))+3.*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*a-3.*a*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2)))^2-6.250000000*10^(-12)*(5.833333333*10^9*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2))-7.500000000*10^9)*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*(4.-4.*a-3.*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))+3.*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*a-3.*a*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2)))^2+0.3645833333e-1*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*(4.-3.*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))+3.*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*a-3.*a*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2)))^2+5.625000000*10^(-11)*(1.000000000*10^10+5.833333333*10^9*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))-7.500000000*10^9*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))-7.500000000*10^9*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2)))*(-1.*B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))+B*sqrt((1.-2.*a+a^2)*B^2/(a^2+B^2-2.*B^2*a+B^2*a^2))*a-1.*a*sqrt(a^2/(a^2+B^2-2.*B^2*a+B^2*a^2)))^2):

> # first, get rid of those suspiciously simple looking floats.
> # (Isn't there as easier way to do this, btw??)

> f:=simplify(subsindets(e,float,t->10^10*identify(10^(-20)*(identify(identify(t)*10^10)))))
> assuming a>0, a<1, B>0, B<1, G>0, G<1:

> f:=simplify(f,size);
/ /
1 | |3 // 4 2 2 \ 4
------------------------- |3 |- (G - 1) ||B - -- B + 1| a
(3/2) \ \4 \\ 27 /
/ 2 2 2\
4 \(a - 1) B + a /

/ 4 4 2\ 3 / 4 2 2\ 2 4 4\
+ |-4 B + -- B | a + |6 B - -- B | a - 4 B a + B |
\ 27 / \ 27 / /

(1/2)
/ 2 2 2\ // 2\ 2 2 2\ //
\(a - 1) B + a / + \\1 + B / a - 2 B a + B / \\(G - 1)

\\
2 \ 3 / 2 \ 2 2 2\||
B - G + 1/ a + \(3 - 2 G) B + G/ a + B (G - 3) a + B /||
//

> ## That attains its (global w.r.t B and a) maximum when a=0, for any given G.
> ## If in doubt, I suppose one could plot it.
> ## It also attains a global max (w.r.t B and a) for all B along a=1, when G=1. See below.
> #plot3d(eval([e],G=1.0),a=0..1,B=0..1,axes=boxed); # or any G>0, G<1

> f_at_a_equals_zero := simplify(limit(f,a=0),size) assuming G>=0, G<=1, B>=0, B<=1;
1 2 3
-- (9 G - 9) B + - B
16 4

> maximize(f_at_a_equals_zero,B=0..1,G=0..1,location); # global max for all B and G, a=0
3 /[ 3]\
-, { [{B = 1, G = 1}, -] }
4 \[ 4]/

But the goal was to find the global maximum for each value of G, not the maximum over all G.

At G=1 the global maximum (in terms of a and B) also occurs all along a=1, and in fact it is constant there,

> eval(f,[a=1,G=1]);
3
-
4

> optB := solve(diff(f_at_a_equals_zero,B),B);
2
- ---------
3 (G - 1)

> simplify(eval(f_at_a_equals_zero,B=optB)); # the answer
1
- ---------
4 (G - 1)

> optG_func := unapply(%,G):

> optG_func(0.15);
0.2941176470

> optG_func(0.10);
0.2777777778

> optG_func(1/3),optG_func(1.0/3);
3
-, 0.3750000000
8

acer

This answer below relates to your follow-up challenge which seems quite different fromn your original post.

Please let us know if you think of other special conditions, as yet unmentioned.

It seems that you are trying to `select` based on the presence of the word "how" and not just the substring "how" so that "thisishowIlikeit" would not match. So, you could Split the strings at delimiter " ", or you could Search for " how " and check both ends as well.

> aa:=[["he",45,123,76,1.0,"4"],["know how",4,9,34,"3.2","5"]]:

> select(t->ormap(z->member("how",StringTools:-Split(z," ")),indets(t,string)),aa);
              [["know how", 4, 9, 34, "3.2", "5"]]

NB. You mentioned StringTools:-Has, before. But that is likely not what you want, since it is a character locater not a substring matcher.

NB. Regarding your earlier talk about parse, the idea of parsing strings containing spaces, to rely on 2D implicit multiplication, looks dubious at best. What about "this 1is 2how $I like it, eh" or "some are 1-1 and some are many-1".

acer

> simplify((combine(expr1-expr2,power))) assuming nonnegative;
                               0

There were some spam responses (now flagged). Is the whole thread just some link-bait spam?

acer

The problem of a missing space (hence, no actual implicit multiplication) also occurs for `&lambda;l`.

That same 2D Math mistake persists in this other post (a duplicate, IMO).

acer

The issue is that the extracted sub-Matrix has global n, and not the assumed, local n.

You can fix it up in several ways. You can create a whole new Matrix, a replica of the extrcated sub-Matrix but with entries evaluated so as to have the assumed n (using copy, or the Matrix constructor, or eval). Or you can use the 'inplace' option to rtable_eval and evaluate the entries of the extracted sub-Matrix without creating yet another Matrix.

Note that merely extracting the sub-Matrix causes creation of a new Matrix. You are thus trying to avoid creating yet another Matrix.

The result of atataa() already has the assumed, local n. There is no need, or effect gained, from copying or evaluating it.

> restart:

> M:=Matrix([[n]]):
> N:=Matrix([[n]]):

> atataa:=proc(a) local s;
> s:=Matrix(1,1);
> s[1,1]:=a[1,1];
> s;
> end proc:

> with(LinearAlgebra):

> assume(n,positive);

> Equal(atataa(M), SubMatrix(N,1..-1,1));
false

> Equal(atataa(M), copy(eval(SubMatrix(N,1..-1,1)))); # another Matrix created
true

> Equal(atataa(M), Matrix(N[1..-1,1])); # another Matrix created
true

> Equal(atataa(M), N[1..-1,1]); # alternate syntax for getting the sub-Matrix
false

> subm_N:=SubMatrix(N,1..-1,1): # or N[1..-1,1], the same deal
> Equal(atataa(M), subm_N);
false

> rtable_eval(subm_N,inplace): # no Matrix created
> Equal(atataa(M), subm_N);
true

A note on efficiency. You wrote that this Equal test will occur inside some loops. Consider altering atataa() to accept both V and Vtmp as a pair of Matrix arguments. You could then re-use the very same Vtmp each time. Even if you have to pay the cost of zeroing Vtmp at the start of atataa (using ArrayTools:-Fill, say) it might still be more efficient than producing garbage Matrix objects inside atataa (which must be collected via memory-management) with each iteration.

acer

First 287 288 289 290 291 292 293 Last Page 289 of 337