Kitonum

20084 Reputation

26 Badges

17 years, 29 days

MaplePrimes Activity


These are answers submitted by Kitonum


 

restart;

B:=<<39,76,151,301,601>|<7.71E-8,5.43E-9,3.55E-10,2.11E-11,1.32E-12>|
        <26,51,101,201,401>|<6.46E-3,1.17E-4,1.88E-6,2.96E-8,4.46E-10>|
        <26,51,101,201,401>|<2.74E-4,6.34E-6,1.16E-7,1.85E-9,2.92E-11>|
        <26,51,101,201,401>|<6.48E-4,4.39E-5,2.99E-6,1.88E-7,1.18E-8>>;

for i from 1 to 5 do
   B[i, 2] := log[10](B[i, 2]):                                          
   B[i, 4] := log[10](B[i, 4]):                 
   B[i, 6] := log[10](B[i, 6]):                 
   B[i, 8] := log[10](B[i, 8]):        
       

   
end do:  # computing the log of the max-error
B: # This is the table of values we'll plot.
local log:
T:=plot([B[..,[1, 2]],B[1..1,[1, 2]], B[.., [3, 4]],B[1..1,[3, 4]],
         B[..,[5, 6]],B[1..1,[5, 6]],B[.., [7, 8]],B[1..1,[7, 8]]],
        legend = ["","BFFM","", "BHT","", "BHTRKNM", "", "BNM"],
        #title="Efficiency Curve for Example 1",
        style = ["pointline","point","pointline","point","pointline","point","pointline","point"],
        symbolsize = 15,axes = framed,
        symbol = [box,box, circle,circle,diamond,diamond,solidcircle, solidcircle],
        color=[red, red, blue,blue, black, black, green, green],
        axis = [gridlines = [colour = green, majorlines = 1,linestyle = dot]],
        labels = ["NFE", log[10](cat(`Max `,Err))]);

Matrix(5, 8, {(1, 1) = 39, (1, 2) = 0.7710000000e-7, (1, 3) = 26, (1, 4) = 0.646e-2, (1, 5) = 26, (1, 6) = 0.274e-3, (1, 7) = 26, (1, 8) = 0.648e-3, (2, 1) = 76, (2, 2) = 0.5430000000e-8, (2, 3) = 51, (2, 4) = 0.117e-3, (2, 5) = 51, (2, 6) = 0.634e-5, (2, 7) = 51, (2, 8) = 0.439e-4, (3, 1) = 151, (3, 2) = 0.3550000000e-9, (3, 3) = 101, (3, 4) = 0.188e-5, (3, 5) = 101, (3, 6) = 0.1160000000e-6, (3, 7) = 101, (3, 8) = 0.299e-5, (4, 1) = 301, (4, 2) = 0.2110000000e-10, (4, 3) = 201, (4, 4) = 0.2960000000e-7, (4, 5) = 201, (4, 6) = 0.1850000000e-8, (4, 7) = 201, (4, 8) = 0.1880000000e-6, (5, 1) = 601, (5, 2) = 0.1320000000e-11, (5, 3) = 401, (5, 4) = 0.4460000000e-9, (5, 5) = 401, (5, 6) = 0.2920000000e-10, (5, 7) = 401, (5, 8) = 0.1180000000e-7})

 

Warning, A new binding for the name `log` has been created. The global instance of this name is still accessible using the :- prefix, :-`log`.  See ?protect for details.

 

 

 


 

Download Help_data_points_new1.mw

 

In the example below, we construct 2 vertical lines (directrixes for an ellipse) in two ways:


 

restart;
a:=5: b:=3:
P:=plots:-implicitplot(x^2/a^2+y^2/b^2=1, x=-a..a, y=-b..b, color=blue):
c:=sqrt(a^2-b^2);
e:=c/a;
L1:=plot([[-a/e,t,t=-4..4],[a/e,t,t=-4..4]], color=red): # The first way
L2:=plots:-implicitplot([x=-a/e, x=a/e], x=-7..7, y=-4..4, color=red): # The second way
plots:-display(P, L1, scaling=constrained, view=[-7..7,-4..4]);
plots:-display(P, L2, scaling=constrained, view=[-7..7,-4..4]);

4

 

4/5

 

 

 

 


Edit. We can also build any straight lines using the plottools:-line  command (the third way).

Download vl-2.mw

Example:

restart;
f:=x->x^3;
(D@@2)(f)(x);
(D@@2)(f)(3);

 

Let (x0,y0) is a point on the ellipse E.


 

restart;
eq:=x0*x/a^2+y0*y/b^2=1: # The equation of the tangent in the point(x0,y0) (from wiki)
OT:=solve(eval(eq,y=0),x);
Om:=x0:
Om*OT;

k:=-coeff(lhs(eq),x)/coeff(lhs(eq),y); # The slope of the line eq
eq1:=y-y0=-1/k*(x-x0); # The equation of the normal in the point(x0,y0)
ON:=solve(eval(eq1,y=0),x);
simplify(ON,{a^2-b^2=c^2});
 

a^2/x0

 

a^2

 

-x0*b^2/(a^2*y0)

 

y-y0 = a^2*y0*(x-x0)/(x0*b^2)

 

(a^2-b^2)*x0/a^2

 

c^2*x0/a^2

(1)

 


Edit.

Download prop_23.mw

 

Or (an example):

restart;
p:=plot(exp(x), x=-2..2);
plottools:-reflect(p, [[0,0],[1,1]]);

 

Probably the procedures  IntegerPoints (or  IntegerPoints1) from the post  https://www.mapleprimes.com/posts/202437-Integer-Points-In-Polyhedral-Regions  will be useful for solving your problems.

You can use nested  seq  for this. What we get is called not permutations but Cartesian product  


 

restart;
S:={0,1,2}:
seq(seq(seq(seq([u,x,y,z], z=S), y=S), x=S), u=S);

[0, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 2], [0, 0, 1, 0], [0, 0, 1, 1], [0, 0, 1, 2], [0, 0, 2, 0], [0, 0, 2, 1], [0, 0, 2, 2], [0, 1, 0, 0], [0, 1, 0, 1], [0, 1, 0, 2], [0, 1, 1, 0], [0, 1, 1, 1], [0, 1, 1, 2], [0, 1, 2, 0], [0, 1, 2, 1], [0, 1, 2, 2], [0, 2, 0, 0], [0, 2, 0, 1], [0, 2, 0, 2], [0, 2, 1, 0], [0, 2, 1, 1], [0, 2, 1, 2], [0, 2, 2, 0], [0, 2, 2, 1], [0, 2, 2, 2], [1, 0, 0, 0], [1, 0, 0, 1], [1, 0, 0, 2], [1, 0, 1, 0], [1, 0, 1, 1], [1, 0, 1, 2], [1, 0, 2, 0], [1, 0, 2, 1], [1, 0, 2, 2], [1, 1, 0, 0], [1, 1, 0, 1], [1, 1, 0, 2], [1, 1, 1, 0], [1, 1, 1, 1], [1, 1, 1, 2], [1, 1, 2, 0], [1, 1, 2, 1], [1, 1, 2, 2], [1, 2, 0, 0], [1, 2, 0, 1], [1, 2, 0, 2], [1, 2, 1, 0], [1, 2, 1, 1], [1, 2, 1, 2], [1, 2, 2, 0], [1, 2, 2, 1], [1, 2, 2, 2], [2, 0, 0, 0], [2, 0, 0, 1], [2, 0, 0, 2], [2, 0, 1, 0], [2, 0, 1, 1], [2, 0, 1, 2], [2, 0, 2, 0], [2, 0, 2, 1], [2, 0, 2, 2], [2, 1, 0, 0], [2, 1, 0, 1], [2, 1, 0, 2], [2, 1, 1, 0], [2, 1, 1, 1], [2, 1, 1, 2], [2, 1, 2, 0], [2, 1, 2, 1], [2, 1, 2, 2], [2, 2, 0, 0], [2, 2, 0, 1], [2, 2, 0, 2], [2, 2, 1, 0], [2, 2, 1, 1], [2, 2, 1, 2], [2, 2, 2, 0], [2, 2, 2, 1], [2, 2, 2, 2]

(1)

nops([%])=ifactor(nops([%]));

81 = ``(3)^4

(2)

 


 

Download nested_seq.mw


 

restart;
opt1:="a=1, b=2":
opt2:="a=0.7, b=3":
f:=a*x^b:
plot([eval(f,[parse(opt1)]),eval(f,[parse(opt2)])], x=-2..2, color=[red,blue], legend=[opt1,opt2], legendstyle=[location=left, font=[times,16]], scaling=constrained, size=[600,600]);

 

 


Edit: Here's another (prettier but more complex) version:

restart;
opt1:="a=1, b=2":
opt2:="a=0.7, b=3":
f:=a*x^b:
A:=plot([eval(f,[parse(opt1)]),eval(f,[parse(opt2)])], x=-2..2, color=[red,blue], thickness=2):
B:=plot([5.2,4.7], x=-0.9..-0.4, color=[red,blue], thickness=3):
T:=plots:-textplot([[-2.9,5.2,opt1],[-3.2,4.7,opt2]], font=[times,16], align=right):
plots:-display(A,B,T, scaling=constrained, size=[600,500]);

                          

 

Download legend.mw

restart;
A:=Matrix([[0,1,-1],[-1,-2,2],[-1,-2,2]]):
v:=Vector([-1,1,1]):
sol := LinearAlgebra:-LinearSolve(A,v);
indets(sol, 'indexed');

 

v:=[2,4,7];
ilcm( op(v));
# Or
ilcm(v[]);

 

In the help for  fsolve  we see  
"variables - (optional) name or set(name); unknowns for which to solve"

So use  x0  and  y0  instead (for example).


 

restart;

x%*x;

`%*`(x, x)

(1)

value(%);

x^2

(2)

 


 

Download inert.mw

restart;         
plot3d(eval([x,y,4*x^2+9*y^2],[x=1/2*r*cos(t),y=1/3*r*sin(t)]), r=0..1, t=0..2*Pi, axes=normal, scaling=constrained);


 

Download _paraboloid.mw

Use  LinearAlgebra:-GenerateMatrix  instead of  linalg:-genmatrix :

 

Download sys.mw

In Maple the imaginary unit should be coded as  I  not  :


 

restart;
with(LinearAlgebra):
with(plots, implicitplot):
i:=I:
M := Matrix([[sigma + Gamma*i*k + 0.5 + 0.5*tanh(c - v) + beta*v, -0.5 + 0.5*tanh(c - v), 0.5*(w - u)*sech^2*(c - v) - beta*u], [-0.5 - 0.5*tanh(c - v), sigma - i*k*Gamma + 0.5 + 0.5*tanh(c - v) + beta*v, 0.5*(u - w)*sech^2*(c - v) - beta*w], [-beta*v, -beta*v, sigma - beta*alpha*(u + w)]]);

Matrix(3, 3, {(1, 1) = sigma+I*GAMMA*k+.5+.5*tanh(c-v)+beta*v, (1, 2) = -.5+.5*tanh(c-v), (1, 3) = (.5*w-.5*u)*sech^2*(c-v)-beta*u, (2, 1) = -.5-.5*tanh(c-v), (2, 2) = sigma-I*GAMMA*k+.5+.5*tanh(c-v)+beta*v, (2, 3) = (.5*u-.5*w)*sech^2*(c-v)-beta*w, (3, 1) = -beta*v, (3, 2) = -beta*v, (3, 3) = sigma-beta*alpha*(u+w)})

(1)

Eq := Determinant(M);

.50*tanh(c-v)*sigma+1.0*tanh(c-v)*sigma^2+.50*tanh(c-v)^2*sigma+1.0*sigma^2+sigma^3-1.0*sigma*tanh(c-v)*beta*alpha*u-1.0*sigma*tanh(c-v)*beta*alpha*w-1.0*tanh(c-v)*beta^2*v*alpha*u-1.0*tanh(c-v)*beta^2*v*alpha*w+.50*tanh(c-v)*beta*v^2*sech^2*u-.50*tanh(c-v)*beta*v^2*sech^2*w-Gamma^2*k^2*beta*alpha*u-Gamma^2*k^2*beta*alpha*w-2*sigma*beta^2*v*alpha*u-2*sigma*beta^2*v*alpha*w+Gamma^2*k^2*sigma+beta^2*v^2*sigma+2*beta*v*sigma^2+1.0*beta*v*sigma-1.0*beta^2*v*w-beta^3*v^2*u-1.0*beta^2*v*u-beta^3*v^2*w-(1.0*I)*Gamma*k*beta*v*c*sech^2*w+(1.0*I)*Gamma*k*beta*v*c*sech^2*u-beta^2*v*u*sigma-.50*tanh(c-v)*beta*alpha*u-.50*tanh(c-v)*beta*alpha*w-.50*tanh(c-v)^2*beta*alpha*u-.50*tanh(c-v)^2*beta*alpha*w+1.0*tanh(c-v)*beta*v*sigma-1.0*tanh(c-v)*beta^2*v*u-1.0*sigma*beta*alpha*u-1.0*sigma*beta*alpha*w-1.0*beta^2*v*alpha*u-1.0*beta^2*v*alpha*w-sigma^2*beta*alpha*u-sigma^2*beta*alpha*w-sigma*beta^2*v*w-beta^3*v^2*alpha*u-beta^3*v^2*alpha*w-(1.0*I)*Gamma*k*beta*v^2*sech^2*u+(1.0*I)*Gamma*k*beta*v^2*sech^2*w-.50*tanh(c-v)*beta*v*c*sech^2*u+.50*tanh(c-v)*beta*v*c*sech^2*w+I*beta^2*v*u*Gamma*k-I*Gamma*k*beta^2*v*w

(2)

alpha := 0.1;
beta := 0.01;
mu := 0.5;
u := 0.5;
v := 1;
Gamma := 0.1;
c := 2;
w := 0.5;

.1

 

0.1e-1

 

.5

 

.5

 

1

 

.1

 

2

 

.5

(3)

p1i := evalc(Re(Eq));

(-0.11110e-3+0.*I)+0.8980e-2*sigma-0.5600e-3*tanh(1)-0.500e-3*tanh(1)^2+.50900*tanh(1)*sigma+1.0*tanh(1)*sigma^2+.50*tanh(1)^2*sigma+0.1e-1*k^2*sigma+1.0190*sigma^2-0.10e-4*k^2+sigma^3

(4)

p1 := implicitplot(Eq, k = 0 .. 10, sigma = -0.01 .. 0.01);

 

 


Edit.  evalc(Im(Eq))  returns  0. , that is  Eq  is real for real  k  and  sigma  and specific values the other parameters.
 

Download plot_new.mw

First 41 42 43 44 45 46 47 Last Page 43 of 280