Mathematica Mathematica not supporting graphs code is as

AI Thread Summary
The discussion revolves around issues encountered while plotting a complex graph using Mathematica. The original poster faced challenges due to the appearance of imaginary components in their calculations, which led to Mathematica not supporting the graph. Key points include the need for proper variable definitions, as the case sensitivity of Mathematica was highlighted—specifically, the distinction between "U" and "u." Users advised breaking down the complex code into simpler parts for troubleshooting and testing. After several exchanges, the poster successfully generated the graph by correcting the code and using appropriate Mathematica syntax, including the correct representation of the exponential function. Additionally, a new query arose regarding solving a system of linear equations using Mathematica, indicating an ongoing exploration of the software's capabilities.
adnan jahan
Messages
93
Reaction score
0
mathematica not supporting graphs,,,code is as



Dear Fellow I was trying to make graph using mathematica but because of imaginary appearing mathematica is not supporting don't now how to evaluate the graph,,where code for mathematica is as

rho = 1.74*10^(3);
lambda = 9.4*10^(11);
mue = 4.0*10^(11);
T0 = 293;
k = 0.6*10^(-2);
K = 1*10^(11);
K1 = 0.3*10^(-3);
CE = 383.1;
gamma = 0.779*10^(-8);
gamma1 = 0.1*10^(-5);
gamma11 = 0.5*10^(-3);
j = 0.2*10^(-21);
alpha0 = 0.779*10^(-4);
lambda0 = 0.5*10^(11);
lambda1 = 0.2*10^(11);
umega = 2;
t = 0.1;
aphat = 1.78*10^(-5);
f = 0.5;
p = 10;
b = 2;
w0 = -2;
xi = 1;
z = 0.1;
w = w0 + xi;
c2 = mue/rho;
c3 = (2*alpha0)/(3*rho*j);
c4 = (2*lambda1)/(9*rho*j);
c5 = (2*lambda0)/(9*rho*j);
c6 = (2*gamma11)/(9*rho*j);
w1 = (rho*CE*c2)/K1;
epsilon1 = ((gamma1^2)*T0)/(rho^2*CE*c2);
epsilon2 = K1/(rho*CE*c2);
epsilon3 = (K*w1)/(rho*CE*c2);
epsilon4 = (gamma1*gamma11*T0)/(rho^2*CE*w1*c2);
epsilon = epsilon2 + epsilon3*w;
c1 = (lambda + 2*mue + k)/rho;
a0 = (c2)/(c1);
a1 = lambda0/(lambda + 2*mue + k);
a2 = (rho*c2)/(mue + k);
a3 = k/(mue + k);
a4 = (k*c2)/(gamma*w1^2);
a5 = (rho*j*c2)/gamma;
a6 = (c3)/(c2);
a7 = (c4)/(w1^2);
a8 = (c5)/(w1^2);
a9 = (2*gamma11*c2)/(9*gamma1*j*w1^2);
A1 = b^2 + a0*(w^2 - umega^2);
A2 = 2*umega*a0*w;
A3 = b^2 + a2*(w^2 - umega^2);
A4 = 2*umega*a2*w;
A5 = b^2 + 2*a4 + a5*w^2;
A6 = b^2*a6 + a7 + w^2;
g1 = epsilon4*w - a1*epsilon1*w^2;
g2 = -epsilon4*w*A1 + a1*epsilon1*w^2*b^2;
g3 = a1*epsilon*b^2 + a1*w^2 + a0*epsilon4*w;
g4 = A2*epsilon4*w;
g5 = A3 + A5 - a3*a4;
g6 = A3*A5 - a3*a4*b^2;
g7 = g2 - g1*g5;
g8 = -g2*g5 + g1*g6 + g4*A4;
g9 = g2*g6 - g4*A4*A5;
g10 = -g3 - a1*epsilon*g5;
g11 = g3*g5 + a1*epsilon*g6;
g12 = g3*g6;
g13 = a6*(epsilon*b^2 + w^2) + A6*epsilon;
g14 = epsilon4*a9*w + A6*(epsilon*b^2 + w^2);
g15 = epsilon1*a6*w^2*b^2 + A6*epsilon1*w^2 - a8*epsilon4*w;
g16 = epsilon4*a8*w*b^2 - epsilon1*w^2*A6*b^2;
g17 = epsilon*(a6*g1 + a1*epsilon1*w^2*a6);
g18 = -a6*(epsilon*g7 + epsilon1*w^2*g10) + g13*g1 + a1*epsilon*g15;
g19 = a6*(epsilon*g8 + epsilon1*w^2*g11) - g13*g7 + g14*g1 -
a1*epsilon*g16 - g10*g15;
g20 = -a6*epsilon*g9 + g13*g8 - g14*g7 + g10*g16 + g11*g15 +
g12*a6*epsilon1*w^2;
g21 = -g13*g9 + g14*g8 - g11*g16 + g12*g15;
g22 = -g14*g9 - g12*g16;
a10 = lambda_ 0/(rho*c2);
a11 = c1/c2;
a12 = lambda/(rho*c2);
a13 = (mue + k)/(rho*c2);
a14 = (k)/(rho*c2);
a15 = (gamma*w1^2)/(rho*c2^4);
a16 = (alpha_ 0*w1)/(rho*c2^(3/2));
k1 = +0.0024
k2 = +0.0018 - 0.0015*I
k3 = 0.0018 + 0.0015*I
k4 = 0.0003 + 0.0019*I
k5 = 0.0003 - 0.0019*I
H21 = (A4*(k1^2 - A5))/(k1^4 - k1^2*g5 + g6);
H22 = (A4*(k2^2 - A5))/(k2^4 - k2^2*g5 + g6);
H23 = (A4*(k3^2 - A5))/(k3^4 - k3^2*g5 + g6);
H24 = (A4*(k4^2 - A5))/(k4^4 - k4^2*g5 + g6);
H25 = (A4*(k5^2 - A5))/(k5^4 - k5^2*g5 + g6);
H11 = (k1^4*a6*epsilon1*w^2 - k1^2*g15 - g16)/(k1^4*a6*epsilon -
k1^2*g13 + g14);
H12 = (k2^4*a6*epsilon1*w^2 - k2^2*g15 - g16)/(k2^4*a6*epsilon -
k2^2*g13 + g14);
H13 = (k3^4*a6*epsilon1*w^2 - k3^2*g15 - g16)/(k3^4*a6*epsilon -
k3^2*g13 + g14);
H14 = (k4^4*a6*epsilon1*w^2 - k4^2*g15 - g16)/(k4^4*a6*epsilon -
k4^2*g13 + g14);
H15 = (k5^4*a6*epsilon1*w^2 - k5^2*g15 - g16)/(k5^4*a6*epsilon -
k5^2*g13 + g14);
H31 = -((a4*A4*(k1^2 - b^2))/(k1^4 - k1^2*g5 + g6));
H32 = -((a4*A4*(k2^2 - b^2))/(k2^4 - k2^2*g5 + g6));
H33 = -((a4*A4*(k3^2 - b^2))/(k3^4 - k3^2*g5 + g6));
H34 = -((a4*A4*(k4^2 - b^2))/(k4^4 - k4^2*g5 + g6));
H35 = -((a4*A4*(k5^2 - b^2))/(k5^4 - k5^2*g5 + g6));
H41 = (a8*(k1^6 - b^2) - a9*H11)/(a6*k1^2 - A6);
H42 = (a8*(k2^6 - b^2) - a9*H12)/(a6*k2^2 - A6);
H43 = (a8*(k3^6 - b^2) - a9*H13)/(a6*k3^2 - A6);
H44 = (a8*(k4^6 - b^2) - a9*H14)/(a6*k4^2 - A6);
H45 = (a8*(k5^6 - b^2) - a9*H15)/(a6*k5^2 - A6);
H61 = a10*H41 - k1*a11*(-k1 + I*b*H21) + I*b*a12*(I*b + k1*H21) - H11;
H62 = a10*H42 - k2*a11*(-k2 + I*b*H22) + I*b*a12*(I*b + k2*H22) - H12;
H63 = a10*H43 - k3*a11*(-k3 + I*b*H23) + I*b*a12*(I*b + k3*H23) - H13;
H64 = a10*H44 - k4*a11*(-k4 + I*b*H24) + I*b*a12*(I*b + k4*H24) - H14;
H65 = a10*H45 - k5*a11*(-k5 + I*b*H25) + I*b*a12*(I*b + k5*H25) - H15;
H71 = I*b*(I*b*H21 - k1) - k1*a13*(I*b + H21*k1) + a14*H31;
H72 = I*b*(I*b*H22 - k2) - k2*a13*(I*b + H22*k2) + a14*H32;
H73 = I*b*(I*b*H23 - k3) - k3*a13*(I*b + H21*k3) + a14*H33;
H74 = I*b*(I*b*H24 - k4) - k4*a13*(I*b + H24*k4) + a14*H34;
H75 = I*b*(I*b*H25 - k5) - k5*a13*(I*b + H25*k5) + a14*H35;
M1 = 8.9842 10^045 + 6.2942 10^(046) I
M2 = 6.9622 10^046 - 5.3668 10^(046) I
M3 = 2.1724 10^046 + 3.7184 10^(046) I
M4 = -9.1931*10^046 + 7.5101 10^(046) I
M5 = -8.3987*10^045 - 1.2156 10^(047) I
U1 = (-k1 + I*b*H21)*M1*e^(-k1*x) + (-k2 + I*b*H22)*M2*
e^(-k2*x) + (-k3 + I*b*H23)*M3*e^(-k3*x) + (-k4 + I*b*H24)*M4*
e^(-k4*x) + (-k5 + I*b*H25)*M5*e^(-k5*x);
U = U1*e^(w*t + I*b*z);
Plot[Re, {x, 0, 5}],
any support in which I can find graph will be appreciated
 
Physics news on Phys.org


Have you defined u? I see where you defined U, but not u.

FYI, this is a horrible mess. You need to start with something simple and gradually build up to something complicated.
 


yes, U=U1 * e^(w*t+Ibz),
basically i did it on MATLAB and found graph now converted the code related to mathematica because want to confirm it,,,,but mathematica is not supporting
 


Yes, I saw that U was defined, but I never saw where u was defined. You are plotting u, not U. Remember, Mathematica is case sensitive. It is not Mathematica's fault that you are asking it to plot something you haven't defined.
 


oopps sory ,,that is "U" not "u"
 


Then there is a problem in your definition of U. For example:

Plot[Re[Exp[-I x]], {x, 0, 5}]

plots fine. So there is not a problem with Plot.
 


In code it is U,,, and U is still not working
 


Is it possible that mathematica is not plotting because the complexity level is high??
 


adnan jahan said:
In code it is U,,, and U is still not working
Yes U is very messy, I am not surprised it is not working. The problem is your definition of U, not a problem with Plot.

If you evaluate
U /. x->1
do you get what you expect?
 
  • #10


adnan jahan said:
Is it possible that mathematica is not plotting because the complexity level is high??
I doubt it. Much more likely you did not correctly define U because the complexity level is high. You should break your code down into smaller chunks and test each chunk to make sure that it is correct at each step. What you have written is a mess.
 
  • #11


yap it is making graph of simple complex ,,,,and even in my last research paper I have plotted for a complex number but this is not working ...

I will make the code bit simple by using mathematica symbls then I will chk what results are,,,
 
  • #12


and I will reply after confirming that,,, thanku so much for your support "DALESPAM"
 
  • #13


Welcome, sorry I cannot help you troubleshoot U other than general advice to break things up and test each small piece.
 
  • #14


e is not the same as e^1 in Mathematica. You need to either specify E or Esc e e Esc. That's one problem, also the way you defined u, you need to make the substitution U/.x->myvariable. So try changing the last part to:

Code:
U1 = (-k1 + I*b*H21)*M1*E^(-k1*x) + (-k2 + I*b*H22)*M2*
    E^(-k2*x) + (-k3 + I*b*H23)*M3*E^(-k3*x) + (-k4 + I*b*H24)*M4*
    E^(-k4*x) + (-k5 + I*b*H25)*M5*E^(-k5*x);
U = U1*E^(w*t + I*b*z);
Plot[Re[U /. x -> x], {x, 1, 5}]
 
  • #15


Dear Fellows by your support and encouragement I successfully draw the graph in mathematica,,,If corrected form is required then do contact,

Thanks to all of you
 
  • #16


How I can find solution of system of linear equation using mathematica??

as,35x1+45x2+90x3=-2
5x1+6x2-3x3=0
10x1+12x2+15x3=5
need to find the values of x1,x2 and x3 using mathematica
 
Back
Top