Kitonum

21595 Reputation

26 Badges

17 years, 162 days

MaplePrimes Activity


These are answers submitted by Kitonum

See  ?plot,axis  help page for this.

Do you just want to check that a number  a  is the root of your equation? In this case, do 

simplify(eval(F(X)=0, X=a));

Sometimes other commands are required instead of  simplify . Then specify the exact form of your equation and the value of .
 

restart;
with(Physics):
Setup(mathematicalnotation = true);                
Setup(signature = `+---`);
ds2 := ((x^2-y^2)*cos(2*u)+2*x*y*sin(2*u))*(du^2)-2*x*(dv^2)-dx^2-dy^2;
Setup(coordinatesystems=(Z=[u, v, x, y]), metric = ds2);

 

Edit.

[{1, 2}, {2, 3}] minus~ [{2}$2];
                                                   
  [{1}, {3}]

A more traditional and programmatic way of obtaining the values of a function obtained as a result of solving an equation, etc., is to use  eval  command. See the same example as tomleslie's one:


 

restart;
PDE := diff(u(x,t),t)=-diff(u(x,t),x);
  IBC := {u(x,0)=sin(2*Pi*x),u(0,t)=-sin(2*Pi*t)};
  pds := pdsolve(PDE,IBC,numeric,time=t,range=0..1);

diff(u(x, t), t) = -(diff(u(x, t), x))

 

{u(0, t) = -sin(2*Pi*t), u(x, 0) = sin(2*Pi*x)}

 

_m2382342501312

(1)


f:=(x0,t0)->eval(u(x,t),pds:-value(t=t0)(x0));
f(0.7,0.5);  # Example of the calculation of a value of u(x,t)
evalf(Int(x->f(x,0.1), 0.25..0.75));  # Example of the calculation of an integral of u(x,t)

proc (x0, t0) options operator, arrow; eval(u(x, t), (pds:-value(t = t0))(x0)) end proc

 

HFloat(0.9510565162951535)

 

HFloat(0.18707013161493055)

(2)

 


 

Download eval.mw

ode:= diff(y(x),x)=2*x:
plots:-display(DEtools:-DEplot(ode,y(x),x = -2 .. 2,y = -2 .. 2, [[0.1,0]],
               labels=["",""],
               linecolour = red,
               color = blue,
               'arrows' = 'medium',
               axesfont=['Times', 'bold', 12]
               ), axis=[tickmarks=[color=red]]);

For your first example, everything is the same:

restart;
plots:-display(plot(sin(x),x=-Pi..Pi, color=blue),axis=[tickmarks=[color=red]]);
 

Here is an example of solving the problem. The method is of a general nature and can be used for any curves given by parametric equations. In the example, the red curve is a broken line, and the blue one is a straight line.

restart;
d:=(P,Q)->sqrt((P[1]-Q[1])^2+(P[2]-Q[2])^2);
P:=piecewise(s>=0 and s<0.3,[s,s/3+0.3],s>=0.3 and s<0.5,[s,-s+0.7],s>=0.5 and s<0.7,[s,7/2*s-1.55],s>=0.7 and s<=1,[s,-s/3+17/15]);
Q:=[t,t];
A:=plot(piecewise(seq(op([op(P)[2*n-1],op(P)[2*n][2]]), n=1..nops([op(P)])/2)), s=0..1,color=red, thickness=3):
B:=plot(t, t=0..1, color=blue, thickness=3):
epsilon:=0.3;
C:=plots:-inequal({d(P,Q)<=epsilon}, s=0..1, t=0..1, optionsfeasible = [color = "WhiteSmoke"], optionsexcluded = [color = "DarkGrey"], view=[0..1,0..1]):
plots:-display(<plots:-display(A,B) | C>, scaling=constrained); # This is "free space diagram"

If the curve is given by a conventional equation, for example  y=f(x) , so you must specify it as the list  [x, f(x)]

FD.mw

Edit.

Try  
A.C;
  # dot product 
# or  
expand(A.C); 

Type this ( ) as an ordinary dot on the keyboard. I use 1d-math input. In 2d-math input (which you use) , this will look like a fat dot in the middle.

For real domain use  discont  command instead of  singular  (the output is empty set):

discont(ln(y^2+1), y);
                                         
 { }

You are not right. Maple calculates everything correctly. Should be

combinat:-numbcomb(n, m) = binomial(n, m)  

See help on this command.

For example  combinat:-numbcomb(7, 3) = (7*6*5)/3! = 35

The mapping of the square  [0,1] x [0,1]  with 2d-grid:

restart;
f:=(r,t)->[r*exp(t),r*exp(-t)];
S:=plot([seq([x,t,t=0..1],x=0..1,0.1),seq([t,y,t=0..1],y=0..1,0.1)], color=red, size=[200,200]):
F:=plottools:-transform(f):
T:=plots:-display(F(S), size=[400,400]):
plots:-display(<S | T>, scaling=constrained);


                       

Edit.
                        

 


 

Try use inert multiplication for this:

A:=x%*y=y%*x + 2*z;
expand(subs(A, w*x%*y));
                              

 

 

Sum is an inert form for sum, when the summation is simply shown on the display, but not calculated in any closed form. See the following example:

Sum(1/n^2, n=1..infinity) = sum(1/n^2, n=1..infinity);


Addition. To avoid possible errors, end each line of code with delimiters (;  or  : ).

In the beginning: 

restart; 
# and so on

Here is another solution. Perhaps for a not very experienced user it will be clearer:

F:=proc(M::Matrix,N::Matrix,a::nonnegint)
local m1, m2, n1, n2, k, i, j, S;
if not a in convert(M, set) then error cat(a, " is not an element of M") fi;
m1, m2 :=op([1,1],M), op([1,1],N);  # Row dimensions of M and N
n1, n2 :=op([1,2],M), op([1,2],N);  # Column dimensions of M and N
if m1<>m2 or n1<>n2 then error "Matrices M and N should be the same size" fi;
k:=0;
for i from 1 to m1 do
for j from 1 to n1 do
if M[i,j]=a then k:=k+1; S[k]:=N[i,j] fi;
od; od;
convert(S, list);
end proc:


 

First 113 114 115 116 117 118 119 Last Page 115 of 290