|
|
| Author |
Message |
Brad Cooper science forum beginner
Joined: 07 May 2005
Posts: 48
|
Posted: Sat Apr 08, 2006 9:06 am Post subject:
Question about plotting in MuPAD
|
|
|
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
|
Posted: Mon Apr 10, 2006 9:24 am Post subject:
Re: Question about plotting in MuPAD
|
|
|
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(`θ`)) <> DOM_FLOAT then
return(procname(args()));
end_if;
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:
Your plot should work after this modification.
Regards, Walter |
|
| Back to top |
|
 |
Brad Cooper science forum beginner
Joined: 07 May 2005
Posts: 48
|
Posted: Mon Apr 10, 2006 1:13 pm Post subject:
Re: Question about plotting in MuPAD
|
|
|
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,`θ`)
....
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,`θ`)
....
return(c^2*sin(alpha(a,b,r,`θ`))/s-r*sin(alpha(a,b,r,`θ`)))
end_proc:
pr2 := proc(a,b,r,`θ`)
....
return(d^2*cos(alpha(a,b,r,`θ`))/s-r*cos(alpha(a,b,r,`θ`)))
end_proc:
curve := plot::Curve2d ([pr1(a,b,r,`θ`), pr2(a,b,r,`θ`)],
`θ` = 0 .. PI/2):
Consider the routine plot::Curve2d.
I "presume" that values of `θ` in the domain [0,PI/2] are chosen
progressively and passed to procedures pr1 and pr2 in the variable
`θ`, so that `θ` has a value by the time pr1 and pr2 are called
and `θ` 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 `θ` 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 `θ` 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
|
Posted: Tue Apr 25, 2006 7:39 am Post subject:
Re: Question about plotting in MuPAD
|
|
|
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,`θ`)
all by itself, too. Why should whatever(pr1(a,b,r,`θ`)) 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
|
Posted: Fri Apr 28, 2006 2:14 am Post subject:
Re: Question about plotting in MuPAD
|
|
|
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,`θ`)
all by itself, too. Why should whatever(pr1(a,b,r,`θ`)) 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
|
Posted: Fri Apr 28, 2006 2:14 am Post subject:
Re: Question about plotting in MuPAD
|
|
|
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,`θ`)
all by itself, too. Why should whatever(pr1(a,b,r,`θ`)) 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
|
Posted: Sat May 13, 2006 4:18 am Post subject:
Re: Question about plotting in MuPAD
|
|
|
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,`θ`)
all by itself, too. Why should whatever(pr1(a,b,r,`θ`)) 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 |
|
 |
|
|
The time now is Wed Jan 07, 2009 8:22 pm | All times are GMT
|
|
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
|
|