Carl Love

Carl Love

28055 Reputation

25 Badges

12 years, 360 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are replies submitted by Carl Love

@Markiyan Hirnyk Yes, the numerators and denominators grow exceptionally fast. It is best to use floating point input for either of the first two arguments. This is an inherent property of the function and is not the fault of my code.

Indeed, Maple does not autocomplete if there is any character in front of the cursor. And this problem also exists in Worksheet mode.

All I see is two lines and a slider. Where's the actual code?

This is a really excellent Question, perhaps the best that I've seen on MaplePrimes. I don't know the answer. I am just posting this Reply to put this Question back on top of the Active Conversations list, with the hope that that will increase the chance for an Answer.

I am inlining your worksheet here.


restart;

M := module()

option package;

  export ModularArithmetic;

 

  export NewModulo := proc(p::posint)

    return Object(ModularArithmetic, p);

  end proc;

 

  ModularArithmetic := module()

  option object;

    local p := 0;

    

    export ModulePrint::static := proc(self::ModularArithmetic)

      cat("mod ", self:-p);

    end proc;

 

    export ModuleCopy::static := proc(self::ModularArithmetic, proto::ModularArithmetic, p::posint)

      self:-p := p;

    end proc;

 

   export ModuleApply := proc(n::nonnegint)

     # N.b. not static

     return modp(n, thismodule:-p);

   end proc;

 

  end module;

 

end module;

module () export ModularArithmetic, NewModulo; option package; end module

(1)

# Create a mla library file into local directory

# Location of the lib file,  It creates "M.mla" if mla does not exist.

savelibname := cat(".", kernelopts(dirsep),"M.mla");

# Save module to the current lib.

LibraryTools:-Save('M');

 

".\M.mla"

(2)

This uses the above typed code

with(M);

[ModularArithmetic, NewModulo]

(3)

Prototype prints as

ModularArithmetic;

thismodule

(4)

Construct new object...

m7 := NewModulo(7);

thismodule

(5)

Now m7 acts as an operator, computes integer mod 7...

m7(42), m7(13);

0, 6

(6)

Force restart and load package M from the .mla....

restart;

with(M);

[ModularArithmetic, NewModulo]

(7)

Prototype...

ModularArithmetic;

thismodule

(8)

Construct new object...

m7 := NewModulo(7);

thismodule

(9)

Now m7 barfs as operator.

Presumably the reference to thismodule has been resolved to point to the prototype instead of the instance.

Why does this happen when saved to .mla?  How can it be prevented / worked around so that the .mla works the same as code typed at command line?

m7(42), m7(13);

Error, (in ModuleApply) division by zero

 

 


Download BugThismoduleMLA.mw

@Syeda The context-menu solve feature that you are using is probably applying a numeric technique such as Newton's method that would never generate a non-real answer given that the starting points are real. It is probably not applying the cubic formula. If it is, then it is trimming the imaginary parts in the manner that I am suggesting.

To use the Re command, after generating each numeric solution, do

Re(%);

@nm The OP's formulas for the solution of the cubic are correct. The imaginary parts are due to round-off error in evaluating those formulas.

@J4James You need to remove the simplify around your dsolve command.

Eq1:=diff(psi(y),y$4)-b*diff(psi(y),y$2)=0; # b is parameter

res1:=dsolve(Eq1);
bcs:=psi(h1)=F,D(psi)(h1)=-1,psi(h2)=-F,D(psi)(h2)=-1;
res2:= dsolve({Eq1,bcs},psi(y));
match(rhs(res2)=rhs(res1),y,s);

                                            true

@J4James In this case, there is an extra pair of square brackets around the solution Cs. Here's a simplified version:

Cs:= solve({_C1+_C2=1, _C1-_C2=1}, [_C1,_C2]);

Notice the two levels of brackets.

eval(_C1, Cs);

Error, invalid input: eval expects its 2nd argument, eqns, to be of type {integer, equation, set(equation)}, but received Cs

eval(_C1, Cs[]);  # [] removes one level of brackets.

                                                           1

@J4James eval(_C1, s);

@ilke Sorry, I don't have any more ideas about what to do with this system. Like Preben says, there is something weird about the system itself; it is not an issue with Maple.

@Markiyan Hirnyk Perhaps I am using the wrong menu, but using the context menu seems limited to changing one curve and one frame.

@brian bovril Your original code does what you want. It just needs to be applied to an appropriate dictionary.

@Joe Riel I think that PatternDictionary is intended for searching largish texts and returning all occurences in the text of words from the dictionary.

@Preben Alsholm Minor point: I think that the issue is that it cannot find the independent variable. In particular, the boundary condition D(psi)(h2) = -1 cannot be easily distinguished from an ODE.

@Kitonum Even shorter is

plots[display](P(7, `>`), axes=none);

First 560 561 562 563 564 565 566 Last Page 562 of 709