Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9062641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:47:17+00:00 2026-06-16T15:47:17+00:00

First off, here is what I have so far: Option Explicit Dim y As

  • 0

First off, here is what I have so far:

Option Explicit

Dim y As Variant
Dim yforx As Variant
Dim yfork As Variant
Dim ynew As Variant
Dim ymin As Variant
Dim x As Variant
Dim xmin As Variant
Dim k As Variant
Dim kmin As Variant
Dim s As Variant
Dim Z As Variant
Dim Track As Variant


Sub PracticeProgram()

'Selects the right sheet
Sheets("PracticeProgram").Select

'y = k ^ 2 * (x ^ 2 + 2 * x * k - 6) / (x + k) ^ 2

'these are the bounds we are stepping through
Track = 0
x = 1
xmin = 1
k = 1
kmin = 1
y = 100000000
yforx = 100000
yfork = 1000000000

Do
    y = 100000000
    For x = 0 To 1000 Step 0.1
        ynew = kmin ^ 2 * (x ^ 2 + 2 * x * kmin - 6) / (x + kmin) ^ 2

        'This checks the new y-value against an absurdly high y-value we know is wrong. if it is less than this y-value, we keep the x-value that corresponds with it.
        If ynew < y Then
            xmin = x
            y = ynew
            yforx = y
            xmin = Application.Evaluate("=Round(" & xmin & ", 3)")
        Else
        End If

    Next
  MsgBox (yforx)


    For k = 0 To 1000 Step 0.1
        y = k ^ 2 * (xmin ^ 2 + 2 * xmin * k - 6) / (xmin + k) ^ 2
        If ynew < y Then
            kmin = k
            y = ynew
            yfork = y
            kmin = Application.Evaluate("=Round(" & kmin & ",3)")
        Else
        End If
        Next

    MsgBox (yfork)

Loop Until (Abs(yforx - yfork) < 10)

End Sub

This program is supposed to find the values of x and k in order to minimize the value of y. This is a practice for a much more complicated program that will use this same concept. In my actual program y, k, and x will all be greater than zero no matter what, but since it was hard to think of a simple equation whose results would be in the shape of a parabola opening up, I decided to allow negative answers for this practice program.

Basically, it should bounce back and forth between the equations finding the ideal values for x and k until finally it has a minimal answer for y using ideal answers for both x and k. I’m not sure what the actual answer is, so I’m letting it stop within a range of 10. If it works, I’ll make it smaller, but I don’t want the program going for forever, just in case.

MY PROBLEM: I keep getting overflow errors! I’m trying to round the values for xmin and kmin to three figures after the decimal, but it doesn’t seem to be helping. Am I using them wrong? Can someone help me get this program working?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T15:47:18+00:00Added an answer on June 16, 2026 at 3:47 pm

    You’re doing a division by zero. xmin = 0, k = 0, (xmin + k) ^ 2 = 0. (I’m not sure why it isn’t reporting division by zero.)

    A suggestion: use the Locals pane to see the value of local variables. You can also use the Watch pane to see the value of expressions you want to monitor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off here is the code! <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
So, first off here's my code to open the dotx and create a new
first off I'm a noob to PHP but here is my problem. I am
First off, here is the situation. I'm using a guild hosting site that allows
First Question in here :) (AS3) First off, how do I access a variable
First off, I'm using XCode 4.0.2. Okay, here is my issue. I can build
First off I have seen Load Java-Byte-Code at Runtime and it was helpful in
First off: I am aware that there have been some vaguely similar requests on
Can anyone explain to me what is going on here? First off, I think
First off I am pretty new to C, so I probably just have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.