Kitonum

21525 Reputation

26 Badges

17 years, 76 days

MaplePrimes Activity


These are answers submitted by Kitonum

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

I think Maple simply cannot cope with the symbolic (that is, exact) calculation of your integral. Therefore, I advise you to calculate it numerically, replacing infinity for example with the number 10. For comparison, I replaced infinity with the number 20. The results are identical. The reason is that the integrand very quickly converges to 0 (see its plot):

restart;

g(x,y):=min(3+(x-y)^2/10+abs(x+y)/sqrt(2),-abs(x-y)+7/sqrt(2));

q:=0; 
h(x,y):=Heaviside(g(x,y)-q);

p := Int(Int(h(x, y)*exp((-x^2-y^2)*(1/2))/(2*Pi), y = -10 .. 10), x = -10 .. 10);
evalf(%);

plot3d(h(x, y)*exp((-x^2-y^2)*(1/2))/(2*Pi), x=-5..5,y=-5..5);

p1 := Int(Int(h(x, y)*exp((-x^2-y^2)*(1/2))/(2*Pi), y = -20 .. 20), x = -20 .. 20);
evalf(%);


 

The number of subintervals is determined by the  partition  option. By default it is [5, 5] , that is, the interval for each variable is divided into 5 parts. Here are 2 examples with different values:


 

restart;

with(Student[MultivariateCalculus]):

ApproximateInt(x^2+y^2, x = 0 .. 2, y = 0 .. 3, partition=[2,3], output=plot);
ApproximateInt(x^2+y^2, x = 0 .. 2, y = 0 .. 3, partition=[4,6], output=plot);

 

 

 


 

Download int.mw

When there is no idea how to symbolically represent a numeric expression, the following trick is useful:

identify(evalf((1/2)!));

                                              

 

 

You can easily do this using just 2 commands (in the title):

A:=DETools:-DEplot(diff(y(t),t)=(3-y(t))*(y(t)+1), y(t), t=0..5, y=-2..4, color=yellow, linecolor=white, [y(0)=4]):
B:=Student:-NumericalAnalysis:-Euler(diff(y(t),t)=(3-y(t))*(y(t)+1), y(0) = 4, t = 5, plotoptions=[color=red, symbolsize=12], output=plot):
plots:-display(A,B,scaling=constrained, size=[400,500]);

        

The nodal points in the Euler method are highlighted with small red circles (Maple does this automatically).

I can not confirm this. Everything works properly. Take a look:

restart;
F := x^2+y^2 = 1;
G := lhs(F) <= rhs(F);
is(eval(G, [x=0.5,y=0.6]));

                                       F := x^2+y^2 = 1
                                      G := x^2+y^2 <= 1
                                              true


Please submit the full text of the code in which you encountered this error "Error, cannot determine if this expression is true or false: x^2+y^2 <= 1"

     

Two syntax errors:

1. Should be  Pi  not  pi (it's just a symbol).

2. Should be  e(1)  instead of  e(T=1) .


 

restart;
k:=T->2/cosh(2/T)/coth(2/T);
delta:=T->sqrt(1-k(T)^2*sin(theta)^2);
e:=T->-2*tanh(2/T)+D(T->k(T)/2/Pi*Int(sin(theta)^2/delta(T)/(1+delta(T)), theta=0..Pi))(T);

proc (T) options operator, arrow; 2/(cosh(2/T)*coth(2/T)) end proc

 

proc (T) options operator, arrow; sqrt(1-k(T)^2*sin(theta)^2) end proc

 

proc (T) options operator, arrow; -2*tanh(2/T)+(D(proc (T) options operator, arrow; (1/2)*k(T)*(Int(sin(theta)^2/(delta(T)*(1+delta(T))), theta = 0 .. Pi))/Pi end proc))(T) end proc

(1)

evalf(e(1));

-1.742031581

(2)

 


 

Download 11.mw

First 92 93 94 95 96 97 98 Last Page 94 of 290