[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Can you do this in GSL?
From: |
Yanlong Yang |
Subject: |
Re: [Help-gsl] Can you do this in GSL? |
Date: |
Wed, 19 Jan 2005 17:04:28 +0800 |
User-agent: |
Mozilla Thunderbird 1.0 (Windows/20041206) |
assume
F(x)=0.067x3 - int_0^x t2/(exp(t)+1) dx
the soultion of the equation F(x)=0 is what Anders wants
the solution of the equation F'(x)=0 is where F(x) 's max/min/inflexion,
e.g ,the following steps are not right to find the solution of the first one
x^2=exp(x) -->
2*x=exp(x) -->
2=exp(x)-->
0=exp(x)
Wrong
So we cannot find a solution of a equation from its derivative form.
Using the following Matlab script,we can find the solution is near
1.8927,
==============
clear all;
clc;
b=linspace(0,20,100); % b=[0,0.2,0.4,...,20]
f1=0.067*b.^3;
f2=[];
f=@(x)x.^2./(exp(x)+1);
for n=1:length(b)
int_f=quad(f,0,b(n)); % integral of f from 0 to b(n)
f2=[f2 int_f];
end
plot(b,f1,b,f2); % from the plot,we can find the solution is near
2. and reduce the b span step by step to
% [1.8926,1.8928]
==================
but the solution of 0.2=1/(exp(x)+1) is 1.3826.
Hope this helps.
Yanlong Yang
address@hidden
zkoza wrote:
0.067*b^3 = \int_0^b x^2/(exp(x)+1) dx
Assume that F(b) = \int_0^b x^2/(exp(x)+1) dx.
Your equation is then 0.067*b^3 = F(b) - F(0) = F(b).
Now differentiate with b, and you have 0.2*b^2 = F'(b) = f(b).
You can calculate f(b) as a finite difference, f(b) = (F(b+h)-F(b-h))/2h.
You can do even better: since b is used only as the upper limit in the
integral, the derivative is simply the integrand:
f(b) = b^2/(exp(b)+1).
After substituting it to 0.2*b^2 = f(b), you are left with
something as simple as exp(b) \approx 4, or
b \approx ln(4).
regards,
Z. Koza
_______________________________________________
Help-gsl mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/help-gsl