Kitonum

21530 Reputation

26 Badges

17 years, 83 days

MaplePrimes Activity


These are answers submitted by Kitonum

RootFinding:-Analytic(exp(x)*sin(x)-exp(1), re=0..100, im=-1..1);
plot(exp(x)*sin(x)-exp(1), x=0..100,-3..3, size=[900,300]);  # Check

Notice that the exponential function with the base  e  must be encoded in Maple as  exp(x)  (not  as  e^x ). e is just a symbol in Maple.

Unfortunately, I do not see the possibility to significantly speed up this calculation. I just rewrote your code as a procedure, slightly simplifying it. The procedure returns  true  if the matrix is  MDS  and  false  otherwise. The example of a matrix of 12 order is considered. This calculation took about 35 minutes on my computer.


 

restart;

IsMDS:=proc(A::Matrix)
local n, k, P, p, q, F, r;
uses combinat, LinearAlgebra;
n:=op([1,1],A);
for k to n do
 P := choose(n, k);
 for p in P do
 for q in P do
 F := A(p, q);
 r := Determinant(F);
 if r = 0 then return false end if;
end do; end do;
end do:
true;
end proc:

ts:=time():
interface(rtablesize=100):
A:=LinearAlgebra:-RandomMatrix(12);
IsMDS(A);
time()-ts;

Matrix(12, 12, {(1, 1) = -69, (1, 2) = -30, (1, 3) = -75, (1, 4) = 42, (1, 5) = -81, (1, 6) = -97, (1, 7) = -63, (1, 8) = -5, (1, 9) = 58, (1, 10) = -29, (1, 11) = 48, (1, 12) = 28, (2, 1) = 17, (2, 2) = -50, (2, 3) = -3, (2, 4) = 55, (2, 5) = 11, (2, 6) = -92, (2, 7) = 27, (2, 8) = 47, (2, 9) = -43, (2, 10) = 9, (2, 11) = -60, (2, 12) = -81, (3, 1) = -87, (3, 2) = 98, (3, 3) = 19, (3, 4) = 34, (3, 5) = -76, (3, 6) = 73, (3, 7) = 58, (3, 8) = -54, (3, 9) = -85, (3, 10) = 81, (3, 11) = 51, (3, 12) = -36, (4, 1) = 37, (4, 2) = 5, (4, 3) = 69, (4, 4) = -55, (4, 5) = 82, (4, 6) = 44, (4, 7) = 2, (4, 8) = -72, (4, 9) = -85, (4, 10) = 35, (4, 11) = 20, (4, 12) = -88, (5, 1) = 33, (5, 2) = -23, (5, 3) = -89, (5, 4) = 54, (5, 5) = -29, (5, 6) = 92, (5, 7) = 54, (5, 8) = -79, (5, 9) = 19, (5, 10) = 80, (5, 11) = -46, (5, 12) = 91, (6, 1) = -17, (6, 2) = 19, (6, 3) = 95, (6, 4) = 79, (6, 5) = 29, (6, 6) = 73, (6, 7) = 47, (6, 8) = 75, (6, 9) = 25, (6, 10) = 20, (6, 11) = 35, (6, 12) = -62, (7, 1) = 58, (7, 2) = -93, (7, 3) = 77, (7, 4) = -99, (7, 5) = 35, (7, 6) = -39, (7, 7) = 90, (7, 8) = -85, (7, 9) = 17, (7, 10) = 39, (7, 11) = -54, (7, 12) = -94, (8, 1) = -21, (8, 2) = 12, (8, 3) = -84, (8, 4) = -32, (8, 5) = -70, (8, 6) = 62, (8, 7) = -41, (8, 8) = -19, (8, 9) = 81, (8, 10) = -35, (8, 11) = -17, (8, 12) = 27, (9, 1) = 15, (9, 2) = 82, (9, 3) = -63, (9, 4) = -9, (9, 5) = -43, (9, 6) = 11, (9, 7) = -79, (9, 8) = 57, (9, 9) = 89, (9, 10) = 26, (9, 11) = -25, (9, 12) = 18, (10, 1) = -58, (10, 2) = -4, (10, 3) = 96, (10, 4) = 69, (10, 5) = -23, (10, 6) = 61, (10, 7) = 9, (10, 8) = 83, (10, 9) = 92, (10, 10) = -74, (10, 11) = 78, (10, 12) = 18, (11, 1) = 75, (11, 2) = 14, (11, 3) = 69, (11, 4) = 31, (11, 5) = -14, (11, 6) = 28, (11, 7) = 45, (11, 8) = -45, (11, 9) = -2, (11, 10) = 13, (11, 11) = 23, (11, 12) = 63, (12, 1) = -31, (12, 2) = 78, (12, 3) = 72, (12, 4) = -66, (12, 5) = 37, (12, 6) = -48, (12, 7) = -10, (12, 8) = 68, (12, 9) = -46, (12, 10) = 32, (12, 11) = -67, (12, 12) = 86})

 

true

 

2090.344

(1)

%/60*minutes;

34.83906667*minutes

(2)

 


 

Download MDS.mw

 

Since the system is easily reduced to a linear system, it can easily be solved symbolically, that is, absolutely exactly:

Sys:=convert({(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}, fraction);
solve(Sys);


                

To solve this problem you can use  PosIntSolve  procedure from this post. This procedure allows you to find the number of non-negative (or positive) integer solutions of a linear Diophantine equation with positive coefficients. For convenience, here are the text of the procedure and 2 examples.

restart;

PosIntSolve:=proc(L::list(posint), n::nonnegint, s::symbol:=nonneg)
local N, n0;
option remember;
if s=pos then n0:=n-`+`(op(L)) else n0:=n fi;
N:=nops(L);
if N=1 then if irem(n0,L[1])=0 then return 1 else return 0 fi; fi;
add(PosIntSolve(subsop(1=NULL,L),n0-k*L[1]), k=0..floor(n0/L[1]));
end proc:

The problem: find the number of non-negative integer solutions of equations  51*x1+53*x2+50*x3=197  and   51*x1+53*x2+50*x3=2697  .

Solutions:

PosIntSolve([51, 53, 50], 197);
PosIntSolve([51, 53, 50], 2697);
                                                             
0
                                                             28
 

Replace  "5"  temporarily some symbol:

applyrule(a*x+a=a*``(x+1), subs(5=a, sqrt(5*x+5+y))):
subs(a=5, %);
                             
sqrt(5*(x+1)+y)

Actually no error. When you differentiate the internal function  r*sin(theta)*(r*cos(theta)-a)^(-1)  by a-variable, then the factor (-1) occurs 2 times.

The result above is incorrect, since the straight line and the parabola in this example intersect not at one, but at two points. To avoid errors for different curves, use different parameter names. Here is the right solution:


 

restart;
L1 := [t-2,(t-2)^2]:        
L2 := [(3*s/2)-4,(3*s/2)-2]:
solve(Equate(L1,L2));
plot([[op(L1),t=-1..5],[op(L2),s=0..5]], color=[red,blue]);  # Check

 

{s = 2, t = 1}, {s = 4, t = 4}

 

 

 


 

Download parametrics.mw

Red arrows (tangent vectors) show the direction of increasing parameter:
 

f:=[t-2,(t-2)^2];
df:=diff(f, t);

[t-2, (t-2)^2]

 

[1, 2*t-4]

(1)

P:=plot([op(f), t=-0.5..4.5], color=blue):
V:=plots:-arrow([seq([f, df], t=0..4)], length=1, color=red, border=false):
plots:-display(P,V, scaling=constrained, size=[400,500]);

 

 


 

Download arrows1.mw

Try the following:

plot([x+deltax, z, x=0..l]);
 

Here is the plot that OP wished according to his link:

restart;
f:=x->sqrt(1-x^2):
g:=x->-sqrt(1-x^2):
y1:=f(a)+D(f)(a)*(x-a):
y2:=g(a)+D(g)(a)*(x-a):
y3:=[-1,t,t=-1.5..1.5]:
y4:=[1,t,t=-1.5..1.5]:
Opt:=x=-2..2,color="Blue":
plots:-display(plot([seq(op([y1,y2]),a=-0.99..0.99,0.02)],Opt),plot([y3,y4],Opt), view=[-2..2,-1.5..1.5], scaling=constrained, size=[700,500],tickmarks=[spacing(0.5),spacing(0.5)],  axis[1]=[gridlines=40], axis[2]=[gridlines=30]);


Output:
                    

 

 

L := [8,7,9,12];
L1:=[seq([i, L[i]], i=1..nops(L))];
map(t->t[1], sort(L1, (x,y)->y[2]<x[2]));

 

Your second result obtained with erroneous syntax (numeric option is  misplaced) is incorrect. To test this, I did both calculations for  T=1, after making some simplifications to your commands (Pi should be instead of pi, and also removed some commands and options that do not affect the result). I don't know how Maple could get it but the second result is also erroneous because the integral in which the integrand is positive must also be positive.

 

restart;

(2/Pi)^(1/2)*int((exp(-32.74123792568-0.8916456579806e-1*ln(4.852623952*10^9*v^2)))*exp(-v^2/(2*T))*v^3, v = 2 .. 100, numeric);
evalf(eval(%,T=1)); # The value of the integral for T=1

2^(1/2)*(1/Pi)^(1/2)*(int(exp(-32.74123793-0.8916456580e-1*ln(4852623952.*v^2))*exp(-.5000000000*v^2/T)*v^3, v = 2. .. 100.))

 

0.4544054310e-15

(1)

(2/Pi)^(1/2)*int((exp(-32.74123792568-0.8916456579806e-1*ln(4.852623952*10^9*v^2)), numeric)*exp(-v^2/(2*T))*v^3, v = 2 .. 100);
evalf(eval(%, T=1)); # It's incorrect result

0.2737688896e-1*2^(1/2)*(1/Pi)^(1/2)*T*exp(-0.8000000000e-10*(0.4092654741e12*T+0.6250000000e14)/T)*(-4.438382806*exp(5000./T)*T+8.837258978*exp(4998./T)*T+17.67451796*exp(4998./T)-4.398876172*T-21994.38086)

 

-0.1121012454e-15

(2)

 

``


 

Download int_(2)_new.mw

What function do you call monotonically increasing (or monotonically decreasing) on some multidimensional set? The issue is that there is a natural order on the number axis: for any two different points, we know for sure which one is greater. And in multidimensional space? For example, on 2D which point is greater: (0,1) or (1,0)?

I do not understand why such a complicated code (nested loops and etc.) for a simple task. You can immediately build all the necessary plots, if you know their equations, and then get the data using  plottools:-getdata  command:

restart;  
H:= 3+2*tanh(x-6);
P:=plot([H, -H, 0], x=0..10, linestyle=[1,1,3], color=black, thickness=[2,2,0], view=[-1..12,-6..6], axes=box);
interface(rtablesize=1000);
map(t->t[3],[plottools:-getdata(P)]);


 

restart;
f:=ln((1-x)^2*(x+1)^2/((-I*x-I+sqrt(-x^2+1))^2*(I*x+I+sqrt(-x^2+1))^2));
applyop(t->numer(t)/expand(denom(t)), 1, f);
simplify(%);
applyrule(ln((-1+x)^2)=2*ln(abs(x-1)), %);
sort(%);
                


Edit.
                    

First 98 99 100 101 102 103 104 Last Page 100 of 290