Algebra help

This is a discussion on Algebra help within the General Discussions forums, part of the Community Boards category; a = (1-e^(bt))/(1-e^(ct)) Isolate t (a, b, c are all known). Anyone? If you are curious as to why I ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183

    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.

  2. #2
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    Believe it would be:

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

    EDIT: Don't hold me to this, though. it is 12:21am

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Pretty sure that's transcendental. That's why God gave us iterative solvers.

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    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.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    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.

  6. #6
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> 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).

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    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!

  8. #8
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,246
    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
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  9. #9
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    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.

  10. #10
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    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.

  11. #11
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    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.

  12. #12
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,183
    Ah ok, I will certainly look into those.

    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.

  13. #13
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,659
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

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

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