none
function of the line RRS feed

  • Question

  • grrr !!...

    I'm trying to encode the function of the line and after  the function of parable

    And surely I am making a stupid mistake with the formula  y = mx + n

    I  Run the program by entering m = 4 n = 2 and x varying from - 4 to 4

    Quite simple and elementary. Thank you for your help !

    ' ecuación de la recta
    ' Resolver la función y= m * x + n
    TextWindow.WriteLine( " La recta - Resolver la función y = m * x + n ")
    TextWindow.WriteLine(" ingrese el valor de m: ")
    m= TextWindow.ReadNumber()
    TextWindow.WriteLine(" ingrese el valor de n: " )
    n= TextWindow.ReadNumber()
    TextWindow.WriteLine(" ingrese el valor inicial de x ")
    x1= TextWindow.ReadNumber()
    TextWindow.WriteLine(" ingrese el valor final de x")
    xn = TextWindow.ReadNumber()
    x[i] = 1  ' inicializo x
    y[i] = 1  ' inicializo y

    For i = x1 To xn  
      TextWindow.WriteLine(i)
      TextWindow.WriteLine(" para x = " + x[i])
      y[i] =( m * x[i] + n )
      TextWindow.WriteLine(" y =:  " + y[i])
    EndFor


    carlosfmur - Buenos Aires

    Saturday, June 9, 2012 1:16 PM

Answers

  • ' ecuación de la recta
    ' Resolver la función y= m*x + n
    
    TextWindow.WriteLine( " La recta - Resolver la función f(x) = m*x + n")
    
    TextWindow.WriteLine(" ingrese el valor de m: ")
    m = TextWindow.ReadNumber()
    
    TextWindow.WriteLine(" ingrese el valor de n: " )
    n = TextWindow.ReadNumber()
    
    TextWindow.WriteLine(" ingrese el valor inicial de x ")
    min = TextWindow.ReadNumber()
    
    TextWindow.WriteLine(" ingrese el valor final de x")
    max = TextWindow.ReadNumber()
    
    For x = min To max  
      TextWindow.WriteLine(x)
      TextWindow.WriteLine(" para x = " + x)
      y[x] = m*x + n
      TextWindow.WriteLine(" y =  " + y[x])
    EndFor


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)


    Saturday, June 9, 2012 1:48 PM
    Answerer
  • Hello Carlos!

    You were trying to display and calculate using the "values" inside the array x[], but there was nothing there!

    You shoulda used the For...EndFor's iterator as the x value instead!

    Also, I've renamed i to x, x1 to min & xn to max.

    Cya!


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Saturday, June 9, 2012 1:54 PM
    Answerer
  • HiYa!

    Quadratic Function was the 1st program I've made for SB to test its waters!

    It also calculates complex roots!  ;-D

    Only catch it is in Portuguese yet -> SZM205


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Sunday, June 10, 2012 5:23 PM
    Answerer
  • I have had a graph plotting extension (LDGraph, part of LitDev extension) with EXCEL export for several months, you can plot data simply with commands like:

    gw = 800
    gh = 800
    GraphicsWindow.Width = gw
    GraphicsWindow.Height = gh
    
    For i = 1 To 100
      data1[i] = i*Math.GetRandomNumber(10)
      data2[i] = i*Math.GetRandomNumber(10)
      data3[i] = i*Math.GetRandomNumber(10)
    EndFor
    
    graph1 = LDGraph.AddGraph(0,0,gw,gh,"Test","X","Y")
    LDGraph.AddSeriesLine(graph1,"1",data1,"Red")
    LDGraph.AddSeriesHitogram(graph1,"2",data2,"Blue")
    LDGraph.AddSeriesPoints(graph1,"3",data3,"Green")

    Or customize to change the plots with other LDGraph commands:

    Various dynamic axes scrolling and scaling options using mouse.

    Right click export options:

    There are also other programmatic ways to export data to CSV files.

    EDIT

    Another possibility is VBA (Visual Basic for Applications) macro programming in EXCEL.

    Sunday, June 10, 2012 9:32 PM
    Moderator
  • Perhaps something like this for the plotting part:

    TextWindow.Write ("Enter x² Coefficient : ")
    A = TextWindow.ReadNumber()
    TextWindow.Write ("Enter x Coefficient : ")
    B = TextWindow.ReadNumber()
    TextWindow.Write ("Enter Constant Coefficient : ")
    C = TextWindow.ReadNumber()
    
    TextWindow.Hide()
    gw = 600
    gh = 600
    GraphicsWindow.Width = gw
    GraphicsWindow.Height = gh
    
    minX = -100
    maxX = 100
    deltaX = 1
    For x = minX To maxX Step deltaX
      data[x] = A*x*x + B*x + C
    EndFor
    
    graph = LDGraph.AddGraph(0,0,gw,gh,"Polynomial","x","F(x)")
    LDGraph.AddSeriesLine(graph,A+"x² + "+B+"x + "+C,data,"Red")
    Tuesday, June 12, 2012 6:13 PM
    Moderator
  • Holá Carlos!

    You wanted both the cheese and the knife to slice it?

    Introducing the Super Graph Quadratic Equation! Import Code -> SZM205-1

    Just adapted litdev's code above and merged into mine below:

    Sub Fazer_Gráfico
      '  Cria e exibe gráfico da equação:
      '  Dependência: LDGraph da extensão do LitDev
      
      gw= 500
      gh= 500
      GraphicsWindow.Width=  gw
      GraphicsWindow.Height= gh
      GraphicsWindow.Left=   700
      GraphicsWindow.Top=    50
      
      GraphicsWindow.BackgroundColor= "Khaki"
      GraphicsWindow.Title= equação + "   " + SETA + "   " + x[1] + "  ,   " + x[2]
      GraphicsWindow.Clear()
      
      xMin= -100
      xMax=  100
      Δx= 1
      
      For x= xMin To xMax Step Δx
        f[x]= a*x*x + b*x + c
      EndFor
      
      gráfico= LDGraph.AddGraph( 0,0  gw,gh  "Quadrático", "x", "f(x)" )
      
      LDGraph.AddSeriesLine( gráfico, equação, f, "Red" )
      
    EndSub

    However, a warning: I haven't tested the fused code for I don't have any extension installed to run it yet!

    Test it out and tell me whether it's working or not.

    Laterz!!!


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Tuesday, June 12, 2012 8:46 PM
    Answerer

All replies

  • ' ecuación de la recta
    ' Resolver la función y= m*x + n
    
    TextWindow.WriteLine( " La recta - Resolver la función f(x) = m*x + n")
    
    TextWindow.WriteLine(" ingrese el valor de m: ")
    m = TextWindow.ReadNumber()
    
    TextWindow.WriteLine(" ingrese el valor de n: " )
    n = TextWindow.ReadNumber()
    
    TextWindow.WriteLine(" ingrese el valor inicial de x ")
    min = TextWindow.ReadNumber()
    
    TextWindow.WriteLine(" ingrese el valor final de x")
    max = TextWindow.ReadNumber()
    
    For x = min To max  
      TextWindow.WriteLine(x)
      TextWindow.WriteLine(" para x = " + x)
      y[x] = m*x + n
      TextWindow.WriteLine(" y =  " + y[x])
    EndFor


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)


    Saturday, June 9, 2012 1:48 PM
    Answerer
  • Hello Carlos!

    You were trying to display and calculate using the "values" inside the array x[], but there was nothing there!

    You shoulda used the For...EndFor's iterator as the x value instead!

    Also, I've renamed i to x, x1 to min & xn to max.

    Cya!


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Saturday, June 9, 2012 1:54 PM
    Answerer
  •   Hello GoToLoop

    I careless my duties viewing this magnificent game

    "New Jersey, USA, - The soccer team of Argentina, with three goals from Lionel Messi Rosario crack, beat Brazil by 4 to 3, in a memorable match in the stadium MetLife, New Jersey"

    But now I deal with this issue that so kindly helped me

    My students must solve the equation of the line using MS Excel and now I add the same algorithm using MS Small Basic

    I deeply appreciate your help

    Regards,


    carlosfmur - Buenos Aires

    Saturday, June 9, 2012 10:38 PM
  •   Hi GoToLoop

    I´ve trying the pgm and it works correctly. Many thanks

    I´ve published it as  PNX937 cause atudents nust to import it to there own files

    After your help, I´ll work with cuadratics funcitons

    Have a good sunday


    carlosfmur - Buenos Aires

    Sunday, June 10, 2012 2:46 PM
  • HiYa!

    Quadratic Function was the 1st program I've made for SB to test its waters!

    It also calculates complex roots!  ;-D

    Only catch it is in Portuguese yet -> SZM205


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Sunday, June 10, 2012 5:23 PM
    Answerer
  •  Hello GoToLoop

    I imported your program and I tried to it. Very good job.

    It works perfectly, thank you very much

    No matter that is in Portuguese, this is well understood

    I have the habit to recognize the author's credit, even a nick name

    So in the 1st line put 'SZM205 created by GoToLoop

    Regards,


    carlosfmur - Buenos Aires

    Sunday, June 10, 2012 6:58 PM
  •  

    HelloGoToLoop and anyone

    Graphics:: once solved linear and quadratic functions, we must make the corresponding graph

    Using GraphicsWindow.DrawLine (x1, y1, x2, y2) it is  complex because  to convert the function scale to pixels.

    litdev ´s suggestion: "If you just want to plot Some data, use an extension (see sticky thread on extensions and the extension has a graphing litdev object) or export to something like Excel"   is very good but we are seeing a language for beginners.

     I think about a public accountant or an economist to make his program and want to see the graphics

     Or students who are familiar with Excel or the Graphs program

     I also tried the Excel object (extension) with  ReadCell and WriteCell but with our functions we need  to export tables (X / Y) to plot their values

    I dont know how much difficulty will be to build something like a link that once found ,return values and graphs like  this:

    ( Continue)


    carlosfmur - Buenos Aires

    Sunday, June 10, 2012 9:03 PM
  •  

     or this:

     80% of people are familiar with Excel and graphics (include students) and will use what they find it easier. But they lose all the rich possibilities of building their own program, a very fun activity

    Well sooner or later we  will find this option, I´m sure

    Best regards


    carlosfmur - Buenos Aires

    Sunday, June 10, 2012 9:08 PM
  • I have had a graph plotting extension (LDGraph, part of LitDev extension) with EXCEL export for several months, you can plot data simply with commands like:

    gw = 800
    gh = 800
    GraphicsWindow.Width = gw
    GraphicsWindow.Height = gh
    
    For i = 1 To 100
      data1[i] = i*Math.GetRandomNumber(10)
      data2[i] = i*Math.GetRandomNumber(10)
      data3[i] = i*Math.GetRandomNumber(10)
    EndFor
    
    graph1 = LDGraph.AddGraph(0,0,gw,gh,"Test","X","Y")
    LDGraph.AddSeriesLine(graph1,"1",data1,"Red")
    LDGraph.AddSeriesHitogram(graph1,"2",data2,"Blue")
    LDGraph.AddSeriesPoints(graph1,"3",data3,"Green")

    Or customize to change the plots with other LDGraph commands:

    Various dynamic axes scrolling and scaling options using mouse.

    Right click export options:

    There are also other programmatic ways to export data to CSV files.

    EDIT

    Another possibility is VBA (Visual Basic for Applications) macro programming in EXCEL.

    Sunday, June 10, 2012 9:32 PM
    Moderator
  • Oh dear litdev

    I see you are also working on a Sunday

    Here we get a mass of cold air from the Antarctic. The sky lovers (south) are happy, but here in Buenos Aires, the day is gray and very cold. It seems London

    Tomorrow I will study your solution andI´ll  return my feed back

    I have no doubt that this will work very well

    Thanks for your quick response

    Regards


    carlosfmur - Buenos Aires

    Sunday, June 10, 2012 9:57 PM
  •   

    Hello litdev and GoToLoop

    I used the quadratic function    x2 +2 x + 5

    Running the program of GoToLoop, I got both roots right:    r1 = -1 + 2i   and      r2 = -1-2i

    Then, I run the litdev´s (extensions) C: \ Program Files \ Microsoft \ Small Basic \ lib \ graph_samples \ polynomial

    I entered the coefficients (1, 2, 5) and it worked well, showing me the graph of the function

    Excellent both programs, thank you very much

    I will work (I'll try) if this is not done already, to enter only once the coefficients, a pgm shows the results and display the graphic directly. I mean, both pgm´s in one

    You have helped me a lot, thank you very much again

    Regards


    carlosfmur - Buenos Aires

    Tuesday, June 12, 2012 5:37 PM
  • Perhaps something like this for the plotting part:

    TextWindow.Write ("Enter x² Coefficient : ")
    A = TextWindow.ReadNumber()
    TextWindow.Write ("Enter x Coefficient : ")
    B = TextWindow.ReadNumber()
    TextWindow.Write ("Enter Constant Coefficient : ")
    C = TextWindow.ReadNumber()
    
    TextWindow.Hide()
    gw = 600
    gh = 600
    GraphicsWindow.Width = gw
    GraphicsWindow.Height = gh
    
    minX = -100
    maxX = 100
    deltaX = 1
    For x = minX To maxX Step deltaX
      data[x] = A*x*x + B*x + C
    EndFor
    
    graph = LDGraph.AddGraph(0,0,gw,gh,"Polynomial","x","F(x)")
    LDGraph.AddSeriesLine(graph,A+"x² + "+B+"x + "+C,data,"Red")
    Tuesday, June 12, 2012 6:13 PM
    Moderator
  • Holá Carlos!

    You wanted both the cheese and the knife to slice it?

    Introducing the Super Graph Quadratic Equation! Import Code -> SZM205-1

    Just adapted litdev's code above and merged into mine below:

    Sub Fazer_Gráfico
      '  Cria e exibe gráfico da equação:
      '  Dependência: LDGraph da extensão do LitDev
      
      gw= 500
      gh= 500
      GraphicsWindow.Width=  gw
      GraphicsWindow.Height= gh
      GraphicsWindow.Left=   700
      GraphicsWindow.Top=    50
      
      GraphicsWindow.BackgroundColor= "Khaki"
      GraphicsWindow.Title= equação + "   " + SETA + "   " + x[1] + "  ,   " + x[2]
      GraphicsWindow.Clear()
      
      xMin= -100
      xMax=  100
      Δx= 1
      
      For x= xMin To xMax Step Δx
        f[x]= a*x*x + b*x + c
      EndFor
      
      gráfico= LDGraph.AddGraph( 0,0  gw,gh  "Quadrático", "x", "f(x)" )
      
      LDGraph.AddSeriesLine( gráfico, equação, f, "Red" )
      
    EndSub

    However, a warning: I haven't tested the fused code for I don't have any extension installed to run it yet!

    Test it out and tell me whether it's working or not.

    Laterz!!!


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    Tuesday, June 12, 2012 8:46 PM
    Answerer
  • Hello
    I used the quadratic equation: x2 + 35 - 11x - 72
    The program SZM205 - made by GoToLoop - Small Basic Forum
    The output is:




    With your last program output is:





    I'd like to get both outputs in the same program

    It is also very advantageous from the graph obtained would be exported to Excel, paint, etc. Very useful facility

    Many thanks litdev and GoToLoop


    carlosfmur - Buenos Aires

    Tuesday, June 12, 2012 8:51 PM
  •  

    I have installed litdev_extensions and the other extensions

    I ran the program SZM205-0  with two equations as examples and worked very well

    Thank you very much GoToLoop           

     

    ;)  :)  :)  ... "You wanted Both the cheese and the knife to slice it?"... it´s good


    carlosfmur - Buenos Aires

    Tuesday, June 12, 2012 9:45 PM