acer

32343 Reputation

29 Badges

19 years, 327 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

[edited] The originating point, where the period cycles, is different. In a sense the cross "crosses" there, since it overlaps with itself. I may need to re-implement the approach.

restart;

eq:=[sin(6*t),cos(2*t)]:

All:={eliminate(Equate(eq,eval(eq,t=s)),[t,s])}:
Temp:=map[2](op,1,All):
Temp:=remove(u->nops(eval({s,t},u))=1, Temp):

LK:=[seq(eval(eq,uu)=uu, uu=Temp)]:
T:=table(LK):
Ans:=[seq(T[uu],uu={seq(lhs(u),u=LK)})];

[{s = Pi, t = 0}, {s = (2/3)*Pi, t = (1/3)*Pi}, {s = (5/6)*Pi, t = (1/6)*Pi}]

BG:=plots:-display(
  plot(map(a->eval(eq,a),Ans),style=point,color=blue,
       symbolsize=25,symbol=solidcircle),
  plot([op(eq),t=0..Pi],color=red),
  gridlines=false
):

BG;

 

Download intersect2.mw

If I understand you, the query is about deriving/constructing the Sum (since we could always just enter it by hand, but that's not exciting).

I'm not aware of anything like a Split (in SumTools or wherever). So that part is manual (but a procedure for it could be written easily, for re-use).

I would not be surprised it were relatively easy to fix up the sign on -a, or expand wrt a instead, or fix up the binomial to be the prettier equivalent.

restart;

expr := (a+b)^n;

(a+b)^n

H := combine(convert(expr, FormalPowerSeries, a),power) assuming n::posint, b>0;

Sum(b^(n-k)*pochhammer(-n, k)*(-a)^k/factorial(k), k = 0 .. infinity)

Y :=  op(0,H)(op(1,H),lhs(op(2,H))=op(1,rhs(op(2,H)))..n)
    + op(0,H)(op(1,H),lhs(op(2,H))=n+1..op(2,rhs(op(2,H))));

Sum(b^(n-k)*pochhammer(-n, k)*(-a)^k/factorial(k), k = 0 .. n)+Sum(b^(n-k)*pochhammer(-n, k)*(-a)^k/factorial(k), k = n+1 .. infinity)

Y1,Y2:=op(Y);

Sum(b^(n-k)*pochhammer(-n, k)*(-a)^k/factorial(k), k = 0 .. n), Sum(b^(n-k)*pochhammer(-n, k)*(-a)^k/factorial(k), k = n+1 .. infinity)

A := convert(Y1 + value(Y2),binomial) assuming n::posint;

Sum(b^(n-k)*binomial(-n+k-1, -n-1)*(-a)^k, k = 0 .. n)

value(A);

(a+b)^n

 

Download binomialSum.mw

Why I'd agree with Kitonum that is can often be a way to go with such things, 

verify(2*cos(phi)^2-1, cos(2*phi), simplify);

                   true

Note that verify,equal may rely upon signum, and,

signum(2*cos(phi)^2-1 - cos(2*phi));

              /          2                 \
        signum\2 cos(phi)  - 1 - cos(2 phi)/

simplify(signum(2*cos(phi)^2-1 - cos(2*phi)));

                   0

Here is something, under assumptions like k::posint, x::real, etc.

(Btw, are those Mathematica results valid everywhere? I don't feel like typing them in.)

restart;

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

P := value(int(sin(x)^k, x)) assuming k::posint, k::even;

-(-k*sin(x)^(1+k)*hypergeom([1, 1+(1/2)*k], [3/2+(1/2)*k], sin(x)^2)/(1+k)+2*sin(x)*arcsin((sin(x)^2)^(1/2))*(-1)^k*GAMMA(1/2+(1/2)*k)/(Pi^(1/2)*(sin(x)^2)^(1/2)*(1-sin(x)^2)^(1/2)*GAMMA((1/2)*k)))*cos(x)/k+GAMMA(1/2+(1/2)*k)*(-1)^((1/2)*k)*x/(Pi^(1/2)*(-1)^(-(1/2)*k)*GAMMA(1+(1/2)*k))

GP := simplify(convert(P,StandardFunctions)) assuming x>0, x<Pi/2;

sin(x)^(1+k)*hypergeom([1, 1+(1/2)*k], [3/2+(1/2)*k], sin(x)^2)*cos(x)/(1+k)

eval(GP, k=4);
simplify(convert(%, elementary)) assuming x>0, x<Pi/2;

(1/5)*sin(x)^5*hypergeom([1, 3], [7/2], sin(x)^2)*cos(x)

(1/8)*(2*cos(x)^3-5*cos(x))*sin(x)+(3/8)*x

simplify(int(sin(x)^4, x));

(1/8)*(2*cos(x)^3-5*cos(x))*sin(x)+(3/8)*x

evalf(eval(GP, [k=4,x=-1.4]));

-.4215258808

int(sin(x)^4, x=0..-1.4);

-.4215258800

G2 := simplify(expand(convert(P,elementary))) assuming x>Pi/2, x<Pi, k::posint, k::even;

(1/2)*(cos(x)*sin(x)^(1+k)*hypergeom([1, 1+(1/2)*k], [3/2+(1/2)*k], sin(x)^2)*Pi^(1/2)*GAMMA((1/2)*k)*k+2*GAMMA(1/2+(1/2)*k)*(x+arcsin(sin(x)))*(1+k))/(Pi^(1/2)*(1+k)*GAMMA(1+(1/2)*k))

evalf(eval(G2, [k=4,x=2.7])), int(sin(x)^4, x=0..2.7);

1.175036864, 1.175036865

G3 := combine(simplify(combine(expand(convert(P,StandardFunctions))))) assuming x::real, k::posint, k::even;

(cos(x)*sin(x)^(1+k)*hypergeom([1, 1+(1/2)*k], [3/2+(1/2)*k], 1/2-(1/2)*cos(2*x))*Pi^(1/2)*GAMMA(1+(1/2)*k)-2*signum(sin(2*x))*arcsin(abs(sin(x)))*GAMMA(3/2+(1/2)*k)+2*GAMMA(3/2+(1/2)*k)*x)/(Pi^(1/2)*GAMMA(1+(1/2)*k)*k+Pi^(1/2)*GAMMA(1+(1/2)*k))

plot([eval(G3,k=4), Int(sin(X)^4, X=0..x)], x=-10.0 .. 10.0,
     style=[line,point], adaptive=false, numpoints=50, size=[500,200]);

Po := value(int(sin(x)^k, x)) assuming k::posint, k::odd;

-sin(x)^(-1+k)*JacobiP((1/2)*k-1/2, -(1/2)*k, 1/2, (sin(x)^2-2)/sin(x)^2)*GAMMA(1/2+(1/2)*k)*GAMMA(1-(1/2)*k)*cos(x)/(Pi^(1/2)*k)

plot([eval(Po,k=3), Int(sin(X)^3, X=Pi/2..x)], x=-10.0 .. 10.0,
     style=[line,point], adaptive=false, numpoints=50, size=[500,200]);

 

Download int_k.mw

restart

kernelopts(version);

`Maple 18.02, X86 64 LINUX, Oct 20 2014, Build ID 991181`

`print/%*` := proc () `&dot;`(args) end proc:

interface(imaginaryunit = IU):

Ke := `%*`(2*I*E/l^3, `<,>`(`<|>`(6, 3*l, -6, 3*l), `<|>`(3*l, 2*l^2, -3*l, l^2), `<|>`(-6, -3*l, 6, -3*l), `<|>`(3*l, l^2, -3*l, 2*l^2)))

Ke := `&dot;`(2*I*E/l^3, Matrix(4, 4, {(1, 1) = 6, (1, 2) = 3*l, (1, 3) = -6, (1, 4) = 3*l, (2, 1) = 3*l, (2, 2) = 2*l^2, (2, 3) = -3*l, (2, 4) = l^2, (3, 1) = -6, (3, 2) = -3*l, (3, 3) = 6, (3, 4) = -3*l, (4, 1) = 3*l, (4, 2) = l^2, (4, 3) = -3*l, (4, 4) = 2*l^2}))

Ke

`&dot;`(2*I*E/l^3, Matrix(4, 4, {(1, 1) = 6, (1, 2) = 3*l, (1, 3) = -6, (1, 4) = 3*l, (2, 1) = 3*l, (2, 2) = 2*l^2, (2, 3) = -3*l, (2, 4) = l^2, (3, 1) = -6, (3, 2) = -3*l, (3, 3) = 6, (3, 4) = -3*l, (4, 1) = 3*l, (4, 2) = l^2, (4, 3) = -3*l, (4, 4) = 2*l^2}))

value(Ke)

Matrix(4, 4, {(1, 1) = 12*I*E/l^3, (1, 2) = 6*I*E/l^2, (1, 3) = -12*I*E/l^3, (1, 4) = 6*I*E/l^2, (2, 1) = 6*I*E/l^2, (2, 2) = 4*I*E/l, (2, 3) = -6*I*E/l^2, (2, 4) = 2*I*E/l, (3, 1) = -12*I*E/l^3, (3, 2) = -6*I*E/l^2, (3, 3) = 12*I*E/l^3, (3, 4) = -6*I*E/l^2, (4, 1) = 6*I*E/l^2, (4, 2) = 2*I*E/l, (4, 3) = -6*I*E/l^2, (4, 4) = 4*I*E/l})

 

Download 2d_inert_star_M18.mw

You are incorrectly interpreting the meaning of _nparams. It does not mean the number of passed arguments.

Compare with _npassed .

See the help pages for parameter processing, especially the one entitled Using Parameters within a Procedure and its section Special Sequences.

This all pertains to procedures and how parameter processing works in general, and is not specific to the debugger.

Rouben's solutions is nice and good, provided you are ok with the first frame in the whole collection being the one with m=1. Note that printing an animation (eg, using the plots:-display command) will always place the menubar's play marker at the beginning.

However, if you are looking to have the play marker be initially set to near the middle of all the frames (slider) then that won't get you what you're after. Here is one way to get that alternative. The animation assigned to A is constructed in a usual way. But, instead of showing it in the worksheet by the usual printing mechanism for plots, it is embedded in a borderless Plot Component and then the frame number is advanced to the desired value.

restart;
A:=plots:-animate(plot,[m*x,x=-10..10],m=-10..10,frames=21):
with(DocumentTools):
with(DocumentTools:-Components):
with(DocumentTools:-Layout):
LK:=InsertContent(Worksheet(Group(Input(Textfield(Plot(
         A,
         identity="Plot",showborders=false))))),output=table):
SetProperty(LK["Plot"],frame,12);

There are lots of possible refinements to this idea. For example, one can embed a Plot Component set visible=false, then set the animation as its value property, then advance the frame, and only then set as visible=true. (This may remove any update flash, which I don't see but someone might conceivably notice...)

Why do you say that the plot doesn't look similar to that in the link (in your pdf file)?  https://www.sfu.ca/~ssurjano/shubert.html

Or are you trying to say that the plots on that URL are not what you expect either? There are no plots in the pdf paper you've cited. On precisely what part of that paper, and formula, do you expect us to focus?

restart;

copts := colorscheme=["zgradient",
                    ["DarkBlue","MediumBlue","Blue","LightBlue",
                     "Cyan","Green","Yellow","Orange","Orange","Red","Red"],
                    colorspace="HSV"]:

f := Sum(i*cos((i+1)*(-2+4*x[1])+i), i = 1 .. 5)*Sum(i*cos((i+1)*(-2+4*x[2])+i), i = 1 .. 5);

(Sum(i*cos((i+1)*(-2+4*x[1])+i), i = 1 .. 5))*(Sum(i*cos((i+1)*(-2+4*x[2])+i), i = 1 .. 5))

plot3d(f, x[1]=0..1, x[2]=0..1,
       view=-200..300, grid=[100,100],
       orientation=[-120,65,0], copts,
       labels=[x[1],x[2],"f(x1,x2)"],
       #font=["DejaVu Sans",bold,12],
       labeldirections=[horizontal,horizontal,vertical],
       title="Shubert Function", titlefont=["DejaVu Sans",bold,12]);

F := (Sum(i*cos((i+1)*x1+i), i = 1 .. 5))*(Sum(i*cos((i+1)*(x2)+i), i = 1 .. 5));

(Sum(i*cos((i+1)*x1+i), i = 1 .. 5))*(Sum(i*cos((i+1)*x2+i), i = 1 .. 5))

plot3d(F, x1=-2..2, x2=-2..2,
       view=-200..300, grid=[100,100],
       orientation=[-120,65,0], copts,
       labels=[x[1],x[2],"f(x1,x2)"],
       #font=["DejaVu Sans",bold,12],
       labeldirections=[horizontal,horizontal,vertical],
       title="Shubert Function", titlefont=["DejaVu Sans",bold,12]);

 

Download shubert_plot3d.mw

The supporting code needs to be auto-execute, for it to work in the MaplePlayer.

The easiest way to do this is put all the supporting code in the Startup Code region (ie. from the main menubar, use Edit->Startup Code).

Cassinian_oval_ac.mw

note: I prefer procedures which utilize uses, rather rely on with being run at the top-level. And I prefer not to declare global variables within a procedure if they don't serve a purpose. Not a big deal. Cassinian_oval_ac2.mw

Either of the two first methods below are about 200 times faster than the last two methods below (MapleMathMatt's and Kitonum's suggestions).

Using inert Int (or int with the numeric option) instead of active int prevents Maple from trying to solve the integral symbolically for each value of epsilon.

Using the operator form of the integrand (or using the specified method) prevents `evalf/int` from trying to check for discontinuities at each value of epsilon.

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

restart;
G := epsilon -> Int( unapply(exp( -epsilon * ( x^4 + x^2 ) ), x), -10 .. 10):
CodeTools:-Usage( plot( G, 0 .. infinity ));

memory used=12.92MiB, alloc change=35.01MiB, cpu time=131.00ms, real time=132.00ms, gc time=6.35ms

restart;
G := Int( exp( -epsilon * ( x^4 + x^2 ) ), x = -10 .. 10, method=_d01ajc):
CodeTools:-Usage( plot( G, epsilon = 0 .. infinity ));

memory used=13.50MiB, alloc change=35.01MiB, cpu time=126.00ms, real time=127.00ms, gc time=5.10ms

restart;
G := proc( epsilon )
  int( exp( -epsilon * ( x^4 + x^2 ) ), x = -10 .. 10, numeric );
end proc:
CodeTools:-Usage( plot( G, 0 .. infinity ));

memory used=3.36GiB, alloc change=36.00MiB, cpu time=26.93s, real time=26.95s, gc time=1.95s

restart;
G := Int( exp( -epsilon * ( x^4 + x^2 ) ), x = -10 .. 10);
CodeTools:-Usage( plot( G, epsilon = 0 .. infinity ));

Int(exp(-epsilon*(x^4+x^2)), x = -10 .. 10)

memory used=3.36GiB, alloc change=36.00MiB, cpu time=27.10s, real time=27.11s, gc time=2.33s

 

Download plot_integral.mw

For this example it seems that fsolve has trouble without some extra hint of the range for some of the variables.

But solve gets it directly.

restart;

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

eqs := {(T[1]-T[0])/(10000-T[1]+T[0]) = -2.000000000,
        (T[2]-T[0])/(20000-T[2]+T[0]) = 0,
        (T[3]-T[0])/(50000-T[3]+T[0]) = 50,
        .1*T[0]+.3*T[1]+.55*T[2]+0.5e-1*T[3]-5000 = 0}:

fsolve(eqs, {T[0], T[1], T[2], T[3]},
       {T[1]=0..20000, T[2]=-infinity..0});

{T[0] = -3450.980392, T[1] = 16549.01961, T[2] = -3450.980392, T[3] = 45568.62745}

solve(eqs);

{T[0] = -3450.980392, T[1] = 16549.01961, T[2] = -3450.980392, T[3] = 45568.62745}

 

Download fsolverng.mw

restart;

L1 := [t-2,(t-2)^2]:        
L2 := [(3*t/2)-4,(3*t/2)-2]:

solve(Equate(L1,L2));

                            {t = 4}

My guess is that you are looking for something like the effect of the plots:-dualaxisplot command.

See this revision: GaußKronrodQuadraturFehlerbehandlung_ac.mw

Don't use the word function like that in relation to Maple. Nobody will know for sure whether you are talking about an expression (which could be evaluated at values for its unknowns) or a procedure (which can be called with values).

I am going to guess that you mean a procedure (of which an arrow-printing operator is one variant).

Have you set up your procedure to do something special (eg, return unevaluated) if it is called with a simple name for its parameter x?

If not, when why not do something like evalf[4](f(x)) where x is some unassigned name?

There is no blazingly simple way to print the body of a procedure and have it be pretty-printed in a modified manner. (There are ways, but advanced.)

restart;

plots:-display(
        seq( plot([cos(t)-q*sin(t), sin(t)+q*cos(t), q=-1..1]),
             t=0..evalf(2*Pi), evalf(Pi/30) ),
        gridlines=false
              );

 

Download some_tangents.mw

And for fun,

Explore(plots:-display(
          seq( plot([cos(n*2*Pi/N)-q*sin(n*2*Pi/N),
                     sin(n*2*Pi/N)+q*cos(n*2*Pi/N), q=-2..2]),
               n=0..N-1 ),
          gridlines=false),
        parameters=[N=1..50], initialvalues=[N=30]);

[edited] The original formulation is not efficient. Each line segments really requires only its two end-points. They are lots of ways to accomplish that: plottools:-line, forced numpoints, pointplot with linestyle, etc. So this runs more smoothly,

Explore(plots:-display(
          seq( plot([seq([cos(n*2*Pi/N)-q*sin(n*2*Pi/N),
                          sin(n*2*Pi/N)+q*cos(n*2*Pi/N)],
                         q=[-2,2])]),
               n=0..N-1 ),
          gridlines=false),
        parameters=[N=1..200], initialvalues=[N=30]);

And, even though the earlier code wasn't unbearably slow,

plots:-display(
          seq( plot([seq([cos(n*2*Pi/60)-q*sin(n*2*Pi/60),
                          sin(n*2*Pi/60)+q*cos(n*2*Pi/60)],
                         q=[-2,2])]),
               n=0..60 ),
          gridlines=false);

or (better than the original, but not as quick as that immediately above),

plots:-display(
        seq( plot([cos(t)-q*sin(t), sin(t)+q*cos(t), q=-2..2],
                  adaptive=false, numpoints=2),
             t=0..evalf(2*Pi), evalf(Pi/30) ),
        gridlines=false
              );
First 162 163 164 165 166 167 168 Last Page 164 of 336