Dr. David Harrington

5535 Reputation

21 Badges

19 years, 181 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

I am a professor of chemistry at the University of Victoria, BC, Canada, where my research areas are electrochemistry and surface science. I have been a user of Maple since about 1990.

MaplePrimes Activity

These are replies submitted by dharr

@MDD The combination of sin(x) and -sin(x) is simplified to zero as part of Maple's automatic simplification. This cannot be prevented unless you write the ode in an inert form and explicitly handle the inertness, which I would not recommend. This simplification is mathematically correct, so presumably what you want.

You could process individual terms into two lists, of coefficients and non-coefficients. This would not use dcoeffs, which has an explicit order and discards information. In other words, you would have to write your own version of dcoeffs. At the moment, your result is not mathematically unique, since b*x^3 + sin(x) gives a different result from sin(x)+b*x^3. Likewise  bacause of the use of expand, sin(x+a) will give sin(a)+cos(a) but perhaps you want sin(x+a). If you don't use expand, then then a*(x-1) and a*x-a are treated differently, which again is not mathematically unique.

So if you want a mathematically unique answer, you need to specify what you want more precisely. If you are interested in the coefficients "as written" then that would be done in a different way, but then you need to think about what you mean by a coefficient, e.g. in ... + (b+x)*diff(y(x),x)+ you presumbly want 1?

@MDD It is not possible to go back. For the non-derivative terms the information about the function of x has been discarded. Even for the derivative terms, they could be squared or other powers and still have the same coefficient. 

@MDD I think this covers all the cases. Only x is treated as a variable in the non-derivative terms. Note that e*(x-1) gives two terms because it is the same as e*x-e.


ode := diff(y(x), x, x, x) = (c-1)*(diff(y(x), x, x))-2*a*(diff(y(x), x))+b*x^3+sin(x)-a*c

diff(diff(diff(y(x), x), x), x) = (c-1)*(diff(diff(y(x), x), x))-2*a*(diff(y(x), x))+b*x^3+sin(x)-a*c

  local ode1,cfs,lastterms,withx,withoutx,vars,xvar,i,dummy,zz;
  if type(ode,`=`) then ode1:=rhs(ode) - lhs(ode) else ode1:=ode end if;
  cfs := [PDEtools:-dcoeffs(ode1,fn)];
  lastterms := [op(expand(cfs[-1] + dummy))];
  withx, withoutx := selectremove(has, lastterms, xvar);
  withx:=map(zz->if type(zz,`*`) then remove(has,zz,xvar) else 1 end if, withx);
  cfs := [cfs[1 .. -2][], withx[]];
  vars := [seq(cat(A, i), i = 1 .. nops(cfs))];
  add(cfs[i]*vars[i], i = 1 .. nops(cfs)) + subs(dummy = 0, add(i,i in withoutx));
end proc:NULL

ode_to_poly(ode, y(x))



Download dcoeffs4.mw

@dharr works at least for your last example


@MDD So I had to guess at what you wanted for the part that doesn't contain y(x).

What do you want for a*sin(x)+b*x+c? (a*sin(x)+b*x)*A4+c or a*sin(x)*A4+b*x*A5 +c? Is the function of x always a polynomial?

@MDD Oops, I uploaded the wrong file. dcoeffs2 above should work.

@MDD Sorry, this should work in your version of Maple.



sol := {solve(HurwitzConditions,useassumptions)}:



`Standard Worksheet Interface, Maple 2022.2, Windows 10, October 23 2022 Build ID 1657361`

expr := x^4-10*x^2+1




Download ploterror.mw

@delvin For the 4th time - you need a modulus! I chose l=1, but you might need some other value or maybe just symbolic.  I put sum back to add as I told you originally.

Eq1 is now found without errors. simplification is slow and I didn't wait. Of course in the next step you can't solve one equation for 13 variables. I've fixed the Maple, but it is up to you to take it to the next step.


@delvin You did not upload your revised version - just insert the link

@delvin JacobiDN (Not Jacoby). You need a modulus.

@delvin As I said before, jacobi has to be changed to Jacobi, and these functions need a modulus as second argument (I don't know what that would be for your application.)

I haven't given much thought to your main question. But you spend a lot of calculation time figuring out the arcs of circles, especially start and end angles. If you just plot full circles and hide the bits outside the unit circle, then this can be done faster. (Though if you want to ultimately color in the regions, I'm not certain this is a good approach.)


@MaPal93 I gave some more thought to the structure of the betas in terms of the lambdas, and found some interesting things. In the expression for lambda__1:

there are no lambda__1's except in the determinant of Q. So if one could prove the numerator was always positive (the demoninator is positive), then the system seems internally consistent - any positive lambda__2 and lambda__3 would make the expression positive and then lambda__1 would be positive. Yet no positive solution can be found for all three equations.

For the calibration system, the signs of betas are as required, and the numerator is positive for positive lambdas.

Thanks for the best answer.


5 6 7 8 9 10 11 Last Page 7 of 56