Solve 1 Equation with 2 Unknowns

Just starting out? Need help? Post your questions and find answers here.
miskox
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Aug 27, 2017 7:37 pm
Location: Slovenia

Re: Solve 1 Equation with 2 Unknowns

Post by miskox »

Little John wrote: Fri Mar 01, 2024 8:46 am 1) This equation also can be written like this:

Code: Select all

Y = 653184000 / (X * 499)
Or could be written as this:

Code: Select all

Y=653184000 / 499 / X
No. That's still just one of infinitely many solutions.
No. I think if

Code: Select all

X=0
then there is no solution (for Y=653184000 / 499 / X)

Saso
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Solve 1 Equation with 2 Unknowns

Post by DarkDragon »

miskox wrote: Fri Mar 01, 2024 6:42 pm
No. That's still just one of infinitely many solutions.
No. I think if

Code: Select all

X=0
then there is no solution (for Y=653184000 / 499 / X)
It's still infinitely many, even if not at X = 0.
bye,
Daniel
Little John
Addict
Addict
Posts: 4777
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Solve 1 Equation with 2 Unknowns

Post by Little John »

DarkDragon wrote: Fri Mar 01, 2024 8:17 pm It's still infinitely many, even if not at X = 0.
Yep, exactly!
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: Solve 1 Equation with 2 Unknowns

Post by VB6_to_PBx »

; these 2 Equations give 100% exact real-world correlation results

Code: Select all


; these 2 Equations give 100% exact real-world correlation results 
; X = (A / (B * Y))
; Y = (A / (B * X))

; i always know in advance what A and B values are 
; the Problem is both X and Y must be solved at the same time
; or both X and Y values need to be known in advance before the calculations

; Value constraints are these :
; A = value Range = 259200 minimum to 1140480000 maximum
; B = value Range = 2.0 minimum to 1100 maximum
; X = value Range = 50.0 minimum to 150.0 maximum
; Y = value Range = 1.0 minimum to 25000 maximum

Global.d A, B, X, Y

; When 
A = 653184000.0
B = 499.0
X = 129.60257147959285
Y = 10100
X = (A / (B * Y))
Debug A
Debug B
Debug X
Debug Y

Debug "---------------------------"
 
; When 
A = 808704000.0
B = 1006
X = 100.48508946322067
Y = 8000

X = (A / (B * Y))
Debug A
Debug B
Debug X
Debug Y

Debug "---------------------------"

Y = (A / (B * X))
Debug Y

impossible to Solve X and Y in advance of calculations ??? :(
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
TassyJim
Enthusiast
Enthusiast
Posts: 183
Joined: Sun Jun 16, 2013 6:27 am
Location: Tasmania (Australia)

Re: Solve 1 Equation with 2 Unknowns

Post by TassyJim »

; these 2 Equations give 100% exact real-world correlation results
; X = (A / (B * Y))
; Y = (A / (B * X))
X = A/(B*Y)
Y = A/(B*X)

rearranging both equations
X = A/B / Y
Y = A/B / X

Substitute X in the second equation

Y = A/B / (A/B / Y)
Y = A/B / A/B * Y
Y = (A/B / A/B) * Y
Y = 1 * Y
Y = Y

I still don't know Why!
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: Solve 1 Equation with 2 Unknowns

Post by DarkDragon »

Look, your equation describes a line in 2d space. Almost every point on that line is a solution. You need another constraint such as another line that crosses this line (but not the same line and not in parallel) to get to a single point.
bye,
Daniel
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Solve 1 Equation with 2 Unknowns

Post by STARGÅTE »

VB6_to_PBx wrote: Fri Mar 01, 2024 9:15 pm impossible to Solve X and Y in advance of calculations ??? :(
Yes, it's not possible.
If you don't know neither X nor Y, it is Impossible to solve X and Y at the same time because there is no unique case.
You can always pick randomly X (in your range) and calculate Y or pick randomly Y and calculate X.
There is no X,Y that would represent a special solution.

If you have 100 cookies, and ask, how many people X can eat how many cookies Y from this set, then this is the same situation:
One solution is 4 people, each can eat 25 cookies.
But also 10 people is right, when each eat 10 cookies.
Or 20 people, each can eat 5 cookies.
Or even one person, eating all 100 cookies.
There is no distinct solution which is more "real" than the others.

Without more information it is simply not possible, and no AI can help.
Except for a racist AI that thinks some numbers are superior to other numbers. :twisted:
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Solve 1 Equation with 2 Unknowns

Post by netmaestro »

The real solution for me is the one that lets me eat 25 cookies. :mrgreen:
BERESHEIT
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Solve 1 Equation with 2 Unknowns

Post by Michael Vogel »

I tend to eat 33 cookies and will have a look if one will remain at the end ;)

I was wondering why the following code does not scale correctly when using PB5.73 (works fine with PB6.04)...

Code: Select all

; Define

	#X=500
	#Y=500

	#Xa=-100
	#Xb=100
	#Ya=-100000
	#Yb=100000
	
	#epsilon=0.0000001
	#dots=10
	
	Global scalex.d
	Global scaley.d

; EndDefine
Procedure.d xo(x.d)
	ProcedureReturn x*scalex
EndProcedure
Procedure.d yo(y.d)
	ProcedureReturn y*scaley
EndProcedure
Procedure.d x(x.d)
	ProcedureReturn (x-#Xa)*scalex
EndProcedure
Procedure.d y(y.d)
	ProcedureReturn (y-#Ya)*scaley
EndProcedure

Procedure.d function(x.d)

	If x=0
		ProcedureReturn 0; Infinitive
	Else
		ProcedureReturn 653184000/499/x
	EndIf

EndProcedure
Procedure.d axis(minx.d,maxx.d,miny.d,maxy.d,stepx.d=1,stepy.d=1,width.d=1)

	Protected.s s
	Protected.d x,y

	MovePathCursor(x(minx),y(0))
	While minx<=maxx
		x=PathCursorX()
		y=PathCursorY()
		s=Str(minx)
		MovePathCursor(x-VectorTextWidth(s)/2,y)
		FlipCoordinatesY(0,#PB_Coordinate_User)
		DrawVectorText(s)
		FlipCoordinatesY(0,#PB_Coordinate_User)
		MovePathCursor(x,y)

		minx+stepx
		AddPathLine(x(minx),y(0))
		AddPathLine(0,5,#PB_Path_Relative)
		MovePathCursor(0,-5,#PB_Path_Relative)
	Wend

	StrokePath(width)

	MovePathCursor(x(0),y(miny))
	While miny<=maxy
		If miny
			x=PathCursorX()
			y=PathCursorY()
			s=Str(miny)
			MovePathCursor(x-12-VectorTextWidth(s)/2,y+VectorTextHeight(s)/2)
			FlipCoordinatesY(0,#PB_Coordinate_User)
			DrawVectorText(s)
			FlipCoordinatesY(0,#PB_Coordinate_User)
			MovePathCursor(x,y)
		EndIf
		miny+stepy
		AddPathLine(x(0),y(miny))
		AddPathLine(5,0,#PB_Path_Relative)
		MovePathCursor(-5,0,#PB_Path_Relative)
	Wend

	StrokePath(width)

EndProcedure
Procedure.d draw(minx.d,maxx.d,steps=100,color=#Red,width=3)

	Protected.d stepx
	Protected.d dot
	
	stepx=(maxx-minx)/steps

	MovePathCursor(x(minx),y(function(minx)))

	While minx<=maxx
		minx+stepx
		AddPathLine(x(minx),y(function(minx)))
		x=PathCursorX()
		y=PathCursorY()
		VectorSourceColor($FF000000|color)
		StrokePath(width)
		
		dot=Round(minx/#dots,#PB_Round_Down)*#dots
		If minx>dot-#epsilon And minx<dot+#epsilon
			AddPathCircle(x,y,5)
			VectorSourceColor($FF000000)
			FillPath()
			AddPathCircle(x,y,2)
			VectorSourceColor($FFFFFFFF)
			FillPath()
		EndIf
		MovePathCursor(x,y)
		
	Wend


EndProcedure

Procedure main()

	LoadFont(0,"Segoe UI",10)

	OpenWindow(0,0,0,#X,#Y,"Function Plotter",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
	CanvasGadget(0,0,0,#X,#Y)

	StartVectorDrawing(CanvasVectorOutput(0))
	scalex=#X/(#Xb-#Xa)
	scaley=#Y/(#Yb-#Ya)
	; ScaleCoordinates(scalex,scaley)
	; TranslateCoordinates(-#Xa,-#Ya)
	; FlipCoordinatesY(y(0))
	FlipCoordinatesY(#Y/2)

	VectorFont(FontID(0),15)

	axis(#Xa,#Xb,#Ya,#Yb,#dots,10000)
	draw(#Xa,#Xb,1000)

	StopVectorDrawing()

	Repeat
		Event = WaitWindowEvent()
	Until Event = #PB_Event_CloseWindow

EndProcedure

main()
Post Reply