# Can't solve for y in a fairly simple work done by magnetic field equation

The equations below are essentially calculations for a railgun-type mechanism (here is a good image description). I also drew an image using my own variables as definitions:

I assumed that introducing assumptions would help, to no avail. Here are my assumptions:

$$\text{\Assumptions}=\{n\in \mathbb{Z}_{>\, 0},A\in \mathbb{R}_{>\, 0},\{x,y\}\in \mathbb{R},\{\text{x1},\text{x2},\text{y1},\text{y2},\text{lx},\text{ly},\text{rx},\text{ry},\text{y0}\}\in \mathbb{R}_{>\, 0}\};$$

$Assumptions = {n \[Element] PositiveIntegers, A \[Element] PositiveReals, {x, y} \[Element] Reals, {x1, x2, y1, y2, lx, ly, rx, ry, y0} \[Element] PositiveReals}; Then I defined a function for the magnetic field: $$B(\text{n\_},\text{A\_},\text{x\_},\text{y\_})=\int_{-y}^0 \frac{2 A n x}{10^7 \left(x^2+y^2\right)^{3/2}} \, dy$$ B[n_, A_, x_, y_] = Integrate[(2*n*A*x)/(10^7*(x^2 + y^2)^(3/2)), {y, -y, 0}] Then force: $$F(\text{n\_},\text{A\_},\text{x1\_},\text{x2\_},\text{y\_})=\int_{\text{x1}}^{\text{x2}} A n B(n,A,x,y) \, dx$$ F[n_, A_, x1_, x2_, y_] = Integrate[n*A*B[n, A, x, y], {x, x1, x2}] Then work: $$W(\text{n\_},\text{A\_},\text{x1\_},\text{x2\_},\text{y1\_},\text{y2\_})=\int_{\text{y1}}^{\text{y2}} F(n,A,\text{x1},\text{x2},y) \, dy$$ W[n_, A_, x1_, x2_, y1_, y2_] = Integrate[F[n, A, x1, x2, y], {y, y1, y2}] Finally, a version of the work function that is more comparable to my real-world scenario: $$\text{W2}(\text{n\_},\text{A\_},\text{y0\_},\text{lx\_},\text{ly\_},\text{ry\_})=W(n,A,\text{ry},\text{lx}+\text{ry},\text{y0},\text{ly})$$ W2[n_, A_, y0_, lx_, ly_, ry_] = W[n, A, ry, lx + ry, y0, ly] # The Problem I plugged in some numbers to test out: • n = 1 loop • A = 1500 amps • lx = 0.01 meters (1cm) • rx = 0.0005 meters (0.5mm) • ry = 0.005 meters (0.5cm) • y0 = 0.01 meters (1cm) • Ug = (0.1)(9.8)(6.096) joules (potential energy due to gravity of an 0.1kg (100g) object 20ft (6.096m) in the air) ...and then solving for ly, or the length that the rails would have to be in order to make it 20 feet in the air before falling. NSolve[Ug == W2[0.01, 0.01, ly, 2.5 10^-3], ly] Neither NSolve nor FindRoot appear to be able to make this calculation, and for the life of me I cannot figure out why. What do I do? • Check W2[n_, A_, y0_, lx_, ly_, ry_] = W[n, A, ry, lx + ry, y0, ly]. Arguments are rearranged here. – Alex Trounev Sep 25 '19 at 21:22 ## 2 Answers Your call to W2 in NSolve passes only 4 parameters, your definition of W2 requires 6. So W2[0.01, 0.01, ly, 2.5 10^-3], will return unevaluated. Here you can calculate all the integrals and define functions explicitly $Assumptions = {n ∈ PositiveIntegers,
A ∈ PositiveReals, {x, y} ∈
Reals, {x1, x2, y1, y2, lx, ly, rx, ry, y0} ∈
PositiveReals};
Integrate[1/(x^2 + yi^2)^(3/2), {yi, -y, 0}]

(* ConditionalExpression[y/(x^2 Sqrt[x^2 + y^2]),
x != 0 && y > 0]*)
B[n_, A_, x_, y_] := (2*n*A*x)/(10^7) y/(x^2 Sqrt[x^2 + y^2])
In[7]:= n*A*Integrate[B[n, A, x, y], {x, x1, x2}]

Out[7]= ConditionalExpression[(
A^2 n^2 (ArcSinh[y/x1] - ArcSinh[y/x2]))/5000000, y != 0 && x1 < x2]

In[8]:= F[n_, A_, x1_, x2_, y_] := (
A^2 n^2 (ArcSinh[y/x1] - ArcSinh[y/x2]))/5000000

Integrate[F[n, A, x1, x2, y], {y, y1, y2}]

(*ConditionalExpression[(1/5000000)
A^2 n^2 (Sqrt[x1^2 + y1^2] - Sqrt[x2^2 + y1^2] - Sqrt[x1^2 + y2^2] +
Sqrt[x2^2 + y2^2] - y1 ArcSinh[y1/x1] + y1 ArcSinh[y1/x2] +
y2 ArcSinh[y2/x1] - y2 ArcSinh[y2/x2]), y1 < y2]*)
W[n_, A_, x1_, x2_, y1_, y2_] :=
1/5000000 A^2 n^2 (Sqrt[x1^2 + y1^2] - Sqrt[x2^2 + y1^2] - Sqrt[
x1^2 + y2^2] + Sqrt[x2^2 + y2^2] - y1 ArcSinh[y1/x1] +
y1 ArcSinh[y1/x2] + y2 ArcSinh[y2/x1] - y2 ArcSinh[y2/x2])


I guess such a definition

W2[n_, A_, ry_, lx_, y0_, ly_] := W[n, A, ry, lx + ry, y0, ly]

n = 1 (*loop*);
A = 1500 (*amps*);
lx = 0.01 (*meters (1cm)*);
rx = 0.0005 (*meters (0.5mm)*);
ry = 0.005 (*meters (0.5cm)*);
y0 = 0.01 (*meters (1cm)*);
Ug = (0.1) (9.8) (6.096) (*joules (potential energy due to gravity of \
an 0.1kg (100g) object 20ft (6.096m) in the air)*);

FindRoot[Ug == W2[n, A, ry, lx + ry, y0, ly], {ly, 5}]
(*{ly -> 9.59142}*)