rahinui

105 Reputation

6 Badges

2 years, 215 days

MaplePrimes Activity


These are replies submitted by rahinui

Thanks for the response! I have a procedure that generates something along the lines of

f(t1,t2) = a*cos(g(t1,t2)):

where g(t1,t2) is an unknown function. I'm then trying to evaluate a derivative such as D[2](f) like so:

f = unapply(a*cos(g(t1,t2)),t1,t2);
eval(D[2](f)(t1,t2), {%});

This code works just fine if I leave a arbitrary (or set it to a number other than 1); but if I set a:=1 before unapplying, I receive the error

Error, (in D[2]) index out of range: cos takes only 1 argument(s)

As a work-around for this particular example, I could use convert/diff and then eval without using unapply. However, in my actual code, I was having trouble consistently converting between D and diff, so I found unapplying to be more robust.

@MapleMathMatt Awesome, thank you very much for your help!

@acer Wonderful, that's exactly what I needed. Thanks a lot!

@Preben Alsholm Very true, though in this case I used dsolve just for consistency between the two cases (and, as you pointed out, it doesn't help here). Thanks for the advice though!

@Kitonum Thanks for your help. I still find it strange that Maple is able to handle the ODEs properly when they're univariate but isn't able to do so in the multivariate case. But I suppose that can't be helped.

Thanks!

@vv Great, thanks a lot for your help!

@ecterrab Thank you very much for fixing this! That's a major help and I appreciate the assistance!

@tomleslie Thank you very much for all your help; I really your work troubleshooting this. And you offered a lot of helpful advice as well!


Thanks for the general guidelines; they should definitely prove helpful. I really appreciate your assistance. As you point out, it probably would have been better for me to post the full code at the start.

My code is solving a nonlinear PDE using a perturbation technique. At each order, I generate a set of equations that must all be satisfied. This was working fine for a few loops of the program; for instance I generated the following set of equations, and pdsolve was able to handle it perfectly:

restart:

# Does work
eqs := {2*`A__3,2`(t__1,t__2,t__3) = 0, 6*`A__3,3`(t__1,t__2,t__3) = 0, 2*`B__3,2`(t__1,t__2,t__3) = 0, 6*`B__3,3`(t__1,t__2,t__3) = 0, -2*diff(_F3(t__2,t__3),t__2) = 0, -_F3(t__2,t__3)^3+2*_F3(t__2,t__3)*diff(_F2(t__2,t__3),t__2) = 0, diff(theta(t__0,t__1,t__2,t__3,x),t__0) = 1, diff(theta(t__0,t__1,t__2,t__3,x),t__1) = 0, diff(theta(t__0,t__1,t__2,t__3,x),t__2) =diff(_F2(t__2,t__3),t__2), diff(theta(t__0,t__1,t__2,t__3,x),t__3) =diff(_F2(t__2,t__3),t__3), diff(theta(t__0,t__1,t__2,t__3,x),x) = -1, diff(theta(t__0,t__1,t__2,t__3,x),x) =-diff(theta(t__0,t__1,t__2,t__3,x),t__0), _F3(t__2,t__3) <> 0, theta(t__0,t__1,t__2,t__3,x) <> 0}:

vars := {`A__3,2`(t__1,t__2,t__3), `A__3,3`(t__1,t__2,t__3), `B__3,2`(t__1,t__2,t__3), `B__3,3`(t__1,t__2,t__3), _F2(t__2,t__3), _F3(t__2,t__3), theta(t__0,t__1,t__2,t__3,x)}:

pdsolve(eqs,vars);

However, this particular loop generates the following set of equations which throws the above mentioned error:

restart:

# Doesn't work
eqs :={-2^(1/2)/_F4(t__3)^(1/2)*diff(_F4(t__3),t__3) = 0, 2*2^(1/2)*_F4(t__3)^(1/2)*(diff(_F4(t__3),t__3)*t__2+diff(_F5(t__3),t__3)) = 0, 6*`A__4,3` (t__1,t__2,t__3) = 0, 12*`A__4,4`(t__1,t__2,t__3) = 0, 2*`B__4,2`(t__1,t__2,t__3) = 0, 6*`B__4,3`(t__1,t__2,t__3) = 0, 12*`B__4,4`(t__1,t__2,t__3) = 0, 4*_F4(t__3)^2+2*`A__4,2`(t__1,t__2,t__3) = 0, diff(theta(t__0,t__1,t__2,t__3,x),t__0) = 1, diff(theta(t__0,t__1,t__2,t__3,x),t__1) = 0, diff(theta (t__0,t__1,t__2,t__3,x),t__2) = _F4(t__3), diff(theta(t__0,t__1,t__2,t__3,x),t__3) = diff(_F4(t__3),t__3)*t__2+diff(_F5(t__3),t__3), diff(theta(t__0, t__1,t__2,t__3,x),x) = -1, diff(theta(t__0,t__1,t__2,t__3,x),x) = -diff(theta(t__0,t__1,t__2,t__3,x),t__0), 2^(1/2)*_F4(t__3)^(1/2) <> 0, theta(t__0, t__1,t__2,t__3,x) <> 0}: 

vars := {`A__4,2`(t__1,t__2,t__3), `A__4,3`(t__1,t__2,t__3), `A__4,4`(t__1,t__2,t__3), `B__4,2`(t__1,t__2,t__3), `B__4,3`(t__1,t__2,t__3), `B__4,4`(t__1,t__2 ,t__3), _F4(t__3), _F5(t__3), theta(t__0,t__1,t__2,t__3,x)}:

dsolve(eqs,vars);

As you has mentioned, I have a number of "pdes" here which aren't actually differential equations; I was surprised it didn't work here, as this method has worked fine for me before (as shown above).

Perhaps it would be better to remove the non-differential equations from the system. Unfortunately, since this list of equations is generated automatically, I don't know how to pull those out and "solve" them seperately (ultimately, I want a list of solutions to run assign on).

Thanks for your response! You're absolutely right, this is a system of ordinary differential equations.

Like I mentioned at the bottom of my question, my real system involves other terms with various partial derivatives; I only included the problematic terms here to simplify things while retaining the error. Chainging F2(t) to, say, F2(t,x), results in the same error.

Of course you're right that the F3(t) = 0 equation is unnecessary, but again, my actual code generates a system to solve, and this would be one of the equations.

Also, running your code (with dsolve instead of pdsolve) only gives the trivial solution F3(t) = F1(t) = 0 whereas I'm looking for the solution {F2(t) = _C1, F1(t) = F1(t), F3(t) = 0}.

So I guess my questions are:

  1. Why doesn't dsolve generate the non-trivial solution when the F3(t)=0 equation is included (but does generate it when F3(t)=0 is not included)
  2. Why does pdsolve work correctly if, say, sqrt(2) is removed from line 1, but doesn't work correctly otherwise?

Thanks again!

1 2 3 4 Page 4 of 4