1
$\begingroup$

I am working on Mathematica just for few days and I am confused to plot the roots of a polynomial which coefficients are functions.

In Mathematica examples, I found some simple examples such as :

Plot[Root[#^5 + a # + 1 &, 1], {a, 0, 10}]

but when I want to plot real part the equation which I have mentioned below, it doesn't work.

DD[z_, y_] := z + y;

EE[z_, y_] := z^2 + y + 1;

H[z_, y_, x_] := x^2 + DD[z, y]*x + EE[z, y];

Plot[Re[Root[H[1, y, x]] &, 1]], {y, 0, 10}]

I am so thankful if anyone can help me, I should to fix it today and I am very sad about it.

$\endgroup$
  • $\begingroup$ Here is an example of plotting roots: Factoring a two variable polynomial in a special way $\endgroup$ – Artes Mar 13 at 11:32
  • $\begingroup$ Another one (more appropriate). $\endgroup$ – Artes Mar 13 at 11:58
  • 1
    $\begingroup$ Hi! You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is useful for learning how to format your questions and answers. You may also find this meta Q&A helpful $\endgroup$ – Michael E2 Mar 13 at 12:55
  • $\begingroup$ @Dear Artes, thank you so much $\endgroup$ – Arian Mar 14 at 9:32
  • $\begingroup$ @Dear Michael E2, thank you for your edit, it was the first time that I was writing and thanks for your helpful comment to write in correct style $\endgroup$ – Arian Mar 14 at 9:35
1
$\begingroup$

Use

Plot[Re[Root[H[1, y, #] &, 1]], {y, 0, 10}]

or

Plot[Re[Root[Function[x, H[1, y, x]], 1]], {y, 0, 10}]  

to get

enter image description here

Note: The first argument of Root should be a pure function.

| improve this answer | |
$\endgroup$
  • $\begingroup$ @Dear kglr, Thank you so much, the first code was OK, I just replaced x by hashtag $\endgroup$ – Arian Mar 13 at 11:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.