dharr

Dr. David Harrington

8837 Reputation

22 Badges

21 years, 121 days
University of Victoria
Professor or university staff
Victoria, British Columbia, Canada

Social Networks and Content at Maplesoft.com

Maple Application Center
I am a retired professor of chemistry at the University of Victoria, BC, Canada. 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

@mehdibaghaee If you use F[3,1] etc in your integrand, then you can't use the variable F to assign the result of the dchange - just change it to FF or something else

@nk2016  You will get the right result if you paste into 1-D Maple (try control-M on the line before you paste), but if you paste into 2-D, the != characters change into "not equal to" and you get a quite different result.

@mehdibaghaee 


 

``

PDEtools:-dchange({x = (1/2)*a*(xi+1), y = (1/2)*b*(eta+1)}, T, [xi, eta], params = [a, b], known = u0)

(1/2)*(int((1/2)*(int((1/2)*I__0*(D[3](u0))((1/2)*a*(xi+1), (1/2)*b*(eta+1), t)^2*b, eta = -1 .. 1))*a, xi = -1 .. 1))

(3)

NULL

NULL

The idea is that if you are solving, say, dy(x)/dx = -k*y(x) with y(0)=1 (y(x) is "unknown") the solution is y(x)=exp(-k*x), and if you change variables x=2*X, then the solution is y(X)=exp(-2*k*X) in which y(X) is a different function than y(x). But if you have a known function like sin(x) then you want sin(x) to change to sin(2*X)
 

Download inttt3.mw

@mehdibaghaee  add known=u0 to get this.

@mehdibaghaee Looks like a bug

Using dchange gives the expected double integral
 

NULL

PDEtools:-dchange({x = (1/2)*a*(xi+1), y = (1/2)*b*(eta+1)}, T, [xi, eta], params = [a, b])

(1/2)*(int((1/2)*(int((1/2)*I__0*(diff(u0(xi, eta, t), t))^2*b, eta = -1 .. 1))*a, xi = -1 .. 1))

(3)

``

``


 

Download inttt2.mw

aside from the main issue raised by @rlopez your loop should be "from 0 to 99" not "by 0 to 99"

@umar khan  

fsolve(y, x = 0 .. 2e6);

works for me.

@leslieglasser Still not clear what the possible inputs are. If it is a monic polynomial and the other coefficents are the variables (as in your example), then the following works:


 

restart;with(LinearAlgebra):

n:=4;
p:=w^n+add(a[i]*w^i,i=0..n-1);

4

 

w^4+w^3*a[3]+w^2*a[2]+w*a[1]+a[0]

(1)

M1:=<seq(a[n-i],i=1..n)>:M2:=<seq(w^(n-i),i=0..n)>^(%T):

M:=<<M1|DiagonalMatrix([-1$n])>,M2>;
Determinant(M);

M := Matrix(5, 5, {(1, 1) = a[3], (1, 2) = -1, (1, 3) = 0, (1, 4) = 0, (1, 5) = 0, (2, 1) = a[2], (2, 2) = 0, (2, 3) = -1, (2, 4) = 0, (2, 5) = 0, (3, 1) = a[1], (3, 2) = 0, (3, 3) = 0, (3, 4) = -1, (3, 5) = 0, (4, 1) = a[0], (4, 2) = 0, (4, 3) = 0, (4, 4) = 0, (4, 5) = -1, (5, 1) = w^4, (5, 2) = w^3, (5, 3) = w^2, (5, 4) = w, (5, 5) = 1})

 

w^4+w^3*a[3]+w^2*a[2]+w*a[1]+a[0]

(2)

 

I don't have any suggestions for more complicated cases.
 

Download Companion3.mw

@leslieglasser  Well you can make a 3x3 one by bordering the 2x2 one with zeroes except for one in the 1,1 entry. But I'm guessing that isn't what you want. Can you be more specifc about your exact requirements? - I don't know what separated variables mean or nomograph in this context.

int(Heaviside(1-x^2-y^2), [x=0..1,y=0..1]); #should be Pi/4

gives -Pi/4

(I thought using even symmetry might help, but it went negative.)

@dharr If you set x=Pi/2 rather than solving for it, then you get the a, b, c values that you want.

ab should be a*b, but if I've interpreted your equation correctly, then odetest suggests that your solution is not correct.

diff(psi(x), x, x)-((b^2-a*(2*p+3))*x^2+2*a*b*x^4+a^2*x^6-energy)*psi(x) = 0;
schro := eval(%,energy=(2*p+1)*b);
odetest(psi(x)=(x^p)*exp((-a*(x^4))/4)-(b*(x^2)/2),schro);

does not return zero, meaning it is not a solution. Using dsolve gives something with Heun functions, but you probably need to check you have the right equation first.

@sunit I'm not entirely sure what you mean. You could certainly write a procedure that tested whether there were minus signs to its argument and adjusted things before passing to sin. But covering all the unexpected cases (the above one was certainly unexpected for me; I just mistakenly typed Phi instead of phi) is probably going to take more effort than it is worth. As I noted, Maple isn't human, and often outputs things in forms that are unexpected (but mathematically correct)

restart;

q1:=sin(omega*(T0-T)+Phi);

sin(omega*(T0-T)+Phi)

(1)

map(expand,q1);

sin(-T*omega+T0*omega+Phi)

(2)

q2:=sin(omega*(T0-T)+phi);

-sin(-omega*(T0-T)-phi)

(3)

Notice the Maple has changed rearranged to have a minus before the sin.

map(expand,q2);

-sin(omega*T)*cos(omega*T0)*cos(phi)+sin(omega*T)*sin(omega*T0)*sin(phi)+cos(omega*T)*sin(omega*T0)*cos(phi)+cos(omega*T)*cos(omega*T0)*sin(phi)

(4)

map applies expand to each operand. For q1, the only operand is the argument to sin, but Maple considers q2 as a product of two operands, the -1 and the sin, so it expands both

whattype(q1);op(q1);

function

 

omega*(T0-T)+Phi

(5)

whattype(q2);op(q2);

`*`

 

-1, sin(-omega*(T0-T)-phi)

(6)

To get what you want requires you to operate the expand on the (first) operand of the second operand, which can be done as follows

applyop(expand,[2,1],q2);

-sin(T*omega-T0*omega-phi)

(7)

But this is a rather complicated solution, which requires attention in individual cases. Of course you could just stick with Phi. In general, getting Maple to rearrange things into the exact form you want is difficult. Depending on your ultimate objective, it may not be worth it. But perhaps others have a simpler solution.

 


Download expand2.mw

@sunit 

 

I misread the correct answer at line (13) followed by the comment "The results are worse than single iteration using jacobian" to mean that you didn't think the default solver was working. I see you have now clarified that with an edit.

As for correctly coding lsode I don't have much comment; I have tried to move away low level coding.

First 87 88 89 90 91 92 93 Page 89 of 95