Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -317,59 +317,59 @@ def find_intersections(z, y, beta, a, s_range, n_guesses, tolerance):
|
|
317 |
return intersections
|
318 |
|
319 |
def generate_curves_plot(z, y, beta, a, s_range, n_points, n_guesses, tolerance):
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
y=0.99,
|
374 |
xanchor="left",
|
375 |
x=0.01
|
|
|
317 |
return intersections
|
318 |
|
319 |
def generate_curves_plot(z, y, beta, a, s_range, n_points, n_guesses, tolerance):
|
320 |
+
s = np.linspace(s_range[0], s_range[1], n_points)
|
321 |
+
|
322 |
+
# Compute curves
|
323 |
+
y1 = curve1(s, z, y)
|
324 |
+
y2 = curve2(s, y, beta, a)
|
325 |
+
|
326 |
+
# Find intersections with improved accuracy
|
327 |
+
intersections = find_intersections(z, y, beta, a, s_range, n_guesses, tolerance)
|
328 |
+
|
329 |
+
fig = go.Figure()
|
330 |
+
|
331 |
+
fig.add_trace(
|
332 |
+
go.Scatter(
|
333 |
+
x=s, y=y1,
|
334 |
+
mode='lines',
|
335 |
+
name='z*s² + (z-y+1)*s + 1',
|
336 |
+
line=dict(color='blue', width=2)
|
337 |
+
)
|
338 |
+
)
|
339 |
+
|
340 |
+
fig.add_trace(
|
341 |
+
go.Scatter(
|
342 |
+
x=s, y=y2,
|
343 |
+
mode='lines',
|
344 |
+
name='y*β*((a-1)*s)/(a*s+1)',
|
345 |
+
line=dict(color='red', width=2)
|
346 |
+
)
|
347 |
+
)
|
348 |
+
|
349 |
+
if len(intersections) > 0:
|
350 |
+
fig.add_trace(
|
351 |
+
go.Scatter(
|
352 |
+
x=intersections,
|
353 |
+
y=curve1(intersections, z, y),
|
354 |
+
mode='markers',
|
355 |
+
name='Intersections',
|
356 |
+
marker=dict(
|
357 |
+
size=12,
|
358 |
+
color='green',
|
359 |
+
symbol='x',
|
360 |
+
line=dict(width=2)
|
361 |
+
)
|
362 |
+
)
|
363 |
+
)
|
364 |
+
|
365 |
+
fig.update_layout(
|
366 |
+
title=f"Curve Intersection Analysis (y={y:.4f}, β={beta:.4f}, a={a:.4f})",
|
367 |
+
xaxis_title="s",
|
368 |
+
yaxis_title="Value",
|
369 |
+
hovermode="closest",
|
370 |
+
showlegend=True,
|
371 |
+
legend=dict(
|
372 |
+
yanchor="top",
|
373 |
y=0.99,
|
374 |
xanchor="left",
|
375 |
x=0.01
|