Skip to content

Commit fb1dcca

Browse files
Merge pull request #221 from Speedrunyourknowledge/develop
Merge Updates from Develop
2 parents c6270f9 + 55c5802 commit fb1dcca

57 files changed

Lines changed: 316286 additions & 30067 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

calc-backend/graph-gen/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Code for Generating Graphs
2-
Each python file outputs an html div for displaying the respective graph on the frontend.<br/>
2+
Each python file outputs a json object for displaying the graph on the frontend.<br/>
33
The following script must be added to index.html to render the graph:
44

55
```html

calc-backend/graph-gen/graph-deriv.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def derivative(func, x, h=1e-5):
3838
return (func(x + h) - func(x - h)) / (2 * h)
3939

4040
# Create an array of x values and evaluate f(x) for these values.
41-
x_vals = np.linspace(x_range[0], x_range[1], num=51)
41+
x_vals = np.linspace(x_range[0], x_range[1], num=101)
4242
f_vals = f(x_vals)
4343

4444
# Initialize the Plotly figure
@@ -51,16 +51,16 @@ def derivative(func, x, h=1e-5):
5151

5252
# Set the final y-axis range with padding
5353
y_min = np.min(f_vals) - pad
54-
# No padding on top to avoid cutting off curve
55-
y_max = np.max(f_vals)
54+
y_max = np.max(f_vals) + pad
5655

5756
# Calculate x-axis padding
5857
x_range_val = x_range[1] - x_range[0]
5958
x_pad = max(x_range_val * 0.05, 0.1)
6059

61-
# Set the final x-axis range with padding
62-
x_min = x_range[0] - x_pad
63-
x_max = x_range[1] + x_pad
60+
# Set the final x-axis range with padding (only pad if lowest x value >= 0)
61+
x_min = x_range[0] - x_pad if x_range[0] >= 0 else x_range[0]
62+
# No padding on right
63+
x_max = x_range[1]
6464

6565
# Vertical line at x=0 (y-axis)
6666
if x_min < 0 < x_max:
@@ -164,6 +164,7 @@ def derivative(func, x, h=1e-5):
164164
yaxis=dict(range=[y_min, y_max], fixedrange=True),
165165
sliders=sliders,
166166
uirevision='static',
167+
showlegend=False,
167168
margin=dict(t=50, r=0,l=60),
168169
)
169170

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import plotly.graph_objects as go
22
import numpy as np
33

4-
# === USER DEFINES ONLY THESE TWO ===
5-
func = lambda x: np.log(x) # ← your function
6-
limit_x = 2 # ← point to approach
4+
# === User Input ===
5+
func = lambda x: np.tan(x) # ← your function
6+
limit_x = 0 # ← point to approach
7+
8+
# === Range of values ===
9+
x_range = [-2, 2]
10+
y_range = [-75, 75]
711

812
# === Slider & sampling settings (fixed) ===
913
num_steps = 50
@@ -63,7 +67,6 @@ def segment(i):
6367
x=[limit_x], y=[y_limit],
6468
mode="markers+text",
6569
marker=dict(color="red", size=10),
66-
text=[f"Limit (x={limit_x})"],
6770
textposition="top center",
6871
showlegend=False
6972
))
@@ -83,16 +86,15 @@ def segment(i):
8386
fig.update_layout(
8487
sliders=[dict(active=0, steps=steps,
8588
currentvalue={"visible": False},
86-
pad={"t": 50}, ticklen=0)],
87-
xaxis=dict(autorange=True, fixedrange=True, title="x-axis"),
88-
yaxis=dict(autorange=True, fixedrange=True, title="y-axis"),
89-
showlegend=True
89+
pad={"t": 50}, ticklen=0, tickcolor="rgba(0,0,0,0)")],
90+
xaxis=dict(range=x_range, fixedrange=True, title="x-axis"),
91+
yaxis=dict(range=y_range, fixedrange=True, title="y-axis"),
92+
showlegend=False
9093
)
9194

92-
fig.show()
95+
# Displays figure in browser window (for local testing)
96+
# fig.show()
9397

9498
fig_json = fig.to_json(pretty=True)
9599

96-
# Save to file
97-
with open("limit-graph.txt", "a") as f:
98-
f.write(fig_json)
100+
print(fig_json)

calc-frontend/public/cosineDeriv.json

Lines changed: 2592 additions & 322 deletions
Large diffs are not rendered by default.

calc-frontend/public/cosineInt.json

Lines changed: 24363 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)