0
$\begingroup$

I am a total Mathematica beginner. I just want to use it to do some calculations, and the reason it is so interesting and attractive to me as an engineering student is that it allows me to write maths symbolically as you would see in a textbook. My mind cannot comprehend mathematics if it is written in code form.

So this is what my code looks like.

(*Power Screws*)

raise = 
  Subscript[M, t] == 
    (W*Subscript[d, m])/2 * 
      ((f*π*Subscript[d, m] + 
      L*Cos[Subscript[α, n]])/(π*Subscript[d, m]*Cos[Subscript[α, n]] - f*L)) + 
    (W*Subscript[f, c]*Subscript[d, c])/2

lower = 
  Subscript[M, t] == 
    (W*Subscript[d, m])/2 * 
      ((f*π*Subscript[d, m] - 
      L*Cos[Subscript[α, n]])/(π*Subscript[d, m]*Cos[Subscript[α, n]] + f*L)) + 
    (W*Subscript[f, c]*Subscript[d, c])/2

stress = σ == (-4 p W)/(π h*(Subscript[d, 0]^2 - Subscript[d, r]^2))
eff = η == (W L)/(2 π Subscript[M, t])
power = w == (2 π (6/n*60) Subscript[M, t])/60

(*Question 2*)
 raise /. 
   {Subscript[M, t](*Changes*)-> (101.5) (125/1000), 
    Subscript[d, m] -> 18.75/1000, f -> 0.15, Subscript[f, c] -> 0.15, 
    L -> 2.5/1000, Subscript[α, n] -> 14.5 Degree, Subscript[d, c] -> 12/1000} 

(*Question 3*)
eff /. 
  {W(*Changes*)-> 4592.508217189424, L -> 2.5/1000, Subscript[M, t] -> 6.62183}

(*Question 4*)
stress /. 
  {W(*Changes*)-> 4592.51, σ(*Changes*)-> 12.1*10^6, 
   Subscript[d, 0] -> 20/1000, Subscript[d, r] -> 17.5/1000, p -> 2.5/1000}

(*Question 6*)
raise /. 
  {Subscript[d, m] -> 22.5/1000, f -> 0.08, 
   Subscript[f, c] -> 0.05, L -> 5/1000, Subscript[α, n] -> 0 Degree, 
   Subscript[d, c] -> 40/1000, W(*Changes*)-> 6000} 

(*Question 7*)
lower /. 
  {Subscript[d, m] -> 22.5/1000, f -> 0.08, 
   Subscript[f, c] -> 0.05, L -> 5/1000, Subscript[α, n] -> 0 Degree, 
   Subscript[d, c] -> 40/1000, W(*Changes*)-> 6000, 
   Subscript[M, t](*Changes*)-> 23} 

(*Question 8*)
eff /. 
  {W(*Changes*)-> 4592.508217189424, L -> 5/1000, Subscript[M, t] -> 6.62183}

(*Question 9*)
eff /. 
  {W(*Changes*)-> 4592.508217189424, L -> 5/1000, Subscript[M, t] -> 6.62183}

(*Question 10*)
raise /. 
  {Subscript[d, m] -> 22.5/1000, f -> 0.08*4/3, 
   Subscript[f, c] -> 0.05*4/3, L -> 5/1000, 
   Subscript[α, n] -> 0 Degree, Subscript[d, c] -> 40/1000, 
   W(*Changes*)-> 6000} 

(*Question 11*)
raise /. 
  {Subscript[d, m] -> 37/1000, f -> 0.1, 
   Subscript[f, c] -> 0.15, L -> 6/1000, Subscript[α, n] -> 14.5 Degree,
   Subscript[d, c] -> 60/1000, W(*Changes*)-> 12500} e here

Basically, when I evaluate the expression for Question 2, I need the answer from that question to do question 3. The way that I am doing it now is I just manually take the answer for W and paste it into the respective variable for question 3. Is there a way that I can generalize it where in question 3 for the variable that is the answer from the previous one is named as something which the program knows it must take the value from the previous calculation? The numbers which are there now are just examples.

Something ideal would be to store numbers in variables which are then placed in the replace functions. And then the outputs of those replace functions could be automatically stored in other variables which I can then put in other replace functions? Or something similar if you get me.

I know my words are all over the place, sorry. I would appreciate any help. If you not understanding me, please ask a question and I will try to clarify myself.

$\endgroup$
5
  • $\begingroup$ Though I'm not sure, I think what you want is SetDelayed :=. Take your answer for question 2 and do q2 := (your code). Then use q2 anywhere you want the answer for that question instead of copy paste. This explains it well. If this doesn't help let me know. $\endgroup$ Commented Oct 7, 2020 at 6:16
  • $\begingroup$ Mathematicas typical best practice is to assign variables and then use those in further calculations. $\endgroup$ Commented Oct 7, 2020 at 9:04
  • $\begingroup$ As morbo said, you can store the answer to some question in a variable and use it later. However, the output of question 2 is an equation. Is this what you want? Usually the answer is either and expression or some replacement rule that you can use later. $\endgroup$ Commented Oct 7, 2020 at 10:02
  • $\begingroup$ Daniel Huber thanks a lot for your response. The output of q2 is an equation, I generally just run the command and then mathematica gives me a clickable option to solve for w. I am looking for a convenient way to store the final value for w in some other letter and then use that for replacing the w value in my next equation. $\endgroup$ Commented Oct 7, 2020 at 12:02
  • $\begingroup$ To store the output of e.g. question 2, simply say, e.g.; "ww = raise /.....". Later you may use ww as you please. $\endgroup$ Commented Oct 8, 2020 at 8:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.