# get the subtraction of two unknown numbers in one equation

In this equation, the $T_0,p,l_1,\rho,C_{DN},d$ are all known and constant. I want to get every $v$, every $x_1$. I can get an $x_2$, and finally get the $x_2-x)_1$ varies as $v$.

The $v$ is from $0-10$

The $x_1$ is about $0-50$ and I don't know for sure.

The $x_2$ is about $0-50$ and I don't know for sure.

But surely $x_2$ is bigger than $x_1$ and $x_2-x_1$ is about $0-10$ or $20$ as $v$ varies.

$$\frac{T_0}{p}\sinh(\frac{p\cdot x_2}{T_0})-\frac{T_0}{p}\sinh(\frac{p\cdot x_1}{T_0})=l_1$$

$$T_0=1/2*\rho*C_{DN}*d*v^2$$

I have tried

cdn = 1.2;
d = 0.0042;
(*\[Phi]2=\[Pi]/2-1;*)
l = 20;
rho = 1025;
rho1=0.97;
p = rho1*l;

t0 = 1/2*rho*cdn*d*v^2;

v = 4;
x1 = 10;

s2 = FindRoot[{t0/p*Sinh[p*x2/t0] - t0/p*Sinh[p*x1/t0] == l}, {{x2,
20}}]
(*{x2 -> 10.3377}*)
(x2 /. s2) - x1
(*0.337682*)


but when

v = 4;
x1 = 20;

s2 = FindRoot[{t0/p*Sinh[p*x2/t0] - t0/p*Sinh[p*x1/t0] == l}, {{x2,
20}}]
(x2 /. s2) - x1
(*{x2 -> 20.0033}*)
0.00334525


So how to get the $x_2-x_1$ varies as $v$?

And as we use different values of $x_1$ and the tried value of $x_2$ in the range, there are multiple solutions for $x2-x1$. So how to get all the $x_2-x_1$ varies as $v$?

• Run this over and over and see what it displays cdn=1.2; d=0.0042; l=20; rho=1025; p=rho*l; v=RandomInteger[{0,10}]; t0=1/2*rho*cdn*d*v^2; x1=RandomInteger[{0,50}]; Print[{v, x1}]; Table[t0/p*Sinh[p*x2/t0]-t0/p*Sinh[p*x1/t0]-l, {x2,x1,x1+20}] Almost always the expression you want to be about l==20 is instead near 10^1000. That might give you an idea how delicate this is going to be to find a solution without error messages. And if v or x1 are zero then this fails because of division by zero. – Bill May 21 '18 at 3:30
• yes i was sorry about that some parameter is unsuitable such p which makes the solution so big – dcydhb May 21 '18 at 13:51

Using FindRoot or any of the other numerical functions to find x2 from x1 and v isn't necessary. And this can avoid many of the problems involved with such root finding when dealing with numbers like you have.

Clear[t0,p,x2,x1,l,rho,cdn,v];
p = rho*l;
t0 = 1/2*rho*cdn*d*v^2;
Simplify[Reduce[t0/p*Sinh[p*x2/t0]-t0/p*Sinh[p*x1/t0]==l ,x2],
{l!=0,cdn!=0,C==0,d!=0,v!=0}]


instantly gives you

x2 == ((I/2)*cdn*d*v^2*(Pi + I*ArcSinh[(2*l^2)/(cdn*d*v^2) +
Sinh[(2*l*x1)/(cdn*d*v^2)]]))/l ||
2*l*x2 == cdn*d*v^2*ArcSinh[(2*l^2)/(cdn*d*v^2) + Sinh[(2*l*x1)/(cdn*d*v^2)]]


and you can ignore the first of those two solutions if you don't want a complex number for x2, giving you

x2 == cdn*d*v^2*/(2*l)*ArcSinh[(2*l^2)/(cdn*d*v^2) + Sinh[(2*l*x1)/(cdn*d*v^2)]]


Now you just have to substitute in constants for your other variables.

Because of the huge numerical values from your expression you will not be able to use decimal approximations with one or two digits after the decimal point. You will need to use exact rational constants. And you will have to experiment with using lots of precision to get a satisfactory answer.

x2 == cdn*d*v^2/(2*l)*ArcSinh[(2*l^2)/(cdn*d*v^2) + Sinh[(2*l*x1)/(cdn*d*v^2)]]/.
{cdn->12/10,d->42/10000,l->20,rho->1025,v->3,x1->5}


instantly giving you exactly

x2 == (567*ArcSinh[10000000/567 + Sinh[2500000/567]])/500000


You can get an approximate decimal value using

N[(567*ArcSinh[10000000/567 + Sinh[2500000/567]])/500000,2048]


and see that x2 is different from the value of 5 that was used for x1. You can obtain your desired difference between x1 and x2 with

N[5-(567*ArcSinh[10000000/567 + Sinh[2500000/567]])/500000,2048]


Try other values of v and x1 to get the information that you want.

Here a solution with FindRoot.

Rationalize parameter, set x2 = x1 + eps and set $MaxExtraPrecision = Infinity. cdn = 12/10; d = 42/10000; (*\[Phi]2=\[Pi]/2-1;*) l = 20; rho = 1025; p = rho*l; t0 = 1/2*rho*cdn*d*v^2;$MaxExtraPrecision = Infinity

equ[eps_, x1_?NumericQ,
v_?NumericQ] = (t0/p*Sinh[p*x2/t0] - t0/p*Sinh[p*x1/t0] == l) /.
x2 -> x1 + eps // TrigToExp // Expand

fr[v_, x1_] :=
FindRoot[equ[eps, x1, v], {eps, -1/10, 1/10}, WorkingPrecision -> 4]

(tab2 = Flatten[
Table[{v, x1, Log[eps /. First@fr[v, x1]]}, {v, 1/2, 10,
1/2}, {x1, 1, 50, 1}], 1]) // Timing


This takes 4190 seconds.

ListPlot3D[tab2, PlotRange -> {-10000, 0}] Attention, this is Log[eps]. There are a few spikes where FindRoot failed.

• may because there is some parameter unsuitable such as p and i have changed it to a small value and that's why the result is so big and whatever your method solved my problem perfeltly and THANKS A LOT! – dcydhb May 21 '18 at 13:49