Adept Scientific - English
The world's best software for research, science and engineering.
flag arrow
clearclear
 

 Adept Store | register Join My Adept | Flags  
Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055  
UKusdedksvnofi
Home
Products
Training
Consultancy
 Buy Online
Downloads
Education
Support
My Adept
International |  About Us |  Contact Us |  Press Room |  Jobs


The Next Steps

• Ask us a question
• Maple Product Tour
• Buy Maple Now
• View Maple Pricing
• Find out about Online Training
• Download a Brochure
• Request a Brochure
• Download a Demo
• Request a Demo
• Meet Our Team
• Read our RSS Feeds

Learn More

Maple Home
Maple 11 Professional
Maple 11 Academic
Maple 11 Student Use
Recorded Online Seminars
FREE Training Resources


MapleNet
Maple T.A.
MapleConnect
BlockImporter for Simulink
BlockBuilder for Simulink
Maple Toolboxes
Maple Rave Reviews
Maple Study Guides
Books about Maple
System Requirements

View Maple 10 in Action
Product Comparison Chart

Latest Information

New Features: Professional
New Features: Academic
The Maple Reporter
The Maple Reporter Online
Numerical Algorithms Group
(NAG)


Service & Support

Maple 10 Training Videos
MaplePrimes, blogs, forums
Elite Maintenance Program
Application Centre
Powertools
Maple User Group (MUG)
Join the Maple User Group
(MUG)

Search the Knowledge Base
Technical Support request

List Archives >  Maple User Group List Archive >  Archive by date >  This Month By Date >  This Month By Topic

[MUG] Forcing Maple Output with Simplifying

Search email archive for  

[MUG] Forcing Maple Output with Simplifying
Author: Fraser Murray    Posted: Wed, 11 Dec 2002 12:40:12 +0000

>> From: Fraser Murray "fraser.murray"

I'm new to Maple and I'm trying to generate a number of MathML examples.
A number of these examples are simplified by Maple, eg a very simplistic
example:

MathML:-Export(3 * x + 4 * x);
gives the MathML output for 7x

Is there a way of forcing Maple to give me output for 3x + 4x?

Please include my address in any reply.

Many thanks in advance,

Fraser

[MUG] Re: Forcing Maple Output with Simplifying
Author: Maple User Group    Posted: Fri, 13 Dec 2002 16:53:33 -0500

>> From: Maple User Group "maple_gr"

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Thu, 12 Dec 2002 13:55:21 -0500 (EST)
From: Carl Devore "devore"
To: "maple-list"
Subject: Forcing Maple Output with Simplifying



On Wed, 11 Dec 2002, Fraser Murray wrote:
| MathML:-Export(3 * x + 4 * x);
| gives the MathML output for 7x
|
| Is there a way of forcing Maple to give me output for 3x + 4x?

MathML:-Export(3*convert(x, `local`) + 4*x);


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: Douglas Harder "dwharder"
Subject: Forcing Maple Output with Simplifying
To: "maple-list"
Date: Thu, 12 Dec 2002 14:42:22 -0500 (EST)

This cannot be done in Maple, as there is no inert +. If you want
to get the output you're looking for do this:

> MathML:-Export(3 * x + 4 * y);

and then you'll have to substitute the y for x in the output (it occurs
3 times.)

Since you're new to Maple, you might not want to look at this:

> MathML:-Export(3 * x + 4 * `tools/gensym`(x));

The gensym generates a new symbol which looks like x, but is not x.

Unfortunately, there is no easy way to export 3 + 4. The standard
Maple tricks don't work because the MathML which is generated
depends on the objects being integers.

Cheers,

Douglas
--
Douglas Wilhelm Harder -: 3- -.- =.- -: -3 .* =. -:- :- . -: .= -:- * -:- -.
Department of Electrical and Computer Engineering http://ece.uwaterloo.ca/
University of Waterloo http://cheetah.vlsi.uwaterloo.ca/~dwharder/
.___ DC 2703 519-885-1211 x7023 http://links.uwaterloo.ca/
\ ."""". .-----._____.-----._______.-----._____.-----._____.--
\____/ --10-- http://www.scg.uwaterloo.ca/ http://mapleapps.com/


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: L Bernardin "lb"
To: "''"
Subject: Forcing Maple Output with Simplifying
Date: Thu, 12 Dec 2002 16:45:13 -0500


You could try this:

> macro(F=`tools/gensym`);
F

> F("3")*F("x")+F("4")*F("x");
3 x + 4 x

> MathML[Export](%):
> XMLTools[Print](%);
<math xmlns='http://www.w3.org/1998/Math/MathML'>
<semantics>
<mrow xref='id7'>
<mrow xref='id3'>
<mi xref='id1'>3</mi>
<mo>&InvisibleTimes;</mo>
<mi xref='id2'>x</mi>
</mrow>
<mo>+</mo>
<mrow xref='id6'>
<mi xref='id4'>4</mi>
<mo>&InvisibleTimes;</mo>
<mi xref='id5'>x</mi>
</mrow>
</mrow>
<annotation-xml encoding='MathML-Content'>
<apply id='id7'>
<plus/>
<apply id='id3'>
<times/>
<ci id='id1'>3</ci>
<ci id='id2'>x</ci>
</apply>
<apply id='id6'>
<times/>
<ci id='id4'>4</ci>
<ci id='id5'>x</ci>
</apply>
</apply>
</annotation-xml>
<annotation encoding='Maple'>`3`*x+`4`*x</annotation>
</semantics>
</math>

best regards

-Laurent


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Thu, 12 Dec 2002 15:02:11 -0800 (PST)
From: Robert Israel "israel"
To: "maple-list"
Subject: Forcing Maple Output with Simplifying


There's no way to get Maple to avoid automatic simplifications: 3*x+4*x
always becomes 7*x. However, for a case such as this you can get around
the problem by using a second variable that looks like x but is different:

> 3*x+4*`tools/gensym`(x);
3 x + 4 x

> MathML:-Export(%);

There are various other tricks that can be used to get around some of the
other automatic simplifications that Maple uses. For example, Maple
always changes x > y to y < x. If you want x > y, you could generate
the MathML for x < y but then substitute "&gt;" for "&lt;":

> StringTools[SubstituteAll](MathML:-Export(x<y), "&lt;", "&gt;");

Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: "Greg Gamble" "gregg"
To: "maple-list" "fraser.murray"
Subject: Forcing Maple Output with Simplifying
Date: Fri, 13 Dec 2002 08:41:13 +0800

Dear Fraser,

Unfortunately, Maple will simplify its argument whatever you do here
... so MathML:-Export only ever sees 7 * x (uneval quotes (') don't
help). What I've done in a similar context is to make the two x s
look different to Maple (while being visually identical to a human);
this can be done by replacing one of the x s with `x ` (i.e. a single
symbol that is an x followed by a blank) e.g.

> MathML:-Export(3 * x + 4 * `x `);

"<math xmlns='http://www.w3.org/1998/Math/MathML'><semantics><mr\
ow xref='id7'><mrow xref='id3'><mn xref='id1'>3</mn><mo>&I\
nvisibleTimes;</mo><mi xref='id2'>x</mi></mrow><mo>+</mo><\
mrow xref='id6'><mn xref='id4'>4</mn><mo>&InvisibleTimes;<\
/mo><mi xref='id5'>x </mi></mrow></mrow><annotation-xml en\
coding='MathML-Content'><apply id='id7'><plus/><apply id='\
id3'><times/><cn id='id1' type='integer'>3</cn><ci id='id2\
'>x</ci></apply><apply id='id6'><times/><cn id='id4' type=\
'integer'>4</cn><ci id='id5'>x </ci></apply></apply></anno\
tation-xml><annotation encoding='Maple'>3*x+4*`x `</annota\
tion></semantics></math>"

As you can see, the <annotation encoding> tag betrays the trick employed
to get what you want. You might find this trick useful for the one-off
expressions you encounter, but a mite tedious for a longer list of such
expressions (and perhaps a bit error-prone).

Hope you find this (a little bit) useful.

Regards,
Greg Gamble

// Greg Gamble, Dept. of Maths & Stats //
// Curtin University, Bentley WA 6102 //
// Mailto: "gregg" //
// WWW: http://www.maths.curtin.edu.au/~gregg //


-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

From: "Dr Francis J. Wright" "F.J.Wright"
To: "fraser.murray"
Subject: Forcing Maple Output with Simplifying
Date: Fri, 13 Dec 2002 15:17:23 -0000

I don't think you will be able to persuade Maple to generate MathML for any
expression that you could not output directly within Maple. The best I can
suggest is to use this:

MathML:-Export(3 * x + `4` * x);

with backquotes around the 4 to make it into an identifier. The MathML
output is similar to what you want, but uses the identifier tags mi and ci
for the `4`. If you edit these by hand to become the number tags mn and cn
then you should end up with the MathML that you wanted. For completeness,
you might also want to remove the backquotes around the 4 in the Maple
encoding towards the end of the output string.

Francis

Previous by date: [MUG] Logplot to file, Emilio Sanchez
Next by date: [MUG] Two bugs in evalapply(), Helmut Kahovec
Previous thread: [MUG] soritng - bubble sort, Trevor Meanwell
Next thread: [MUG] Two bugs in evalapply(), Helmut Kahovec



Ready to buy?

Maple - single user licence
Add to shopping basket
$ 1,895.00
Upgrade to Maple 12 from v11
Add to shopping basket
$ 995.00
Upgrade to Maple 12 from v10 & below
Add to shopping basket
$ 1,395.00

Featured Downloads

Maple White Paper: Technical Knowledge - An Asset You Can Afford to Lose?
Maple in Electronics Application Pack
Maple in Robotics & Aerospace Application Pack
Maple in Finance Application Pack

Product Reviews

"Without the Maple software, we would have to spend weeks generating the equations of motion for every experiment. Then the chances that we did it right would basically be near zero. There would always be a mistake somewhere. It is very difficult to set up a dynamic motion model by hand."
- Jean-Claude PiedBeouf, Ph.D Manager of Robotics, Canadian Space Agency

"Its very good - highly accurate and easy to use. The speed of Maple allows me to change equations and quickly reintegrate them into the application, so more possibilities can be explored to achieve the precise effect desired."
Shawn Neely, Senior R & D Director for PDI/Dreamworks
adept

Top of the Page

Our Privacy and Terms and Conditions Statement
All Trademarks Recognised. Copyright © 2007, Adept Scientific plc.
Site designed and maintained by Adeptise

Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055