MATLAB Answers

Solving nonlinear equations that include integrals with embedded variables

1 view (last 30 days)
Ke Wu
Ke Wu on 8 Sep 2020
Answered: Star Strider on 8 Sep 2020
Hi there,
As mentioned in the subject, I have a fsolve-related question here.
This below is what I need to solve considering that theta_o is the only unknown:
I tried to use 'fsolve' to solve this, but no solution found.
clear;clc;close all
options = optimset('TolFun', 1e-20, 'Display', 'iter', 'MaxFunEvals', 1e10, 'MaxIter', 1e9, 'Algorithm', 'levenberg-marquardt');
T = 0.003;
H = 0.08;
I = H*T^3/12;
Px=10;
Py=1;
Mo=5;
P=Py;
n=Px/Py;
l=0.1;
E=69*10^10;
UnknownGuess = rand(1, 1);
[Unknowns, fval,exitflag] = fsolve('LD', UnknownGuess, options, I, P, n, Mo, l, E);
Theta = Unknowns(1);
%% LD function
function Eq = LD(Unknown, I, P, n, l, E, Mo)
Eq(1)=integral(@(x) 1./((2*P/E/I*(n*cos(x)-sin(x)-n*cos(Unknown(1))+sin(Unknown(1)))+Mo^2/E/E/I/I).^0.5),0,Unknown(1))-l;
end
%%%
No solution found.
fsolve stopped because the problem appears regular as measured by the gradient,
but the vector of function values is not near zero as measured by the
value of the function tolerance.
It‘s supposed to have a solution but I must made a mistake there.
Anyone can help me out?
Thanks so much,
Ke

  0 Comments

Sign in to comment.

Answers (3)

Dana
Dana on 8 Sep 2020
Your call to fsolve:
fsolve('LD', UnknownGuess, options, I, P, n, Mo, l, E)
Your function syntax for LD:
Eq = LD(Unknown, I, P, n, l, E, Mo)
The last three parameters are in a different order. Change your call to fsolve to
fsolve('LD', UnknownGuess, options, I, P, n, l, E, Mo)
and I suspect that'll fix the problem.

  0 Comments

Sign in to comment.


Alan Stevens
Alan Stevens on 8 Sep 2020
If Dana's suggestion doesn't work, the following non-symbolic approach does:
theta0init = pi/2;
theta0 = fzero(@intfn, theta0init);
disp([num2str(theta0) ' radians'])
disp([num2str(theta0*180/pi) ' degrees'])
function F = intfn(theta0)
T = 0.003;
H = 0.08;
I = H*T^3/12;
Px=10;
Py=1;
Mo=5;
P=Py;
n=Px/Py;
E=69*10^10;
l=0.1;
F = integral(@(theta) 1./(2*P/E/I*(n*cos(theta)-sin(theta)-n*cos(theta0)+sin(theta0))+Mo^2/E/E/I/I).^0.5 , 0 ,theta0) - l;
end

  0 Comments

Sign in to comment.


Star Strider
Star Strider on 8 Sep 2020
Try this version of your code instead:
T = 0.003;
H = 0.08;
I = H*T^3/12;
Px=10;
Py=1;
Mo=5;
P=Py;
n=Px/Py;
l=0.1;
E=69E10;
LD = @(Unknown) integral(@(x) 1./((2*P/E/I*(n*cos(x)-sin(x)-n*cos(Unknown)+sin(Unknown))+Mo^2/E/E/I/I).^0.5),0,Unknown)-l;
UnknownGuess = rand;
options = optimset('TolFun', 1e-20, 'Display', 'iter', 'MaxFunEvals', 1e10, 'MaxIter', 1e9, 'Algorithm', 'levenberg-marquardt');
[Unknowns, fval,exitflag] = fsolve(LD, UnknownGuess, options);
Theta = Unknowns
producing:
Theta =
0.004067116685622
.

  0 Comments

Sign in to comment.

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!