Maximizing a function in Mathematica - wolfram-mathematica

I am trying to Maximize this function with given constraints,
Maximize[1200 + 6.95 x11 + 1.95 x12 - 13.05 x13 + 11.95 x21 + 6.95 x22 -8.05 x23 + 14.95 x31 + 9.95 x32 - 5.05 x33,
x11 + x12 + x13 + x21 + x22 + x23 + x31 + x32 + x33 <= 28000 &&
x11 + x21 + x31 >= 6000 &&
x12 + x22 + x32 >= 4000 &&
x13 + x23 + x33 >= 2000 &&
2 x11 - 4 x21 - 2 x31 >= 0 &&
4 x12 - 2 x22 >= 0 &&
6 x13 - 2 x33 >= 0 &&
- 0.5 x11 + x21 + 2 x31 <= 0 &&
- 1.5 x12 + x32 <= 0 &&
- 0.5 x13 + x23 + 2 x33 <= 0 &&
x11 >= 0 && x12 >= 0 && x13 >= 0 && x21 >= 0 && x22 >= 0 &&
x23 >= 0 && x31 >= 0 && x32 >= 0 && x33 >= 0, {x11, x12, x13, x21,
x22, x32, x31, x32, x33}]
I don't know if this is my coding or just a big problem, but Mathematica is just giving me this back. Is there anyone who knows why?

Related

Proving Big theta for polynomials using quantificational definition

How can I prove Big Theta using quantificational definition? I know that u have to find 2 constants such that c1*g(n)<= f(n)<= c2*g(n)- but how do you find these constants?
Could anyone help me prove the following to show an example 5x3 − 7x2 + 5x + 1 = Θ(x3)?
Let's assume x > 0, which is usually what we have.
5x^3 − 7x^2 + 5x + 1 <= 5x^3 + 5x + 1
<= 5x^3 + 5x^3 + x^3 ; x >= 1
= 11x^3
On the other hand
5x^3 − 7x^2 + 5x + 1 >= 5x^3 - 7x^2
>= 5x^3 - 4x^3 ; if 7x^2 <= 4x3, i.e. x >= 7/4
= x^3
In conclusion, for x >= 7/4 we have:
x^3 <= (5x^3 − 7x^2 + 5x + 1) <= 11x^3
and we are done.

Rotate an image with bicubic interpolation without imrotate

I have implemented a code for image warping using bilinear interpolation:
Matlab image rotation
I would like to improve the code by using bicubic interpolation to rotate the image WITHOUT using the built-in functions like imrotate or imwarp and interp functions in MATLAB.
I successfully managed to implement a full working example.
Code is based on Anna1994's code: Matlab image rotation
Biqubic code is also based on Java (and C++) implementation posted here: http://www.paulinternet.nl/?page=bicubic
The following code applies image rotation example using biqubic interpolation:
function BicubicInterpolationTest()
close all;
% clear all;
img = 'cameraman.tif';
input_image =double(imread(img))./255;
H=size(input_image,1); % height
W=size(input_image,2); % width
th=120*pi/180; %Rotate 120 degrees
s0 = 2;
s1 = 2;
x0 = -W/2;
x1 = -H/2;
T=[1 0 x0 ; ...
0 1 x1 ; ...
0 0 1];
RST = [ (s0*cos(th)) (-s1*sin(th)) ((s0*x0*cos(th))-(s1*x1*sin(th))); ...
(s0*sin(th)) (s1*cos(th)) ((s0*x0*sin(th))+(s1*x1*cos(th))); ...
0 0 1];
M=inv(T)*RST;
N = inv(M);
output_image=zeros(H,W,size(input_image,3));
for i=1:W
for j=1:H
x = [i ; j ; 1];
y = N * x;
a = y(1)/y(3);
b = y(2)/y(3);
%Nearest neighbor
% a = round(a);
% b = round(b);
%Bilinear interpolation (applies RGB image):
% x1 = floor(a);
% y1 = floor(b);
% x2 = x1 + 1;
% y2 = y1 + 1;
% if ((x1 >= 1) && (y1 >= 1) && (x2 <= W) && (y2 <= H))
% %Load 2x2 pixels
% i11 = input_image(y1, x1, :); %Top left pixel
% i21 = input_image(y2, x1, :); %Bottom left pixel
% i12 = input_image(y1, x2, :); %Top right pixel
% i22 = input_image(y2, x2, :); %Bottom right pixel
%
% %Interpolation wieghts
% dx = x2 - a;
% dy = y2 - b;
%
% %Bi-lienar interpolation
% output_image(j, i, :) = i11*dx*dy + i21*dx*(1-dy) + i12*(1-dx)*dy + i22*(1-dx)*(1-dy);
% end
x1 = floor(a);
y1 = floor(b);
%Bicubic interpolation (applies grayscale image)
if ((x1 >= 2) && (y1 >= 2) && (x1 <= W-2) && (y1 <= H-2))
%Load 4x4 pixels
P = input_image(y1-1:y1+2, x1-1:x1+2);
%Interpolation wieghts
dx = a - x1;
dy = b - y1;
%Bi-bicubic interpolation
output_image(j, i) = bicubicInterpolate(P, dx, dy);
end
end
end
imshow(output_image);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Verify implementation by comparing with Matalb build in function imwarp:
tform = affine2d(M');
ref_image = imwarp(input_image, tform, 'OutputView', imref2d(size(input_image)), 'Interp', 'cubic');
figure;imshow(ref_image)
figure;imshow(output_image - ref_image)
max_diff = max(abs(output_image(:) - ref_image(:)));
disp(['Maximum difference from imwarp = ', num2str(max_diff)]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%http://www.paulinternet.nl/?page=bicubic
%double cubicInterpolate (double p[4], double x) {
% return p[1] + 0.5 * x*(p[2] - p[0] + x*(2.0*p[0] - 5.0*p[1] + 4.0*p[2] - p[3] + x*(3.0*(p[1] - p[2]) + p[3] - p[0])));
%}
function q = cubicInterpolate(p, x)
q = p(2) + 0.5 * x*(p(3) - p(1) + x*(2.0*p(1) - 5.0*p(2) + 4.0*p(3) - p(4) + x*(3.0*(p(2) - p(3)) + p(4) - p(1))));
%http://www.paulinternet.nl/?page=bicubic
% double bicubicInterpolate (double p[4][4], double x, double y) {
% double arr[4];
% arr[0] = cubicInterpolate(p[0], y);
% arr[1] = cubicInterpolate(p[1], y);
% arr[2] = cubicInterpolate(p[2], y);
% arr[3] = cubicInterpolate(p[3], y);
% return cubicInterpolate(arr, x);
% }
function q = bicubicInterpolate(p, x, y)
q1 = cubicInterpolate(p(1,:), x);
q2 = cubicInterpolate(p(2,:), x);
q3 = cubicInterpolate(p(3,:), x);
q4 = cubicInterpolate(p(4,:), x);
q = cubicInterpolate([q1, q2, q3, q4], y);
I verified implementation by comparing to Matalb build in function imwarp
Result:
The following example uses the "CachedBicubicInterpolator" code version, and also supports RGB image:
function BicubicInterpolationTest2()
close all;
% clear all;
img = 'peppers.png';
input_image = double(imread(img))./255;
H=size(input_image,1); % height
W=size(input_image,2); % width
th=120*pi/180; %Rotate 120 degrees
s0 = 0.8;
s1 = 0.8;
x0 = -W/2;
x1 = -H/2;
T=[1 0 x0 ; ...
0 1 x1 ; ...
0 0 1];
RST = [ (s0*cos(th)) (-s1*sin(th)) ((s0*x0*cos(th))-(s1*x1*sin(th))); ...
(s0*sin(th)) (s1*cos(th)) ((s0*x0*sin(th))+(s1*x1*cos(th))); ...
0 0 1];
M=inv(T)*RST;
N = inv(M);
output_image=zeros(H,W,size(input_image,3));
for i=1:W
for j=1:H
x = [i ; j ; 1];
y = N * x;
a = y(1)/y(3);
b = y(2)/y(3);
x1 = floor(a);
y1 = floor(b);
%Bicubic interpolation (applies grayscale image)
if ((x1 >= 2) && (y1 >= 2) && (x1 <= W-2) && (y1 <= H-2))
%Load 4x4 pixels
P = input_image(y1-1:y1+2, x1-1:x1+2, :);
%Interpolation wieghts
dx = a - x1;
dy = b - y1;
%Bi-bicubic interpolation
output_image(j, i, :) = bicubicInterpolate(P, dx, dy);
end
end
end
imshow(output_image);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Verify implementation by comparing with Matalb build in function imwarp:
tform = affine2d(M');
ref_image = imwarp(input_image, tform, 'OutputView', imref2d(size(input_image)), 'Interp', 'cubic');
figure;imshow(ref_image)
figure;imshow(abs(output_image - ref_image), []);impixelinfo
max_diff = max(abs(output_image(:) - ref_image(:)));
disp(['Maximum difference from imwarp = ', num2str(max_diff)]);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [p0, p1, p2, p3] = list4(P)
P = squeeze(P);
p0 = P(1, :);
p1 = P(2, :);
p2 = P(3, :);
p3 = P(4, :);
%http://www.paulinternet.nl/?page=bicubic
% public void updateCoefficients (double[][] p) {
% a00 = p[1][1];
% a01 = -.5*p[1][0] + .5*p[1][2];
% a02 = p[1][0] - 2.5*p[1][1] + 2*p[1][2] - .5*p[1][3];
% a03 = -.5*p[1][0] + 1.5*p[1][1] - 1.5*p[1][2] + .5*p[1][3];
% a10 = -.5*p[0][1] + .5*p[2][1];
% a11 = .25*p[0][0] - .25*p[0][2] - .25*p[2][0] + .25*p[2][2];
% a12 = -.5*p[0][0] + 1.25*p[0][1] - p[0][2] + .25*p[0][3] + .5*p[2][0] - 1.25*p[2][1] + p[2][2] - .25*p[2][3];
% a13 = .25*p[0][0] - .75*p[0][1] + .75*p[0][2] - .25*p[0][3] - .25*p[2][0] + .75*p[2][1] - .75*p[2][2] + .25*p[2][3];
% a20 = p[0][1] - 2.5*p[1][1] + 2*p[2][1] - .5*p[3][1];
% a21 = -.5*p[0][0] + .5*p[0][2] + 1.25*p[1][0] - 1.25*p[1][2] - p[2][0] + p[2][2] + .25*p[3][0] - .25*p[3][2];
% a22 = p[0][0] - 2.5*p[0][1] + 2*p[0][2] - .5*p[0][3] - 2.5*p[1][0] + 6.25*p[1][1] - 5*p[1][2] + 1.25*p[1][3] + 2*p[2][0] - 5*p[2][1] + 4*p[2][2] - p[2][3] - .5*p[3][0] + 1.25*p[3][1] - p[3][2] + .25*p[3][3];
% a23 = -.5*p[0][0] + 1.5*p[0][1] - 1.5*p[0][2] + .5*p[0][3] + 1.25*p[1][0] - 3.75*p[1][1] + 3.75*p[1][2] - 1.25*p[1][3] - p[2][0] + 3*p[2][1] - 3*p[2][2] + p[2][3] + .25*p[3][0] - .75*p[3][1] + .75*p[3][2] - .25*p[3][3];
% a30 = -.5*p[0][1] + 1.5*p[1][1] - 1.5*p[2][1] + .5*p[3][1];
% a31 = .25*p[0][0] - .25*p[0][2] - .75*p[1][0] + .75*p[1][2] + .75*p[2][0] - .75*p[2][2] - .25*p[3][0] + .25*p[3][2];
% a32 = -.5*p[0][0] + 1.25*p[0][1] - p[0][2] + .25*p[0][3] + 1.5*p[1][0] - 3.75*p[1][1] + 3*p[1][2] - .75*p[1][3] - 1.5*p[2][0] + 3.75*p[2][1] - 3*p[2][2] + .75*p[2][3] + .5*p[3][0] - 1.25*p[3][1] + p[3][2] - .25*p[3][3];
% a33 = .25*p[0][0] - .75*p[0][1] + .75*p[0][2] - .25*p[0][3] - .75*p[1][0] + 2.25*p[1][1] - 2.25*p[1][2] + .75*p[1][3] + .75*p[2][0] - 2.25*p[2][1] + 2.25*p[2][2] - .75*p[2][3] - .25*p[3][0] + .75*p[3][1] - .75*p[3][2] + .25*p[3][3];
% }
% public double getValue (double x, double y) {
% double x2 = x * x;
% double x3 = x2 * x;
% double y2 = y * y;
% double y3 = y2 * y;
%
% return (a00 + a01 * y + a02 * y2 + a03 * y3) +
% (a10 + a11 * y + a12 * y2 + a13 * y3) * x +
% (a20 + a21 * y + a22 * y2 + a23 * y3) * x2 +
% (a30 + a31 * y + a32 * y2 + a33 * y3) * x3;
% }
function q = bicubicInterpolate(P, x, y)
[p00, p01, p02, p03] = list4(P(1, :, :));
[p10, p11, p12, p13] = list4(P(2, :, :));
[p20, p21, p22, p23] = list4(P(3, :, :));
[p30, p31, p32, p33] = list4(P(4, :, :));
a00 = p11;
a01 = -.5*p10 + .5*p12;
a02 = p10 - 2.5*p11 + 2*p12 - .5*p13;
a03 = -.5*p10 + 1.5*p11 - 1.5*p12 + .5*p13;
a10 = -.5*p01 + .5*p21;
a11 = .25*p00 - .25*p02 - .25*p20 + .25*p22;
a12 = -.5*p00 + 1.25*p01 - p02 + .25*p03 + .5*p20 - 1.25*p21 + p22 - .25*p23;
a13 = .25*p00 - .75*p01 + .75*p02 - .25*p03 - .25*p20 + .75*p21 - .75*p22 + .25*p23;
a20 = p01 - 2.5*p11 + 2*p21 - .5*p31;
a21 = -.5*p00 + .5*p02 + 1.25*p10 - 1.25*p12 - p20 + p22 + .25*p30 - .25*p32;
a22 = p00 - 2.5*p01 + 2*p02 - .5*p03 - 2.5*p10 + 6.25*p11 - 5*p12 + 1.25*p13 + 2*p20 - 5*p21 + 4*p22 - p23 - .5*p30 + 1.25*p31 - p32 + .25*p33;
a23 = -.5*p00 + 1.5*p01 - 1.5*p02 + .5*p03 + 1.25*p10 - 3.75*p11 + 3.75*p12 - 1.25*p13 - p20 + 3*p21 - 3*p22 + p23 + .25*p30 - .75*p31 + .75*p32 - .25*p33;
a30 = -.5*p01 + 1.5*p11 - 1.5*p21 + .5*p31;
a31 = .25*p00 - .25*p02 - .75*p10 + .75*p12 + .75*p20 - .75*p22 - .25*p30 + .25*p32;
a32 = -.5*p00 + 1.25*p01 - p02 + .25*p03 + 1.5*p10 - 3.75*p11 + 3*p12 - .75*p13 - 1.5*p20 + 3.75*p21 - 3*p22 + .75*p23 + .5*p30 - 1.25*p31 + p32 - .25*p33;
a33 = .25*p00 - .75*p01 + .75*p02 - .25*p03 - .75*p10 + 2.25*p11 - 2.25*p12 + .75*p13 + .75*p20 - 2.25*p21 + 2.25*p22 - .75*p23 - .25*p30 + .75*p31 - .75*p32 + .25*p33;
x2 = x * x;
x3 = x2 * x;
y2 = y * y;
y3 = y2 * y;
% q = (a00 + a01 * y + a02 * y2 + a03 * y3) +...
% (a10 + a11 * y + a12 * y2 + a13 * y3) * x +...
% (a20 + a21 * y + a22 * y2 + a23 * y3) * x2 +...
% (a30 + a31 * y + a32 * y2 + a33 * y3) * x3;
q = (a00 + a01 * x + a02 * x2 + a03 * x3) +...
(a10 + a11 * x + a12 * x2 + a13 * x3) * y +...
(a20 + a21 * x + a22 * x2 + a23 * x3) * y2 +...
(a30 + a31 * x + a32 * x2 + a33 * x3) * y3;
Result:

Reduce function syntax in Mathematica

I would like to know whats wrong with my code. I am trying to solve system of non-linear equations (initially in wolfram but the command was too long) in Mathematica:
Reduce[Pi*(h^2 + 2*R*(R - r))/sqrt (h^2 + (R - r)^2) - 2*x*Pi/3*h*R -
x*Pi/3*h*r == 0 &&
Pi*(h^2 + 2*r*(r - R))/sqrt (h^2 + (R - r)^2) + 2*Pi*r -
x*Pi/3*h*R - 2*x*Pi/3*h*r == 0 &&
Pi*h*(r + R)/sqrt (h^2 + (R - r)^2) - x*Pi/3*R^2 - x*Pi/3*R*r -
x*Pi/3*r^2 == 0 && -Pi/3*h*(R^2 + R*r + r^2) + 1 == 0, {R, r, h,
x}];
Do you know how to retype it and solve these equations? I tried to type it according to documentation, but I evidently made some mistake...
These are the original equations (in LaTeX, I dont know if they will show correctly here:
\begin{equation*}
\frac{\partial}{\partial R} L(R, r, h, \lambda) = \frac{\pi(h^2 + 2R(R-r))}{\sqrt{h^2 + (R - r)^2}} - 2\lambda \frac{\pi}{3}hR - \lambda \frac{\pi}{3}hr= 0
\end{equation*}
\begin{equation*}
\frac{\partial}{\partial r} L(R, r, h, \lambda) = \frac{\pi(h^2 + 2r(r-R))}{\sqrt{h^2 + (R - r)^2}} + 2\pi r - \lambda \frac{\pi}{3}hR - 2\lambda \frac{\pi}{3}hr= 0
\end{equation*}
\begin{equation*}
\frac{\partial}{\partial h} L(R, r, h, \lambda) = \frac{\pi h(r + R)}{\sqrt{h^2 + (R - r)^2}} - \lambda \frac{\pi}{3}R^2 - \lambda \frac{\pi}{3}Rr - \lambda \frac{\pi}{3}r^2= 0
\end{equation*}
\begin{equation*}
\frac{\partial}{\partial \lambda} L(R, r, h, \lambda) = - \frac{\pi}{3} h (R^2 + Rr + r^2) + 1 = 0
\end{equation*}
edit:
I corrected pi to PI, now it started evaluating so maybe it was the mistake...It just takes a very long time...
You have to learn at least the basics. Go to Help->Documentation Center and click on the book in the search bar. There is everything explained from the very start.
As already pointed out in the comments, all functions and built-in symbols start with a capital letter. Therefore your call should be
Reduce[Pi*(h^2 + 2*R*(R - r))/Sqrt[h^2 + (R - r)^2] - 2*x*Pi/3*h*R -
x*Pi/3*h*r == 0 &&
Pi*(h^2 + 2*r*(r - R))/Sqrt[h^2 + (R - r)^2] + 2*Pi*r -
x*Pi/3*h*R - 2*x*Pi/3*h*r == 0 &&
Pi*h*(r + R)/Sqrt[h^2 + (R - r)^2] - x*Pi/3*R^2 - x*Pi/3*R*r -
x*Pi/3*r^2 == 0 && -Pi/3*h*(R^2 + R*r + r^2) + 1 == 0, {R, r, h,
x}]

Eigenvalue calculation of a eigenfunction from a differential equation using mathematica [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Suppose, I have an differential equation like this one:
mu1 u1[x] - u1''[x] - 10 u1[x] == 0
where mu1 is the eigenvalue and u1 is the eigenfuntion. Now, How can i calculate the eigenvalue mu1 numerically??? Can anyone help me out with this problem??
I'm assuming you want to solve something like
u1''[x] + 10 u1[x] == mu1 u1[x]
with boundary conditions
u1[x0] == 0; u1[x1] == 0; u1'[x0] =!= 0
for some x0 < x1. One way to do that is to first solve the differential equation plus the boundary conditions at x0, e.g.
sol = DSolve[{mu1 u1[x] - u1''[x] - 10 u1[x] == 0, u1[x0] == 0, u1'[x0] == 1}, u1, x][[1]]
which gives as output
{u1 -> Function[{x}, -((E^(-Sqrt[-10 + mu1] x - Sqrt[-10 + mu1] x0)
(-E^(2 Sqrt[-10 + mu1] x) + E^(2 Sqrt[-10 + mu1] x0)))/(2 Sqrt[-10 + mu1]))]}
We can then use this solution to find mu1 such that the boundary condition at x1 is satisfied:
sol1 = Solve[{u1[x1] == 0 /. sol[[1]], x1 > x0}, mu1, MaxExtraConditions -> All]
From which we find
{{mu1 -> ConditionalExpression[(10 x0^2 - 20 x0 x1 + 10 x1^2 - 4 \[Pi]^2 C[1]^2)/(
x0^2 - 2 x0 x1 + x1^2),
x0 \[Element] Reals && C[1] \[Element] Integers && C[1] >= 1 && x1 > x0]},
{mu1 -> ConditionalExpression[(-\[Pi]^2 + 10 x0^2 - 20 x0 x1 + 10 x1^2 -
4 \[Pi]^2 C[1] - 4 \[Pi]^2 C[1]^2)/(x0^2 - 2 x0 x1 + x1^2),
x0 \[Element] Reals && C[1] \[Element] Integers && C[1] >= 0 && x1 > x0]}}

Symbolical mathematical problem (mathematica)

I got given this question in my tutorial for which I could do parts a) and b). Do you have
any ideas for part c)?
Question :
Symbolically solve the following equation for the quantity r=y/x:
3/y^4==3/x^4+a/(x+2y)^4
(a) Use Map or Thread to perform the substitution y->r x to both sides of the equation.
ans:
3/(r^4 x^4) == 3/x^4 + a/(x + 2 r x)^4
(b) Plot the solutions for a\[Element]{-1,1}. For a\[Element]{-1,1}, how many solutions are real valued? Does this number depend on a ?
ans: Graph and 4 solutions and no its doesn't depend on `a`.
(c) Construct numerical solutions by letting a run between -1 and 1 with steps of 0.02 in your solutions obtained above. Use Cases to choose solutions whenever they are real, and using ListPlot, plot all the real solutions occurring in the interval a\[Element]{-1,1}.
Ans : no idea.
You can shortcut a) and b) by using Eliminate. You can also ask Mathematica to solve equations over reals. (In v8):
In[538]:= eq =
Eliminate[3/y^4 == 3/x^4 + a/(x + 2 y)^4 && r == y/x, {x, y}]
Out[538]= -24 r - 72 r^2 - 96 r^3 + (-45 + a) r^4 + 24 r^5 + 72 r^6 +
96 r^7 + 48 r^8 == 3
In[539]:= r /. Solve[eq && -1 < a < 1, r, Reals]
Out[539]= {ConditionalExpression[
Root[-3 - 24 #1 - 72 #1^2 - 96 #1^3 + (-45 + a) #1^4 + 24 #1^5 +
72 #1^6 + 96 #1^7 + 48 #1^8 &, 1], -1 < a < 0 ||
0 < a < Root[-184528125 + 267553125 #1 + 11238750 #1^2 +
110250 #1^3 - 225 #1^4 + #1^5 &, 1] ||
Root[-184528125 + 267553125 #1 + 11238750 #1^2 + 110250 #1^3 -
225 #1^4 + #1^5 &, 1] < a < 1],
ConditionalExpression[
Root[-3 - 24 #1 - 72 #1^2 - 96 #1^3 + (-45 + a) #1^4 + 24 #1^5 +
72 #1^6 + 96 #1^7 + 48 #1^8 &, 2], -1 < a < 0 ||
0 < a < Root[-184528125 + 267553125 #1 + 11238750 #1^2 +
110250 #1^3 - 225 #1^4 + #1^5 &, 1] ||
Root[-184528125 + 267553125 #1 + 11238750 #1^2 + 110250 #1^3 -
225 #1^4 + #1^5 &, 1] < a < 1],
ConditionalExpression[
Root[-3 - 24 #1 - 72 #1^2 - 96 #1^3 + (-45 + a) #1^4 + 24 #1^5 +
72 #1^6 + 96 #1^7 + 48 #1^8 &, 3],
0 < a < Root[-184528125 + 267553125 #1 + 11238750 #1^2 +
110250 #1^3 - 225 #1^4 + #1^5 &, 1]],
ConditionalExpression[
Root[-3 - 24 #1 - 72 #1^2 - 96 #1^3 + (-45 + a) #1^4 + 24 #1^5 +
72 #1^6 + 96 #1^7 + 48 #1^8 &, 4],
0 < a < Root[-184528125 + 267553125 #1 + 11238750 #1^2 +
110250 #1^3 - 225 #1^4 + #1^5 &, 1]]}
You can then plot the resulting solution:
The Out[539] gives you exact algebraic solutions along with conditions when they are real. So the maximum number of real solutions is 4 and occurs when a is between zero and Root[-184528125 + 267553125 #1 + 11238750 #1^2 + 110250 #1^3 - 225 #1^4 + #1^5 &, 1]
Now, let's get to part c). You should use NSolve to construct all solutions. Then, as suggested Cases to extract real solutions, and then ListPlot:
Table[Thread[{a,
Cases[r /. NSolve[eq, r], r_ /; Im[r] == 0]}], {a, -1, 1,
0.02}] // ListPlot

Resources