How do I solve lhs=rhs by iteration?
3 views (last 30 days)
Show older comments
For my research I want to use decompaction and ultimately backstripping to solve subsidence of geological layers in the subsurface. I could do this for one layer by hand, but I want to write a script that will automatically solve this for all layers in my borehole data.
For the first step in decompaction, I want to solve the following function:
y2'-y1'=y2-y1-phi0/c*{exp-(c*y1)-exp(-c*y2)}+phi0/c*{exp(-c*y1')-exp(-c*y2')
The following variables I already have: y1',y1 and y2. I want to solve for y2', but using test-data (for which I have the answers) I keep getting the wrong answers.
(y1 is the initial top of the layer, y2 is the base and y1' is the shallower depth for decompaction) For simplicity purposes, I use y1'=0.
My test-data are: y1= 3000 y2= 4000 y1'=0 phi0=0.70 c=0.71
the answer for this test-data for my script should be y2'=1620.
can anyone help me solve my problem?
I am not proficient enough in Matlab to solve this problem myself, but I would love to learn.
3 Comments
Walter Roberson
on 2 Dec 2017
y2'-y1'=y2-y1-phi0/c*{exp-(c*y1)-exp(-c*y2)}+phi0/c*{exp(-c*y1')-exp(-c*y2')
has bad brackets. At the very least it is missing a } . The exp should not be followed by a -
Answers (2)
Star Strider
on 1 Dec 2017
Geology is regrettably not an area of my expertise, so I am not familiar with what you are doing.
It might be best to approach this as an optimization problem. Since you have all but one variable, you can use either fzero or fsolve to solve for y2' (that I call ‘y2p’ here).
This is returning undefined values at the initial point, so I ask you to be certain the parentheses are correct, since they are not precise in your equation, and I might have placed them incorrectly in mine:
y1 = 3000;
y2 = 4000;
y1p = 0;
phi0 = 0.70;
c = 0.7;
fcn = @(y2p) y2-y1-phi0/(c*(exp(-c*y1)-exp(-c*y2)))+phi0/(c*(exp(-c*y1p)-exp(-c*y2p))) - y2p + y1p;
y2p = fzero(fcn, 2E+3);
I rearranged your equation so that it is implicit (equals zero) for the fzero and fsolve functions, since they require that.
I used fzero here because everyone has it. The Optimization Toolbox fsolve function is more robust. With correctly-placed parentheses, that should produce the correct result.
I will help as I can to get this working.
9 Comments
Star Strider
on 3 Dec 2017
My pleasure.
Please post the script you found here. I would like to see it.
Walter Roberson
on 2 Dec 2017
If the equation is
y2_new-y1_new = y2-y1-phi0*(exp(-c*y1)-exp(-c*y2))/c+phi0*(exp(-c*y1_new)-exp(-c*y2_new))/c;
then this has a solution f
y2_new = (LambertW(-phi0*exp(-phi0*exp(-c*y1_new)+phi0*exp(-c*y1)-exp(-c*y2)*phi0+(y1-y1_new-y2)*c))+phi0*exp(-c*y1_new)-phi0*exp(-c*y1)+exp(-c*y2)*phi0+(-y1+y2+y1_new)*c)/c
With real inputs, LambertW often has exactly two real solutions, one denoted as LambertW(-1,x) and the other as LambertW(0,x) which gets abbreviated to LambertW(x) .
With the coefficients you gave in the original Question, the corresponding real solutions are approximately -9.7643 and 1000.9859
See Also
Categories
Find more on Linear Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!