# FindRoot does not work II

Posted 10 years ago
7903 Views
|
2 Replies
|
2 Total Likes
|
 Dear:I have tried to use the example in Pos 7387 from Schaum's Outline of Mathematica (example 9.18). Unfortunatelly it did not work. Based on tips from the Community I have tyried to use ?NumericQ when defining Integrate or Assumptons->. Unfortunatelly it did not work.  I substitute the function defined by their expression inside the  Integrate and all was ok. Neverthless it is more elegant and easier to verify the solution proposal by Eugene Don, PhD (Schaum). So I would like  to ask your help to solve this problem.Below I show the Eugene Don solution and mine one.  (*my solution*)  In[478]:= Clear[x] In[596]:= Off[General::ivar] In[597]:= f[x_] = x^2; s[x_] = Integrate[Sqrt[1 + (f'[t])^2], {t, 0, x}]; Plot[Integrate[Sqrt[1 + (f'[t])^2], {t, 0, x}], {x, 0, 3}, AxesLabel -> {"x", "s(x)"}] In[482]:= Off[Set::write] In[483]:= resposta =  FindRoot[NIntegrate[Sqrt[1 + (f'[t])^2], {t, 0, x}] == 5, {x, 2}]Out[483]= {x -> 2.08401}In[484]:= x = x /. x -> 2.08401;{x, f[x]}Out[485]= {2.08401, 4.3431}(*Eugen Don Solution*)f[x_] = x^2;s[x_] = Integrate[Sqrt[1 + (f'[t])^2], {t, 0, x}];Plot[s[x], {x, 0, 3}, AxesLabel -> {"x", "s(x)"}]solution = FindRoot[s[x] == 5, {x, 2}] x = x /. solution;{x, f[x]}Thanks,Anaref: community.wolfram.com/groups/-/m/t/187841
2 Replies
Sort By:
Posted 10 years ago
 This is the exact same issue as in the previous post (in V9 and later Integrate returns a ConditionalExpression).Try ClearAll["Global*"]f[x_] = x^2;s[x_] = Integrate[Sqrt[1 + (f'[t])^2], {t, 0, x}, Assumptions -> x > 0];FindRoot[s[x] == 5, {x, 2}] Another way: ClearAll["Global*"]f[x_] = x^2;s[x_] = Integrate[Sqrt[1 + (f'[t])^2], {t, 0, x}];FindRoot[Normal[s[x]] == 5, {x, 2}] And a third way, using _?NumericQ ClearAll["Global`*"]f[x_] = x^2;s[x_?NumericQ] = Integrate[Sqrt[1 + (f'[t])^2], {t, 0, x}];FindRoot[s[x] == 5, {x, 2}]
Posted 10 years ago
 Please delete all the "In" from the code because those are auto-generated by Mathematica. I also don't see the need for Off. Your code produces the same output as the reference code, namely x = 2.084