nm

11353 Reputation

20 Badges

13 years, 13 days

MaplePrimes Activity


These are replies submitted by nm

there is syntax error  

Error, `)` unexpected
 

 

@ecterrab 

Thank you for ConstantFirst. But it does not work exactly the way I wanted it for all examples. Here is one case

restart;

macro(_C = suffixed(_C, posint));

ConstantsFirst := u -> subsindets(subsindets(u, `*`, p -> `*`(op(map(op, [selectremove(type, subsindets([op(p)], _C, convert, `local`), _C)])))), _C, w -> c__||(substring(w, 3..-1))):

sol:=dsolve(diff(y(x),x) = x+y(x),y(x));

ConstantsFirst(sol);

What I want is otuput of  sort(sol)  but with _C1 replaced by c[1]. i.e. all terms with _Cn to appear at front with _Cn in front also of each term. Like this

restart;
sol:=dsolve(diff(y(x),x) = x+y(x),y(x));
sort(sol);

The above is what I want, but looking _C1 replaced by c__1 or c[1], like this

The original solution by vv posted in https://www.mapleprimes.com/questions/231221-How-To-Make-Sort-Work-With-Alias#comment275751  works on this and now thanks to your fix for latest Latex, the Latex no do not drop the constant

restart;
assign(seq(`print/_C`||k, k=0..10) = seq(c[k], k=0..10)):
S:=[seq(_C||k = _C||k(), k=0..10)]:

sol:=dsolve(diff(y(x),x) = x+y(x),y(x));
sol:=subs(S, sort(sol));

Also the new version by vv below at https://www.mapleprimes.com/questions/231230-Why-Latex-Removes-Constant-From-Expression#comment275790  works on this

restart;

Cc:=proc(u)
  local c, Cc1 := C -> c[parse(convert(C,string)[3..])];
  subsindets(u, `*`,
    proc(u)
      local k,r;
      k,r:=selectremove(type, [op(u)], suffixed(_C,integer));
      if nops(k)<>1 then return u fi;
      `*`(Cc1(k[]),r[])
    end):
  subsindets(%, suffixed(_C,integer), Cc1)
end:

sol:= dsolve(diff(y(x),x) = x+y(x),y(x));
Cc(sort(sol));  #note, must call sort first

I am still testing all the other solutions posted so far to see if they work for all the cases I have. 

thanks to everyone for the help. This is not an easy problem. May be Maple eventially will have a build-in support for such feature.  It helps with the Latex final formating to make it look better.

 

@ecterrab 

By the way: what you tried to achieve is achievable directly using alias

Thank you. I know about alias. I was using it for a while. But alias does not work for what I want. That is why I  was using VV solution.

The issue is this: I want the constant of integration to be on front of terms. As it looks better. Instead of at the end.  Sometimes Maple shows it at end.

So need to use sort() but sort does not work when using alias. Here is an example

restart;
alias(seq(c[k]=_C||k,k=0..10)):
sol:=dsolve(diff(y(x),x) = x+y(x),y(x));

Now if I do sort() on the above, before calling Latex, sort does not work

sort(sol)

If I had not used alias, it would have worked

restart;
sol:=dsolve(diff(y(x),x) = x+y(x),y(x));
sort(sol);

That is why I no longer use alias. 

@tomleslie 

Thanks. I was using the solution code from the reference post I had at the top.

I will go now and try your method on my large file. So far, it looks good and Latex is not dropping the initial constant any more.

Still, I think Latex should not have dropped the constant, even if the user code being used might not be optimal. So there is an issue there.  

It will take a little bit time to test this so I am sure it works for all cases.

 

@vv 

I've tested it more, and it looks good so far.

btw, you forgot the actual sort command in your new method (so it now works for all cases and not this example)

assign(seq(`print/_C`||k, k=0..10) = seq(c[k], k=0..10)):
S:=[seq(_C||k = _C||k(), k=0..10)]:

sol:=dsolve(t^2*diff(diff(y(t),t),t)-t*diff(y(t),t)+5*y(t) = 0,y(t)):
subs(S, sort(sol));

Thanks.

@Carl Love 

I think there is something else. not just bad luck. but I had no problem uploading and displaying the content for a while  now. 

But now I can't upload and display content any more even using same worksheet which worked few days ago.

I assume there is someone at Maplesoft who maintains this site (This site belongs to Maplesoft I assume). If there an email to report mapleprimes problems, if so, that will be a good starting place. They should know the cause hopefully.

 

@ecterrab 

great information all in one place. thank you.

Is there a technical reason why  it translates sin(x)^2 to   \sin^{2}x   but inverse trig remain the same under mixed?  ie.  arcsin(x)^2  does not change to \arcsin^{2}x ? May be you mentioned this before.

It now looks unsymmetric:

restart;
Latex:-Settings(UseImaginaryUnit=i,
      UseColor = false,
      powersoftrigonometricfunctions=  mixed,
      leavespaceafterfunctionname = true,
      cacheresults = false,
      spaceaftersqrt = true  
);
expr:=sin(x)^2+arcsin(x)^2;
Latex(expr)

Compared to

Currently, there is no option for one to obtain the above. I tried all three (mix, computer, textbook).

May be you could consider adding an option or modifying the current mixed one, so as to keep the paranthesis there, even for the case of one argument. i.e. to show this instead

As this could sometimes can be more appealing than removing the () for the one argument case as it does now. (may be mixedkeepparanthesis value?)

ps. if this should be separate question, I can move it.

Thanks.

@vv 

Thanks. Will try your new method on my large file and see if it works for all cases. It will take a day or so to finish building.

 

@vv 

I am afraid this does not work for all cases.  Here is an example

restart;
S:=[seq(_C||k=c[k], k=0..10)]:
sol:=dsolve(t^2*diff(diff(y(t),t),t)-t*diff(y(t),t)+5*y(t) = 0,y(t));
sort(subs(S,sol));  

You see _C1 and _C2 were at the front as given by Maple, which is what I wanted, but when applying the subs, the c[1] and c[2]  now they no longer at the front.

Compare to using alias, where now it just happend that no sort is needed (but this is for this example only), but I am running this in a program, and can't look at screen to decide what to do. So I apply sort all the time.

restart;
alias(seq(c[k]=_C||k,k=0..10)):
sol:=dsolve(t^2*diff(diff(y(t),t),t)-t*diff(y(t),t)+5*y(t) = 0,y(t), singsol=all);

So your method works on some cases, but not for all cases.

I need something that works all the time, to make _C1 and _C2 always at the front, but using c[1] and c[2] instead to make the Latex looks better.

This problem is not as easy as it looks.

Sorry, but I have to keep looking for another solution which works for all cases.

I think it is a problem with the mapleprime server now.

I just now tried to upload same worksheet  I uploaded  in this question https://www.mapleprimes.com/questions/231212-Why-Maple-Refuses-To-Change-Location

And got error. But it worked OK 2-3 days ago.

It seems you just happened to try when the server was having hard time for some reason. I've seen this upload error before also, but not much lately.    But at this moment it is back again.

Someone at Mapleprime IT should look into this.

 

it works for me on 2020.2 on windows.  It could be a version issue since you are not using 2020.2

restart;
Z := n -> op~(2, { allvalues(solve(LegendreP(n,x))) } );
Digits:=10:
Z(17):
numelems(%);
	
Z(18):
numelems(%);

Digits:=15:
Z(18):
numelems(%);

What is the reason please? 

it could be a bug. You could try with latest Maple version and see if this is fixed.

Actually a simpler final result than the one you showed as your desired is

    

@Carl Love 

You are right that the basic version is simple to code, something probably most of us have done before in first year at school.

But Matlab's trapz handles other options and 2D and higher dimensions. It is  about 70 lines long (with 30 of these documenation). Its listing is shown here 

I was not asking how to code one, just was wondering why Maple does not have a similar version a build-in, that takes input as just pure data instead of an actual function as the case now.

Since it is simple to implement, may be Maple should have it in one of its packages to avoid having to invent the wheel each time one needs it.

 

 

 

 

 

@wanderson 

"Do you know some references out of Maple? Articles, books.."

Sorry, I do not understand the question exactly.

May be if you could explain more what is it you are looking for, someone can answer it.  

First 44 45 46 47 48 49 50 Last Page 46 of 91