Skip to content

Commit 45650cf

Browse files
author
Guiners
committed
adding samples, test, lints
1 parent 6d3ba66 commit 45650cf

File tree

2 files changed

+53
-50
lines changed

2 files changed

+53
-50
lines changed

genai/thinking/thinking-includethoughts-with-txt.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async function generateContent(
5252
console.log(part.text);
5353
}
5454
}
55+
5556
// Example Response:
5657
// **My Thought Process for Solving the Quadratic Equation**
5758
//
@@ -87,6 +88,7 @@ async function generateContent(
8788
// equation: (-2)² + 4(-2) + 4 = 0. That's 4 - 8 + 4 = 0. It checks out.
8889
//
8990
// Conclusion: the solution is x = -2. Confirmed.
91+
9092
return response.text;
9193
}
9294
// [END googlegenaisdk_thinking_includethoughts_with_txt]

genai/thinking/thinking-with-txt.js

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -37,58 +37,59 @@ async function generateContent(
3737

3838
console.log(response.text);
3939

40+
// Example Response:
41+
// Okay, let's solve the quadratic equation x² + 4x + 4 = 0.
42+
//
43+
// We can solve this equation by factoring, using the quadratic formula,
44+
// or by recognizing it as a perfect square trinomial.
45+
//
46+
// **Method 1: Factoring**
47+
//
48+
// 1. We need two numbers that multiply to the constant term (4)
49+
// and add up to the coefficient of the x term (4).
50+
// 2. The numbers 2 and 2 satisfy these conditions: 2 * 2 = 4 and 2 + 2 = 4.
51+
// 3. So, we can factor the quadratic as:
52+
// (x + 2)(x + 2) = 0
53+
// or
54+
// (x + 2)² = 0
55+
// 4. For the product to be zero, the factor must be zero:
56+
// x + 2 = 0
57+
// 5. Solve for x:
58+
// x = -2
59+
//
60+
// **Method 2: Quadratic Formula**
61+
//
62+
// The quadratic formula for an equation ax² + bx + c = 0 is:
63+
// x = [-b ± sqrt(b² - 4ac)] / (2a)
64+
//
65+
// 1. In our equation x² + 4x + 4 = 0, we have a = 1, b = 4, and c = 4.
66+
// 2. Substitute these values into the formula:
67+
// x = [-4 ± sqrt(4² - 4 * 1 * 4)] / (2 * 1)
68+
// x = [-4 ± sqrt(16 - 16)] / 2
69+
// x = [-4 ± sqrt(0)] / 2
70+
// x = [-4 ± 0] / 2
71+
// x = -4 / 2
72+
// x = -2
73+
//
74+
// **Method 3: Perfect Square Trinomial**
75+
//
76+
// 1. Notice that the expression x² + 4x + 4 fits the pattern of a perfect square trinomial:
77+
// a² + 2ab + b², where a = x and b = 2.
78+
// 2. We can rewrite the equation as:
79+
// (x + 2)² = 0
80+
// 3. Take the square root of both sides:
81+
// x + 2 = 0
82+
// 4. Solve for x:
83+
// x = -2
84+
//
85+
// All methods lead to the same solution.
86+
//
87+
// **Answer:**
88+
// The solution to the equation x² + 4x + 4 = 0 is x = -2.
89+
// This is a repeated root (or a root with multiplicity 2).
90+
4091
return response.text;
4192
}
42-
// Example Response:
43-
// Okay, let's solve the quadratic equation x² + 4x + 4 = 0.
44-
//
45-
// We can solve this equation by factoring, using the quadratic formula,
46-
// or by recognizing it as a perfect square trinomial.
47-
//
48-
// **Method 1: Factoring**
49-
//
50-
// 1. We need two numbers that multiply to the constant term (4)
51-
// and add up to the coefficient of the x term (4).
52-
// 2. The numbers 2 and 2 satisfy these conditions: 2 * 2 = 4 and 2 + 2 = 4.
53-
// 3. So, we can factor the quadratic as:
54-
// (x + 2)(x + 2) = 0
55-
// or
56-
// (x + 2)² = 0
57-
// 4. For the product to be zero, the factor must be zero:
58-
// x + 2 = 0
59-
// 5. Solve for x:
60-
// x = -2
61-
//
62-
// **Method 2: Quadratic Formula**
63-
//
64-
// The quadratic formula for an equation ax² + bx + c = 0 is:
65-
// x = [-b ± sqrt(b² - 4ac)] / (2a)
66-
//
67-
// 1. In our equation x² + 4x + 4 = 0, we have a = 1, b = 4, and c = 4.
68-
// 2. Substitute these values into the formula:
69-
// x = [-4 ± sqrt(4² - 4 * 1 * 4)] / (2 * 1)
70-
// x = [-4 ± sqrt(16 - 16)] / 2
71-
// x = [-4 ± sqrt(0)] / 2
72-
// x = [-4 ± 0] / 2
73-
// x = -4 / 2
74-
// x = -2
75-
//
76-
// **Method 3: Perfect Square Trinomial**
77-
//
78-
// 1. Notice that the expression x² + 4x + 4 fits the pattern of a perfect square trinomial:
79-
// a² + 2ab + b², where a = x and b = 2.
80-
// 2. We can rewrite the equation as:
81-
// (x + 2)² = 0
82-
// 3. Take the square root of both sides:
83-
// x + 2 = 0
84-
// 4. Solve for x:
85-
// x = -2
86-
//
87-
// All methods lead to the same solution.
88-
//
89-
// **Answer:**
90-
// The solution to the equation x² + 4x + 4 = 0 is x = -2.
91-
// This is a repeated root (or a root with multiplicity 2).
9293

9394
// [END googlegenaisdk_thinking_with_txt]
9495

0 commit comments

Comments
 (0)