Carl Love

Carl Love

28085 Reputation

25 Badges

13 years, 98 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

If LL is your list of lists, then the list of the averages of the sublists can computed by (add/nops)~(LL). This works for both symbolic and numeric data. 

You can't meaningfully assign values to both a name and an indexed form of the same name. In this case, you've done this with and r[1] and and k[1]. You can avoid this problem while still having the prettyprinted form of the index appear as a subscript by using r__1. If you don't care about whether the index appears as a subscript, you can use and r1.

There is no problem with assigning to multiple indexed forms of the same main name as long as you don't assign to the main stem. For example, you can assign to r[0] and r[1] as long as you don't assign to r.

The command that you're trying to use, ExpandSteps, is only for polynomial expansion, not for matrix arithmetic. The command that applies to your situation is Student:-LinearAlgebra:-GaussJordanEliminationTutor; however, its use is limited to matrices at most 5 x 5.

I see that your matrix has 9-digit exact integers and exact imaginary values. So what's the point of seeing the steps? Do you suspect an error in Maple's computation?

Maple handles regular expressions. See these help pages:

  • ?StringTools,Regular_Expressions
  • ?StringTools,RegMatch
  • ?StringTools,RegSplit
  • ?StringTools,RegSub
  • ?StringTools,RegSubs

All that VV said is true. I'd just like to add that if you want symbolic variables to be treated like would-be integers until they have values assigned, then use irem instead of mod.

@tomleslie Thanks for testing. The results are not surprising given that I used an array half the size of yours but a more complicated indexing scheme, and otherwise our codes are remarkably similar. Here's an update---much terser but not significantly faster---that probably satisfies the OP's titular no-loop request (thus I made this an Answer):

EratosthenesSieve:= proc(N::posint)
description "Returns list of primes <= N";
local p, k, P:= rtable(1..iquo(N-1,2), k-> 2*k+1);
   if N < 5 then return remove(`>`, [2, 3], N) fi;
   P[[seq(seq(iquo(k-1, 2), k= p^2..N, 2*p), p= thisproc(isqrt(N))[2..])]]:= ();
   [2, seq(P)]
end proc:

 

It is useful---and often essential---to avoid repetition when generating combinatorial objects. It can, for example, reduce the time complexity from O(n^2) to O(n), which can be the difference between doability and nondoability.

Here is a generalization of your problem: Let B be the base set from which the integers are drawn, e the exponent, and n the number of integers to draw (with replacement, but regardless of order). Then your problem can be done by:

B:= [$0..5]:  e:= 2:  n:= 2:
[seq(add(B[[seq(C)]]^~e), C= Iterator:-MultiCombination([n$nops(B)], n))];

Note that I used no sets, only lists, yet there are no repetitions. Thus, each desired object was generated only once. The Iterator package is generally very good about that.

Just change the last line to

Maximize(simplify(S), {a^2+b^2+c^2 = 1}) assuming real;

This is needed to get rid of the absolute-value / complex-modulus operators, which are messing up the differentiability of the objective function.

I can confirm using your worksheet that I get the same syntax error as you do. I don't know why. But you can do this:

q1:= (n1, n2)-> `if`(n1 < 0 or n2 < 0 or abs(n1-n2) <> 1, 0, sqrt(max(n1,n2)/2));

That gives me no syntax error.

The Maple equivalent of the Matlab syntax Q(:, 1), where Q is a Matrix, is Q[.., 1].

To answer your overall question---to wit:

  • I would like to ask if there is any command in Maple while solving the equations that are responsible for possible approximations when solving equations

If you use the command solve or any command in its "family", which include the package SolveTools and numerous other commands and packages, and your input does not include any decimal numbers, then there are no approximations used. If the command cannot find an exact solution, then it returns nothing.

What makes you think that the solution that you got is wrong?

In the worksheet attached to your original Question, you give the following formula, which you attribute to VV:

  • The total number of set partitions of n distinct items into e sets of length L, with n = e*L, is n!/e!/(L!)^e.

To be more precise, that is the number of ways of doing it if the subsets are unlabeled. If they are labeled (as in red team, green team, orange team), then the formula is n!/L!^e. Both of these formulas can be easily generalized to the situation where the subsets aren't necessarily equally sized.

Let be a list of positive integers representing the sizes of the blocks of the partition. If the blocks are labeled, then the number of partitions is add(B)!/mul(B!~). This can also be computed in Maple as combinat:-multinomial(add(B), B[]). If the blocks are unlabeled, then the number of partitions is add(B)!/mul(B!~)/mul(rhs~(Statistics:-Tally(B))!~). This can also be computed in Maple as Number(Iterator:-SetPartitionFixedSize(B)).

For B = [5,5,5], the labeled-block formula gives 756756 and the unlabeled 126126. The former leads to the probability 1/1001 and the latter 6/1001. The denominator from my original Answer is binomial(15,5)*binomial(10,5)/3!, which also equals 126126.

 

If you're expecting the result 2, as if differentiating with respect to x(t), do like this:

f:= 2*x(t)+5;
Physics:-diff(f, x(t));

I never use 2D input, so I can't help with that aspect of doing it.

It's not a bug (although it's very often majorly inconvenient), and it's not anything specific to IntegrationTools:-Change. Changing assumptions makes new copies of variables which are not automatically substituted into the expressions containing the old copies. The way to get that substitution to happen (temporarily) is to use assuming instead of the second assume and assuming additionally instead of additionally, like this:

restart;
assume(a>0,b>a,c>0,t>0);
F := Int(sqrt(d-a*c^2*t),d=0...infinity);
IntegrationTools[Change](F,-a*t*c^2+d=-y,y) assuming b > a;

or

restart;
assume(a>0,b>a,c>0,t>0);
F := Int(sqrt(d-a*c^2*t),d=0...infinity);
IntegrationTools[Change](F,-a*t*c^2+d=-y,y) assuming additionally, b > a;

 

As you probably know, there is a one-to-one correspondence between partitions of n of length k and partitions of n whose maximum element is k. Using that principle, here's a procedure that's much more efficient than my prior Answer:

PartitionFixedSize:= proc(n::posint, k::depends(integer[1..n]))
local p, P;
   [seq(1 +~ `+`(seq([0$(k-p), 1$p], p= P)), P= combinat:-partition(n-k, min(n-k, k)))]
end proc:

 

First 143 144 145 146 147 148 149 Last Page 145 of 395