Alec Mihailovs

Dr. Aleksandrs Mihailovs

4470 Reputation

21 Badges

19 years, 294 days
Mihailovs, Inc.
Owner, President, and CEO
Tyngsboro, Massachusetts, United States

Social Networks and Content at Maplesoft.com

Maple Application Center

I received my Ph.D. from the University of Pennsylvania in 1998 and I have been teaching since then at SUNY Oneonta for 1 year, at Shepherd University for 5 years, at Tennessee Tech for 2 years, at Lane College for 1 year, and this year I taught at the University of Massachusetts Lowell. My research interests include Representation Theory and Combinatorics.

MaplePrimes Activity


These are answers submitted by Alec Mihailovs

For example, you can write q instead of q(t), f:= q*sin(q); f := q sin(q) diff(f,q); sin(q) + q cos(q)
L:=[[3,2,5],[2,34,6]]: nops(L); 2
The values of the coloring function are scaled so that the minimum value gets HUE(0) color and the maximium value gets HUE(1) color, with other values between them. One can also use a list with 3 procedures, in which case RGB color is used for correspondingly scaled values. See examples in ?colorfunc help page. This rule has an exception - if values of the coloring function are between 0 and 1, they are not scaled. In your example, pictures with coloring functions x/20 and x/40 are different. For Mandelbrot set, see John Oprea's worksheet. Also, that can be done using densityplot command. In the example below I use mandelbrot from the cited above John Oprea's worksheet,
mandelbrot := proc(x, y) 
local c, z, m; 
c := evalf(x+y*I); z := c; 
for m to 50 while abs(z) < 2 do z := z^2+c od; 
m end;

plots[densityplot](mandelbrot,-2 .. 0.7, -1.35 .. 1.35,
s_tyle=patchnogrid,colorstyle=HUE,numpoints=62500,axes=none);
One needs to replace s_tyle with style to make this working (there is a problem with using 'style' inside <pre>.) Changing 50 in the mandelbrot procedure to 30, 40, or other number, produces slightly different pictures. The picture also looks interesting in RGB,
plots[densityplot](mandelbrot,-2 .. 0.7, -1.35 .. 1.35,
s_tyle=patchnogrid,colorstyle=RGB,numpoints=62500,axes=none);
For example, L:=[[1,2,3],[0,4,5],[3,8,1],[0,-1,2]]: select(x->x[1]=0,L); [[0, 4, 5], [0, -1, 2]]
Lagrange equations can be constructed using VariationalCalculus[EulerLagrange] command, see its help page for details. As far as I recall, Variational Calculus package was added in Maple 8.
Evalb doesn't test identities. You should use either is, or testeq instead, is(exp(I*x)=cos(x)+I*sin(x)); true testeq(exp(I*x)=cos(x)+I*sin(x)); true
I just tried to save B2 in a library in Maple 10 and it was saved in the original form, as well as included in a module, and worked after restarting without problems, either with specifying option package, or without. I didn't try that in Maple 8 or 9 (because I don't have them on this computer). I also didn't try an external procedure with 'MAPLE' parameter. Perhaps, that matters, too. The exports are protected if option package is specified.
You missed an assignment sign in splcurve. It should be splcurve:=Spline(points1,v): The problem with file attaching at this site is well known, I think.
Also, it can be done by adding known=k[1] in the dsolve command, i.e. changing the definition of sol2 in the original post to
sol2:=dsolve({diff(y(t),t)=-k[1](t-1),y(1)=k[1](1)},y(t),
numeric, output=listprocedure,known=k[1]):
One more workaround is in replacing k[1](t-1) in the same line with 'apply'(k[1],t-1), i.e. define sol2 as
sol2:=dsolve({diff(y(t),t)=-'apply'(k[1],t-1),y(1)=k[1](1)},y(t),
numeric, output=listprocedure);
Here is a workaround,
k[0]:=t->(1+t)*t^2*cos(t);

sol1:=dsolve({diff(y(t),t)=-k[0](t-1),y(0)=k[0](0)},y(t),
numeric, output=listprocedure):

k[1]:=rhs(sol1[2]):

k1:=t->k[1](t-1):

plot([[t,k[0](t),t=-1..0],[t,k[1](t),t=0..1]],color=blue);

sol2:=dsolve({diff(y(t),t)=-'k1'(t),y(1)=k[1](1)},y(t),
numeric, output=listprocedure):

k[2]:=rhs(sol2[2]):

plot([[t,k[0](t),t=-1..0],[t,k[1](t),t=0..1],
[t,k[2](t),t=1..2]],color=blue);
See ?reduceOrder and ?reduce_order help pages.
evalhf doesn't support special functions. For example,
evalhf(BesselJ(0,1));
Error, remember tables are not supported in evalhf
?evalhf/fcnlist has the list of functions supported by evalhf.
For example, let  xa=1, y1=y(1), f(y(x),y1,x)=y(x)*y1*x, g(y0,y1)=sin(y0)*y1+y0*exp(y1)-2. Then the solution can be obtained as follows,
s:=dsolve({diff(y(x),x)=y1*x*y(x),y(1)=y1});
s := y(x) = y1/exp(1/2*y1)*exp(1/2*y1*x^2)
y0:=eval(rhs(s),x=0);
y0 := y1/exp(1/2*y1)
fsolve(sin(y0)*y1+y0*exp(y1)-2);
.9320747205
sol:=eval(s,y1=%);
sol := y(x) = .5848618254*exp(.4660373602*x^2)
It is really easier to do such things in 1D mode. Many multiplication signs are missing. It is not exactly clear what you are trying to achieve. If you are trying to solve a differential equation, then dsolve should be used. Anyway, here is the simplification in 1D-mode. with(LinearAlgebra): T:=<||>; [ sin(l a) cos(l a) F exp(k a I) ] T := [ ] [l cos(l a) -l sin(l a) k F exp(k a I) I] LinearSolve(T); [F exp(k a I) (cos(l a) k I + l sin(l a))] [----------------------------------------] [ 2 2 ] [ l (cos(l a) + sin(l a) ) ] [ ] [F exp(k a I) (l cos(l a) - k sin(l a) I)] [----------------------------------------] [ 2 2 ] [ l (cos(l a) + sin(l a) ) ] simplify(%); [F exp(k a I) (cos(l a) k I + l sin(l a))] [----------------------------------------] [ l ] [ ] [F exp(k a I) (l cos(l a) - k sin(l a) I)] [----------------------------------------] [ l ] My guess is that it is not what you wanted.
Here is the simplest program,
f:=n->select(isprime,{$1..n}):
It is not Eratosthenes Sieve though. The program ES below implements the Eratosthenes Sieve,
s := proc(n::integer[4], A::Array(datatype = integer[4]),
B::Array(datatype = integer[4]))::integer[4];
local k, j;
    for k from 2 to isqrt(n) do
        if A[k] = 0 then
            for j from k to iquo(n, k) do A[k*j] := 1 end do
        end if
    end do;
    j := 1;
    for k from 2 to n do
        if A[k] = 0 then B[j] := k; j := j + 1 end if
    end do
end proc:

cs := Compiler:-Compile(s):

ES := proc(n)
local A, B;
    A := Array(1 .. n, datatype = integer[4]);
    B := Array(1 .. numtheory:-pi(n), datatype = integer[4]);
    cs(n, A, B);
    B
end proc:
ES is much faster than f. For example,
time(f(1000000));
                                13.438
time(ES(1000000));
                                0.155
The prime numbers produced by both procedures, are the same,
is(convert(ES(1000000),set)=f(1000000));

                                 true
First 72 73 74 75 76 Page 74 of 76