Carl Love

Carl Love

28065 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Any such repetitive code can be and should be simplified. Your whole code above can be replaced by

V:= [E,L,P,M]:
Vf:= (op@index~)~([V,V], [1,2]);
dV:= [d||~((V||~1)[], (V||~2)[])]; 
Data:= {a= 1, b= 2, c= 3}: #Put your actual data here.
Sistem:= diff~(Vf(t),t) =~ subs(Vf=~ Vf(t), Data, dV);

The direct cause of your error is that Data must be an equation or a list or set of equations (as shown above).
 

Like this:

eq:= diff(z(x,t),t) + diff(R(x,t),x)*L(x,t) + 
    A*diff(L(x,t),x) + diff(k(x,t),x,x) - diff(k(x,t),t,t) = 
    0;
PDEtools:-dchange(
    eliminate({X= x-alpha*t, T=beta*t}, {x,t})[1],
    eq, [X,T], params= {alpha, beta}
);

 

Your procedure only makes sense for integer n, but plot, by default, passes it real values in the interval 0..10.

One possible correction is 

plot(b@trunc, 0..10)

The trunc will convert the numbers passed to b by plot into integers. The @ is the function composition operator.

There are numerous other ways to correct this.

You could use FileTools:-ModificationTime.

The one-line procedure AssignToClusters does both jobs.

To create a discrete distribution with support other than positive integers, use Empirical rather than ProbabilityTable. For example,

pr:= [1/2, 1/4, 1/8, 1/16, 1/32, 1/32]:
X:= Statistics:-RandomVariable(
    Empirical([0,1,2,3,4,5],
    probabilities= pr)
):
S:= Statistics:-Sample(X, 1000):
plots:-display(
    Statistics:-Histogram(S, discrete, thickness= 5),
    plot([seq([h,pr[h+1]], h= 0..5)]),
    axes= normal
);


 

Do

solve(ineq1, chi, parametric);

In some sense, degree-2 nodes are a waste of space, and they can be replaced by edges, while still maintaining the "information content" of the graph. Since your graph has a very large number of degree-2 nodes, this should greatly simplify its plot. In the below, each degree-2 node is replaced with a red edge, so they'll be visible on the plot. You'll need to replace my random graph with your actual graph. 


GT:= GraphTheory:  LT:= ListTools:
G:= GT:-RandomGraphs:-RandomGraph(267, 727, connected);
do
    v:= LT:-Search(2, GT:-DegreeSequence(G));
    if v=0 then break fi;
    v:= GT:-Vertices(G)[v];
    e:= {GT:-Neighbors(G, v)[]};
    G:= GT:-DeleteVertex(G, v);
    GT:-AddEdge(G, e, inplace);
    GT:-HighlightEdges(G, e, red, inplace)
od:
    
GT:-DrawGraph(G, style= spring);

Note that a red edge in the final graph may represent more than one degree-two nodes.

If your graph also has a large number of degree-one nodes, I have an idea to neatly represent them also.

You mean printf, not fprint. Here is code that prints using printf a minimal-length representation of each integer satisfying your requirements. Note how cat and are used in the printf to construct a format string with a variable number of format codes (the %ds).

restart:
Squares:= [$1..12]^~2;
for n from 129 to 129+13^2 do
    found:= false;
    for m to nops(Squares) do
        for c in combinat:-choose(Squares,m) do
            if add(c)=n then
                printf(cat("\n%d = %d^2", " + %d^2"$(m-1)), n, sqrt~(c)[]);
                found:= true
            fi
        until found
    until found;
    if not found then printf("\n%d: no solution", n) fi
od:

129 = 2^2 + 5^2 + 10^2
130 = 3^2 + 11^2
131 = 1^2 + 3^2 + 11^2
132 = 1^2 + 3^2 + 4^2 + 5^2 + 9^2
133 = 4^2 + 6^2 + 9^2
134 = 2^2 + 3^2 + 11^2
135 = 1^2 + 2^2 + 3^2 + 11^2
136 = 6^2 + 10^2
137 = 4^2 + 11^2
138 = 1^2 + 4^2 + 11^2
139 = 3^2 + 7^2 + 9^2
140 = 2^2 + 6^2 + 10^2
141 = 2^2 + 4^2 + 11^2
142 = 5^2 + 6^2 + 9^2
143 = 1^2 + 5^2 + 6^2 + 9^2
144 = 12^2
145 = 1^2 + 12^2
146 = 5^2 + 11^2
147 = 1^2 + 5^2 + 11^2
148 = 2^2 + 12^2
149 = 7^2 + 10^2
150 = 1^2 + 7^2 + 10^2
151 = 1^2 + 2^2 + 5^2 + 11^2
152 = 4^2 + 6^2 + 10^2
153 = 3^2 + 12^2
154 = 1^2 + 3^2 + 12^2
155 = 3^2 + 5^2 + 11^2
156 = 1^2 + 3^2 + 5^2 + 11^2
157 = 6^2 + 11^2
158 = 1^2 + 6^2 + 11^2
159 = 1^2 + 3^2 + 7^2 + 10^2
160 = 4^2 + 12^2
161 = 1^2 + 4^2 + 12^2
162 = 4^2 + 5^2 + 11^2
163 = 1^2 + 4^2 + 5^2 + 11^2
164 = 8^2 + 10^2
165 = 1^2 + 8^2 + 10^2
166 = 3^2 + 6^2 + 11^2
167 = 1^2 + 3^2 + 6^2 + 11^2
168 = 2^2 + 8^2 + 10^2
169 = 5^2 + 12^2
170 = 7^2 + 11^2
171 = 1^2 + 7^2 + 11^2
172 = 1^2 + 3^2 + 4^2 + 5^2 + 11^2
173 = 2^2 + 5^2 + 12^2
174 = 2^2 + 7^2 + 11^2
175 = 1^2 + 2^2 + 7^2 + 11^2
176 = 1^2 + 3^2 + 6^2 + 7^2 + 9^2
177 = 2^2 + 3^2 + 8^2 + 10^2
178 = 3^2 + 5^2 + 12^2
179 = 3^2 + 7^2 + 11^2
180 = 6^2 + 12^2
181 = 9^2 + 10^2
182 = 1^2 + 9^2 + 10^2
183 = 1^2 + 5^2 + 6^2 + 11^2
184 = 2^2 + 6^2 + 12^2
185 = 8^2 + 11^2
186 = 1^2 + 8^2 + 11^2
187 = 1^2 + 4^2 + 7^2 + 11^2
188 = 1^2 + 2^2 + 3^2 + 5^2 + 7^2 + 10^2
189 = 2^2 + 8^2 + 11^2
190 = 3^2 + 9^2 + 10^2
191 = 1^2 + 3^2 + 9^2 + 10^2
192 = 1^2 + 3^2 + 5^2 + 6^2 + 11^2
193 = 7^2 + 12^2
194 = 1^2 + 7^2 + 12^2
195 = 5^2 + 7^2 + 11^2
196 = 4^2 + 6^2 + 12^2
197 = 2^2 + 7^2 + 12^2
198 = 1^2 + 2^2 + 7^2 + 12^2
199 = 2^2 + 5^2 + 7^2 + 11^2
200 = 6^2 + 8^2 + 10^2
201 = 4^2 + 8^2 + 11^2
202 = 9^2 + 11^2
203 = 1^2 + 9^2 + 11^2
204 = 2^2 + 6^2 + 8^2 + 10^2
205 = 5^2 + 6^2 + 12^2
206 = 2^2 + 9^2 + 11^2
207 = 1^2 + 2^2 + 9^2 + 11^2
208 = 8^2 + 12^2
209 = 1^2 + 8^2 + 12^2
210 = 5^2 + 8^2 + 11^2
211 = 3^2 + 9^2 + 11^2
212 = 2^2 + 8^2 + 12^2
213 = 7^2 + 8^2 + 10^2
214 = 1^2 + 7^2 + 8^2 + 10^2
215 = 2^2 + 3^2 + 9^2 + 11^2
216 = 4^2 + 6^2 + 8^2 + 10^2
217 = 3^2 + 8^2 + 12^2
218 = 4^2 + 9^2 + 11^2
219 = 1^2 + 4^2 + 9^2 + 11^2
220 = 1^2 + 3^2 + 5^2 + 8^2 + 11^2
221 = 10^2 + 11^2
222 = 1^2 + 10^2 + 11^2
223 = 1^2 + 2^2 + 4^2 + 9^2 + 11^2
224 = 4^2 + 8^2 + 12^2
225 = 9^2 + 12^2
226 = 1^2 + 9^2 + 12^2
227 = 5^2 + 9^2 + 11^2
228 = 1^2 + 5^2 + 9^2 + 11^2
229 = 2^2 + 9^2 + 12^2
230 = 3^2 + 10^2 + 11^2
231 = 1^2 + 3^2 + 10^2 + 11^2
232 = 1^2 + 2^2 + 5^2 + 9^2 + 11^2
233 = 5^2 + 8^2 + 12^2
234 = 3^2 + 9^2 + 12^2
235 = 1^2 + 3^2 + 9^2 + 12^2
236 = 3^2 + 5^2 + 9^2 + 11^2
237 = 4^2 + 10^2 + 11^2
238 = 6^2 + 9^2 + 11^2
239 = 1^2 + 6^2 + 9^2 + 11^2
240 = 1^2 + 3^2 + 7^2 + 9^2 + 10^2
241 = 4^2 + 9^2 + 12^2
242 = 1^2 + 4^2 + 9^2 + 12^2
243 = 3^2 + 7^2 + 8^2 + 11^2
244 = 10^2 + 12^2
245 = 1^2 + 10^2 + 12^2
246 = 5^2 + 10^2 + 11^2
247 = 1^2 + 5^2 + 10^2 + 11^2
248 = 2^2 + 10^2 + 12^2
249 = 1^2 + 2^2 + 10^2 + 12^2
250 = 5^2 + 9^2 + 12^2
251 = 7^2 + 9^2 + 11^2
252 = 1^2 + 7^2 + 9^2 + 11^2
253 = 3^2 + 10^2 + 12^2
254 = 1^2 + 3^2 + 10^2 + 12^2
255 = 2^2 + 7^2 + 9^2 + 11^2
256 = 1^2 + 2^2 + 7^2 + 9^2 + 11^2
257 = 6^2 + 10^2 + 11^2
258 = 1^2 + 6^2 + 10^2 + 11^2
259 = 3^2 + 5^2 + 9^2 + 12^2
260 = 4^2 + 10^2 + 12^2
261 = 6^2 + 9^2 + 12^2
262 = 1^2 + 6^2 + 9^2 + 12^2
263 = 5^2 + 6^2 + 9^2 + 11^2
264 = 2^2 + 4^2 + 10^2 + 12^2
265 = 11^2 + 12^2
266 = 1^2 + 11^2 + 12^2
267 = 1^2 + 8^2 + 9^2 + 11^2
268 = 1^2 + 4^2 + 7^2 + 9^2 + 11^2
269 = 2^2 + 11^2 + 12^2
270 = 7^2 + 10^2 + 11^2
271 = 1^2 + 7^2 + 10^2 + 11^2
272 = 3^2 + 5^2 + 6^2 + 9^2 + 11^2
273 = 2^2 + 5^2 + 10^2 + 12^2
274 = 3^2 + 11^2 + 12^2
275 = 1^2 + 3^2 + 11^2 + 12^2
276 = 5^2 + 7^2 + 9^2 + 11^2
277 = 4^2 + 6^2 + 9^2 + 12^2
278 = 2^2 + 3^2 + 11^2 + 12^2
279 = 3^2 + 7^2 + 10^2 + 11^2
280 = 6^2 + 10^2 + 12^2
281 = 4^2 + 11^2 + 12^2
282 = 1^2 + 4^2 + 11^2 + 12^2
283 = 3^2 + 7^2 + 9^2 + 12^2
284 = 2^2 + 6^2 + 10^2 + 12^2
285 = 8^2 + 10^2 + 11^2
286 = 1^2 + 8^2 + 10^2 + 11^2
287 = 6^2 + 7^2 + 9^2 + 11^2
288 = 1^2 + 6^2 + 7^2 + 9^2 + 11^2
289 = 8^2 + 9^2 + 12^2
290 = 5^2 + 11^2 + 12^2
291 = 1^2 + 5^2 + 11^2 + 12^2
292 = 1^2 + 5^2 + 8^2 + 9^2 + 11^2
293 = 7^2 + 10^2 + 12^2
294 = 1^2 + 7^2 + 10^2 + 12^2
295 = 5^2 + 7^2 + 10^2 + 11^2
296 = 4^2 + 6^2 + 10^2 + 12^2
297 = 2^2 + 7^2 + 10^2 + 12^2
298 = 3^2 + 8^2 + 9^2 + 12^2

 

In your expression sin(4*pi)+(1/3)*cos(6*pi)pi is treated as the independent variable, not the well-known constant. The constant in Maple is Pi, with a capital P. So perhaps you mean to plot sin(4*x)+(1/3)*cos(6*x) or sin(4*Pi*x)+(1/3)*cos(6*Pi*x)? The plotting domain (the range of the independent variable) is specified as the second argument to plot:

plot(sin(4*x)+(1/3)*cos(6*x), x= 0..2*Pi)

If you don't specify a plotting domain, the command picks one for you, usually -10..10.

I concur with the VV and Axel: The limit (over the real numbers) exists. If it makes you more comfortable, translate the problem to an unbounded domain:

g:= x-> sin(sin(x)/x)/(sin(x)/x):
limit(g(x), x= infinity);

                           1
plot(g(x), x= 1..50);

Now clearly for any epsilon > 0, there exist uncountably many x such that |g(x) - 1| < epsilon, and 1 is the only value for which this is true.

Or, using a more traditional definition: Let D be the domain of g. For any epsilon > 0, there exists M such that for all x in (D intersect [M, infinity)), |g(x) - 1| < epsilon. (This formulation automatically implies the uniqueness of 1.)

Is this what you have in mind?

plots:-animate(
    plots:-display, 
    ['''plot3d''']~(
        [[sqrt(8*y),t,y], [y^2,t,y]], 
        y= 0..Y, t= 0..2*Pi, coords= cylindrical, color=~["Khaki", "LightBlue"],
        labels= ['x', 'z', 'y'], axes= normal, scaling= constrained,
        view= [-4..4, -4..4, 0..4]
    ),   
    Y= 0..2, frames= 60, paraminfo= false
);

Like this:

plots:-animate(
   plot3d,
   [[[r,t,r^2/8],[r,t,sqrt(r)]], r= 0..4, t= 0..T, coords= cylindrical],
   T= 0..2*Pi, frames= 60

);
);

You can do

coeff(select(t-> degree(t,x)=1, S), x, 1)

@Mike Graber The default assignment is by value, not by address. If I execute your code, I get 7 and 9, not 9 and 9. Try doing a restart and doing your example again.

restart:
A:= 7:  B:= A:  A:= 9:  C:= A:  B, C;

                             7, 9

To refer to the address of a name rather than its value, enclose it in single forward quotes (aposthropes):

restart:
A:= 7:  B:= 'A':  A:= 9:  C:= A:  B, C

                             
9, 9

Most of the rules are described on help page ?eval. There are some subtleties involved with the above when working with local variables. Occasionally, one needs to use eval to get the final value. And even less frequently, one needs to use eval with a numeric second argument to prevent evaluation to the final value.
 

First 107 108 109 110 111 112 113 Last Page 109 of 395