4
$\begingroup$

I am trying to solve the following two equations, but I am having troubles doing so.

Equation 1 :

eq1[n_] := 
  2.21355*10^(-16)/((1 - n)^2)*(1024/5 + 3*7133.17 n^2) - 
   4.42709*10^(-16)/((1 - n)^3)*(1024/5*n + 7133.17 n^3) ;
Solve[eq1[n] == 0, n]

If I can find an "n", I would then plug it into the following equation and solve for V.

eq2[n_] := 1024/5*n + 7133.17 n^3 - 
  0.06287*V^2*2.21355*10^(-16)/((1 - n)^2);

Solve[eq2[nFound] == 0, V]
$\endgroup$

2 Answers 2

6
$\begingroup$

Sorry, I am not very sure what you want to ask. Maybe you want to substitute the solution of the first equation into the second equation? Then you can do this.

eq1[n_] := 
  2.21355*10^(-16)/((1 - n)^2)*(1024/5 + 3*7133.17 n^2) - 
   4.42709*10^(-16)/((1 - n)^3)*(1024/5*n + 7133.17 n^3);
ansList = Values@Solve[eq1[n] == 0, n]

eq2[n_] := 
  1024/5*n + 7133.17 n^3 - 0.06287*V^2*2.21355*10^(-16)/((1 - n)^2);

Solve[eq2[#] == 0, V] & /@ ansList

You also can use the following code to get the value of n.

sol=Solve[eq1[n] == 0, n]
nList=n/.sol

That's all. Please enjoy the fun of Mathematica.

$\endgroup$
2
  • $\begingroup$ Thanks ! This was exactly what I was looking for. $\endgroup$
    – james
    Commented Dec 16, 2018 at 9:13
  • $\begingroup$ Never thought about using the Values function in this context. Thanks for the new idea! $\endgroup$ Commented Dec 16, 2018 at 14:02
3
$\begingroup$

Solve can handle simultaneous equations. Solve is an exact solver so use Rationalze to provide exact numbers as input. Solve will work without doing this but will provide a warning that it did it internally. Or use NSolve.

eq1[n_] := 
  Evaluate[2.21355*10^(-16)/((1 - n)^2)*(1024/5 + 3*7133.17 n^2) - 
      4.42709*10^(-16)/((1 - n)^3)*(1024/5*n + 7133.17 n^3) // 
     Rationalize[#, 0] & // Simplify];

eq2[n_] := Evaluate[1024/5*n + 7133.17 n^3 - 
 0.06287*V^2*2.21355*10^(-16)/((1 - n)^2) // Rationalize[#, 0] &];

Solve[{eq1[n] == 0, eq2[n] == 0}, {n, V}] // N

(* {{n -> 0.00634203 + 0.0986751 I, 
  V -> -7.58581*10^8 - 6.22509*10^8 I}, {n -> 0.00634203 + 0.0986751 I, 
  V -> 7.58581*10^8 + 6.22509*10^8 I}, {n -> 0.00634203 - 0.0986751 I, 
  V -> 7.58581*10^8 - 6.22509*10^8 I}, {n -> 0.00634203 - 0.0986751 I, 
  V -> -7.58581*10^8 + 6.22509*10^8 I}, {n -> 0.587316, 
  V -> -4.37685*10^9}, {n -> 0.587316, V -> 4.37685*10^9}} *)

For real solutions

Solve[{eq1[n] == 0, eq2[n] == 0}, {n, V}, Reals] // N

(* {{n -> 0.587316, V -> -4.37685*10^9}, {n -> 0.587316, V -> 4.37685*10^9}} *)

For real, positive solutions

Solve[{eq1[n] == 0, eq2[n] == 0, V > 0}, {n, V}] // N

(* {{n -> 0.587316, V -> 4.37685*10^9}} *)
$\endgroup$
3
  • $\begingroup$ This is a great answer ! Thank you very much ! $\endgroup$
    – james
    Commented Dec 17, 2018 at 14:24
  • $\begingroup$ How would you do it with Rationalize ? $\endgroup$
    – james
    Commented Dec 17, 2018 at 14:42
  • $\begingroup$ Look at the definition of eq1 above. At the end you will see that Rationalize and Simplify are used. Since SetDelayed ( := ) is used in the definition rather than Set ( = ), Evaluate is used to have these evaluated at the time of definition rather than for each use of the function eq1. Similarly for eq2 except Simplify wasn't needed. Read the documentation for each of these functions. $\endgroup$
    – Bob Hanlon
    Commented Dec 17, 2018 at 15:52

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.