FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Forum index » Science and Technology » Math » Symbolic
Question about plotting in MuPAD
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
Author Message
Brad Cooper
science forum beginner


Joined: 07 May 2005
Posts: 48

PostPosted: Sat Apr 08, 2006 9:06 am    Post subject: Question about plotting in MuPAD Reply with quote

The following MuPAD 3.0 code produces the error message

Error: symbolic parameters not allowed in non-polynomial equations
[numeric::solve]

It doesn't appear to me that plot::Curve2d is calling the procedure alpha
with symbolic parameters, so I cannot understand why the error appears.

Any help much appreciated.

Cheers, Brad

delete a, b, c, d, r, `α`, `θ`:

assume(a, Type::Real): assume(b, Type::Real): assume(r, Type::Real):
assume(`α`, Type::Real): assume(`θ`, Type::Real):

alpha := proc(a,b,r,`θ`)
local s;
begin
c := a + r:
d := b + r:
s := sqrt(c^2*sin(`α`)^2+d^2*cos(`α`)^2):
return(op(numeric::solve(tan(`θ`)=tan(`α`)*(c^2-r*s)/(d^2-r*s),`
α`=0..PI/2,RestrictedSearch),1)):
end_proc:

pr1 := proc(a,b,r,`θ`)
local s;
begin
c := a + r:
d := b + r:
s :=
sqrt(c^2*sin(alpha(a,b,r,`θ`))^2+d^2*cos(alpha(a,b,r,`θ`))^2):
return(c^2*sin(alpha(a,b,r,`θ`))/s-r*sin(alpha(a,b,r,`θ`)))
end_proc:

pr2 := proc(a,b,r,`θ`)
local s;
begin
c := a + r:
d := b + r:
s :=
sqrt(c^2*sin(alpha(a,b,r,`θ`))^2+d^2*cos(alpha(a,b,r,`θ`))^2):
return(d^2*cos(alpha(a,b,r,`θ`))/s-r*cos(alpha(a,b,r,`θ`)))
end_proc:

a:=7: b:=2: r:=2:
curve := plot::Curve2d ([pr1(a,b,r,`θ`), pr2(a,b,r,`θ`)],
`θ` = 0.00 .. PI/2):
plot(curve):

Error: symbolic parameters not allowed in non-polynomial equations
[numeric::solve]
Back to top
Walter Oevel
science forum beginner


Joined: 26 Aug 2005
Posts: 5

PostPosted: Mon Apr 10, 2006 9:24 am    Post subject: Re: Question about plotting in MuPAD Reply with quote

Brad Cooper wrote:
Quote:
The following MuPAD 3.0 code produces the error message

Error: symbolic parameters not allowed in non-polynomial equations
[numeric::solve]

It doesn't appear to me that plot::Curve2d is calling the procedure alpha
with symbolic parameters, so I cannot understand why the error appears.

Any help much appreciated.

Cheers, Brad

delete a, b, c, d, r, `α`, `θ`:

assume(a, Type::Real): assume(b, Type::Real): assume(r, Type::Real):
assume(`α`, Type::Real): assume(`θ`, Type::Real):

alpha := proc(a,b,r,`θ`)
local s;
begin
c := a + r:
d := b + r:
s := sqrt(c^2*sin(`α`)^2+d^2*cos(`α`)^2):
return(op(numeric::solve(tan(`θ`)=tan(`α`)*(c^2-r*s)/(d^2-r*s),`
α`=0..PI/2,RestrictedSearch),1)):
end_proc:

pr1 := proc(a,b,r,`θ`)
local s;
begin
c := a + r:
d := b + r:
s :=
sqrt(c^2*sin(alpha(a,b,r,`θ`))^2+d^2*cos(alpha(a,b,r,`θ`))^2):
return(c^2*sin(alpha(a,b,r,`θ`))/s-r*sin(alpha(a,b,r,`θ`)))
end_proc:

pr2 := proc(a,b,r,`θ`)
local s;
begin
c := a + r:
d := b + r:
s :=
sqrt(c^2*sin(alpha(a,b,r,`θ`))^2+d^2*cos(alpha(a,b,r,`θ`))^2):
return(d^2*cos(alpha(a,b,r,`θ`))/s-r*cos(alpha(a,b,r,`θ`)))
end_proc:

a:=7: b:=2: r:=2:
curve := plot::Curve2d ([pr1(a,b,r,`θ`), pr2(a,b,r,`θ`)],
`θ` = 0.00 .. PI/2):
plot(curve):

Error: symbolic parameters not allowed in non-polynomial equations
[numeric::solve]




Hi Brad,

when generating 'curve', you call pr1 and pr2 with a **symbolic**
`θ`, i.e., you finally call the routine alpha and numeric::solve
with a symbolic parameter `θ`!
The cleanest way to get around this is to test whether `θ` is a
symbol. If so, return a procname(args()):


alpha := proc(a,b,r,`θ`)
local s;
begin
if domtype(float(`&theta;`)) <> DOM_FLOAT then
return(procname(args()));
end_if;
c := a + r:
d := b + r:
s := sqrt(c^2*sin(`&alpha;`)^2+d^2*cos(`&alpha;`)^2):
return(op(numeric::solve(tan(`&theta;`)=tan(`&alpha;`)*(c^2-r*s)/(d^2-r*s),`
&alpha;`=0..PI/2,RestrictedSearch),1)):
end_proc:

Your plot should work after this modification.

Regards, Walter
Back to top
Brad Cooper
science forum beginner


Joined: 07 May 2005
Posts: 48

PostPosted: Mon Apr 10, 2006 1:13 pm    Post subject: Re: Question about plotting in MuPAD Reply with quote

Hi Walter,

f := proc(x)
begin
return(x^2):
end_proc:

plot(plot::Function2d(f(x),x=0..3));

The plot of x^2 is produced just fine. I "presume" that values of x in the
domain [0,3] are chosen progressively and passed to the procedure f in the
variable x. f is not handed "x", but the contents of x in the argument.


Now, for another case...

alpha := proc(a,b,r,`&theta;`)
....
return(op(numeric::solve(tan(`&theta;`)=tan(`&alpha;`)*(c^2-r*s)/(d^2-r*s),`
&alpha;`=0..PI/2,RestrictedSearch),1)):
end_proc:

pr1 := proc(a,b,r,`&theta;`)
....
return(c^2*sin(alpha(a,b,r,`&theta;`))/s-r*sin(alpha(a,b,r,`&theta;`)))
end_proc:

pr2 := proc(a,b,r,`&theta;`)
....
return(d^2*cos(alpha(a,b,r,`&theta;`))/s-r*cos(alpha(a,b,r,`&theta;`)))
end_proc:

curve := plot::Curve2d ([pr1(a,b,r,`&theta;`), pr2(a,b,r,`&theta;`)],
`&theta;` = 0 .. PI/2):

Consider the routine plot::Curve2d.

I "presume" that values of `&theta;` in the domain [0,PI/2] are chosen
progressively and passed to procedures pr1 and pr2 in the variable
`&theta;`, so that `&theta;` has a value by the time pr1 and pr2 are called
and `&theta;` still has this value by the time pr1 and pr2 call alpha.

So it seems odd to me that the numeric::solve routine in alpha complains...

Error: symbolic parameters not allowed in non-polynomial equations
[numeric::solve]

I can't see that numeric::solve has been passed a symbolic `&theta;` because
it has a value by the time it is passed to numeric::solve, just like the
argument x has a value which is passed to the procedure f.

If I type alpha(7,2,2,PI/6) then numeric::solve is happy and an answer is
returned.

If the PI/6 for `&theta;` comes from the plot::Curve2d instead of me typing,
I don't see why there should be different treatment.

Walter, the workaround you sent me is brilliant! Thank you. The whole
notebook is much larger than what I had submitted to the newsgroup. I had
written all the code and got the animation going using frames and timing.
But, I scrapped all that and your workaround allows a much more elegant
solution which works well.

I suggest that arguments be passed by the plot routines to procedures in a
consistent way so that what I am doing just works. It does seem like a
natural way to code things from a user's point of view.

In the meantime, I am going to keep your workaround handy because I find I
often have the same situation and have coded things using frames in the past
which is messy.

Cheers,
Brad
Back to top
Christopher Creutzig
science forum Guru Wannabe


Joined: 03 May 2005
Posts: 107

PostPosted: Tue Apr 25, 2006 7:39 am    Post subject: Re: Question about plotting in MuPAD Reply with quote

Brad Cooper wrote:
Quote:
Hi Walter,

f := proc(x)
begin
return(x^2):
end_proc:

plot(plot::Function2d(f(x),x=0..3));

The plot of x^2 is produced just fine. I "presume" that values of x in the
domain [0,3] are chosen progressively and passed to the procedure f in the
variable x. f is not handed "x", but the contents of x in the argument.

Please try

f :=
proc(x)
begin
print("f called with argument ", x);
return(x^2);
end_proc:

plot(plot::Function2d(f(x),x=0..3))

to see what happens here: You call f(x), which returns x^2, which is
then the evaluated argument of plot::Function2d. Contrast this with

plot(plot::Function2d(f, x=0..3, XMesh=10))

or

plot(plot::Function2d(hold(f(x)), x=0..3, XMesh=10))

where the XMesh settings are just there to reduce the amount of text
messages.

Quote:
So it seems odd to me that the numeric::solve routine in alpha complains...

It does that when you invoke

pr1(a,b,r,`&theta;`)

all by itself, too. Why should whatever(pr1(a,b,r,`&theta;`)) be
different? (With very few exceptions, such as whatever=hold.)

Quote:
I suggest that arguments be passed by the plot routines to procedures in a
consistent way so that what I am doing just works. It does seem like a
natural way to code things from a user's point of view.

Well, they are. It's really that you have called pr1 with symbolic
arguments long before plot::Curve2d sees it. The code Walter sent you
is not really a workaround, it is a way to write such programs. I agree
there should be an easier way of getting this result; not for the next
release, though, it's too late for that.


Best regards,
Christopher
Back to top
Brad Cooper
science forum beginner


Joined: 07 May 2005
Posts: 48

PostPosted: Fri Apr 28, 2006 2:14 am    Post subject: Re: Question about plotting in MuPAD Reply with quote

Hi Christopher,

I only just noticed your reply to the newsgroup....

"Christopher Creutzig" <christopher@creutzig.de> wrote in message
news:444dd233$0$11078$9b4e6d93@newsread4.arcor-online.net...
Quote:
Brad Cooper wrote:
Hi Walter,

f := proc(x)
begin
return(x^2):
end_proc:

plot(plot::Function2d(f(x),x=0..3));

The plot of x^2 is produced just fine. I "presume" that values of x in
the
domain [0,3] are chosen progressively and passed to the procedure f in
the
variable x. f is not handed "x", but the contents of x in the argument.

Please try

f :=
proc(x)
begin
print("f called with argument ", x);
return(x^2);
end_proc:

plot(plot::Function2d(f(x),x=0..3))

to see what happens here: You call f(x), which returns x^2, which is
then the evaluated argument of plot::Function2d. Contrast this with

plot(plot::Function2d(f, x=0..3, XMesh=10))

or

plot(plot::Function2d(hold(f(x)), x=0..3, XMesh=10))

OK. That makes it clear why the argument *is* symbolic.

Quote:
where the XMesh settings are just there to reduce the amount of text
messages.

So it seems odd to me that the numeric::solve routine in alpha
complains...

It does that when you invoke

pr1(a,b,r,`&theta;`)

all by itself, too. Why should whatever(pr1(a,b,r,`&theta;`)) be
different? (With very few exceptions, such as whatever=hold.)

I suggest that arguments be passed by the plot routines to procedures in
a
consistent way so that what I am doing just works. It does seem like a
natural way to code things from a user's point of view.

Well, they are. It's really that you have called pr1 with symbolic
arguments long before plot::Curve2d sees it. The code Walter sent you
is not really a workaround, it is a way to write such programs. I agree
there should be an easier way of getting this result; not for the next
release, though, it's too late for that.

I see now the approach within the MuPAD code. I really like the MuPAD/User
interface - it mostly seems quite natural and this comes out in the
wonderful examples in the books by Prof. Majewski. If an easier way to get
the result I am seeking comes out in a later version, I believe it will go
towards enhancing the simplicity of the user interface.

Thanks for taking the trouble to reply.

Cheers,
Brad

Quote:

Best regards,
Christopher
Back to top
Brad Cooper
science forum beginner


Joined: 07 May 2005
Posts: 48

PostPosted: Fri Apr 28, 2006 2:14 am    Post subject: Re: Question about plotting in MuPAD Reply with quote

Hi Christopher,

I only just noticed your reply to the newsgroup....

"Christopher Creutzig" <christopher@creutzig.de> wrote in message
news:444dd233$0$11078$9b4e6d93@newsread4.arcor-online.net...
Quote:
Brad Cooper wrote:
Hi Walter,

f := proc(x)
begin
return(x^2):
end_proc:

plot(plot::Function2d(f(x),x=0..3));

The plot of x^2 is produced just fine. I "presume" that values of x in
the
domain [0,3] are chosen progressively and passed to the procedure f in
the
variable x. f is not handed "x", but the contents of x in the argument.

Please try

f :=
proc(x)
begin
print("f called with argument ", x);
return(x^2);
end_proc:

plot(plot::Function2d(f(x),x=0..3))

to see what happens here: You call f(x), which returns x^2, which is
then the evaluated argument of plot::Function2d. Contrast this with

plot(plot::Function2d(f, x=0..3, XMesh=10))

or

plot(plot::Function2d(hold(f(x)), x=0..3, XMesh=10))

OK. That makes it clear why the argument *is* symbolic.

Quote:
where the XMesh settings are just there to reduce the amount of text
messages.

So it seems odd to me that the numeric::solve routine in alpha
complains...

It does that when you invoke

pr1(a,b,r,`&theta;`)

all by itself, too. Why should whatever(pr1(a,b,r,`&theta;`)) be
different? (With very few exceptions, such as whatever=hold.)

I suggest that arguments be passed by the plot routines to procedures in
a
consistent way so that what I am doing just works. It does seem like a
natural way to code things from a user's point of view.

Well, they are. It's really that you have called pr1 with symbolic
arguments long before plot::Curve2d sees it. The code Walter sent you
is not really a workaround, it is a way to write such programs. I agree
there should be an easier way of getting this result; not for the next
release, though, it's too late for that.

I see now the approach within the MuPAD code. I really like the MuPAD/User
interface - it mostly seems quite natural and this comes out in the
wonderful examples in the books by Prof. Majewski. If an easier way to get
the result I am seeking comes out in a later version, I believe it will go
towards enhancing the simplicity of the user interface.

Thanks for taking the trouble to reply.

Cheers,
Brad

Quote:

Best regards,
Christopher
Back to top
Brad Cooper
science forum beginner


Joined: 07 May 2005
Posts: 48

PostPosted: Sat May 13, 2006 4:18 am    Post subject: Re: Question about plotting in MuPAD Reply with quote

Hi Christopher,

I only just noticed your reply to the newsgroup....

"Christopher Creutzig" <christopher@creutzig.de> wrote in message
news:444dd233$0$11078$9b4e6d93@newsread4.arcor-online.net...
Quote:
Brad Cooper wrote:
Hi Walter,

f := proc(x)
begin
return(x^2):
end_proc:

plot(plot::Function2d(f(x),x=0..3));

The plot of x^2 is produced just fine. I "presume" that values of x in
the
domain [0,3] are chosen progressively and passed to the procedure f in
the
variable x. f is not handed "x", but the contents of x in the argument.

Please try

f :=
proc(x)
begin
print("f called with argument ", x);
return(x^2);
end_proc:

plot(plot::Function2d(f(x),x=0..3))

to see what happens here: You call f(x), which returns x^2, which is
then the evaluated argument of plot::Function2d. Contrast this with

plot(plot::Function2d(f, x=0..3, XMesh=10))

or

plot(plot::Function2d(hold(f(x)), x=0..3, XMesh=10))

OK. That makes it clear why the argument *is* symbolic.

Quote:
where the XMesh settings are just there to reduce the amount of text
messages.

So it seems odd to me that the numeric::solve routine in alpha
complains...

It does that when you invoke

pr1(a,b,r,`&theta;`)

all by itself, too. Why should whatever(pr1(a,b,r,`&theta;`)) be
different? (With very few exceptions, such as whatever=hold.)

I suggest that arguments be passed by the plot routines to procedures in
a
consistent way so that what I am doing just works. It does seem like a
natural way to code things from a user's point of view.

Well, they are. It's really that you have called pr1 with symbolic
arguments long before plot::Curve2d sees it. The code Walter sent you
is not really a workaround, it is a way to write such programs. I agree
there should be an easier way of getting this result; not for the next
release, though, it's too late for that.

I see now the approach within the MuPAD code. I really like the MuPAD/User
interface - it mostly seems quite natural and this comes out in the
wonderful examples in the books by Prof. Majewski. If an easier way to get
the result I am seeking comes out in a later version, I believe it will go
towards enhancing the simplicity of the user interface.

Thanks for taking the trouble to reply.

Cheers,
Brad

Quote:

Best regards,
Christopher
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [7 Posts] View previous topic :: View next topic
The time now is Wed Jan 07, 2009 8:22 pm | All times are GMT
Forum index » Science and Technology » Math » Symbolic
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Question about Life. socratus Probability 0 Sun Jan 06, 2008 10:01 pm
No new posts Probability Question dumont Probability 0 Mon Oct 23, 2006 3:38 pm
No new posts Question about exponention WingDragon@gmail.com Math 2 Fri Jul 21, 2006 8:13 am
No new posts question on solartron 1260 carrie_yao@hotmail.com Electrochem 0 Fri Jul 21, 2006 7:11 am
No new posts A Combinatorics/Graph Theory Question mathlover Undergraduate 1 Wed Jul 19, 2006 11:30 pm

Debt Consolidation | MPAA | Web Designer | Problem Mortgage | Store Cards for the best credit
Copyright © 2004-2005 DeniX Solutions SRL
Other DeniX Solutions sites: Electronics forum |  Medicine forum |  Unix/Linux blog |  Unix/Linux documentation |  Unix/Linux forums


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.4106s ][ Queries: 16 (0.2725s) ][ GZIP on - Debug on ]