Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Solving Implicit Integral

Subject: Solving Implicit Integral

From: Mayur

Date: 3 Jul, 2013 17:58:11

Message: 1 of 14

Hi

I want to solve the following equation using MATLAB but do not know or understand how to do it.

I would really appreaciate your help on this.

The equation is :

U(t) = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1

where y(t) = integral (0-t) U(t)dt and A is a constant

y(0)=0

or same can be written as :

dy/dt = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1

Please let me know if someone can help me with this. I am just not sure how to go about it.

Thanks

Subject: Solving Implicit Integral

From: Torsten

Date: 4 Jul, 2013 06:34:11

Message: 2 of 14

"Mayur" wrote in message <kr1onj$eql$1@newscl01ah.mathworks.com>...
> Hi
>
> I want to solve the following equation using MATLAB but do not know or understand how to do it.
>
> I would really appreaciate your help on this.
>
> The equation is :
>
> U(t) = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
>
> where y(t) = integral (0-t) U(t)dt and A is a constant
>
> y(0)=0
>
> or same can be written as :
>
> dy/dt = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
>
> Please let me know if someone can help me with this. I am just not sure how to go about it.
>
> Thanks

I don't understand what you mean by
[dz/tanh(A*z + arctanh(1-A*y(t)))]^-1.
Do you want to take "dz" in the denominator ?

Best wishes
Torsten.

Subject: Solving Implicit Integral

From: Mayur

Date: 4 Jul, 2013 16:16:09

Message: 3 of 14

Hi Torsten

Yeah the equation is set up that way.
The whole equation is raised to -1 power.

If you want I can send you the equation file.

Thanks a lot for replying.

Mayur
"Torsten" wrote in message <kr3513$plo$1@newscl01ah.mathworks.com>...
> "Mayur" wrote in message <kr1onj$eql$1@newscl01ah.mathworks.com>...
> > Hi
> >
> > I want to solve the following equation using MATLAB but do not know or understand how to do it.
> >
> > I would really appreaciate your help on this.
> >
> > The equation is :
> >
> > U(t) = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> >
> > where y(t) = integral (0-t) U(t)dt and A is a constant
> >
> > y(0)=0
> >
> > or same can be written as :
> >
> > dy/dt = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> >
> > Please let me know if someone can help me with this. I am just not sure how to go about it.
> >
> > Thanks
>
> I don't understand what you mean by
> [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1.
> Do you want to take "dz" in the denominator ?
>
> Best wishes
> Torsten.

Subject: Solving Implicit Integral

From: Mayur

Date: 4 Jul, 2013 18:27:10

Message: 4 of 14

Hi Torsten

I guess I made a slight error in writing up the equation.
The integral is raised to power (negative) 1

Maybe this was not clear in my original post.

The right equation looks like:

U(t) = C^-1

where C = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]

Please let me know how to go about solving it.

Thanks
Mayur

"Torsten" wrote in message <kr3513$plo$1@newscl01ah.mathworks.com>...
> "Mayur" wrote in message <kr1onj$eql$1@newscl01ah.mathworks.com>...
> > Hi
> >
> > I want to solve the following equation using MATLAB but do not know or understand how to do it.
> >
> > I would really appreaciate your help on this.
> >
> > The equation is :
> >
> > U(t) = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> >
> > where y(t) = integral (0-t) U(t)dt and A is a constant
> >
> > y(0)=0
> >
> > or same can be written as :
> >
> > dy/dt = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> >
> > Please let me know if someone can help me with this. I am just not sure how to go about it.
> >
> > Thanks
>
> I don't understand what you mean by
> [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1.
> Do you want to take "dz" in the denominator ?
>
> Best wishes
> Torsten.

Subject: Solving Implicit Integral

From: Torsten

Date: 5 Jul, 2013 06:37:10

Message: 5 of 14

"Mayur" wrote in message <kr4epu$n7i$1@newscl01ah.mathworks.com>...
> Hi Torsten
>
> I guess I made a slight error in writing up the equation.
> The integral is raised to power (negative) 1
>
> Maybe this was not clear in my original post.
>
> The right equation looks like:
>
> U(t) = C^-1
>
> where C = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]
>
> Please let me know how to go about solving it.
>
> Thanks
> Mayur
>
> "Torsten" wrote in message <kr3513$plo$1@newscl01ah.mathworks.com>...
> > "Mayur" wrote in message <kr1onj$eql$1@newscl01ah.mathworks.com>...
> > > Hi
> > >
> > > I want to solve the following equation using MATLAB but do not know or understand how to do it.
> > >
> > > I would really appreaciate your help on this.
> > >
> > > The equation is :
> > >
> > > U(t) = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> > >
> > > where y(t) = integral (0-t) U(t)dt and A is a constant
> > >
> > > y(0)=0
> > >
> > > or same can be written as :
> > >
> > > dy/dt = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> > >
> > > Please let me know if someone can help me with this. I am just not sure how to go about it.
> > >
> > > Thanks
> >
> > I don't understand what you mean by
> > [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1.
> > Do you want to take "dz" in the denominator ?
> >
> > Best wishes
> > Torsten.

In this case, you have a simple differential equation of the form
dy/dt= 1/integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]
with initial condition y(0)=0.
Use ODE45 which solves equations of the form
dy/dt=f(t,y).
In the function routine where you have to supply f(t,y), call MATLAB's
quad function to evaluate the integral for the y-value supplied by ODE45.

Best wishes
Torsten.
 

Subject: Solving Implicit Integral

From: Torsten

Date: 5 Jul, 2013 06:59:09

Message: 6 of 14

"Torsten" wrote in message <kr5pim$m7r$1@newscl01ah.mathworks.com>...
> "Mayur" wrote in message <kr4epu$n7i$1@newscl01ah.mathworks.com>...
> > Hi Torsten
> >
> > I guess I made a slight error in writing up the equation.
> > The integral is raised to power (negative) 1
> >
> > Maybe this was not clear in my original post.
> >
> > The right equation looks like:
> >
> > U(t) = C^-1
> >
> > where C = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]
> >
> > Please let me know how to go about solving it.
> >
> > Thanks
> > Mayur
> >
> > "Torsten" wrote in message <kr3513$plo$1@newscl01ah.mathworks.com>...
> > > "Mayur" wrote in message <kr1onj$eql$1@newscl01ah.mathworks.com>...
> > > > Hi
> > > >
> > > > I want to solve the following equation using MATLAB but do not know or understand how to do it.
> > > >
> > > > I would really appreaciate your help on this.
> > > >
> > > > The equation is :
> > > >
> > > > U(t) = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> > > >
> > > > where y(t) = integral (0-t) U(t)dt and A is a constant
> > > >
> > > > y(0)=0
> > > >
> > > > or same can be written as :
> > > >
> > > > dy/dt = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> > > >
> > > > Please let me know if someone can help me with this. I am just not sure how to go about it.
> > > >
> > > > Thanks
> > >
> > > I don't understand what you mean by
> > > [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1.
> > > Do you want to take "dz" in the denominator ?
> > >
> > > Best wishes
> > > Torsten.
>
> In this case, you have a simple differential equation of the form
> dy/dt= 1/integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]
> with initial condition y(0)=0.
> Use ODE45 which solves equations of the form
> dy/dt=f(t,y).
> In the function routine where you have to supply f(t,y), call MATLAB's
> quad function to evaluate the integral for the y-value supplied by ODE45.
>
> Best wishes
> Torsten.
>

Or even simpler (because the integral can be evaluated analytically):
dy/dt = A/(log(sinh(A+arctanh(a-A*y)))-log(sinh(arctanh(a-A*y))))
with initial condition
y(0)=0.

Best wishes
Torsten.

Subject: Solving Implicit Integral

From: Mayur

Date: 5 Jul, 2013 15:32:13

Message: 7 of 14

Hi Torsten

How did you get the analytical solution?

Plus, I am very new to MATLAB and thus was wondering if you could provide me with a script file to solve the equation numerically?

I really appreaciate your help.

Thanks
Mayur

"Torsten" wrote in message <kr5qrt$orp$1@newscl01ah.mathworks.com>...
> "Torsten" wrote in message <kr5pim$m7r$1@newscl01ah.mathworks.com>...
> > "Mayur" wrote in message <kr4epu$n7i$1@newscl01ah.mathworks.com>...
> > > Hi Torsten
> > >
> > > I guess I made a slight error in writing up the equation.
> > > The integral is raised to power (negative) 1
> > >
> > > Maybe this was not clear in my original post.
> > >
> > > The right equation looks like:
> > >
> > > U(t) = C^-1
> > >
> > > where C = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]
> > >
> > > Please let me know how to go about solving it.
> > >
> > > Thanks
> > > Mayur
> > >
> > > "Torsten" wrote in message <kr3513$plo$1@newscl01ah.mathworks.com>...
> > > > "Mayur" wrote in message <kr1onj$eql$1@newscl01ah.mathworks.com>...
> > > > > Hi
> > > > >
> > > > > I want to solve the following equation using MATLAB but do not know or understand how to do it.
> > > > >
> > > > > I would really appreaciate your help on this.
> > > > >
> > > > > The equation is :
> > > > >
> > > > > U(t) = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> > > > >
> > > > > where y(t) = integral (0-t) U(t)dt and A is a constant
> > > > >
> > > > > y(0)=0
> > > > >
> > > > > or same can be written as :
> > > > >
> > > > > dy/dt = integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1
> > > > >
> > > > > Please let me know if someone can help me with this. I am just not sure how to go about it.
> > > > >
> > > > > Thanks
> > > >
> > > > I don't understand what you mean by
> > > > [dz/tanh(A*z + arctanh(1-A*y(t)))]^-1.
> > > > Do you want to take "dz" in the denominator ?
> > > >
> > > > Best wishes
> > > > Torsten.
> >
> > In this case, you have a simple differential equation of the form
> > dy/dt= 1/integral(0-1) [dz/tanh(A*z + arctanh(1-A*y(t)))]
> > with initial condition y(0)=0.
> > Use ODE45 which solves equations of the form
> > dy/dt=f(t,y).
> > In the function routine where you have to supply f(t,y), call MATLAB's
> > quad function to evaluate the integral for the y-value supplied by ODE45.
> >
> > Best wishes
> > Torsten.
> >
>
> Or even simpler (because the integral can be evaluated analytically):
> dy/dt = A/(log(sinh(A+arctanh(a-A*y)))-log(sinh(arctanh(a-A*y))))
> with initial condition
> y(0)=0.
>
> Best wishes
> Torsten.

Subject: Solving Implicit Integral

From: Torsten

Date: 6 Jul, 2013 11:32:10

Message: 8 of 14

"Mayur" wrote in message <kr6ott$rru$1@newscl01ah.mathworks.com>...
> > Or even simpler (because the integral can be evaluated analytically):
> > dy/dt = A/(log(sinh(A+arctanh(a-A*y)))-log(sinh(arctanh(a-A*y))))
> > with initial condition
> > y(0)=0.
> >
> > Best wishes
> > Torsten.

> Hi Torsten
>
> How did you get the analytical solution?
>
 
I used the integrator under
http://integrals.wolfram.com

> Plus, I am very new to MATLAB and thus was wondering if you could provide me with a script file to solve the equation numerically?
>

Look at example 1 under
http://www.mathworks.de/de/help/matlab/ref/ode23.html


> I really appreaciate your help.
>
> Thanks
> Mayur

Subject: Solving Implicit Integral

From: Torsten

Date: 8 Jul, 2013 06:24:09

Message: 9 of 14

"Torsten" wrote in message <kr8v7q$nuj$1@newscl01ah.mathworks.com>...
> "Mayur" wrote in message <kr6ott$rru$1@newscl01ah.mathworks.com>...
> > > Or even simpler (because the integral can be evaluated analytically):
> > > dy/dt = A/(log(sinh(A+arctanh(a-A*y)))-log(sinh(arctanh(a-A*y))))
> > > with initial condition
> > > y(0)=0.
> > >
> > > Best wishes
> > > Torsten.
>
> > Hi Torsten
> >
> > How did you get the analytical solution?
> >
>
> I used the integrator under
> http://integrals.wolfram.com
>
> > Plus, I am very new to MATLAB and thus was wondering if you could provide me with a script file to solve the equation numerically?
> >
>
> Look at example 1 under
> http://www.mathworks.de/de/help/matlab/ref/ode23.html
>
>
> > I really appreaciate your help.
> >
> > Thanks
> > Mayur

There was a mistake in the integrated function.
The differential equation to be solved must read
dy/dt = A/log(sinh(A+arctanh(1-A*y))/sinh(arctanh(1-A*y)))
with initial condition
y(0)=0.

Best wishes
Torsten.

Subject: Solving Implicit Integral

From: Mayur

Date: 8 Jul, 2013 17:24:07

Message: 10 of 14

Hi Torsten

I really appreaciate your help. Thank you very much.
I tried to use Mathematica for finding the analytical solution but cant seem to get it right.

Can you send me the file that you used to find the analytical solution.

I am also trying to solve it numerically using MATLAB but without any success so far. I guess I am missing something there or just cant figure out how to write the MATLAB code

Thanks
Mayur

"Torsten" wrote in message <krdlu9$7r1$1@newscl01ah.mathworks.com>...
> "Torsten" wrote in message <kr8v7q$nuj$1@newscl01ah.mathworks.com>...
> > "Mayur" wrote in message <kr6ott$rru$1@newscl01ah.mathworks.com>...
> > > > Or even simpler (because the integral can be evaluated analytically):
> > > > dy/dt = A/(log(sinh(A+arctanh(a-A*y)))-log(sinh(arctanh(a-A*y))))
> > > > with initial condition
> > > > y(0)=0.
> > > >
> > > > Best wishes
> > > > Torsten.
> >
> > > Hi Torsten
> > >
> > > How did you get the analytical solution?
> > >
> >
> > I used the integrator under
> > http://integrals.wolfram.com
> >
> > > Plus, I am very new to MATLAB and thus was wondering if you could provide me with a script file to solve the equation numerically?
> > >
> >
> > Look at example 1 under
> > http://www.mathworks.de/de/help/matlab/ref/ode23.html
> >
> >
> > > I really appreaciate your help.
> > >
> > > Thanks
> > > Mayur
>
> There was a mistake in the integrated function.
> The differential equation to be solved must read
> dy/dt = A/log(sinh(A+arctanh(1-A*y))/sinh(arctanh(1-A*y)))
> with initial condition
> y(0)=0.
>
> Best wishes
> Torsten.

Subject: Solving Implicit Integral

From: Torsten

Date: 9 Jul, 2013 06:26:07

Message: 11 of 14

"Mayur" wrote in message <kresjn$dbf$1@newscl01ah.mathworks.com>...
> Hi Torsten
>
> I really appreaciate your help. Thank you very much.
> I tried to use Mathematica for finding the analytical solution but cant seem to get it right.
>
> Can you send me the file that you used to find the analytical solution.

Under
http://integrals.wolfram.com
type in:
1/TanH[a*x+b]
After MATHEMATICA returned the solution, insert a=A and b=arctanh(1-A*y)
on a piece of paper, insert upper (1) and lower (0) limit of integration in the solution and subtract the two.

> I am also trying to solve it numerically using MATLAB but without any success so far. I guess I am missing something there or just cant figure out how to write the MATLAB code

Try
A=10;
func = @(t,y) A/log(sinh(A+atanh(1-A*y))/sinh(atanh(1-A*y)));
[T,Y] = ode45(func,[0 10],[0]);
plot(T,Y(:,1),'-');
in MATLAB.

>
>
> Thanks
> Mayur

Best wishes
Torsten.

Subject: Solving Implicit Integral

From: Torsten

Date: 10 Jul, 2013 09:27:16

Message: 12 of 14

"Torsten" wrote in message <krgadv$p8$1@newscl01ah.mathworks.com>...
> "Mayur" wrote in message <kresjn$dbf$1@newscl01ah.mathworks.com>...
> > Hi Torsten
> >
> > I really appreaciate your help. Thank you very much.
> > I tried to use Mathematica for finding the analytical solution but cant seem to get it right.
> >
> > Can you send me the file that you used to find the analytical solution.
>
> Under
> http://integrals.wolfram.com
> type in:
> 1/TanH[a*x+b]
> After MATHEMATICA returned the solution, insert a=A and b=arctanh(1-A*y)
> on a piece of paper, insert upper (1) and lower (0) limit of integration in the solution and subtract the two.
>
> > I am also trying to solve it numerically using MATLAB but without any success so far. I guess I am missing something there or just cant figure out how to write the MATLAB code
>
> Try
> A=10;
> func = @(t,y) A/log(sinh(A+atanh(1-A*y))/sinh(atanh(1-A*y)));
> [T,Y] = ode45(func,[0 10],[0]);
> plot(T,Y(:,1),'-');
> in MATLAB.
>
> >
> >
> > Thanks
> > Mayur
>
> Best wishes
> Torsten.

I tried to determine y by myself, but to get a solution you must proceed differently from what I suggested above.
First use the addition theorem for tanh:
1/tanh(A*z+atanh(1-A*y))=(1+tanh(A*z)*(1-A*y))/(tanh(A*z)+(1-A*y))
Then write a separate m-file for ODE45 and call quad with the function above.

The complete code then looks like this:

A=0.1;
[T,Y] = ode45(@(t,y)myfun(t,y,A),[0 10],[0]);
plot(T,Y(:,1),'-');
 
dy = myfun(t,y,A)
fun=@(x) (1+tanh(A*x)*(1-A*y(1)))/(tanh(A*x)+(1-A*y(1)));
integral=quad(fun,0,1);
dy=1/integral;

Best wishes
Torsten.

Subject: Solving Implicit Integral

From: Mayur

Date: 10 Jul, 2013 15:55:08

Message: 13 of 14

Hi Torsten

Thanks a lot.
I wrote a code to solve it numerically and it seems to work fine.
Its mostly similar to the code you have provided me in the last reply.

I will try your code as well.

Thanks
Mayur
"Torsten" wrote in message <krj9dk$g06$1@newscl01ah.mathworks.com>...
> "Torsten" wrote in message <krgadv$p8$1@newscl01ah.mathworks.com>...
> > "Mayur" wrote in message <kresjn$dbf$1@newscl01ah.mathworks.com>...
> > > Hi Torsten
> > >
> > > I really appreaciate your help. Thank you very much.
> > > I tried to use Mathematica for finding the analytical solution but cant seem to get it right.
> > >
> > > Can you send me the file that you used to find the analytical solution.
> >
> > Under
> > http://integrals.wolfram.com
> > type in:
> > 1/TanH[a*x+b]
> > After MATHEMATICA returned the solution, insert a=A and b=arctanh(1-A*y)
> > on a piece of paper, insert upper (1) and lower (0) limit of integration in the solution and subtract the two.
> >
> > > I am also trying to solve it numerically using MATLAB but without any success so far. I guess I am missing something there or just cant figure out how to write the MATLAB code
> >
> > Try
> > A=10;
> > func = @(t,y) A/log(sinh(A+atanh(1-A*y))/sinh(atanh(1-A*y)));
> > [T,Y] = ode45(func,[0 10],[0]);
> > plot(T,Y(:,1),'-');
> > in MATLAB.
> >
> > >
> > >
> > > Thanks
> > > Mayur
> >
> > Best wishes
> > Torsten.
>
> I tried to determine y by myself, but to get a solution you must proceed differently from what I suggested above.
> First use the addition theorem for tanh:
> 1/tanh(A*z+atanh(1-A*y))=(1+tanh(A*z)*(1-A*y))/(tanh(A*z)+(1-A*y))
> Then write a separate m-file for ODE45 and call quad with the function above.
>
> The complete code then looks like this:
>
> A=0.1;
> [T,Y] = ode45(@(t,y)myfun(t,y,A),[0 10],[0]);
> plot(T,Y(:,1),'-');
>
> dy = myfun(t,y,A)
> fun=@(x) (1+tanh(A*x)*(1-A*y(1)))/(tanh(A*x)+(1-A*y(1)));
> integral=quad(fun,0,1);
> dy=1/integral;
>
> Best wishes
> Torsten.

Subject: Solving Implicit Integral

From: Mayur

Date: 10 Jul, 2013 19:22:14

Message: 14 of 14

Hi Torsten

Thanks a lot.
I wrote a code to solve it numerically and it seems to work fine.
Its mostly similar to the code you have provided me in the last reply.

I will try your code as well.

Thanks
Mayur
"Torsten" wrote in message <krj9dk$g06$1@newscl01ah.mathworks.com>...
> "Torsten" wrote in message <krgadv$p8$1@newscl01ah.mathworks.com>...
> > "Mayur" wrote in message <kresjn$dbf$1@newscl01ah.mathworks.com>...
> > > Hi Torsten
> > >
> > > I really appreaciate your help. Thank you very much.
> > > I tried to use Mathematica for finding the analytical solution but cant seem to get it right.
> > >
> > > Can you send me the file that you used to find the analytical solution.
> >
> > Under
> > http://integrals.wolfram.com
> > type in:
> > 1/TanH[a*x+b]
> > After MATHEMATICA returned the solution, insert a=A and b=arctanh(1-A*y)
> > on a piece of paper, insert upper (1) and lower (0) limit of integration in the solution and subtract the two.
> >
> > > I am also trying to solve it numerically using MATLAB but without any success so far. I guess I am missing something there or just cant figure out how to write the MATLAB code
> >
> > Try
> > A=10;
> > func = @(t,y) A/log(sinh(A+atanh(1-A*y))/sinh(atanh(1-A*y)));
> > [T,Y] = ode45(func,[0 10],[0]);
> > plot(T,Y(:,1),'-');
> > in MATLAB.
> >
> > >
> > >
> > > Thanks
> > > Mayur
> >
> > Best wishes
> > Torsten.
>
> I tried to determine y by myself, but to get a solution you must proceed differently from what I suggested above.
> First use the addition theorem for tanh:
> 1/tanh(A*z+atanh(1-A*y))=(1+tanh(A*z)*(1-A*y))/(tanh(A*z)+(1-A*y))
> Then write a separate m-file for ODE45 and call quad with the function above.
>
> The complete code then looks like this:
>
> A=0.1;
> [T,Y] = ode45(@(t,y)myfun(t,y,A),[0 10],[0]);
> plot(T,Y(:,1),'-');
>
> dy = myfun(t,y,A)
> fun=@(x) (1+tanh(A*x)*(1-A*y(1)))/(tanh(A*x)+(1-A*y(1)));
> integral=quad(fun,0,1);
> dy=1/integral;
>
> Best wishes
> Torsten.

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us