nm

11458 Reputation

20 Badges

13 years, 77 days

MaplePrimes Activity


These are answers submitted by nm

b:=(X__2-I__22)/((x__1-I__11)*(X__2-I__22)-I__12*I__21);

You have a typo there. It should be X__1 and not lower case x__1 

simplify(a) almost gets there:

But to get to exactly b, which is 

I do not know, (could not find direct way, but may be there is). other than looking at it, and do the following

restart;
a:=-(I__22-X__2)/(I__11*I__22-I__11*X__2-I__12*I__21-I__22*X__1+X__1*X__2);
a:=simplify(a);
term:=X__1 - I__11;
algsubs(term=A,a);
collect(%,A):
subs(A=term,%);

Getting CAS to give the same exact form one wants, is one of the hardest things. sometimes CAS has it own way of formating expressions.   So some manual steps would be needed.

 

 

You could check the difference is zero between each corresponding elements?

V1 := Vector[column](8, [1, 2, 2, 1, 3, A, B, 1/(A + B)^2]);
V2 := Vector[column](8, [1, 2, 2, 1, 3, A, B, 1/(A^2 + 2*A*B + B^2)]);
ArrayTools:-IsZero(simplify(V1-V2))

      true

 

I generate everything from Maple using Latex.  CAS systems (either Maple or Mathematica) can't compete with Latex when it comes to formating output. 

ps. I get different numbers for f(x,t) and g(x,t). May be you used different definition than you showed

Running this Maple code below and pasting the output into your Latex editor and compiling will generate the above table.
 

restart;

f:=(x,t)->x*t:
g:=(x,t)->x^2*t:
toX:=s->Latex(s,output=string):
val:=[seq(i,i=0.125..0.875,0.25)]:
s:="":
s:=cat(s,"\\documentclass{article}
\\usepackage{multirow}
\\renewcommand{\\arraystretch}{1.2}
\\usepackage{color, colortbl}
\\definecolor{Gray}{gray}{0.9}
\\begin{document}
\\begin{table}[hbt!]
\\begin{center}
\\begin{tabular}{|c|c|c|c|}\\hline
\\rowcolor{Gray}$x$ & $t$ & $f(x,t)$ & $g(x,t)$\\\\ \\hline\\hline \n"):
for x in val do
    for N,t in val do
        if N=1 then
            s:=cat(s,"\\multirow{4}{*}{$",toX(x),"$}&");
        else
            s:=cat(s,"&");
        fi;
        s:=cat(s,"$",toX(t),"$&$",toX(f(x,t)),"$&$",toX(g(x,t)),"$\\\\ "):
        if N=numelems(val) then
           s:=cat(s,"\\hline \n");
        fi:
    od:
od:
s:=cat(s,"\\end{tabular}
\\end{center}
\\end{table}
\\end{document}"):

printf("%s",s)

\documentclass{article}
\usepackage{multirow}
\renewcommand{\arraystretch}{1.2}
\usepackage{color, colortbl}
\definecolor{Gray}{gray}{0.9}
\begin{document}
\begin{table}[hbt!]
\begin{center}
\begin{tabular}{|c|c|c|c|}\hline
\rowcolor{Gray}$x$ & $t$ & $f(x,t)$ & $g(x,t)$\\ \hline\hline
\multirow{4}{*}{$ 0.125$}&$ 0.125$&$ 0.015625$&$ 0.001953125$\\ &$ 0.375$&$ 0.046875$&$ 0.005859375$\\ &$ 0.625$&$ 0.078125$&$ 0.009765625$\\ &$ 0.875$&$ 0.109375$&$ 0.013671875$\\ \hline
\multirow{4}{*}{$ 0.375$}&$ 0.125$&$ 0.046875$&$ 0.017578125$\\ &$ 0.375$&$ 0.140625$&$ 0.052734375$\\ &$ 0.625$&$ 0.234375$&$ 0.087890625$\\ &$ 0.875$&$ 0.328125$&$ 0.123046875$\\ \hline
\multirow{4}{*}{$ 0.625$}&$ 0.125$&$ 0.078125$&$ 0.048828125$\\ &$ 0.375$&$ 0.234375$&$ 0.146484375$\\ &$ 0.625$&$ 0.390625$&$ 0.244140625$\\ &$ 0.875$&$ 0.546875$&$ 0.341796875$\\ \hline
\multirow{4}{*}{$ 0.875$}&$ 0.125$&$ 0.109375$&$ 0.095703125$\\ &$ 0.375$&$ 0.328125$&$ 0.287109375$\\ &$ 0.625$&$ 0.546875$&$ 0.478515625$\\ &$ 0.875$&$ 0.765625$&$ 0.669921875$\\ \hline
\end{tabular}
\end{center}
\end{table}
\end{document}

#copy paste the above using the mouse to your Latex editor and compile it.


 

Download make_table.mw

one possibility

restart;
F:=x*y^2-x;
G:=x*sin(Pi*x);
solve([F,G],[x,y]);

_EnvAllSolutions:=true;
solve([F,G],[x,y])

or

restart;
F:=x*y^2-x;
G:=x*sin(Pi*x);
solve([F,G],[x,y],allsolutions=true);

I would not do this. This is the wrong way to program.  

restart;
sol:=solve(x^2+3*x+4=0,x);
assign(('A','B')=sol):
         

A better way is to just assign all the solutions to one variable. A list. Then use indexing to access each solution.

The less variables there are, the more control on your code you have., You do not want a function with 100 variables in it.

The above assumes there are 2 solutions ofcourse. In code, if you want to do this in a more robust way, you'd need to first find the number of solutions, then come up with, at run-time, variable names on the fly, and do the above, so they match.

For example:

Assign solution to list and access sol using [] indexing or iteration

restart;
sol:=[solve(x^2+3*x+4=0,x)];
for N,item in sol do
    print("solution ",N," is ",item);
od;

#or
sol[1];  

sol[2];  #etc..

 

or

restart;
sol:=[solve(x^2+3*x+4=0,x)];
for i from 1 to numelems(sol) do
    print(sol[i]);
od;

Only one variable is needed. sol to store all solutions. No need to come up with other variable names.

I found the problem. I did not look too close before.

To get the arrows, you need to have coupling between the two ODE's. Before you had 

    OnDE:=diff(On(t),t)=(rhs(solEr))/500*60-On(t)/1500*60;

where you replaced the actual Er(t) above. This removed the coupling between the two ODE's.

Instead, you need to just write Er(t) in the second ODE, and Maple will figure it out.  Now Maple see the two ODE's make a system.

If you do not have coupling, then these were 2 separate ODE's and that is why the arrows were missing.

 

restart;
ErDE:=diff(Er(t),t)=30-Er(t)/500*60;
OnDE:=diff(On(t),t)=Er(t)/500*60-On(t)/1500*60; 
initvals := [[Er(0)=0,On(0)=0], [Er(0)=500,On(0)=0],[Er(0)=500,On(0)=1500]];
DEtools:-DEplot( {ErDE,OnDE} , {Er(t),On(t)}, t=0..150, initvals, numpoints=100, linecolour=[blue,red,yellow]); 

 

 

if I understand right, see if this works for you. To make it go by 1,3,5,7,... just add "2" after, so it jump by 2 each time, starting from 1.

 

restart;
h:=x->sin(x)/x;
A:=n->Int(mul(h(x/a),a=1..2*n+1,2),x=0..infinity);

A(2);
A(3);
A(4);

You can add value() to evaluate the integral at end.

in numerical integration, you can't have parameter with no numerical value in the integrand. (how is Maple going to find numerical value if a has no value?)

Assign a some value before calling int, then it will work

a:=.4;
f := (x, y) ->(1/2)*a*(sinh(y-x^2)+tanh(x-y^3)); 
sol := evalf(int(int(f(x, y), x = -6 .. 5), y = -5 .. 5));

or

restart;

Explore( 
   evalf(int(int((1/2)*a*(sinh(y-x^2)+tanh(x-y^3)), x = -6 .. 5), y = -5 .. 5)),
   a=1..10,initialvalues=[a=1],size=[800,60]
);

You can also use Explore, and change the raduis using the slider with the mouse.

 

restart;
Explore(plots:-display( plottools:-sphere([0,0,0],r),view=[-3 .. 3,-3..3,-3..3]),
        r=0.1..3.0,initialvalues=[r=0.5]):

always use exact numbers, unless there is a reason not to

a := 12/100;
kn := n -> (n + 1/2)*Pi/a;
g := (n, x) -> cos(kn(n)*x);
g(1, a);

   0

It makes it easier if you replace  by say A before.

restart;	
s1 := Ls*cos(omega*t + phi__l + theta)*omega + sin(omega*t + phi__l + theta)*Rs;
s2 := sqrt((omega*Ls)^2+Rs^2)*sin(omega*t + phi__l + theta + arctan(omega*Ls/Rs));
s1:=subs(omega*t + phi__l + theta=A,s1):
s2:=algsubs(omega*t + phi__l + theta=A,s2):	

And now

s2:=simplify(expand(s2)) assuming positive:
evalb(s2=s1)

                true

You can also replace the above by

s2:=simplify(expand(s2),symbolic);
evalb(s2=s1)

            true

another option, if you want to do it more manualy

restart;
roll_col_1:=rand(10..20):
roll_col_2:=rand(50..100):
col_1:= Vector([seq(roll_col_1(),i=1..6)]);
col_2:= Vector([seq(roll_col_2(),i=1..6)]);
A:=<col_1|col_2>

You need to be careful which convention to use for spherical coordinates. There is the Physics one and there is the mathematics one. See https://en.wikipedia.org/wiki/Spherical_coordinate_system

Using the Physics one (more common)

evalf(int(int(int(ln(r^2 + theta^2 + phi^2 +1),r=0..2),theta=-Pi/2..Pi/2),phi=0..2*Pi))

97.2256142300

Using the math convention for the angles

evalf(int(int(int(ln(r^2 + theta^2 + phi^2 +1),r=0..2),theta=0..2*Pi),phi=-Pi/2..Pi/2))

97.2256142300

if you use 0..Pi instead of -Pi/2..Pi/2 you get

evalf(int(int(int(ln(r^2 + theta^2 + phi^2 +1),r=0..2),theta=0..2*Pi),phi=0..Pi))

105.5237634000

Not sure which convention you want. Wikepida page above describes these more.

ps. only numerical integration worked in Maple. 

 

 

restart;
ode:=diff(y(x),x)+k*piecewise(y(x)>=0,y(x),y(x)<0,0) =sin(x);
dsolve(ode)

Can't solve it analytically. You can solve this nuemrically only

 

restart;
k:=1;
ode:=diff(y(x),x)+k*piecewise(y(x)>=0,y(x),y(x)<0,0) =sin(x);
sol:=dsolve([ode,y(0)=1],numeric)

Maple used to have many of these cases, but it got better over years handling them.

A trick to bypass this issue, is to delay the substitution of the actual function until after you obtained the series solution. As follows.

Using a generic f(x,y) first, then this function is replaced by the actual value of the function after the series solution is obtained. This makes life much easier for Maple pdsolve.
 

 

restart;

interface(version);

`Standard Worksheet Interface, Maple 2020.1, Windows 10, July 30 2020 Build ID 1482634`

pde := diff(u(x,y,t),t,t) = diff(u(x,y,t),x,x) + diff(u(x,y,t),y,y);
bc := u(x,0,t)=0, u(x,1,t)=0, u(0,y,t)=0, u(1,y,t)=0;
ic := u(x,y,0) =f(x,y),  D[3](u)(x,y,0)=0;
sol := pdsolve({pde, bc, ic});
my_actual_function :=x*y*sin(Pi*x)*sin(Pi*y);
sol:=eval(sol, [infinity=4,f(x,y)=my_actual_function]);

diff(diff(u(x, y, t), t), t) = diff(diff(u(x, y, t), x), x)+diff(diff(u(x, y, t), y), y)

u(x, 0, t) = 0, u(x, 1, t) = 0, u(0, y, t) = 0, u(1, y, t) = 0

u(x, y, 0) = f(x, y), (D[3](u))(x, y, 0) = 0

u(x, y, t) = Sum(Sum(4*sin(n*Pi*x)*sin(n1*Pi*y)*cos(Pi*(n^2+n1^2)^(1/2)*t)*(Int(sin(n1*Pi*y)*(Int(sin(n*Pi*x)*f(x, y), x = 0 .. 1, AllSolutions)), y = 0 .. 1, AllSolutions)), n = 1 .. infinity), n1 = 1 .. infinity)

x*y*sin(Pi*x)*sin(Pi*y)

u(x, y, t) = Sum(Sum(4*sin(n*Pi*x)*sin(n1*Pi*y)*cos(Pi*(n^2+n1^2)^(1/2)*t)*(Int(sin(n1*Pi*y)*(Int(sin(n*Pi*x)*x*y*sin(Pi*x)*sin(Pi*y), x = 0 .. 1, AllSolutions)), y = 0 .. 1, AllSolutions)), n = 1 .. 4), n1 = 1 .. 4)

#now it works        
value(sol)

u(x, y, t) = (1/900)*(225*Pi^2*sin(Pi*x)*sin(Pi*y)*cos(Pi*2^(1/2)*t)-1600*sin(Pi*y)*cos(5^(1/2)*Pi*t)*sin(Pi*x)*cos(Pi*x)-512*sin(Pi*y)*cos(17^(1/2)*Pi*t)*sin(Pi*x)*cos(Pi*x)^3+256*sin(Pi*y)*cos(17^(1/2)*Pi*t)*sin(Pi*x)*cos(Pi*x))/Pi^2-(8/9)*sin(Pi*x)*sin(2*Pi*y)*cos(5^(1/2)*Pi*t)/Pi^2+(256/81)*sin(2*Pi*x)*sin(2*Pi*y)*cos(Pi*8^(1/2)*t)/Pi^4+(512/2025)*sin(4*Pi*x)*sin(2*Pi*y)*cos(Pi*20^(1/2)*t)/Pi^4-(16/225)*sin(Pi*x)*sin(4*Pi*y)*cos(17^(1/2)*Pi*t)/Pi^2+(512/2025)*sin(2*Pi*x)*sin(4*Pi*y)*cos(Pi*20^(1/2)*t)/Pi^4+(1024/50625)*sin(4*Pi*x)*sin(4*Pi*y)*cos(Pi*32^(1/2)*t)/Pi^4

 


 

Download pdsolve.mw

First 10 11 12 13 14 15 16 Last Page 12 of 20