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] Creating new names

Search email archive for  

[MUG] Creating new names
Author: Bob McElrath    Posted: Wed, 1 May 2002 00:19:01 -0500

>> From: Bob McElrath "mcelrath"

I wish to create new global names inside a procedure, and I'm finding
experimentally that there are often several names defined by maple where
I want only one, usually with zero to two tilde's on the end.

I have tried every combination I can think of using evaln, eval, ||, and
assume(), but nothing seems to work.

Essentially what I want to do is inside a procedure, if a variable is
complex, convert it to a real representation like:

realrep := proc(EX, x)
local myEX;
myEX := EX;
if(is(x, complex)) then
assume(r||x, real);
assume(i||x, real);
myEX := subs(x=r||x+I*i||x, myEX);
fi;
return myEX;
end;

> assume(x, complex);
> realrep(x^2+y*3*x, x);
2
(rx~~ + I ix~~) + 3 y (rx~~ + I ix~~)

> is(rx, real);
FAIL

> is(ir, real);
FAIL

As you can see this procedure created the symbols rx~~ and ix~~.
Normally when you assume(x, real), it creates a symbol x~. (note one
less tilde)

How can I do this?

Cheers,
-- Bob

Bob McElrath ()
Univ. of Wisconsin at Madison, Department of Physics

[MUG] Re: Creating new names
Author: Maple User Group    Posted: Mon, 6 May 2002 13:56:40 -0400 (

>> From: Maple User Group "maple_gr"

On Wed, 1 May 2002, Bob McElrath wrote:
> I wish to create new global names inside a procedure, and I'm finding
> experimentally that there are often several names defined by maple where
> I want only one, usually with zero to two tilde's on the end.

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

Date: Wed, 1 May 2002 14:44:34 -0700 (PDT)
From: Robert Israel "israel"
To: "maple-list"
Subject: Creating new names

The problem seems to be that when an assumed variable name is converted to
a string, it has the trailing tilde (even if you set the Assumed Variables
option to "No annotation": that only affects how things are printed).

> assume(z, complex);
convert(z, string);
"z~"

Well, to remove the extra tilde you could do something like this:

> notilde:= a ->
StringTools[Remove](evalb@rcurry(`=`,"~"),a);

[ this is in Maple 7: it isn't too hard to program a version for previous
releases where StringTools doesn't exist ]

and then in your procedure:

> realrep := proc(EX, x)
local myEX, xp, rx, ix, r, i;
myEX := EX;
if(is(x, complex)) then
xp:= notilde(x);
rx:= cat(r,xp);
ix:= cat(i,xp);
assume(rx,real);
assume(ix,real);
myEX:= subs(x=rx+I*ix, myEX);
fi;
return myEX;
end;

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


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

Date: Sun, 05 May 2002 18:31:01 +0200
From: Helmut Kahovec "helmut.kahovec"
To: "maple-list"
Subject: Creating new names

The following Maple7 session might help you. Note that I have set
'Assumed Variables' to 'No Annotation' in the 'Options' menu.

> restart;
> realrep:=proc(expr,x)
if is(x,complex) then
assume(r||x,real,i||x,real);
eval(expr,eval(x)=r||x+I*i||x)
else
expr
end if
end proc:
> assume(x,complex);
> is(r||('x'),real),is(i||('x'),real);

FAIL, FAIL

> is(rx,real),is(ix,real);

FAIL, FAIL

> realrep(x^2+y*3*x,'x');

2
(rx + I ix) + 3 y (rx + I ix)

> is(r||('x'),real),is(i||('x'),real);

true, true

> is(rx,real),is(ix,real);

true, true


Kind regards

Helmut

Previous by date: [MUG] Re: Finding the maximum value of a function over a rang e,  Willard, Daniel Dr DUSA-OR
Next by date: [MUG] FW: Position at WMI, L Bernardin
Previous thread: [MUG] Re: Swap hunter, Maple User Group
Next thread: [MUG] FW: Position at WMI, L Bernardin



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