Venkat Subramanian

256 Reputation

10 Badges

9 years, 136 days

MaplePrimes Activity

These are replies submitted by


I believe a procedure is the best way to approach this. But there are situations when the OP's approach is better. For example, let us assume that we need to call fsolve or Roots or something similar and it fails. In the OP's approach, it will be easier to debug, and in a procedure, it will be a pain.

Once someone is absolutely sure of all the commands in a code, then the procedure makes sense. The OP may not have the ability to share the code (copyrights/etc).

@Daniel Skoog 

Please don't stop classic worksheet. Though it is unstable now, that is what I use. For me it is 100x faster than any of the Java based interfaces.

Also, it will be great to have a fsolve that works and gives answers for a specified tolerance. Provide an option that uses the Newton Raphson for mutliple variables which is guaranteed to give a better answer compared to the starting initial guess just with Digits:=15 without increasing Digits to seek unrealistic tolerances. 



FWIW, I never delete any old installations specifically for this point. 

It may be hard to accept, but your best would be to remove maple 2018, reinstall maple 2017 and matlab 2017 again.


@Daniel Skoog 

I wish Maplecloud is disabled by default and enabled only if the users choose to enable it.

@ solve the case with the BC, u = 1 and then apply Duhamel's superposition theorem. Maple can be used to do this. Or just apply Laplace transform method, solve the BVP in x, and invert back to time domain.


I realize there are signficant new additions in Maple lately and with physics package many more PDEs being solved analytically.

IMHO we should expect analytical solutions for linear ODEs and not PDEs. For PDEs, boundary conditions will complicate the existence, convergence, etc of a solution approach.

Just presenting Fourier or SOV solution will not work for all the PDEs. I wish the focus and expectation will be on guiding the user to use Maple to arrive at a Separation of variable solution from scratch or using Laplace transform or similarity solution instead of a click of a button to get a solution.

I can break any software for a solution of a PDE. Just take a simple linear PDE see if any software can do both short-time and long-time solution.

Thanks for bringing up bugs, etc. This will be a never ending game. (For example I saw another post with a fortuitious analytical solution for wave/Burger's equation)


Modifying the nonlinear constraint procedure to provide output W[1] seems to fix this mistake and the Matrix form works in 2017 with this corrected format. The use of 'evalf' form for Matrix/operator form is still seen.
end proc;


It appears that the result depends on the version of Maple.

Matrix approach fails in Maple 14.

Matrix approah fails in Maple2017 if there is a nonlinear constraint.

Both operator and Matrix approaches use evalf mode compared to algebraic form (which uses evalhf). 

. (By setting infolevel=3 or more one can find this).

So, the help file is technically correct (stating that Matrix form is more efficient).




obj := 100*(x[1]-2.1)^2+10000.0*(x[2]-3.3)^2+0.3e-4*exp(-x[1])*exp(-x[2])




[0.135497428232022180e-6, [x[1] = 2.10000000067749, x[2] = 3.30000000000677]]



[401.000000122603808, [x[1] = 2., x[2] = 3.50000000000000]]



constraint := x[1]*x[2]+ln(x[1]-0.1e-3)-4



[497.527740765090868, [x[1] = 1.11243865776721, x[2] = 3.50000000000000]]


 Next operator method is used


obj1 := proc (x_1, x_2) options operator, arrow; 100*(x_1-2.1)^2+10000.0*(x_2-3.3)^2+0.3e-4*exp(-x_1)*exp(-x_2) end proc




[401.000000122603808, Vector(2, {(1) = 2., (2) = 3.50000000000000})]



nlc1 := proc (x_1, x_2) options operator, arrow; x_1*x_2+ln(x_1-0.1e-3)-4 end proc



[497.527740765090868, Vector(2, {(1) = 1.11243865776721, (2) = 3.50000000000000})]





 Next, Matrix approach


obj2 := proc (x) options operator, arrow; 100*(x[1]-2.1)^2+10000.0*(x[2]-3.3)^2+0.3e-4*exp(-x[1])*exp(-x[2]) end proc



[1.35497428232022180*10^(-7), Vector(2, {(1) = 2.10000000067749, (2) = 3.30000000000677})]



[401.000000122603808, Vector(2, {(1) = 2., (2) = 3.50000000000000})]



nlc2 := proc (x) options operator, arrow; x[1]*x[2]+ln(x[1]-0.1e-3)-4 end proc




[401.000000122603808, Vector(2, {(1) = 2., (2) = 3.50000000000000})]





 Matrix form seems to fail when there is a nonlinear constraint in 2017 Maple. Any Matrix form fails in Maple 14.
















Download optimizationexamples.mws


Perhaps Maplesoft should not assume that all the users require a simple call/GUI and provide more examples for directly calling NAG's subroutines. I am wondering if what you found out is the reason for NLPSolve (sqp approaches) to fail for bounded or constrained optimization problems in Matrix or operator form.

For example take any arbitrary set of nonlinear equations for x1, x2. Solve using fsolve. Solve the same set of equations using NLPSolve objective =1 . This should work well.

Then write a procedure that returns 10*(x1-x1sol)^2+(x2-x2sol)^2*1000 or something like that or just 1.

Give bounds and arbitrary nonlinear or linear constraints (stating x1=x1sol, etc).

NLPSolve won't give the expected solution

@Robert Israel 

In Maple 2015, 2016 and 2017 the following command works for pdsolve numeric with compile =true selectively. I am not sure if the value saved at t = 1 as a function of x is a compiled procedure, but it works. However, trying to recover solution at different times does not work.
I am restating my request and interest in storing compiled dsolve numeric solutions.



save uu,sol,"pdesol.m";

Error, (in pdsolve/numeric/value) cannot determine if this expression is true or false: INFO[errorest]

@ Robert Israel 

If I unassign sol after saving it to .m file and then call the .m file and use sol without using restart command, this works.

But this beats the purpose. This means that one cannot save the solution for future use when compile=true is used. I have a feeling that module, moduleapply or package or something similar which will store all the local variables, procedures,files during the compiling process might help.


                         d                        2
                  eq1 := -- y(t) = -k1 y(t) - z(t)

> eq2:=diff(z(t),t)=y(t)*k1+z(t)^2-k2*z(t);

                     d                       2
              eq2 := -- z(t) = k1 y(t) + z(t)  - k2 z(t)

> sol:=dsolve({eq1,eq2,y(0)=1,z(0)=0},type=numeric,compile=true,'parameters'=[k1,k2],stop_cond=[y(t)-0.5],stiff=true,implicit=true):

> save sol, "dsolvesol.m";
> sol:='sol':
> #restart;
> sol(1);


> read("dsolvesol.m");
> sol('parameters'=[1,1]):
> sol(1);
Warning, cannot evaluate the solution further right of .63313380, event #1 triggered a halt

  [t = 0.633133804626753, y(t) = 0.500000000000000,

        z(t) = 0.361834982920762]

@Robert Israel 

This is a great strategy for parameters (as opposed to using savelib).

compile=true is still not working. 

@Robert Israel 

Robert, Thanks. If you hard code k1 =1 and k 2= 1. Create sol with compile =true, and proceed. It still won't work and will likely crash the maple code.


@Robert Israel 

Sorry for bringing this discussion back again. The command given does not work with compile=true and with unknown parameters. 

Anyone up for a challenge to fix this? If not, SCR should be submitted? Note that savelib route enables the use of parameters (not stable), but not compile=true.



Dr. Venkat Subramanian




eq1 := diff(y(t), t) = -k1*y(t)-z(t)^2



eq2 := diff(z(t), t) = k1*y(t)+z(t)^2-k2*z(t)



save sol, "dsolvesol.mpl";




[k1 = 1., k2 = 1.]



Error, (in sol) parameters must be initialized before solution can be computed




Download Savedsolvecompileandpars.mws


Does this work in classic worksheet mode for you? I have had no luck to make this work in lenova yoga windows 10 (unfortunately the laptop won't work with windows 7).



1 2 3 4 5 6 7 Last Page 1 of 13