nm

11353 Reputation

20 Badges

13 years, 11 days

MaplePrimes Activity


These are replies submitted by nm

Try to write normal looking code instead. No one writes a function name with a name like `Δε`(T, z). This is absolutely ridiculous.

@Preben Alsholm 

fyi, I found another one:

ode:=(-x^2+y(x))*(diff(y(x), x))-x;
sol:=dsolve(ode=0,y(x));
latex(sol);

y \left( x \right) ={x}^{2}+1/2\,{\rm W} \left(

Error, (in fprintf) string expected for string format

I used this subs on this to make it happy:

latex(subs(erf=Erf,arctanh=Artanh,LambertW=lambertW,sol));

y \left( x \right) ={x}^{2}+1/2\,{\it lambertW} \left( -4\,{\it \_C1}
\,{{\rm e}^{-2\,{x}^{2}-1}} \right) +1/2

 

@Preben Alsholm 

thanks., Those subs did help indeed to resolve few of the problems in conversion.

@nm 

Ok, solved. Needed to clear the variable. Like this:

restart;
with(CodeTools):
ode:=diff(y(x), x)+a*y(x)-c*exp(b*x);
result:=Usage(assign(resultOfSolve=dsolve(ode=0,y(x))),output='cputime');
resultOfSolve:='resultOfSolve';
ode:=diff(y(x), x)+a*y(x)-c*exp(b*x);  #this can be different ode
result:=Usage(assign(resultOfSolve=dsolve(ode=0,y(x))),output='cputime');

solved :)

@Mac Dude 

It fails when I call it again. I am running in a loop making such calls to different ode's. Do you why it fails and how to fix it please?

restart;
with(CodeTools):
ode:=diff(y(x), x)+a*y(x)-c*exp(b*x);
result:=Usage(assign(resultOfSolve=dsolve(ode=0,y(x))),output='cputime');

ode:=diff(y(x), x)+a*y(x)-c*exp(b*x);  #this can be different ode
result:=Usage(assign(resultOfSolve=dsolve(ode=0,y(x))),output='cputime');

Error, (in CodeTools:-Usage) invalid left hand side in assignment

@Preben Alsholm 

thanks. Yes needed the output in a variable. Using assign solved the problem for me.

@Mac Dude 

thanks. It is the assign trick that I needed.

@sarra 

It is better to preallocate memory for the array before using it.

When you do

    bb[i]:=

without pre-allocating bb, the loop becomes inefficient as a new larger bb array has to be created each time.

 

 

If you want just any code, I would think searching google will be much easier and more efficient than posting a question to one forum.  Google will search millions and millions of pages in a fraction of a second, especially since your requirment is so specific and detailed asking for "some code"

your formulas must be wrong then.

You never said where you got the formulas from, or give any link. if you copied them from somewhere, check again.

some hints and smart tricks can be found here

interface(verboseproc=3);

print(exp);

 

 

@Carl Love 

great. Nice function. did not know about "is". it is hidden in the assume help.

"Even without assumptions, is has knowledge about the properties of some mathematical functions"

So, will change all my comparsions to do  IF is(.....) THEN .... from now on.
I just do not like using evalf() so much, it started to feel like I am using Fortran and not a computer algebera system!

thanks

@Alejandro Jakubi 

"I wonder what the Ada feature looks like."

In ada:

  SWAP:
       declare
          TEMP : INTEGER;
       begin
          TEMP := V; V := U; U := TEMP;
       end SWAP; 


http://archive.adaic.com/standards/83lrm/html/lrm-05-06.html
It is a very useful feature. Similar things can be done in C++ by simply writing a nested {}

  main()
 {
   int a=2;
   {
     int tmp=3;  // this has scope only inside enclosing {}
     .....
    }
   ....
 }



@Carl Love 

thanks. I was very close. I tried value(expr) and evalf(expr), but somehow forgot there is also eval(expr).

Help in that page could be a little more clear for newbies. A small example sometimes is worth 1000 words :)

@Carl Love 

thanks, that is good news. Looking at it now. Some Maple expert should consider adding an entry to http://rosettacode.org/wiki/Named_parameters since Maple is missing from there while many other languages are present. This gives one the impression that Maple does not support this feature.

First 83 84 85 86 87 88 89 Page 85 of 91