Definite Integral with symbolic upper and lower limits and a constant

Hi! I have the following integration: on both sides is -1/k*int(1/v)dv=int(1ds) where int is the symbol of integration The limits for left integral is from v0 to v The limits for right integral is from 0 to s
I have tried the following in code:
>> g=inline('(1/-k)*(1/v)')
g =
Inline function:
g(k,v) = (1/-k)*(1/v)
>> int(g(v))
Error using inline/subsref (line 12)
Not enough inputs to inline function.
Also I have tried this:
>> syms k
>> g=inline('(1/-k)*(1/v)')
g =
Inline function:
g(k,v) = (1/-k)*(1/v)
>> int(g(k,v))
ans =
-log(v)/k
Is there a way to take into account the v0 to v integration limits? The result should be: -1/k*(log(v)-log(v0))
Also k is a constant.
This is a Dynamics Mechanics sample problem by Meriam & Kraige

 Risposta accettata

Try this:
syms k v v0
assume(v > 0)
assume(v0 > 0)
g(k,v) = (1/-k)*(1/v); % Symbolic Function
Ig = int(g(k,v), v, v0, v)
Result:
Ig =
-(log(v) - log(v0))/k
You can define symbolic functions in R2012a and later.

9 Commenti

Alexandros ‘Answer’ moved here ...
To Star Strider:
Previous answer works fine.
Part of the same problem is to solve: s=int(v0/(1+k*t*v0) from 0 to t
So I have done the folowing:
syms k v v0 t
assume(v > 0)
assume(v0 > 0)
assume(t > 0)
g(k,v0,t) = v0/(1+k*t*v0); % Symbolic Function
Ig = int(g(k,v0,t), t , 0, t)
I get as an output: Ig =
piecewise([k <= 0, int(v0/(t*k*v0 + 1), t, 0, t)], [angle(k) < pi & k ~= 0, log(k*t*v0 + 1)/k])
What does this mean?
By changing to the code to
syms k v v0 t
assume(v > 0)
assume(v0 > 0)
assume(t > 0)
assume(k > 0)
g(k,v0,t) = v0/(1+k*t*v0); % Symbolic Function
Ig = int(g(k,v0,t), t , 0, t)
I now get the answer: Ig = log(k*t*v0 + 1)/k
Also I am trying to solve for k the following:
syms k
eqn=1.1*k-log(1+k*8*(10/60)) == 0;
solve(eqn, k)
but I get : ans = Empty sym: 0-by-1
How do I get the proper answer?
‘What does this mean?’
It means that the Symbolic Math Toolbox is attempting to account for complex values of the integrated function, those being the logarithm of the negative value of the product of ‘k’, ‘t’ or ‘v0’. By specifying that ‘t’ and ‘k’ are also greater than zero (so the logarithm of the product will always be finite), you eliminated the need to account for that possibility.
‘Previous answer works fine.’
Thank you.
If my Answer helps you solve your problem, please Accept it!
Hi. Can anyone answer this...
Also I am trying to solve for k the following:
syms k
eqn=1.1*k-log(1+k*8*(10/60)) == 0;
solve(eqn, k)
but I get : ans = Empty sym: 0-by-1
How do I get the proper answer?
For:
syms k
eqn=1.1*k-log(1+k*8*(10/60)) == 0;
solution = solve(eqn, k)
I get:
solution =
0
- (10*wrightOmega(log(33/40) - pi*1i - 33/40))/11 - 3/4
in R2017a.
If my Answer helps you solve your problem, please Accept it!
I have 2015a. I want to solve f=k*s-ln(1+k*t*v0)=0 for k
The answer should be k=0.3392 according to the book. After runing your code I get:
solution =
0
I don’t have ‘the book’ so I’ve no idea how it calculated the result. It apparently did not use the Symbolic Math Toolbox.
Using fzero:
k = fzero(@(k) 1.1*k-log(1+k*8*(10/60)), 1)
k =
0.339230533424708
If my Answer helps you solve your problem, please Accept it!
Hi. I get a four decimal place accuracy. Is there a way to get what you got for k?
Yes.
format long g
k = fzero(@(k) 1.1*k-log(1+k*8*(10/60)), 1)
See the documentation on the format (link) function for details.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by