Why I cannot compute stress terms correctly? - wolfram-mathematica

I am new to mathematica and I am trying to write a simple code to compute the stress and strains.
I can compute the strain.
I am trying to calculate stress, using the Hooke's Law:
disp = {{u1[x, y, z], u2 [x, y, z], u3[x, y, z]}, {x, y, z}};
\[CurlyEpsilon] =
1/2 (Grad ## disp + Transpose[Grad ## disp]) // MatrixForm
\[Sigma] = Table[\[Lambda]*Tr[\[CurlyEpsilon]]*IdentityMatrix[3] + 2*\[Mu]*\[CurlyEpsilon]*KroneckerDelta[i,j],{i,3},{j,3}]//MatrixForm
But the output is not correct for the stress terms. Can you help me in understanding the error here?
Thanks in advance,

Related

Pythagorean theorem for calculating distance between two points. Prolog

We all know that the Pythagorean theorem formula is: a2 + b2 = c2. I wanted to implement this formula, for calculating the distance between two points. This is my data of the coordinates of the cities (in km):
city(amsterdam, 121.813/487.362).
city(breda, 112.095/398.291).
city(eindhoven, 161.871/382.839).
city(groningen, 233.871/582.030).
city(haarlem, 103.690/488.416).
city(hertogenbosch, 149.225/412.119).
city(leeuwarden, 182.605/583.855).
city(maastricht, 176.830/318.793).
city(rotterdam, 92.548/437.734).
city(utrecht, 135.923/456.419).
city(zwolle, 203.252/503.130).
I implemented a program for this cause, but it doesn't seem to work:
estimate(State/NextState, Estimate) :-
city(State, X/Y),
city(NextState, X1/Y1),
X2 is X1 - X,
Y2 is Y1 - Y,
Estimate is X2^2 + Y2^2,
DifferentVar is sqrt(Estimate),
estimate(State/NextState, DifferentVar).
If a query something like this it returns false:
?- estimate(amsterdam/utrecht, X).
false.
?- estimate(utrecht/amsterdam, X).
false.
I also tried this, but it doesn't work:
estimate(State/NextState, Estimate) :-
city(State, X/Y),
city(NextState, X1/Y1),
Estimate is sqrt((X1 - X)^2 + sqrt(Y1 - Y)^2).
I have checked each 'subgoal' and I can't find the mistake or the wrong implementation. In my eyes it seems to me that each 'subgoal' has been reached, but it still returns false. I would really appreciate it if somebody could help me further!
The estimation rule should be:
estimate(State/NextState, Estimate) :-
city(State, X/Y),
city(NextState, X1/Y1),
X2 is X1 - X,
Y2 is Y1 - Y,
Estimate is sqrt(X2^2 + Y2^2).
Note that only the last line changed (and the next 2 lines were deleted).

How to calculate the integral with the condition in wolfram

How to calculate the integral with the condition in Wolfram like
Integral(1/(x^4 + y^4)dxdy) where y >=x^2+1
I assume you mean the definite integral over all x, y>x^2+1. The syntax is this:
Integrate[1/(x^4 + y^4), {x, -Infinity, Infinity},{ y, x^2 + 1,Infinity}]
Note mathematica's ordering of the integration variables is reverse of standard convention, ie. left to right is outside to inside. This takes quite a while to report that it does not converge. However the numerical integration gives a result:
NIntegrate[1/(x^4 + y^4), {x, -Infinity, Infinity},{ y, x^2 + 1,Infinity}]
0.389712
My guess is the numeric result is correct and mathematica is simply wrong about the analytic convergence. You might try math.stackexchange.com or mathematica.stackexchange.com if you need to prove convergence. I am doubtful there is a nice analytic result.
How about
Integrate[1/(x^4 + y^4), y, x, Assumptions -> y >= x^2 + 1]
note also Multiple Integral

Matematica. Residue integral

I just started to use Mathematica and wanted to try out if I got a result correct from a residue integral i made. I have two poles in the UHP, actually looking more complicated but I just wanted to see if Mathematica could to this. This is my code:
x1 = Iw;
x2 = 2 Iw;
Integrate [e^(Ixt)/((x - x1) (x - x2)), {x, -infinity, infinity}, Assumptions -> t > 0]
Is this integral possible to do in Mathematica?
Mathematica sees Iw as a two character variable name, but I w as the product of two things.
Mathematica is fanatic about correct capitalization and spelling.
x1=I w; x2=2 I w;
Integrate[E^(I x t)/((x-x1)(x-x2)), {x,-Infinity,Infinity}, Assumptions-> t>0]
returns a large complicated result depending on the signs and whether w might be zero. If you can supply additional domain information the result might be simplified.

Mathematica's error by solving an ODE

I would know what is the problem with this Mathematica's code. Is there anyone that can give me an explanation of the bug, and also that can tell me how to improve the code?
V[x_, y_, z_] := x^2 + y - z;
m = 10;
DSolve[m*x''[t] == -Grad[V[x, y, z], {x, y, z}]*x[t], x[t], t]
Model of a particle in a potential-field. In this model we consider a particle as being a point of mass which describes a trajectory in space which is modeled by a function giving its coordinates in space as a function of time. The potential field is given by a function V : R^3 → R and the trajectory is a solution of the differential equation
Note this model assumes the particle is a point mass, which is certainly known to be false in many cases in which we use this model; for example, as a model of planetary motion.
Actual equation:
First: don't trust Wikipedia. It good for some basic knowledge, but for something specific better use some field-specific sources.
The correct equation is:
And the correct code:
V[x_, y_, z_] := x^2 + y - z;
m = 10;
DSolve[m*{x''[t], y''[t], z''[t]} ==
-(Grad[V[x, y, z], {x, y, z}] /. {x -> x[t], y -> y[t], z -> z[t]})
, {x[t], y[t], z[t]}, t]
Solution:
{{x[t] -> C[1] Cos[t/Sqrt[5]] + C[2] Sin[t/Sqrt[5]],
y[t] -> -(t^2/20) + C[3] + t C[4],
z[t] -> t^2/20 + C[5] + t C[6]}}

Gradient of a function at specific x,y,z values in Mathematica

I'm looking for a way to find the gradient of a function and then evaluate the output at specific x,y,z values. Thus far, I have
Needs["VectorAnalysis`"]
Clear[x, y, z]
v1 = Grad[x^2 + y^2 + z^2 - 9, Cartesian[x, y, z]]
which outputs
{2 x, 2 y, 2 z}. How could I evaluate this at x=2,y=2, and z=1, for instance? This seems trivial for the function above, but it would be immensely useful for more complicated functions. Thank you very much for any advice.
You can Replace the variables by values using Rule:
v1/.{x->2,y->2,z->1}

Resources