|
-
Sep 24th, 2007, 11:13 PM
#1
Thread Starter
Lively Member
is there a maths plugin??
hey dudes
i studied mechanical engineering and found vb a great tool for modelling certain processes and to automate calculations especially when thoose calculations were iterative!! [god bless the loop]
anyway i was wondering if there was some kind of library of functions you could load into your project [you'll have to excuse me, library could be completey the wrong term, i'm not a native programmer]
as i saw in one of the other posts vb has no atan function??
just wondering was there a plugin or add-on to give more maths functionality.
one thing i would be interested in is a function which handles arrays as matrices, so that you could extract eigen values/vectors from a matrix stored in an array? multiply arrays/matrices together get the inverse of an array/matrix......
nothing specific, just wondering
-
Sep 25th, 2007, 03:46 AM
#2
Re: is there a maths plugin??
You can google for it.
http://www.google.com/search?q=vb6+%...&start=10&sa=N
There are loads of stuff, most of it you must pay for
http://www.bluebit.gr/matrix/
but I'm sure there must be some free stuff as well.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 25th, 2007, 10:22 AM
#3
Frenzied Member
Re: is there a maths plugin??
 Originally Posted by new fish
as i saw in one of the other posts vb has no atan function??
As far as I remember the 'atan function' in VB is Atn().
-
Sep 25th, 2007, 11:35 AM
#4
Fanatic Member
Re: is there a maths plugin??
-
Sep 25th, 2007, 09:25 PM
#5
Thread Starter
Lively Member
Re: is there a maths plugin??
cool thanks i'll check em out!!
btw yes the inverse tan fn is atn()
but no asin fn which you have to define yourself as
Function ArcSin(x As Double) As Double
ArcSin = Atn(x / Sqr(-x * x + 1))
End Function
-
Sep 26th, 2007, 01:29 AM
#6
Frenzied Member
Re: is there a maths plugin??
Just took this from MSDN:
Derived Math Functions
The following is a list of nonintrinsic math functions that can be derived from the intrinsic math functions:
Function Derived equivalents
Secant Sec(X) = 1 / Cos(X)
Cosecant Cosec(X) = 1 / Sin(X)
Cotangent Cotan(X) = 1 / Tan(X)
Inverse Sine Arcsin(X) = Atn(X / Sqr(-X * X + 1))
Inverse Cosine Arccos(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
Inverse Secant Arcsec(X) = Atn(X / Sqr(X * X – 1)) + Sgn((X) – 1) * (2 * Atn(1))
Inverse Cosecant Arccosec(X) = Atn(X / Sqr(X * X - 1)) + (Sgn(X) – 1) * (2 * Atn(1))
Inverse Cotangent Arccotan(X) = Atn(X) + 2 * Atn(1)
Hyperbolic Sine HSin(X) = (Exp(X) – Exp(-X)) / 2
Hyperbolic Cosine HCos(X) = (Exp(X) + Exp(-X)) / 2
Hyperbolic Tangent HTan(X) = (Exp(X) – Exp(-X)) / (Exp(X) + Exp(-X))
Hyperbolic Secant HSec(X) = 2 / (Exp(X) + Exp(-X))
Hyperbolic Cosecant HCosec(X) = 2 / (Exp(X) – Exp(-X))
Hyperbolic Cotangent HCotan(X) = (Exp(X) + Exp(-X)) / (Exp(X) – Exp(-X))
Inverse Hyperbolic Sine HArcsin(X) = Log(X + Sqr(X * X + 1))
Inverse Hyperbolic Cosine HArccos(X) = Log(X + Sqr(X * X – 1))
Inverse Hyperbolic Tangent HArctan(X) = Log((1 + X) / (1 – X)) / 2
Inverse Hyperbolic Secant HArcsec(X) = Log((Sqr(-X * X + 1) + 1) / X)
Inverse Hyperbolic Cosecant HArccosec(X) = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X)
Inverse Hyperbolic Cotangent HArccotan(X) = Log((X + 1) / (X – 1)) / 2
Logarithm to base N LogN(X) = Log(X) / Log(N)
Edit: Remember these are on top of your regular: Tan(),Atn(),Cos() & Sin()
Further Edit: I recommend just putting these into a module and using the module whenever you need advanced trig functions.
Last edited by 03myersd; Sep 26th, 2007 at 01:32 AM.
-
Sep 26th, 2007, 01:56 AM
#7
Frenzied Member
Re: is there a maths plugin??
Was just trying to be nice for newfish and put all the functions in a module. But.... I got a whole load of errors. This is my code:
Code:
Function Sec(x As Double) As Double
Sec = 1 / Cos(x)
End Function
Function HArccos(x As Double) As Double
HArccos = Log(X + Sqr(X * X – 1))
End Function
Function HArcsin(x As Double) As Double
HArcsin = Log(x + Sqr(x * x + 1))
End Function
Function HCotan(x As Double) As Double
HCotan = (Exp(X) + Exp(-X)) / (Exp(X) – Exp(-X))
End Function
Function HCosec(x As Double) As Double
HCosec = 2 / (Exp(X) – Exp(-X))
End Function
Function HSec(x As Double) As Double
HSec = 2 / (Exp(x) + Exp(-x))
End Function
Function HTan(x As Double) As Double
HTan = (Exp(X) – Exp(-X)) / (Exp(X) + Exp(-X))
End Function
Function HCos(x As Double) As Double
HCos = (Exp(x) + Exp(-x)) / 2
End Function
Function LogN(x As Double) As Double
LogN = Log(x) / Log(N)
End Function
Function HArccotan(x As Double) As Double
HArccotan = Log((X + 1) / (X – 1)) / 2
End Function
Function HArccosec(x As Double) As Double
HArccosec = Log((Sgn(x) * Sqr(x * x + 1) + 1) / x)
End Function
Function HArcsec(x As Double) As Double
HArcsec = Log((Sqr(-x * x + 1) + 1) / x)
End Function
Function HArctan(x As Double) As Double
HArctan = Log((1 + X) / (1 – X)) / 2
End Function
Function HSin(x As Double) As Double
HSin = (Exp(X) – Exp(-X)) / 2
End Function
Function Arccotan(x As Double) As Double
Arccotan = Atn(x) + 2 * Atn(1)
End Function
Function Arccosec(x As Double) As Double
Arccosec = Atn(X / Sqr(X * X - 1)) + (Sgn(X) – 1) * (2 * Atn(1))
End Function
Function Arcsec(x As Double) As Double
Arcsec = Atn(X / Sqr(X * X – 1)) + Sgn((X) – 1) * (2 * Atn(1))
End Function
Function Arccos(x As Double) As Double
Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End Function
Function Arcsin(x As Double) As Double
Arcsin = Atn(x / Sqr(-x * x + 1))
End Function
Function Cotan(x As Double) As Double
Cotan = 1 / Tan(x)
End Function
Function Cosec(x As Double) As Double
Cosec = 1 / Sin(x)
End Function
All the lines with errors are in red. It only seems to be where I have:
Sgn((X) – 1) and highlights the '-' sign saying expected list separator or ")"
or
Sqr(X * X – 1) and once again hightlights the '-' with the same message.
Does anyone know why this is?
-
Sep 26th, 2007, 02:04 AM
#8
Re: is there a maths plugin??
That's right, it's the - sign. But for some reason it's as though it were not a minus sign. I have deleted all of them and replaced by newly typed minus signs and the errors disappear.
Code:
Option Explicit
Function Sec(x As Double) As Double
Sec = 1 / Cos(x)
End Function
Function HArccos(x As Double) As Double
HArccos = Log(x + Sqr(x * x - 1))
End Function
Function HArcsin(x As Double) As Double
HArcsin = Log(x + Sqr(x * x + 1))
End Function
Function HCotan(x As Double) As Double
HCotan = (Exp(x) + Exp(-x)) / (Exp(x) - Exp(-x))
End Function
Function HCosec(x As Double) As Double
HCosec = 2 / (Exp(x) - Exp(-x))
End Function
Function HSec(x As Double) As Double
HSec = 2 / (Exp(x) + Exp(-x))
End Function
Function HTan(x As Double) As Double
HTan = (Exp(x) - Exp(-x)) / (Exp(x) + Exp(-x))
End Function
Function HCos(x As Double) As Double
HCos = (Exp(x) + Exp(-x)) / 2
End Function
Function LogN(x As Double) As Double
LogN = Log(x) / Log(N)
End Function
Function HArccotan(x As Double) As Double
HArccotan = Log((x + 1) / (x - 1)) / 2
End Function
Function HArccosec(x As Double) As Double
HArccosec = Log((Sgn(x) * Sqr(x * x + 1) + 1) / x)
End Function
Function HArcsec(x As Double) As Double
HArcsec = Log((Sqr(-x * x + 1) + 1) / x)
End Function
Function HArctan(x As Double) As Double
HArctan = Log((1 + x) / (1 - x)) / 2
End Function
Function HSin(x As Double) As Double
HSin = (Exp(x) - Exp(-x)) / 2
End Function
Function Arccotan(x As Double) As Double
Arccotan = Atn(x) + 2 * Atn(1)
End Function
Function Arccosec(x As Double) As Double
Arccosec = Atn(x / Sqr(x * x - 1)) + (Sgn(x) - 1) * (2 * Atn(1))
End Function
Function Arcsec(x As Double) As Double
Arcsec = Atn(x / Sqr(x * x - 1)) + Sgn((x) - 1) * (2 * Atn(1))
End Function
Function Arccos(x As Double) As Double
Arccos = Atn(-x / Sqr(-x * x + 1)) + 2 * Atn(1)
End Function
Function Arcsin(x As Double) As Double
Arcsin = Atn(x / Sqr(-x * x + 1))
End Function
Function Cotan(x As Double) As Double
Cotan = 1 / Tan(x)
End Function
Function Cosec(x As Double) As Double
Cosec = 1 / Sin(x)
End Function
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 26th, 2007, 10:30 AM
#9
Frenzied Member
Re: is there a maths plugin??
-
Sep 26th, 2007, 12:07 PM
#10
Re: is there a maths plugin??
 Originally Posted by 03myersd
And that worked!?!
It did. Well, I didn't try the functions but I placed them in a form and there was no error when I loaded it.
Haven't you tried to copy them as I've posted them?
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 26th, 2007, 12:28 PM
#11
Frenzied Member
Re: is there a maths plugin??
Wow... It did work... Thats so weird.....
Oh well. There you go new fish. Thats a nice little module for you, courtesy of krtxmrtz.
-
Sep 26th, 2007, 12:41 PM
#12
Re: is there a maths plugin??
 Originally Posted by 03myersd
Wow... It did work... Thats so weird.....
It is... I wonder what key or key combination you may have struck that produced that strange character
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 26th, 2007, 12:42 PM
#13
Frenzied Member
Re: is there a maths plugin??
It was copied and pasted from MSDN....
-
Sep 26th, 2007, 02:55 PM
#14
Re: is there a maths plugin??
 Originally Posted by 03myersd
It was copied and pasted from MSDN....
It figures
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Sep 26th, 2007, 03:11 PM
#15
Frenzied Member
Re: is there a maths plugin??
Yeah the post was going to be:
It was copied and pasted from MSDN....Oh...
But everybody beware!! MS can't even type properly!!!! Lol.
-
Oct 9th, 2007, 11:55 PM
#16
Thread Starter
Lively Member
Re: is there a maths plugin??
lol thanks for the effort guys, give me a reason to learn what modules are !!
-
Oct 10th, 2007, 03:09 AM
#17
Re: is there a maths plugin??
 Originally Posted by new fish
lol thanks for the effort guys, give me a reason to learn what modules are !!
Not that much to be learned. Modules are simply text files with code. They are very much like forms but, unlike them, modules have no graphical representation. Add modules to your VB project and the code in them (subs, variables...) will be available to the other parts of it.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|