Solution for my equation using matlab is different from what i get manually.

2 views (last 30 days)
The equation above is the one I'm working on. I wrote the equation in Matlab as follows;
s = sqrt ( (x-10)^2 + (sqrt(9-x^2)-2)^2 ) + sqrt( (10-x)^2 + (-2-sqrt(9-x^2))^2 )
Then I differentiate s in term of x, and equate ds/dx = 0. When I solve for x, I expected the value to be 3, as that's the solution I got manually. However Matlab return the value x = 10.
Did I make any mistake in writing the equation for s?

Answers (1)

Walter Roberson
Walter Roberson on 14 Apr 2018
No, definitely not 3. 3 leads to 0/0 for diff(s(x),x), requiring much finer analysis to show that ds at 3 is -1036*sqrt(53)*(1/2809) . The 10 value is correct.
You can plot the derivative to see that it is not 0 at 3.
  4 Comments
Image Analyst
Image Analyst on 19 Apr 2018
You forgot to include your formula for the derivative of s, and the MATLAB code you used to solve for setting that to 0.
Walter Roberson
Walter Roberson on 19 Apr 2018
The formula they used for s is correct. It is sum of cartesian distances between point (x,y) and points S and F, followed by the substitution x^2 + y^2 = 9 implies y = sqrt(9 - x^2)
It is just that using calculus to minimize by looking for derivative being zero does not take into account constraints that y must be real-valued. The point with x = 10 that is found really does have the minimum total distance... it just has imaginary y.

Sign in to comment.

Categories

Find more on Stress and Strain 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!