Results 1 to 8 of 8

021705, 03:53 #1Registered User
 Join Date
 Nov 2004
 Posts
 19
Unanswered: complex maths equation... help needed
hello people
hmm have another problem on hand... two maths problem in fact...
1) suppose i have b= (6.44*10E9 *c^3/2)/ B
where b, B is both known... and we need to find unknown value "c" hmm how should we go about doing it .. seems kind of simple but i actually have a hard time doing it....
2) suppose we have two equation : b = (6.44*10E9 * c^3/2)/B....(1)
a = (J *1.54*10E6*B^2*exp(10.4/sqr(c)) / c...(2)
suppose a,b and j are known values... and we need to find c and B.... i have problem doing that.. initally i try to find one unknow first .. ie) making B the value we want to find first in terms of c.... so we have
B = (6.44*10E9 * c^3/2)/b ... (3)
then we sub formula (3) into (2) so we have
a= (J *1.54*10E6*(((6.44*10E9 * c^3/2)/b)^2)exp(10.4/sqr(c))/c....(4)
so with a, J and b known... how are we going to find the value of c since there is going to be exponential part to be solved... hmm i ask around and i was told that by bringing everything to one side and then solve by trial and error.. i would be able to find the unknown values.. but i have been trying and cannot seems to get it...
if (J *1.54*10E6*(((6.44*10E9 * c^3/2)/b)^2)exp(10.4/sqr(c))/c  a =0
find c..and then B.. how are we going to do it by using a program ????
hope u guys know wat i am trying to do here and help me out in any way that u can...
really appreciate the effort...
thanks in advance...
regardsLast edited by sportyboy; 021705 at 03:55. Reason: missing parameters

021705, 06:24 #2Registered User
 Join Date
 Jan 2004
 Location
 Aberdeen, Scotland
 Posts
 1,067
Iteration, Find a lower bound and an upper bound i.e.
for equation 1)
0= (6.44*10E9 *c^3/2)/ Bb
find a lower bound for c and an upper bound for C i.e.
Lower Bound
(6.44*10E9 *c^3/2)/ Bb equates < 0
Upper Bound equates >0
take the value at the midpoint of this and equate if its above 0 change upper bound
if its below 0 change lower bound
then Loop
here is a v quick example for #1
try to improve on this and get yourself an answer for #2

021705, 10:37 #3Registered User
 Join Date
 Nov 2004
 Posts
 19
help required
hello david..
thanks for the quick reply.. but i still have difficulty in solving the iteration... cause i am quite weak in my programming..so can u pls help me out here??
thanks alot for yr help
regards sportyboy

021705, 10:55 #4Registered User
 Join Date
 Jan 2004
 Location
 Aberdeen, Scotland
 Posts
 1,067
it depends how you want to do it,
are you creating a form for users to input values on or is it a stand alone module,
im assuming that this is homework so ill just post some ideas on how to go about it,
I also assume that your using VB,
youll need a variable for each part of your expression, also for the upper bound and a lower bound
work out your Value for C by taking the midpoint of your lower bound and your upper bound and adding it to the lower bound
run it through a do loop testing when your equation gets close to 0 pick a reasonable value to test to i.e. 0.00000000005 reset either upper or lower bound dependant on whether or not you obtain a positive or negative result
give it a try and post what you get and we can talk about getting Your soloution as good as you need it
as a quick side note you can evaluate expression 1 by pure algebra and just work it out

021805, 03:51 #5Registered User
 Join Date
 Nov 2004
 Posts
 19
another few problem.. big ones...
done with part 1 already...
hmm actually its my project.. hmm having a lot of problem... well here is another problem that i have face...
i wan to link VB and matlab together ... using just a click of the button.. already have the interface for it and also the matlab part for plotting has so far been finish... it look something like this///
x=xlsread('test')
V=U( : , 1)'
I=U( : , 2)'
S=size(V)
N=S(1,1)*S(1,2)
n=1
while n<N+1
x(1,n)=1/V(1,n)
y(1,n)=log(I(1,n)/(V(1,n)*V(1,n)))
y(1,n)
n=n+1
end
S=size(x)
N=S(1,1)*S(1,2)
n=2
Slope=0
Interception=0
while n<N+1
Slope=Slope+( y(1,n)y(1,n1) )/( x(1,n)x(1,n1) )
Interception=Interception( y(1,n)y(1,n1) )*x(1,n)/( x(1,n)x(1,n1) )+y(1,n)
n=n+1;
n
end
Slope_Average=Slope/(N1)
Interception_Average=Interception/(N1)
Interception_Assumption=y(1,1)/((y(1,2)y(1,1))/(x(1,2)x(1,1)))+x(1,1)
X_Constrain=Interception_Assumption
Y_Constrain=(y(1,1)y(1,2))/(x(1,1)x(1,2))*(X_Constrainx(1,1))+y(1,1)
Plot_X= [X_Constrain x 0]
Plot_Y=[Y_Constrain y Interception_Average]
plot(Plot_X, Plot_Y)
grid
xlabel('1/V')
ylabel('ln(I/V*V)')
title('Linear Plot for a&b Value')
diary M.xls
M= [exp(Interception_Average) Slope_Average]
diary off
end
but i have two problems here... 1) i can open only the file that is being place under the xlsread command... i cannot open from a directory and choose the file that i desired...
2) i search for some reference and then find that by keying in the command...
Dim x As Long
x = Shell("E:\MATLAB6p5\bin\win32\matlab.exe", 1)
i am being able to start the entire matlab program.. but thats not wat i want... cause it will still need to go through whole process... so wat should i do in order to just by a click of a button.. just start matlab and ask user to choose the file that they want and then when press ok .. the plot would be produce... hmm i hope u know wat i am trying to say here.. and of course i do hope that u can help me in any way that u can....
thanks a lot

022105, 21:44 #6Registered User
 Join Date
 Nov 2004
 Posts
 19
help me pls
hello there..
hmm i have write some code for the problem..but there seems to have a overflow problem...
the source code look like this..
Sub Benny()
Sheets("Sheet2").Select
Dim alpha As Double
Dim a As Double
Dim b As Double
Dim beta As Double
Dim funnySign As Double
Dim row As Integer
Dim tempStr As String
Dim temp As Double
alpha = Range("A1").Value
a = Range("A2").Value
b = Range("A3").Value
beta = 1
row = 4
Do While beta < 10 ^ 5
funnySign = ((b * beta) / (6.44 * (10 ^ 9))) ^ (2 / 3)
tempStr = Str(funnySign)
Call formatNumber(tempStr)
temp = (a  (alpha * 1.54 * (10 ^ 6) * (beta ^ 2) * Exp(10.4 / formatNo)) / formatNo)
MsgBox temp
If temp = 0 Then
Range("A" & row).Value = counter
row = row + 1
End If
beta = beta + 2
Loop
End Sub
Sub formatNumber(temp As String)
'up to 3 decimal places
Dim start As Double
Dim extract As String
extract = Mid(temp, 1, 3)
formatNo = CDbl(extract)
For counter = 1 To 3
extract = Mid(temp, counter + 3, 1)
start = 1
For times = 1 To counter
start = start / 10#
Next
formatNo = formatNo + CDbl(extract) * start
Next
End Sub
hmm wat can i do elimate this problem..
thanks a lot

022205, 08:47 #7Registered User
 Join Date
 Jan 2004
 Location
 Aberdeen, Scotland
 Posts
 1,067
are you still trying to solve the equation finding the values that c can hold or are you chart the function now
formatNo doesnt appear to be a global variable but if it is it will allow for divisions by 0
im not sure where your overflow is comming in what line does it stop on and what values are you getting
your second sub is also redundant if your using excel as you can use something like
Application.WorksheetFunction.Round
to round your number to however many decimal places
looking at your equation you also cant have negative numbers also
here is my soloution to part 1 this will need to be heavily altered for part 2
Code:Sub calcEqn1() Dim wks As Worksheet Dim a As Double Dim b As Double Dim beta As Double, betaMin As Double, betaMax As Double Dim Gamma As Double 'changed funny sign to gamma Dim bolReverse As Boolean Dim iterations As Double Dim temp As Double Set wks = Worksheets("Sheet2") a = wks.Range("A2").Value b = wks.Range("A3").Value beta = 1: betaMin = 1: betaMax = 1 bolReverse = False 'need to find upper and lower bounds for beta 'start with lower bounds 'do until Gamma is less than 0 Do 'as the eqaution is a cube root ( values under 1 are not defined (i.e. Imaginary numbers) Gamma = (((6.44 * (10 ^ 9) * betaMin ^ (3 / 2))) / b)  a If Not bolReverse Then If temp <> 0 Then 'test if temp < Gamma(Gamma increasing) if so reverse direction of search If temp < Gamma Then bolReverse = True End If temp = Gamma If Gamma > 0 Then betaMin = betaMin  0.1 Else If Gamma > 0 Then betaMin = betaMin + 0.1 End If Loop Until Gamma <= 0 'next upper bound Do Gamma = Gamma = (((6.44 * (10 ^ 9) * betaMax ^ (3 / 2))) / b)  a If Not bolReverse Then If Gamma > 0 Then betaMax = betaMax + 0.1 Else If Gamma > 0 Then betaMin = betaMax  0.1 End If Loop Until Gamma >= 0 'now we have obtained an upper and lower bounds iterate through function 'we can now calculate beta 'we want betamin to be the lower value for ease of use 'so adjust betamin so that its less than betamax If betaMin > betaMax Then temp = betaMin betaMin = betaMax betaMax = temp End If Do 'set up instance of beta as midpoint of betamin and betamax beta = betaMin + Abs(betaMax  betaMin) / 2 'Calculate value of beta Gamma = (((6.44 * (10 ^ 9) * beta ^ (3 / 2))) / b)  a 'check sign of gamma if its < 0 then replace betamin If Gamma < 0 Then betaMin = beta Else betaMax = beta End If iterations = iterations + 1 If iterations > 1000000 Then MsgBox "Lots of iterations i give up", vbOKOnly Exit Sub End If Loop Until Abs(Gamma) < 0.000000005 MsgBox "beta = " & beta & " after " & iterations & " iterations" End Sub
also try thinking how you would manually solve the problem and see if you can programatically put these processes down in order (i know how i would do it manually)
finally is this a maths exercise or is it a programming exercise as i would do the 2 in different ways

030705, 23:59 #8Registered User
 Join Date
 Nov 2004
 Posts
 19
help me pls
this is a programming exercise.. and its really urgent...
have been trying but still cannot get the correct answer
there is always a overflow problem...
wat can i do.. pls help
regards