![]() |
| | #1 |
| Registered User Join Date: Dec 2006
Posts: 1,780
| Algebra help 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 | |
| | #2 |
| Jaxom's & Imriel's Dad 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 | |
| | #3 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Pretty sure that's transcendental. That's why God gave us iterative solvers. |
| tabstop is offline | |
| | #4 |
| Guest 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 | |
| | #5 |
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| If you're telling me (5-1)/(4-1) is equal to 5/4, I'm a bit worried about you. |
| tabstop is offline | |
| | #6 |
| Guest 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 | |
| | #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 | |
| | #8 |
| Senior software engineer 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;
}
__________________ "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 | |
| | #9 |
| and the Hat of Guessing 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 | |
| | #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 | |
| | #11 | ||
| and the Hat of Guessing Join Date: Nov 2007
Posts: 8,740
| Quote:
Quote:
| ||
| tabstop is offline | |
| | #12 | |
| Registered User Join Date: Dec 2006
Posts: 1,780
| Ah ok, I will certainly look into those. Quote:
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 | |
| | #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:
| |
| Elysia is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
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 |