Kitonum

21435 Reputation

26 Badges

17 years, 26 days

MaplePrimes Activity


These are answers submitted by Kitonum

A:=plot(eval(R*cos(omega*t),[R=2,omega=1]), t=0..4*Pi, color=black, tickmarks=[[seq(2*Pi*k=2*k*Pi/omega,k=0..2)],[seq(2*k=k*R,k=-1..1)]], scaling=constrained, size=[800,300], axesfont=[times,16], view=[-0.7..4*Pi+1.5,-2.2..2.5],labels=[``,``]):
B:=plots:-textplot([[1.3,2.5,x=R*cos(omega*t)],[4*Pi+1.5,-0.2,t]], font=[times,16]):
C1:=plots:-arrow([0,2.35],[0,0.15], head_length=0.15,head_width=0.07):
C2:=plots:-arrow([4*Pi+1.35,0],[0.15,0], head_length=0.15,head_width=0.07):
plots:-display(A,B,C1,C2);

       


Of course, for any plottings, all parameters must be specified, but the inscriptions on the plot you can specify any you wish, using tickmarks , plots:-textplot , labels  and so on. 

I think it’s important not only to get a formal solution, but also to understand why the solution is unique. In this example, we have an underdetermined system (two equations with 3 unknowns) and, for example, the  fsolve  command refuses to solve such systems at all. Let's approach the problem from a geometric point of view: to find the intersection of two surfaces in 3D, given by its equations. It is easy to verify that the first surface is a sphere with a radius of 5. The second equation is a plane. We find the distance from the center of the sphere to the plane and see that it is equal to the radius of this sphere. So the plane touches the sphere, and we find the point of tangency simply by projecting the center of the sphere onto this plane:

restart;
Eq1, Eq2 := x^2+y^2+z^2-4*x+6*y-2*z-11 = 0, 2*x+2*y-z = -18:
Student:-Precalculus:-CompleteSquare(Eq1, [x,y,z]);
with(geom3d):
point(o,2,-3,1):
plane(P,Eq2, [x,y,z]):
distance(o, P);
projection(p, o, P):
detail(p);

          

 

In most cases, the results are the same. However, eval is a more "intelligent" command. For example, when calculating derivatives or integrals, eval works correctly, but subs does not.

Examples:

eval(int(f(x),x=0..x),x=1);
subs(x=1,int(f(x),x=0..x));
eval(diff(f(x),x), x=1);
subs(x=1,diff(f(x),x));


See help on these command for details.

restart;
a := <3, 4, 5>;
Explore(a(i), i = 1 .. 3);


Here we used a functional notation (arguments of functions in parenthesis).

restart;
for i from 50 by 5 to 85 do
ThetaBn := (1/180)*i*Pi;
s := cos(2*ThetaBn)*x+(2*sin(ThetaBn)*sin(ThetaBn))*sin(x);
Point[i]:=[i,180.0*fsolve(s = 0, x, 1 .. 6)*(1/Pi)];
end do:
Points:=convert(Point,list);
plot(Points, color=red);

 

You forgot to take into account the triangle inequality, there are also a number of errors. Here is the corrected version:

E := proc(n::posint)
local p, k, x, y, z, L;
p:=n ; k:=0;
L:=table();
for x from 1 to floor(p/3) do
for y from x to floor((p-x)/2) do
z:=p-x-y;
if z<x+y then k:=k+1; L[k]:=[x,y,z] fi;
od; od;
convert(L, list);
end proc:

Examples of use:

E(3);
E(4);
E(9);
E(15);
                        

Edit.

This should probably be considered a bug in the  solve  command. Here are 2 workarounds (in Maple 2018.3):

RealDomain:-solve({x^2=2, x^3 = (sqrt(2))^3}, {x});
# Or
Sol1:=`union`(solve(x^2=2, {x}));
Sol2:=`union`(solve(x^3 = (sqrt(2))^3, {x}));
Sol1 intersect Sol2;

 

You can use  plots:-textplot  command for this:

restart;
with(plots):
P:=inequal({sqrt((1/2)*x) < y and sqrt(Pi/(2*x)) < y and y < sqrt(x) and y < sqrt(Pi/x)}, x = 1 .. 3, y = 0 .. 2):
T:=textplot([[1.5,1.7,sqrt(Pi/x)], [1.4,0.6,sqrt(x/`2`)], [2.5,0.6,sqrt(Pi/(`2`*x))], [2.5,1.7,sqrt(x)]], font=[times,bold,14]):
display(P,T);
                        

I think this a known behaviour. `+`, `*`  and so on are the prefix form of binary operators of addition and multiplication. But  `-`  should only apply to one argument so `-`(a,b) <>a-b . See examples below:


 

`-`(a);
`-`(a,b);

-a

 

-a

(1)

Matrix(3, 3, `-`);
Matrix(3, 3, (i,j) -> i-j);

Matrix(3, 3, {(1, 1) = -1, (1, 2) = -1, (1, 3) = -1, (2, 1) = -2, (2, 2) = -2, (2, 3) = -2, (3, 1) = -3, (3, 2) = -3, (3, 3) = -3})

 

Matrix(%id = 18446746664292233078)

(2)

Matrix(3, 3, `*`);
Matrix(3, 3, (i,j) -> i*j);

Matrix(3, 3, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 3, (2, 1) = 2, (2, 2) = 4, (2, 3) = 6, (3, 1) = 3, (3, 2) = 6, (3, 3) = 9})

 

Matrix(%id = 18446746664292228742)

(3)

`*`(2,3);
((i,j)->i*j)(2,3);

6

 

6

(4)

`/`(6,2);
((i,j)->i/j)(6,2);

3

 

3

(5)

 


 

Download prefix.mw

restart;
f1:=cos(x-t):
f2:=-cos(x+t):
g:=f1+f2:
plots:-animate(plot,[[f1,f2,g,0], x=-2*Pi..2*Pi, color=[blue,red,black,grey], thickness=[1,1,3,1], scaling=constrained, size=[1200,400], axes=none], t=0..4*Pi, frames=120, background=plot([seq([Pi*k,0],k=-2..2)], style=point, color=red, symbol=solidcircle, symbolsize=12));

Edit.

Here is a simple procedure for solving your problem. S  is a list of any objects:

MyPermute:=proc(S::list)
local L, n, m, i, r, k, u;
L:=S;
n:=nops(L); m:=n;
for i from 1 to n do
r:=rand(1..m);
k:=r();
u[i]:=L[k];
L:=subsop(k=NULL,L);
m:=m-1;
od;
[seq(u[i],i=1..n)];
end proc:

Example of use:

MyPermute([$1..100]);
       
  [53, 80, 11, 49, 30, 54, 22, 97, 36, 98, 47, 26, 82, 73, 41, 92, 20, 69, 52, 23, 9, 2, 94, 19, 16, 48, 63, 51, 57, 18, 60, 75, 13, 59, 91, 3, 89, 5, 25, 38, 87, 96, 55, 62, 90, 21, 17, 61, 37, 7, 78, 79, 70, 72, 58, 45, 56, 24, 46, 64, 100, 35, 88, 85, 32, 50, 44, 28, 43, 15, 65, 71, 27, 29, 66, 68, 14, 40, 10, 77, 86, 31, 8, 74, 33, 76, 81, 93, 34, 95, 84, 39, 12, 67, 4, 83, 1, 6, 99, 42]

One relationship between variables reduces the dimension by 1. Therefore, the set

exp(-r*T)*(-(1/2)*erf((1/4)*sqrt(2)*(sigma^2*T-2*r*T+2*ln(K)-2*ln(S[0]))/(sigma*sqrt(T)))+1/2) = C, C>0,

will be a 4-dimensional surface in R^5  (the same as  f(x,y,z)=C  is a 2-dimensional surface in R^3).

815427339135043.^5579408896058;
                                                   
 1.126609694 10^83196715617351

You can do this with high accuracy if you first use logarithm:

A:=5579408896058*ln(815427339135043);
evalf[100](exp(1)^A);

 

You can label a vertex of any graph by any symbols, if you use  strings. You can also color it with any color as in the example:


 

with(GraphTheory):
G:=Graph(["Source","Sink"], {["Source","Sink"]});
DrawGraph(G);
HighlightVertex(G, "Source", "Magenta"):
HighlightVertex(G, "Sink", "LightGreen"):
DrawGraph(G);

GRAPHLN(directed, unweighted, ["Source", "Sink"], Array(%id = 18446746804317258566), `GRAPHLN/table/1`, 0)

 

 

 

 


 

Download labelling.mw

The plotting of all 3 roots for  V=0.8  is shown below. The real part is plotted with a solid line, and the imaginary - with a dashed line:


 

restart;
with(plots):

gm := V -> 1/sqrt(1-V^2):
T := w-k*V:
S := w*V-k:

f := unapply(T*S^2*gm(V)^3*3/2+I*S^2(1+I*27/4*T*gm(V))*gm(V)^2-(1+I*27/4*T*gm(V))*(1+I*5*T*gm(V))*T*gm(V),
             w,V,k);

proc (w, V, k) options operator, arrow; (3/2)*(-V*k+w)*(V*w-k)^2/(-V^2+1)^(3/2)+I*(V*w-k)^2/(-V^2+1)-(1+((27/4)*I)*(-V*k+w)/(-V^2+1)^(1/2))*(1+(5*I)*(-V*k+w)/(-V^2+1)^(1/2))*(-V*k+w)/(-V^2+1)^(1/2) end proc

(1)

Hgen := simplify(rationalize(f(w, V, k)))

-47*(((I*k^2-((4/47)*I)*w^2)*V^2-((86/47)*I)*V*k*w-((4/47)*I)*k^2+I*w^2)*(-V^2+1)^(1/2)+(135/47)*((k^2+(2/45)*w^2+4/135)*V^2-(94/45)*V*k*w+(2/45)*k^2+w^2-4/135)*(V*k-w))*(-V^2+1)^(1/2)/(4*V^4-8*V^2+4)

(2)

altcols := ["Black","Red","Blue"]:

Vlist :=  [ 0.8, 0.9, 0.99 ];

[.8, .9, .99]

(3)

_EnvExplicit := true;

true

(4)

H:=[solve(numer(Hgen),w)]:
indets(%,name);
nops(H);

{V, k}

 

3

(5)

A := plot(([Re, Im])(eval(H[1], V = .8)), k = 0 .. 1, color = red, linestyle = [1, 3]); B := plot(([Re, Im])(eval(H[2], V = .8)), k = 0 .. 1, color = blue, linestyle = [1, 3]); C := plot(([Re, Im])(eval(H[3], V = .8)), k = 0 .. 1, color = green, linestyle = [1, 3]); display(A, B, C)

 

 

 

 

 


 

Download file1_new.mw

First 91 92 93 94 95 96 97 Last Page 93 of 289