Carl Love

Carl Love

28025 Reputation

25 Badges

12 years, 311 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

Hmm. Somehow your default plot options got changed. Try this:

plot3d(x^2-y^2, x = -1 .. 1, y = -1 .. 1, style= patch);

If that shows the grid, then set the option as default by

plots:-setoptions3d(style= patch);

But I still wonder how your default got changed.

Actually, the representation of the table as matrices fits across my screen.

restart:
interface(rtablesize= 27):
M:= [seq(seq(seq(< < a,0 > | < b,c > >, a= 0..2), b= 0..2), c= 0..2)]:
T:= Matrix(27,27, (i,j)-> M[i].M[j] mod 3);

 

The piecewise command is easier to use than a chain of if-then-else statements.

Grades:= proc(x::realcons)
local a,b,c,d,f;
     piecewise(
          x < 0, undefined, x < 59.5, f, x < 69.5, d, x < 79.5, c,
          x < 89.5, b, x <= 100, a, undefined
     )
end proc:

If you still want to use if statements, then use elif, which is short for else if. That way, you can turn a chain of nested if statements into a single statement:

Grades:= proc(x::realcons)
local a,b,c,d,f;
     if x < 0 then undefined
     elif x < 59.5 then f
     elif x < 69.5 then d
     elif x < 79.5 then c
     elif x < 89.5 then b
     elif x <= 100 then a
     else undefined
     end if
end proc:

You need a for loop, an if-then statement, the isprime command, and a counter variable.

CountPrimes:= proc(n::posint)
local j, count:= 0;
     for j from 2 to n do
          if isprime(j) then
               count:= count+1
          end if
     end do;
     count
end proc:

CountPrimes(15);
                              
6

Go to the Maple Applications Center, and download and install the OrthogonalExpansions package. Then

OrthogonalExpansions:-FourierSeries(evalc(x*exp(I*x)), x= -Pi..Pi, infinity);

The evalc is necessary to get the correct coefficients at i=1. Don't confuse the summation index i with the imaginary I.

 

The last constraint, constraint 21, "Eilish is not next to the person with straight hair", needs to be specified as Rel(Separated, Eilish, straight, PN, [1]), which says that they are separated by at least 1 when measured wrt position. You merely have Eilish <> straight. Since Separated is an export of the dynamic module, this constraint needs to be specified after the with of the module.

When I do this, the program reports multiple solutions. The second solution that it gives is the same as the solution on the website from which you got the problem. From my reading, the first solution that the program gives also satisfies every constraint. Please verify this.

 

Here's how to get the answers with fsolve. This can be modified to instead use the multivariate Newton procedure that Markiyan directed you to.

restart:
eqns:= {
     t*((p-.764*z-2.194768)^2-1.170308549+.529948*(z-.382)^2)-(1-t)*p,
     t*((p+.382*z+.661624*y-1.907568)^2-1.018097144+.529984*(-.866*y-.5*z-.382)^2)+(1-t)*y,
     t*((p+.382*z-.661624*y-2.470348)^2-1.31636154+.529984*(.866*y-.5*z-.382)^2)+(1-t)*z
}:

(a,b):= (0,1):  h:= 0.0001:
N:= round((b-a)/h)+1;

Sols:= Array(1..N, 1..4):
inits:= {y=1,z=1,p=1}:
tt:= a:
for n to N do
     Sol:= fsolve(eval(eqns, t= tt), inits);
     Sol:= eval([y,z,p], Sol);
     Sols[n,..]:= < tt, Sol[] >;
     tt:= tt+h;
     inits:= {([y,z,p] =~ Sol)[]}
end do:

The solutions can be plotted as a space curve as a function of t like this:

plots:-spacecurve(convert(Sols[.., 2..4], listlist), labels= [y,z,p]);

Use an animation, so that one of a, c, n becomes the time parameter. Here I use a as the time parameter.

restart:
f:= (a,c,n)->
     64*a^2*n-16*a^4*n-256*c^2*n+32*c^4*n-96*a^2*c^2+ 8*a^2*c^4+24*a^4*c^2
     -64*a^2*n^2+256*a^2-124*a^4+ 15*a^6+256*n^2+64*a^2*c^2*n
:
plots:-animate(plot3d, [f(a,c,n), c= 0..2, n= 0..4], a= 0..2);



The above ideas can be made into a custom convert procedure:

`convert/decimalfraction`:= (x::float)-> op(1,x)/``(10^(-op(2,x))):

convert(.25, decimalfraction);

x^(1/3) is complex valued for negative because Maple uses the principal branch with `^`. The real-valued alternative is surd.

plot(surd(x,3), thickness= 5);

You can generate the procedure by calling LinearAlgebra:-Eigenvectors on a symbolic 2x2 matrix A = < < a, b > | < c, d > > and then reverse engineering the results. Doing that, I got the following

Eigen:= proc(A::'Matrix'(2,2))
local
     a:= A[1,1], b:= A[2,1], c:= A[1,2], d:= A[2,2],
     s:= sqrt((a-d)^2+4*b*c)/2,
     e1:= (a+d)/2 + s, e2:= (a+d)/2 - s,
     ev1:= < c, (d-a)/2+s >, ev2:= < c, (d-a)/2-s >
;
     if s=0 then [] else [e1, e2, ev1, ev2] end if
end proc:

This procedure needs a little modification. There are cases where s=0 but there are still two linearly independent eigenvectors. For example, any nonzero vector is an eigenvector of the zero matrix.

Simply include z=t with the equations that you pass to solve and include z in the output variables.

L1:= {4*x + 3*y + z = 0, x + y - z - 15 = 0}:
solve(L1 union {z=t}, {x,y,z});

BinomialMod2:= (n,k)-> `*`(Bits:-Split(Bits:-Implies(k,n))[]);

This is about 32,000 times faster than binomial(n,k) mod 2 when the input is 5-digit integers. For larger integers, it is even faster than that.

 

Note that the gridlines do not appear in the actual plot. They are an artifact of this forum, MaplePrimes.

restart: #Put restart on its own line, in its own execution group.

hgk:= 0.9:  vgk:= 5:  vb:= 25:  rg:= 0.15:

tb:= 22*sqrt(1+tan(x*Pi/180)^2+tan(y*Pi/180)^2)/vb;

(22/25)*(1+tan((1/180)*x*Pi)^2+tan((1/180)*y*Pi)^2)^(1/2)

tgk:= 2*sqrt(121*tan(x*Pi/180)^2+(11*tan(y*Pi/180)-hgk)^2)/vgk+0.15;

(2/5)*(121*tan((1/180)*x*Pi)^2+(11*tan((1/180)*y*Pi)-.9)^2)^(1/2)+.15

X:= -18..18:  Y:= 0..12:

Pts:= select(
     P-> evalf(eval(tgk-tb, [x,y]=~P)) < 0,
     [seq(seq([x,y], x= X), y= Y)]
):

plot(
     Pts,
     style= point, symbol= cross,
     view= [X,Y], axes= boxed, labels= [x,y]
);

 


Download tan_pointplot.mw

Your procedure does not work because you did not specify a return value. The last line of the procedure should be simply S to return S.

You have the right idea, but your procedure is much more complicated than it needs to be. You never need to have something like

do "statement"; break; od;

because it is equivalent to just

"statement";

Also, there's no need to do S:= S union {}. That statement does not change S. You only need to account for the ones. Here's all that you need:

m:= proc(n::list)
local S:= {}, i;
     for i to nops(n) do
          if n[i]=1 then
               S:= S union {i}
          fi
     od;
     S

end proc;

The above code is for educational purposes only, because it is not an efficient way to perform the task. I just wanted to illustrate the correct loop structure. For an efficient way, see Acer's Answer.

First 318 319 320 321 322 323 324 Last Page 320 of 395