0
|
6079 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
GROUPS:

# Cubic Equation Demonstration

Posted 10 years ago
 Dear, I saw the CDF example "Cubic Equation" at the Wolfram site http://demonstrations.wolfram.com/CubicEquation/. The author made available the Mathematica code in order the reader could learn a high level development. So I typed all the code (you can not copy because the code is in a .png file) and run to verify my typing. I verify many times but the code did not work well (it did not plot the zeros, inflection points and critical points). Bellow you can see the code and I ask you to help me to understand what happend. Manipulate[  Plot[a3 x^3 + a2 x^2 + a1 x + a0, {x, -2, 2}, PlotRange -> 10,   PlotLabel -> TraditionalForm[a3 x^3 + a2 x^2 + a1 x + a0],    PlotStyle -> Thickness[.005],   Epilog -> {     PointSize[.015],     (*KEY*)     {RGBColor[1, .26, .0], Point[{1.2, 7}]},    Text[Style["zeros", 12, Italic], {1.3, 7}, {-1, 0}],    {RGBColor[.12, .61, .78], Point[{1.2, 6}]},    Text[Style["critical points", 12, Italic], {1.3, 6}, {-1, 0}],    {RGBColor[.67, .75, .15], Point[{1.2, 5}]},    Text[Style["inflection points", 12, Italic], {1.3, 5}, {-1, 0}],    (*zeros*)    RGBColor[1, .26, .0],    If[Flatten[#] === {}, {},        Point[{#, Function[x, a3 x^3 + a2 x^2 + a1  x + a0][#]}] & /@                                    {x /. #}] &[{ToRules[       Quiet@Reduce[a3 x^3 + a2 x^2 + a1 x + a0 == 0, x, Reals]]}],    (*critical points*)    RGBColor[.12, .61, .78],    If[Flatten[#] === {}, {},        Point[{#, Function[x, a3 x^3 + a2 x^2 + a1 x + a0][#]}] & /@                                    {x /. #}] &[{ToRules[       Quiet@Reduce[3 x^2 a3 + 2 a2 x + a2 x^2 + a1 == 0, x, Reals]]}],    (*inflection points*)    RGBColor[.67, .75, .15],    If[Flatten[#] === {}, {},        Point[{#, Function[x, a3 x^3 + a2 x^2 + a1 x + a0][#]}] & /@                                    {x /. #}] &[{ToRules[       Quiet@Reduce[6 x a3 + 2 a2 x + 2 a2 == 0, x, Reals]]}]    }, ImageSize -> {500, 400}], {a3, -5, 5}, {a2, -5, 5}, {a1, -5,   5}, {a0, -5, 5}]Thank you,Ana
3 Replies
Sort By:
Posted 10 years ago
 The preview seems completely fine to me. Besides, I think the image is automatically generated from the notebook, so there isn't too much room for errors.
Posted 10 years ago
 It is not mine. I just copy. I open the .nb file. His preview is totally wrong. Thank you
Posted 10 years ago
 It is a typo, the original code has in several places (x /. #) while you have {x /. #} Also your second derivative isn't quite right, should be just 6 x a3 + 2 a2. There is a link to download a notebook, where it says 'Download Author Code' (not 'preview'), so it shouldn't be necessary to copy the code from the picture.