| New Reply |
Mathematica:Solving two equations with two variables ?? |
Share Thread | Thread Tools |
| Jul18-12, 11:43 AM | #1 |
|
|
Mathematica:Solving two equations with two variables ??
Hi,
I am trying to solve two equations with two unkonwn variables. These equations are equal to zero so my way was first picking one of the variable to one side of the equations and equalize them and find the other unknown parameter. After that, by using the known parameter, I can calculate the other one. Here is the codes from mathematica : Code:
Ts[1,2] is :0.333184+sf (0.0559331+0.998885 Tan[\[Beta]ex])
Solution for sf with Ts[1,2]=0 = {{sf->-(0.333184/(0.0559331+0.998885 Tan[\[Beta]ex]))}}
Ts[3,4] is :13.0898+sf (1.00075-39.2433 Tan[\[Beta]ex-0.024 (1+Sin[\[Beta]ex]^2)])
Solution for sf with Ts[3,4]=0 = {{sf->-(13.0898/(1.00075-39.2433 Tan[\[Beta]ex-0.024 (1.+Sin[\[Beta]ex]^2)]))}}
However, I could not handle with that one. Please show me a way. Thanks. |
| Jul18-12, 12:39 PM | #2 |
|
|
In[7]:= FindRoot[{0.333184+sf (0.0559331+0.998885 Tan[βex])==0,
13.0898+sf (1.00075-39.2433 Tan[βex-0.024 (1+Sin[βex]^2)])==0},{{sf, -4}, {βex, 10}}] Out[7]= {sf->-6.32311,βex->9.42153} In[8]:= {0.333184+sf (0.0559331+0.998885 Tan[βex]), 13.0898+sf (1.00075-39.2433 Tan[βex-0.024 (1+Sin[βex]^2)])}/.% Out[8]= {2.9976021664879227`*^-15, -1.8118839761882555`*^-13} |
| Jul18-12, 12:41 PM | #3 |
|
|
I usually use FindRoot to solve nonlinear systems like this one. It uses Newton's Method to converge on a solution given a starting point. It found the solution below, but there may be other solutions:
Code:
In[238]:=
LHS = {0.333184 + sf (0.0559331 + 0.998885 Tan[\[Beta]ex]),
13.0898 +
sf (1.00075 -
39.2433 Tan[\[Beta]ex - 0.024 (1 + Sin[\[Beta]ex]^2)])};
In[252]:= Solution =
FindRoot[{0.333184 + sf (0.0559331 + 0.998885 Tan[\[Beta]ex]) == 0,
13.0898 +
sf (1.00075 -
39.2433 Tan[\[Beta]ex - 0.024 (1 + Sin[\[Beta]ex]^2)]) ==
0}, {{sf, -6.0}, {\[Beta]ex, 0.20}}]
Out[252]= {sf -> -6.32311, \[Beta]ex -> -0.00324361}
In[253]:= LHS /. Solution
Out[253]= {1.27676*10^-15, -5.15143*10^-14}
|
| Jul18-12, 12:46 PM | #4 |
|
|
Mathematica:Solving two equations with two variables ??
Note that Bill Simpson's solution and mine just have Betax differing by 3*pi. There will of course be an infinite number of solutions since Tan and Sin are periodic functions.
|
| Jul18-12, 04:28 PM | #5 |
|
|
Bill Simpson and phyzguy, thank you so much for quick answers. Here is my code and final result after some work. The result looks like a ok. I post the code so you can try it and discuss later.
Code:
Print["We'll use FindRoot command to find \
\[Beta]ex "]
rooot = FindRoot[-(0.33318362982304933`/(
0.0559331001312733` + 0.998884522209502` Tan[\[Beta]ex])) +
13.08983820439489`/(
1.0007491562059996` -
39.24333493677589` Tan[\[Beta]ex -
0.024` (1.` + Sin[\[Beta]ex]^2)]) == 0, {\[Beta]ex, 1.5}]
Print ["Calculated \[Beta]ex is assigned as rooot => \[Beta]ex = ", \
rooot]
myrooot = Evaluate[\[Beta]ex] /. rooot
Print ["Evaluated value is myrooot = ", myrooot]
Print["Calculated \[Beta]ex in degree is : ", myrooot 180/Pi // N]
Print ["Using \[Beta]ex value sf is calculated for Ts[1,2] as : ", tff]
tff = Evaluate[sf] /. tf ;
Print ["Numerical solution in meter for sf from Ts[1,2] is => sf= ",
tff /. \[Beta]ex -> myrooot]
Print ["Using \[Beta]ex value sf is calculated for Ts[3,4] as : ", tff]
ott = Evaluate[sf] /. ot ;
Print ["Numerical solution in meter for sf from Ts[3,4] is => sf= ",
ott /. \[Beta]ex -> myrooot]
sff = ott /. \[Beta]ex -> myrooot;
Print["Finally sf in meter=", sff]
|
| New Reply |
| Tags |
| mathematica, solve, solve for variable |
| Thread Tools | |
Similar Threads for: Mathematica:Solving two equations with two variables ??
|
||||
| Thread | Forum | Replies | ||
| Solving differential equations in four variables | Math & Science Software | 2 | ||
| Solving 2 unknown variables with 2 equations | Calculus & Beyond Homework | 2 | ||
| Solving for variables using 3 different equations (simultaneous equations) | Precalculus Mathematics Homework | 1 | ||
| [Mechanics] Solving equations with 2 variables | Precalculus Mathematics Homework | 1 | ||
| solving equations for variables | General Math | 2 | ||