C Board  

Go Back   C Board > Community Boards > General Discussions

Reply
 
LinkBack Thread Tools Display Modes
Old 10-22-2009, 11:12 PM   #1
Registered User
 
Join Date: Dec 2006
Posts: 1,780
Algebra help

a = (1-e^(bt))/(1-e^(ct))

Isolate t (a, b, c are all known).

Anyone?

If you are curious as to why I need to solve this - I am trying to determine the parameters of an exponential decay given 3 points.

V = Vf - (Vf - Vi)e^(-t/r)
where r is the time constant.

(this is the transient response of a battery after a charging current or a load has been removed)

After solving the system (3 V's and 3 t's), I got an equation in the form above, and couldn't solve it.

Last edited by cyberfish; 10-22-2009 at 11:15 PM.
cyberfish is offline   Reply With Quote
Old 10-22-2009, 11:21 PM   #2
Jaxom's & Imriel's Dad
 
Kennedy's Avatar
 
Join Date: Aug 2006
Location: Alabama
Posts: 801
Believe it would be:

t = ln(1 - a(1-e^(ct)))/b

EDIT: Don't hold me to this, though. it is 12:21am
Kennedy is offline   Reply With Quote
Old 10-22-2009, 11:22 PM   #3
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Pretty sure that's transcendental. That's why God gave us iterative solvers.
tabstop is offline   Reply With Quote
Old 10-23-2009, 12:00 AM   #4
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 4,923
I might be wrong, but maybe:

r = ( e ^ ( b - c ) )
a = r ^ t

The subtraction of one can be dropped, since it occurs on both sides (the ratio is unchanged).

EDIT:

Doh, I still haven't isolated 't'. Lemme think on that a bit.

EDIT#2:

I do know that isolating 't' from 'r' is a simple matter. Something to do with the log function...it's on the tip of my mind here...someone?

Last edited by Sebastiani; 10-23-2009 at 12:10 AM.
Sebastiani is offline   Reply With Quote
Old 10-23-2009, 12:06 AM   #5
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Quote:
Originally Posted by Sebastiani View Post
I might be wrong, but maybe:

r = ( e ^ ( b - c ) )
a = r ^ t

The subtraction of one can be dropped, since it occurs on both sides (the ratio is unchanged).

EDIT:

Doh, I still haven't isolated 't'. Lemme think on that a bit.
If you're telling me (5-1)/(4-1) is equal to 5/4, I'm a bit worried about you.
tabstop is offline   Reply With Quote
Old 10-23-2009, 12:25 AM   #6
Guest
 
Sebastiani's Avatar
 
Join Date: Aug 2001
Posts: 4,923
>> If you're telling me (5-1)/(4-1) is equal to 5/4, I'm a bit worried about you.

Hehe. I can assure you that your worries are justified. I'm not sure why I came to that conclusion, actually (bad intuition, I guess).
Sebastiani is offline   Reply With Quote
Old 10-23-2009, 03:25 PM   #7
Registered User
 
Join Date: Dec 2006
Posts: 1,780
Thanks for the replies!

Kennedy -
I tried plugging it in and got
a = a(1-e^(ct))/(1-(1-a(1-e^(ct)))^(c/b))

Meaning, if a != 0, (1-e^(ct)) = (1-(1-a(1-e^(ct)))^(c/b))

I don't think that is possible, since the left side does not depend on b at all.
How did you arrive at that answer?

tabstop -
No idea what that means (I am only doing second year math), but will look that up. Thanks!
cyberfish is offline   Reply With Quote
Old 10-23-2009, 06:15 PM   #8
Senior software engineer
 
brewbuck's Avatar
 
Join Date: Mar 2007
Location: Portland, OR
Posts: 5,381
No solution exists in closed form. However, since both the numerator and denominator are monotonic, the ratio is also monotonic, which means you can use bisection to find a solution iteratively.

In other words, find two initial values of t such that the value of the RHS is less than a for one of them, and greater than a for the other. Then recursively bisect the interval, getting closer and closer to the true root.

Something like:

Code:
double Function( double b, double c, double t )
{
    return ( 1.0 - exp( b * t ) ) / ( 1.0 - exp( c * t ) );
}

double FindRoot( double a, double b, double c )
{
    double tLow = ???;
    double tHigh = ???;
    double guess = Function( b, c, tLow );

    while( fabs( a - guess ) > 1e-5 )
    {
        double tMid = ( tLow + tHigh ) * 0.5;
        guess = Function( b, c, tMid );
        if( guess > a ) tHigh = tMid else tLow = tMid;
    }
    return tLow;
}
If you don't know what to put in for the ??? marks, just use a very small (but nonzero) value for tLow and a very large value for tHigh. The only requirement is that tLow < tTrue < tHigh
__________________
"Congratulations on your purchase. To begin using your quantum computer, set the power switch to both off and on simultaneously." -- raftpeople@slashdot
brewbuck is offline   Reply With Quote
Old 10-23-2009, 06:47 PM   #9
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Notes:
(1) I know that I mentioned iterative solvers up top too, but if you are at an actual institution of higher learning you probably have access to Mathematica or Maple or the moral equivalent thereof. (It won't give you a closed form either, unless there's one of those weird functions out there that can be used; but none of the ones I'm familiar with work.)
(2) Even if you are not, Wolfram has unbent so far as to have Wolfram Alpha solve that equation numerically using the Mathematica engine, if you have numbers for a, b, and c.
tabstop is offline   Reply With Quote
Old 10-23-2009, 07:39 PM   #10
Registered User
 
Join Date: Dec 2006
Posts: 1,780
brewbuck - Thanks! That makes sense. It's like a binary search.

Yeah we have all those programs on lab computers, but we haven't learned to use them, yet.

We have only used Matlab so far in our math (and engineering) courses (btw, after writing a moderately sized program for a project in Matlab, I can't imagine any more fundamentally flawed language than Matlab. Fine for interactive prompt, garbage for actual programming).

Last edited by cyberfish; 10-23-2009 at 07:42 PM.
cyberfish is offline   Reply With Quote
Old 10-23-2009, 07:57 PM   #11
and the Hat of Guessing
 
tabstop's Avatar
 
Join Date: Nov 2007
Posts: 8,740
Quote:
Originally Posted by cyberfish View Post
Yeah we have all those programs on lab computers, but we haven't learned to use them, yet.
Yes, but that will be time very very very very very very very very well spent. (And if you use Wolfram Alpha, I just typed in .5 = (1-e^(3t))/(1-e^(4t)) and got an answer.)
Quote:
Originally Posted by cyberfish View Post
We have only used Matlab so far in our math (and engineering) courses (btw, after writing a moderately sized program for a project in Matlab, I can't imagine any more fundamentally flawed language than Matlab. Fine for interactive prompt, garbage for actual programming).
I don't remember too much being silly about the language per se, once you accept the premise that numbers are special cases of matrices (which can take a while); I do remember the performance being atrocious though.
tabstop is offline   Reply With Quote
Old 10-23-2009, 08:08 PM   #12
Registered User
 
Join Date: Dec 2006
Posts: 1,780
Ah ok, I will certainly look into those.

Quote:
I don't remember too much being silly about the language per se, once you accept the premise that numbers are special cases of matrices (which can take a while); I do remember the performance being atrocious though.
The biggest complaint I have is that it, for all intents and purposes, requires either the whole program to be in 1 huge file, or have a separate file for every single function. Both of which are impractical (and there is no "include", so not even a way to simulate some kind of organization). This is from the fact that a script can only see 1 function in every file, the one that matches the name of the file. So if you have functions A and B that you want to access, and they both need to access helper functions c, d, and e, you have a few options -
1) put them all in separate files
2) have A and B in separate files, and a copy of c, d, and e in both
3) just have the whole program in one file to eliminate this problem

None of which are elegant IMHO.

And then there is the OOP thing, where member functions have to take an explicit "this" parameter, and accesses to class members must be made through that reference (this.variable). And the funniest thing - member functions return a copy of the object!

We eventually gave up on both, and just have a bunch of global functions and global variables in one huge file.

EDIT:
And of course, since variables don't need to be declared, a typo in a variable name usually means the program won't complain, it will just make it a new variable. But I guess that applies to many scripting languages.

Last edited by cyberfish; 10-23-2009 at 08:14 PM.
cyberfish is offline   Reply With Quote
Old 10-24-2009, 02:42 AM   #13
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
Since Matlab allows its functionality to be used in C/C++, why not give it a whirl? Cannot say I have tried it myself, but it is on my list to-do if and when I get another project to do in it and I have the time for it.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Linear algebra algorithm Cogman C++ Programming 3 03-09-2009 08:53 AM
Algebra project treenef C++ Programming 10 04-03-2005 04:58 PM
algebra solver treenef C++ Programming 20 03-18-2005 12:12 PM
Linear Algebra API curlious A Brief History of Cprogramming.com 2 01-13-2005 05:34 PM
Looking for a Boolean Algebra site Majin_Flack38 A Brief History of Cprogramming.com 1 11-21-2002 12:03 PM


All times are GMT -6. The time now is 09:12 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22