how to say 2 variables are equal and solve for one variable? I have two eqations having variables a and x. After integrating the equation, i get the solution 'y' in terms of 'a' and 'x'. Now I wand to differentiate 'y' w.r.t. 'a' for a=x. How to do?

1 view (last 30 days)
syms x a
Mx = (-150 + 20.556*x - ((1/2)*(x-10)^2 - (1/60)*(x-10)^3))*heaviside(20-x) + (5.556*x+(250/3))*heaviside(x-20);
delM = (a*(1-x/30))*heaviside(20-a) + (x*(1-a/30)*heaviside(20-x) + a*(1-x/30)*heaviside(x-20))*heaviside(a-20);
y = vpa((int(Mx*delM,x,0,30)),6)
  2 Comments
Ramneet Sidhu
Ramneet Sidhu on 25 Oct 2019
I an getting the solution for y as:
y =
0.00000262726*int(-a*heaviside(20 - a)*(x/30 - 1)*((1389*x)/250 + 250/3), x, 20, 30) + 0.00000262726*int(-a*heaviside(20 - a)*(x/30 - 1)*((5139*x)/250 - (x - 10)^2/2 + (x - 10)^3/60 - 150), x, 0, 20) + 0.00000262726*int(-a*heaviside(a - 20)*(x/30 - 1)*((1389*x)/250 + 250/3), x, 20, 30) + 0.00000262726*int(-x*heaviside(a - 20)*(a/30 - 1)*((5139*x)/250 - (x - 10)^2/2 + (x - 10)^3/60 - 150), x, 0, 20)
Ramneet Sidhu
Ramneet Sidhu on 25 Oct 2019
That helped a lot. Thankyou!!
In continuation of this question, I am trying to find the derivative of the result and equate it equal to 0 for a>20. This is the code I am trying:
syms a x
E = 29000*12^2; %ksf
I = 1890/12^4; %ft^4
M = (-150 + 20.556*x - ((1/2)*(x-10)^2 - (1/60)*(x-10)^3))*heaviside(20-x) + (5.556*x+(250/3))*heaviside(x-20);
m = x*(1-a/30)-(x-a)*heaviside(x-a);
y = simplify(int(expand(M*m),x,0,30))/(E*I)
assume(a > 0 )
assume(a>20)
f1 = diff(y,a)
eq1 = f1 ==0
a1 = solve(eq1,a)
And this gives me the following result:
y =
piecewise(a <= 0, (17753*a)/17128125, 20 <= a, (11668*a*heaviside(20 - a))/5709375 - (66448*heaviside(20 - a))/1141875 - (29168*heaviside(30 - a))/126875 - (117256*a)/17128125 + (25001*a*heaviside(30 - a))/1903125 + (13*a^2*heaviside(20 - a))/45675 - (2963*a^3*heaviside(20 - a))/190312500 + (a^4*heaviside(20 - a))/4567500 - (a^5*heaviside(20 - a))/456750000 - (a^2*heaviside(30 - a))/9135 - (463*a^3*heaviside(30 - a))/190312500 + 234512/1141875, a in Dom::Interval([0], [20]), (66448*heaviside(a - 20))/1141875 - (17251*a)/17128125 - (11668*a*(heaviside(a - 20) - 1))/5709375 - (13*a^2*(heaviside(a - 20) - 1))/45675 + (2963*a^3*(heaviside(a - 20) - 1))/190312500 - (a^4*(heaviside(a - 20) - 1))/4567500 + (a^5*(heaviside(a - 20) - 1))/456750000)
f1 =
(29168*dirac(a - 30))/126875 + (11668*heaviside(20 - a))/5709375 + (25001*heaviside(30 - a))/1903125 + (a^2*dirac(a - 30))/9135 + (463*a^3*dirac(a - 30))/190312500 + (26*a*heaviside(20 - a))/45675 - (2*a*heaviside(30 - a))/9135 - (2963*a^2*heaviside(20 - a))/63437500 + (a^3*heaviside(20 - a))/1141875 - (a^4*heaviside(20 - a))/91350000 - (463*a^2*heaviside(30 - a))/63437500 - (25001*a*dirac(a - 30))/1903125 - 117256/17128125
eq1 =
(29168*dirac(a - 30))/126875 + (11668*heaviside(20 - a))/5709375 + (25001*heaviside(30 - a))/1903125 + (a^2*dirac(a - 30))/9135 + (463*a^3*dirac(a - 30))/190312500 + (26*a*heaviside(20 - a))/45675 - (2*a*heaviside(30 - a))/9135 - (2963*a^2*heaviside(20 - a))/63437500 + (a^3*heaviside(20 - a))/1141875 - (a^4*heaviside(20 - a))/91350000 - (463*a^2*heaviside(30 - a))/63437500 - (25001*a*dirac(a - 30))/1903125 - 117256/17128125 == 0
a1 =
Empty sym: 0-by-1
Please tell me how to resolve this. Much appreciated!!

Sign in to comment.

Answers (1)

Surya Talluri
Surya Talluri on 6 Aug 2020
I understand that you want to get y as a function of x, a and after that you want to using x=a condition and find a>20 at which diff(y) becomes 0.
For that limits of integral should be from 0 to x
y = simplify(int(expand(M*m),x , 0, x))/(E*I);
y = subs(y, x, a)
the above generated y is a piecewise function and if you set the condition that a>20, it comes down to single expression
assume(a>20)
f1 = diff(y,a);
eq1 = f1 ==0;
S = simplify(eq1);
a1 = solve(S,a);
a1 = vpa(a1)
a1 =
22.827639369688447070895637509608
From the code that you have mentioned in the comments, simplifying eq1 gives Symfalse as an output, which shows that there is no a >20 which satisfies the condition if you directly replace integral bound with 30.
S = simplify(eq1)
S =
Symfalse
You can refer to Symfalse documentation for further understanding - https://www.mathworks.com/help/symbolic/symfalse.html

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!