nm

9779 Reputation

19 Badges

12 years, 65 days

MaplePrimes Activity


These are replies submitted by nm

@acer 

Ah, so the command I using was not the right one as I suspected. googling send me to wrong command!

@Thomas Richard 

 but how often does one need to feed a solution that's not coming from dsolve?

Most if not all the time.

What is the point of using odetest to test Maple's own solution? That is almost always correct. 

Students use odetest to test their own hand solution to verify it is correct or not before giving the HW to the teacher.

And odetest could fail if the solution given to it does not use _C1 and _C2. So one has to use these. I've been using these for years with no problem.

I know about arbitraryconstants but do not see how this has anything to do with this. If I use c__1 and c__2, then these are just aliases to _C1 and _C2.  (and I do not like aliases anyway).

May be _Z is special case. But from user point of view, I see nothing wrong with using system level reserved symbols as just symbols as long as they are not assigned any values.

Anyway, I will not use _Z any more, and change it to my own letter for now for the upper limit of the integration. It is not a big deal. I just found it a little strange that one can't even type the letter _Z in the equation they make, that is all.

@Thomas Richard 

But I use for example _C1 and _C2 everywhere in my code.  Are you saying I am not supposed to do that? I use them as symbols. Do not assign any values to them.

If I do not use _C1,_C2 in setting up my own solution, then odetest will not be happy as it expects the constants of integrations to be of this form.

Same fo _Z. I do not assign any values to it, I just use it as symbol in my integration upper limit to match Maple's.

For me a reserved symbol means one can't assign a value to it. But this does not mean one also can't even use it as symbol in the equations they generate? 

@Thomas Richard 

Ok, thanks. But I was looking at help and when I searched combine terms and it says at the top

The combine function applies transformations which combine terms in sums, products, and powers into a single term

Isn't that what I was trying to do? I have sum of two terms.

I would think any user looking to combine terms into one will hit this help page before the normal command, just from the name of the command itself if nothing else.

The help page should really direct the user when to use combine then or when to use normal

Here is my google search for how to combine terms in Maple. Even ChatGPT told me to use the combine command !

@ecterrab 

Thanks for the quick fix.

@janhardo 

I don't understand this, but it works 

You do not have to use evalindents if you do not know it. You could use pattern matching. Here is version which uses patmatch which gives same result.
 

 

 

restart;

 

# Definieer de parameters
L := Pi:

# Stel de golfvergelijking op
pde := diff(u(x,t),t,t) = c^2 * diff(u(x,t),x,x):

# Definieer de randvoorwaarden
bc := u(0,t) = 0, u(L,t) = 0:

# Definieer de beginvoorwaarden
ic := u(x,0) = f(x), D[2](u)(x,0) = g(x):

# Los de PDE op met begin- en randvoorwaarden
sol := pdsolve([pde, bc, ic], u(x,t));

u(x, t) = Sum(2*sin(n*x)*((Int(sin(n*x)*f(x), x = 0 .. Pi))*cos(c*n*t)*n*c+(Int(sin(n*x)*g(x), x = 0 .. Pi))*sin(c*n*t))/(Pi*n*c), n = 1 .. infinity)

#new_sol
RHS:=rhs(sol);
a:='a':the_body:='the_body':the_index:='the_index':
if patmatch(RHS,a::anything*Sum(the_body::anything,the_index::anything),'la') then  
   assign(la);   
   RHS:=a*Sum(expand(the_body),the_index):
fi:
new_sol:=lhs(sol)=RHS;

 

Sum(2*sin(n*x)*((Int(sin(n*x)*f(x), x = 0 .. Pi))*cos(c*n*t)*n*c+(Int(sin(n*x)*g(x), x = 0 .. Pi))*sin(c*n*t))/(Pi*n*c), n = 1 .. infinity)

u(x, t) = Sum(2*sin(n*x)*(Int(sin(n*x)*f(x), x = 0 .. Pi))*cos(c*n*t)/Pi+2*sin(n*x)*(Int(sin(n*x)*g(x), x = 0 .. Pi))*sin(c*n*t)/(Pi*n*c), n = 1 .. infinity)

 


 

Download not_same_V3.mw

 

@janhardo 

Your updated book solution does not seem to be correct either. If you look at Maple's solution, you see there is  an extra sin(n*x) outside everything which you do not have. 

Any way, to make it look similar to what I think you want, simply expand the body of the sum itself. One possible way to do this is like this
 

 

 

restart;

 

# Definieer de parameters
L := Pi:

# Stel de golfvergelijking op
pde := diff(u(x,t),t,t) = c^2 * diff(u(x,t),x,x):

# Definieer de randvoorwaarden
bc := u(0,t) = 0, u(L,t) = 0:

# Definieer de beginvoorwaarden
ic := u(x,0) = f(x), D[2](u)(x,0) = g(x):

# Los de PDE op met begin- en randvoorwaarden
sol := pdsolve([pde, bc, ic], u(x,t)):

# Toon de oplossing
simplify(sol);

u(x, t) = 2*(Sum(sin(n*x)*((Int(sin(n*x)*f(x), x = 0 .. Pi))*cos(c*n*t)*c*n+(Int(sin(n*x)*g(x), x = 0 .. Pi))*sin(c*n*t))/(n*c), n = 1 .. infinity))/Pi

#new_sol
new_sol:=lhs(sol)=evalindets(rhs(sol),'specfunc(anything,Sum)',X->Sum(expand(op(1,X)),op(2,X)));

 

u(x, t) = Sum(2*sin(n*x)*(Int(sin(n*x)*f(x), x = 0 .. Pi))*cos(c*n*t)/Pi+2*sin(n*x)*(Int(sin(n*x)*g(x), x = 0 .. Pi))*sin(c*n*t)/(Pi*n*c), n = 1 .. infinity)

 


 

Download not_same_V2.mw

 

@C_R 

 I use them allot in techincal documentation.

Equations labels are great for documenation. I use them all the time, in Latex. 

In actual, code they make no sense, as one can no longer copy/paste code and use it, as it has all these hardcoded label numbers in the code. 

How will one run code that says  convert((13), diff); copied from help page in order to try it in their own worksheet? It makes code in help page read-only.

Code in help pages should be such that it can be copied and used to try it. equation labels get in the way of doing this.

For final reports, meant for presentation only and publication, sure. equation labels are great and I use them all the time.

But I do not think they make sense for use in help pages meant to be a page that a user can copy any command from it and try them.

Btw, there is a big difference between saying something like

         see equation (13) for .....

and between writing

        eval( (13) , x=0 )   

where now (13) is a equation number.

The first case is fine and should be used in help to refere to something,. I am talking about the second one above, where the actual equation number is embeded inside the Maple code itself.

 

@acer 

wow, that was it. 

Yes, I had turned off the  "show equation labels" in the Tools->Options->Display

This is one of the first things I do when I install Maple, as I hate these and do not like them and do not use them at all. To refer to something, I assign it to a variable. I do not need equation labels.

I had no idea that turning off the equation lables messes up the help pages now.

After turning them on, now all input in help page shows as 1D with equation numbers in them instead of 2D math,

But still, can't copy any individual command shown. As the command now itself has equation label embeded in it.

Here is an example from same page ?D

When copying the above command (the convert command) to my worksheet, it shows as

           convert(??, diff);
 

In the worksheet. So if I wanted to run these two commands in my worksheet, I can't.

Better way to do help pages is to use normal variables. This way it is not hardcoded like this. So the above example would be this

e:=D(f)(0);
convert(e, diff);

Now one can copy each command and evaluate them in their own worksheet since there is no hardcoded label references that are only valid in the help page and not outside the help page.

I know assigning results to variables is very old fashioned and not the modern cool fashion like using equation labels, but it works everywhere and all the time and this is how Maple was in the good old days.

@C_R 

does the help pages itself on your Maple shows some input as 2D and some as 1D and some mixed?

It does for me. I am on windows, may be if you are not, this is why.

I can't copy anything to mywork sheet from the help page when the input in the help page in in 2D.

Here is small movie. (right click on it and open in new tab to see large)  You see how it is all mixed up. I use interface extended if this makes any difference, 

Windows 10.