i need to make integrat for this equation from 0 to x ,, with respect to x ,,i make several program but i cant reach to my object

1 view (last 30 days)
y= sqrt(2*m*(E-(a.*x)))
where m,E,A, IS constant

Accepted Answer

Stephan
Stephan on 14 Aug 2018
Hi,
syms g(x) a m E
g(x) = (sqrt(2*m*(E-(a.*x))))
G(x) = int(g(x),x)
pretty(G(x))
gives the indefinite integral, which is:
G(x) =
-(2*2^(1/2)*(m*(E - a*x))^(1/2)*(E - a*x))/(3*a)
or by using pretty:
2 sqrt(2) sqrt(m (E - a x)) (E - a x)
- -------------------------------------
3 a
Best regards
Stephan
  6 Comments
Aalaa Abu alrob
Aalaa Abu alrob on 14 Aug 2018
Thank very much I try it .. but has you an opinion how to collect term (add..subtract ..) And the term i get too long .. Such a code !!
Stephan
Stephan on 14 Aug 2018
Edited: Stephan on 14 Aug 2018
fun_x1 = G(x);
fun_x0 = G(0);
result = simplify(fun_x1 - fun_x0);
pretty(result)
gives:
2 sqrt(2) E sqrt(E m) 2 sqrt(2) sqrt(m (E - a x)) (E - a x)
--------------------- - -------------------------------------
3 a 3 a
which is the analytical solution of your integral in the bounds from 0...x. To calculate values for this use:
fun = matlabFunction(result)
which is:
fun =
function_handle with value:
@(E,a,m,x)(sqrt(2.0).*E.*sqrt(E.*m).*(2.0./3.0))./a-(sqrt(2.0).*sqrt(m.*(E-a.*x)).*(E-a.*x).*(2.0./3.0))./a
This function handle you can call like shown in this example:
m = 10;
E = 2;
a = 0.3;
x = 5
numeric_result = fun(E,a,m,x)
and ist value is:
numeric_result =
24.5955

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!