Message Boards Message Boards

0
|
2955 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

HornerForm doesn't produce expected form?

Posted 2 years ago

Hi, I have a number of complicated expressions "q", dependent on three symbolic variables "a", "b", "c" and "t". It should be possible to present all these expressions in the form:

q=a*p1+(p2+b*p3)*c

where p1, p2 and p3 are polynomials of variable "t" (in fact some of the expressions are already in this form). I need to extract these polynomials, from these expressions, and cast them into the Horner form. I tried something like:

hf[expr_]=HornerForm[expr,t];
Collectb[expr_]=Collect[expr,b,hf]; 
Collectc[expr_]=Collect[expr,c,Collectb]; 
Collect[q,a,Collectc]

but this does not produce the desired Horner form of the polynomials. What am I doing wrong?
Leslaw

POSTED BY: Leslaw Bieniasz
2 Replies
Posted 2 years ago

Please give a specific example. The following works as expected:

p1 = a + b t^2 + c t^3;
p2 = a + 6 b t + 11 c t^2;
p3 = a + 17 b t^2 + c t^3;
q = a p1 + (p2 + b p3) c;
HornerForm[q, t]
(* a^2 + a c + a b c + t (6 b c + t (a b + 17 b^2 c + 11 c^2 + (a c + b c^2) t)) *)
POSTED BY: Jim Baldwin

You must use delayed assignments hf[expr_]:=HornerForm[expr,t], otherwise HornerForm[expr,t] is evaluated immediately and it simply gives expr:

hf[expr_] = HornerForm[expr, t];
?hf
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract