Message Boards Message Boards

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

How to solve numerically an equation when NSolve is not appropriate?

Posted 9 years ago

Hi, This is my code:

    In[1]:= f[x_] := x^2
    In[2]:= g[a_, b_] := NIntegrate[f[x], {x, a, b}]
    In[3]:= g[1, 2]     
    Out[3]= 2.33333  
    In[4]:= NSolve[g[1, b] == 3, b]
    During evaluation of In[4]:= NIntegrate::nlim: x = b is not a valid limit of integration. >>

I am unable to Numericaly Solve for the variable b.

Marcel

POSTED BY: Marcel Pelletier
2 Replies

FindRoot works with polynomials and related symbolic expressions.

In[7]:= f[x_] = x^2;
g[a_?NumberQ, b_?NumberQ] := NIntegrate[f[x], {x, a, b}]

In[9]:= FindRoot[g[1, b] == 3, {b, 1}]

Out[9]= {b -> 2.15443}
POSTED BY: Frank Kampas

Hi, Thank you for your help! Marcel

POSTED BY: Marcel Pelletier
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