Message Boards Message Boards

0
|
8412 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

FindRoot does not work II

Posted 11 years ago
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,

Ana

ref: community.wolfram.com/groups/-/m/t/187841
POSTED BY: Ana Squadri
2 Replies
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 
POSTED BY: Isaac Abraham
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 BY: Ilian Gachevski
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract