Jump to content

Autoit Math


Recommended Posts

i'm in 9th grade Algebra II... and i was trying to make a script that calculates the 'zeros' of a quadratic equation, but i couldn't figure it out, and i kept getting floating point numbers when i know they should be natural numbers...can someone help me?

for reference listed below are the things you'd need to make it...

x represents the value we need to find, the 'zero'...

formula:

x = {-b + (b - 4*a*c) ^ (1/2)} / 2a

and

x = {-b - (b - 4*a*c) ^ (1/2)} / 2a

i want it to ask for the values of a, b, and c and give the solution... plz help

Link to comment
Share on other sites

i'm in 9th grade Algebra II... and i was trying to make a script that calculates the 'zeros' of a quadratic equation, but i couldn't figure it out, and i kept getting floating point numbers when i know they should be natural numbers...can someone help me?

for reference listed below are the things you'd need to make it...

x represents the value we need to find, the 'zero'...

formula:

x = {-b + (b - 4*a*c) ^ (1/2)} / 2a

and

x = {-b - (b - 4*a*c) ^ (1/2)} / 2a

i want it to ask for the values of a, b, and c and give the solution... plz help

doesn't a stright calculation like below work?

$a = 2

$b=24

$c=1

$x1 = (-$b + Sqrt($b-4*$a*$c))/(2*$a)

$x2 = (-$b - Sqrt($b-4*$a*$c))/(2*$a)

msgbox(0,$x1,$x2)

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I believe you have the quadratic formula wrong.

$x1 = (-$b + Sqrt(($b^2)-4*$a*$c))/(2*$a)

Edited by mikehunt114
IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
Share on other sites

I made this once before, but before i posted it in the examples, i searched to see if one had already been posted, It appeared one had been posted, so i use that one now since its better then mine

Func _Quadratic($_A, $_B, $_C, $_Acc=3)
    Local $_Result[2]
    Local $_NegB = $_B*-1, $_Top1 = ($_NegB - Sqrt((($_B^2)-(4*$_A*$_C)))), _
    $_Top2 = ($_NegB + Sqrt((($_B^2)-(4*$_A*$_C)))), $_Bottom = (2*$_A)
    $_Result[0] = Round($_Top1/$_Bottom, $_Acc)
    $_Result[1] = Round($_Top2/$_Bottom, $_Acc)
    Return $_Result
EndFunc

Can't remember the original author, but a simple title search for "Quadratic" should turn it up.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...