Stephen Forrest

Mr. Stephen Forrest

461 Reputation

13 Badges

20 years, 45 days
Maplesoft
Software Architect

Social Networks and Content at Maplesoft.com

Maple Application Center

MaplePrimes Activity


These are replies submitted by Stephen Forrest

I presume that a, h, k are all parameters in your system.

You have to enter them as "k y" or "k*y", as "ky" is a variable by itself.

For example for a, h, k set to your initial defaults you have:

a := 1; h := 1; k := 1;
eq3 := k*y^2+x^2 = 4;
eq4 := -h*x^2+a*y = 0;
fsolve({eq3, eq4}, {x, y});

{x = -1.249621068, y = 1.561552813}

@Carl Love Fair enough.  Easily done with FileTools:-Exists.  Modify what I said above to the following:

From within Part1.mw:

VarA := [apple, banana, cherry];
VarB := [elderberry, fig, guava];
VarC := [jackfruit, kiwi, lemon];
if not FileTools:-Exists("MyNewArchive.mla") then
    LibraryTools:-Create("MyNewArchive.mla");
end if;
LibraryTools:-Save(VarA, VarB, "MyNewArchive.mla");

That's assuming you don't mind living with the previous contents of MyNewArchive.  Otherwise, you could check if it exists and delete it with FileTools:-Remove.

@Carl Love mode=log was introduced in Maple 10 (released 2005), so Aakanksha must be using Maple 9.5 or earlier.

To produce a 2-D plot with logarithmic scale on the y-axis (but a linear scale on the x-axis) in any version of Maple since Maple 6 at least, you can use plots[logplot].

Where did you get this code from?  It assumes that 'random' and 'empirical' are tables or modules defined earlier in the session, and no definitions for these are provided here.

@cloz54 Thanks for the clarification.  I believe the difficulty stems from the fact that Maple 18 introduces UTF-8 as its default encoding across all platforms, Windows included.  This is a change from Maple 17.

To get the behaviour you want from Maple 18, open Notepad++.  Under Encoding select Encode in UTF-8 without BOM.  Enter the Maple code you want to use (in your case, your module definition for TestModule including the accented characters) into the editor.  Save the file.  Then try the read command within Maple: it should behave as you expect.

@cloz54 Given the difficulties reproducing your problem, I suspect it stems from the default character encoding on your computer.

When you use the Alt codes (such as Alt-130 for e acute) to enter accented characters you're implicitly using an old mapping from the days of DOS called Code page 437.  I believe that Windows then transforms that into the appropriate encoding for the default character set for your system.

Note that Maple uses UTF-8 in encoding all characters beyond 7-bit ASCII, so if your Windows installation is configured to use something else (such as ISO 8859-1), characters entered with Alt codes may not be understood.

One test to confirm this is the source of the problem is the following. In Maple enter:
convert("é",bytes)

where é is entered using Alt-130. On my system, I get the result:
[195, 169]

This is the correct encoding for é in UTF-8 and behaves as expected when I programmatically display the resulting string.  Is this the result you get?  Also, are you using Maple Classic or Maple Standard?

I thought I'd address the progress Maple has made on these tasks in the time since these suggestions were offered.

Import and Export

In Maple 18 it is now quite easy to automate synchronization between a text file and a Code Edit Region, as the content of the latter can now be programmatically controlled using DocumentTools.

Example:

  1. Create a file, say "C:\Temp\MyScript.mpl" containing the code you would like to work with.
  2. In a new document insert a Code Edit Region.  Right-click and note there is a Component Properties confirming this is a component which can be programmatically controlled.  Its name should be CodeEditRegion0.
  3. Insert two buttons. Update their captions to 'Import' and 'Export'. In the Click Action for Import, add the following:
    code := FileTools:-Text:-ReadFile("C:\\Temp\\MyScript.mpl"):
    DocumentTools:-SetProperty("CodeEditRegion0", value, code);
    Correspondingly in the Click Action for Export, add the following:
    code := DocumentTools:-GetProperty("CodeEditRegion0", value);
    FileTools:-Text:-WriteFile("C:\\Temp\\MyScript.mpl", code);

You'll now have a worksheet where you can synchronize between an external file and a code edit region with the click of a button.

2D Math to Code Edit Region

While there is is no "convert to Code Edit Region" as yet, one can use cut-and-paste to move content from 2D math to Code Edit Regions.

Find and Replace

Both of these have been available for both Startup Code and Code Edit Regions since Maple 17.

@Axel Vogt If you would like to override the User-Agent string that is sent, either for the reason you give or because a remote site is filtering content based on User-Agent settings, you can do so.

To override the default User-Agent string, use the requestheaders option to URL:-Get or URL:-Post.

In the following example, Maple disguises itself as Internet Explorer and Chrome, respectively, when making HTTP requests:

IE_UserAgent := "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko":
Chrome_UserAgent := "Mozilla/5.0 (Windows NT 6.1; WOW64) "
    "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36":
URL:-Get("http://myhttp.info", requestheaders=["User-Agent" = IE_UserAgent]);
URL:-Get("http://myhttp.info", requestheaders=["User-Agent" = Chrome_UserAgent]);

You can also set the User-Agent string to the empty string:

URL:-Get("http://myhttp.info", requestheaders=["User-Agent" = ""]);

Hope that helps.

@Axel Vogt You wrote:

I think it is possible to download such files without browser or Maple in anonymous
way (using WIN DLLs or wget) and that this is a better idea.

For what it's worth, the new URL package in Maple 18 which Daniel mentioned above is essentially a straightforward interface to the curl library from within Maple, and does not include any session-specific data in outgoing requests except that which is explicitly provided in the URL:-Get or URL:-Post call.

 

Can you please clarify the question?

What is A and what are the left and right hand sides of this equation supposed to be?

@Axel Vogt Here is what is sent from Maple 18 on Windows 7 as a result of the command URL:-Get("http://myhttp.info").

GET / HTTP/1.1
Host: myhttp.info
Accept: */*
User-Agent: Maple/18.00 (unix;X86 64 LINUX;en_US.UTF-8) Maple/922027 Cmaple/922027 Lib/922027

As you can see the only nontrivial data is in the User-Agent string which contains some Maple versioning info.  In including this we follow the precedent established by web browsers; for example, this is the User-Agent string from my Chrome browser:

Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36

Hope that helps.

 

There are of course infinitely many solutions to this.

For example, you could find a piecewise expression with CurveFitting:

V := <916, 935, 713, 845, 274, 914, 255>:
p := CurveFitting:-Spline(<<seq(1..numelems(V))>|V>, v, degree=1);
f := unapply(p, v):
[f(i) $ i=1..7];

[916, 935, 713, 845, 274, 914, 255]

I unsuccessfully tried looking this up in the On-Line Encyclopedia of Integer Sequences. Some more information on the type of solution you expect would be helpful.

Just a brief comment on @Kitonum's solution:

Note that to normalize a vector you don't need to divide by the norm, you can simply use the LinearAlgebra:-Normalize command.  Using this command instead of dividing by the norm also has the advantage of avoiding a division by zero exception in the case when the input is the zero vector.

E.g. adapting the above solution:

with(LinearAlgebra):
a,b,c := <22,11,5>, <13,6,3>, <-5,-2,-1>:
a1 := Normalize(a, 2):
b0 := b-(a1.b)*a1:
b1 := Normalize(b0, 2):
c0 := c-((a1.c)*a1+(b1.c)*b1):
c1 := Normalize(c0, 2):
[a1,b1,c1];

[Vector(3, {(1) = (11/105)*sqrt(70), (2) = (11/210)*sqrt(70), (3) = (1/42)*sqrt(70)}), Vector(3, {(1) = (58/13755)*sqrt(9170), (2) = -(257/27510)*sqrt(9170), (3) = (11/5502)*sqrt(9170)}), Vector(3, {(1) = -(3/131)*sqrt(131), (2) = (1/131)*sqrt(131), (3) = (11/131)*sqrt(131)})]

Could you clarify what you are looking for?

The expression aiaj-ajai=0 uses both multiplication and subtraction, whereas in group theory one uses only a single operation. Where do ai and aj come from?

Note that you can generate the (infinite) free Abelian group on two generators with this command:

Group({a, b}, [[a, b, 1/a, 1/b]]);

The second argument expresses the commutative relation a b=b a.

Can you let us know what you were intending to do?  It looks like you may have been intending to replace the zeroes in a container called Butcher with the empty symbol ``.

That can be achieved with this, which is only slightly different than your code:

Butcher := [0, "test", 34, y^2, 0]:
Butcher := map( x->if x=0 then `` else x end if, Butcher );

[``, "test", 34, y^2, ``]

Alternatively, perhaps you were simply trying to remove all the zero elements from your container. You can do that with remove:

Butcher := [0, "test", 34, y^2, 0]:
Butcher := remove( verify, Butcher, 0 );

["test", 34, y^2]

1 2 3 4 5 6 7 Page 2 of 7