hmm have another problem on hand... two maths problem in fact...
1) suppose i have b= (6.44*10E-9 *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*10E-9 * c^3/2)/B....(1)
a = (J *1.54*10E-6*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
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*10E-6*(((6.44*10E-9 * 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...
Last edited by sportyboy; 02-17-05 at 02:55.
Reason: missing parameters
Iteration, Find a lower bound and an upper bound i.e.
for equation 1)
0= (6.44*10E-9 *c^3/2)/ B-b
find a lower bound for c and an upper bound for C i.e.
(6.44*10E-9 *c^3/2)/ B-b 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
here is a v quick example for #1
try to improve on this and get yourself an answer for #2
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
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///
V=U( : , 1)'
I=U( : , 2)'
Slope=Slope+( y(1,n)-y(1,n-1) )/( x(1,n)-x(1,n-1) )
Interception=Interception-( y(1,n)-y(1,n-1) )*x(1,n)/( x(1,n)-x(1,n-1) )+y(1,n)
Plot_X= [X_Constrain x 0]
Plot_Y=[Y_Constrain y Interception_Average]
title('Linear Plot for a&b Value')
M= [exp(Interception_Average) -Slope_Average]
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....
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
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
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
'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
temp = Gamma
If Gamma > 0 Then betaMin = betaMin - 0.1
If Gamma > 0 Then betaMin = betaMin + 0.1
Loop Until Gamma <= 0
'next upper bound
Gamma = Gamma = (((6.44 * (10 ^ 9) * betaMax ^ (3 / 2))) / b) - a
If Not bolReverse Then
If Gamma > 0 Then betaMax = betaMax + 0.1
If Gamma > 0 Then betaMin = betaMax - 0.1
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
'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
betaMax = beta
iterations = iterations + 1
If iterations > 1000000 Then
MsgBox "Lots of iterations i give up", vbOKOnly
Loop Until Abs(Gamma) < 0.000000005
MsgBox "beta = " & beta & " after " & iterations & " iterations"
Dont use this as your soloution but see if you can figure out whats going on and write your own (always better for learning how to do things), this uses the principles of iteration i stated above whereas yours just seems to be developing numbers for charting
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