<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
	<channel>
		<title>My Mind Leaks</title>
		<description></description>
		<link>http://www.maheshsubramaniya.com</link>
		<atom:link href="http://www.maheshsubramaniya.com/rss.xml" rel="self" type="application/rss+xml"/>
		
			
				<item>
					<title>todo.freedom - free as in freedom todo model</title>
					<description>&lt;h3 id="whats-the-problem-with-current-todo"&gt;What’s the problem with current Todo.&lt;/h3&gt;

&lt;p&gt;Yet another TODO software or service?&lt;/p&gt;

&lt;p&gt;Why am I looking at age old matured solution.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;OpenClaw made me rethink how I interact with my data.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For those unfamiliar (don’t tell me?) — &lt;a href="https://openclaw.ai/"&gt;Openclaw&lt;/a&gt; is a local agent. You run it on your machine. It can take actions on your behalf. Read files, write files, call APIs, automate workflows. The promise of agentic AI, but running locally, under your control.&lt;/p&gt;

&lt;p&gt;Once you start thinking in agents, you start noticing all the places your data is trapped.&lt;/p&gt;

&lt;p&gt;My todos are one of them.&lt;/p&gt;

&lt;p&gt;Now you are left to deal with integration fatigue, look for APIs, generate tokens, make sure you do not get throttled.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="the-problem-with-every-todo-app"&gt;The Problem With Every TODO App&lt;/h3&gt;

&lt;p&gt;There are many ways to handle a todo list. Reminders, Notes, OneNote, Google Tasks, Gmail, Todoist, and many many more.&lt;/p&gt;

&lt;p&gt;Handling todos is one of those universal problems. We’ve been solving it forever. And we have all sorts of solutions.&lt;/p&gt;

&lt;p&gt;The simplest? A text file. List down your tasks. Done.&lt;/p&gt;

&lt;p&gt;But in the modern world, we need our todos at the flick of a finger — irrespective of platform. Phone, laptop, tablet. This is what apps like Reminders, Todoist solve. Sync everywhere.&lt;/p&gt;

&lt;p&gt;So what’s the problem?&lt;/p&gt;

&lt;p&gt;The problem is the &lt;em&gt;lock-in&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Your todos live inside their database. Or in their cloud. You interact with them through &lt;em&gt;their&lt;/em&gt; UI. &lt;em&gt;Their&lt;/em&gt; app. &lt;em&gt;Their&lt;/em&gt; API. &lt;em&gt;Their&lt;/em&gt; subscription.&lt;/p&gt;

&lt;p&gt;Want to access your todos from a Telegram bot? Build an integration.&lt;/p&gt;

&lt;p&gt;Want an agent to check your tasks? Hope there’s an API.&lt;/p&gt;

&lt;p&gt;Want to switch apps? Export, pray the format transfers, re-import, lose metadata.&lt;/p&gt;

&lt;p&gt;Your data. Their jail.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="what-agents-made-me-realize"&gt;What Agents Made Me Realize&lt;/h3&gt;

&lt;p&gt;With local agents like OpenClaw — and the agentic future that’s coming — I want to interact with my todos as a basic action.&lt;/p&gt;

&lt;p&gt;A primitive.&lt;/p&gt;

&lt;p&gt;Not through a special UI. Not through a proprietary API. Just… files.&lt;/p&gt;

&lt;p&gt;Let me interact via a text file I can open in any editor.&lt;/p&gt;

&lt;p&gt;Let me interact via agents — through Telegram, WhatsApp, CLI, whatever I’m using.&lt;/p&gt;

&lt;p&gt;Let the file live in my cloud storage — Google Drive, iCloud, Dropbox. Setup local sync and use what works for you.&lt;/p&gt;

&lt;p&gt;I own the data. I control the format. The agents just read and write text.&lt;/p&gt;

&lt;p&gt;No dependency on anything.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="the-existing-plain-text-formats"&gt;The Existing Plain-Text Formats&lt;/h3&gt;

&lt;p&gt;This isn’t a new idea. I explored what’s already out there:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://todotxt.org/"&gt;todotxt.org&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="https://github.com/todotxt"&gt;github.com/todotxt&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="https://github.com/todomd/todo.md"&gt;todo.md&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Fantastic concept. Plain text. Human readable. Version controllable. Sync via any file service.&lt;/p&gt;

&lt;p&gt;I tried todo.txt for a few days. Then slowly hit the fatigue.&lt;/p&gt;

&lt;p&gt;The problem? Those systems have a very rigid structure. They provide flexibility of metadata — priorities, projects, contexts, due dates — all in a specific syntax with specific rules.&lt;/p&gt;

&lt;p&gt;But 90% of my tasks don’t need much metadata.&lt;/p&gt;

&lt;p&gt;I’d find myself fighting the format instead of just writing down what I need to do.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id="what-i-actually-need"&gt;What I Actually Need&lt;/h2&gt;

&lt;p&gt;I sat with this for a while.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What metadata do I &lt;em&gt;consistently&lt;/em&gt; maintain over years? Not what sounds useful.&lt;/li&gt;
  &lt;li&gt;What actually survives?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Required&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;State&lt;/strong&gt; — done or not done&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Priority&lt;/strong&gt; — something eye-catching so urgent things stand out&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Optional&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Date&lt;/strong&gt; — human-interpretable, however I want to read it&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Context&lt;/strong&gt; — what is this actually about&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Tags&lt;/strong&gt; — optionally, if I want to filter later&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;That’s the metadata that survives. Everything else decays.&lt;/p&gt;

&lt;p&gt;You start with elaborate systems — projects, contexts, energy levels, time estimates.&lt;/p&gt;

&lt;p&gt;Within weeks, you stop maintaining them.&lt;/p&gt;

&lt;p&gt;The cruft falls away.&lt;/p&gt;

&lt;p&gt;So why build systems for the cruft?&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id="the-requirements"&gt;The Requirements&lt;/h2&gt;

&lt;p&gt;So here’s what I want:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Human editable&lt;/strong&gt; — I can open the file in Notepad, vim, Apple Notes, whatever. Read it. Edit it. No special tooling required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Agent parseable&lt;/strong&gt; — A bot can read the file, understand the structure, add tasks, mark things complete. Simple enough that an LLM can handle it without elaborate parsing logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Platform agnostic&lt;/strong&gt; — The file lives wherever I want. iCloud, Google Drive, Dropbox, a git repo. Any sync mechanism works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No lock-in&lt;/strong&gt; — No proprietary format. No API. Just a text file with a simple convention.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Minimal structure&lt;/strong&gt; — Only the metadata humans actually maintain. State, priority, date, description, optional tags. Nothing more.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Here’s the rewrite:&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="todofreedom-format"&gt;todo.freedom format&lt;/h3&gt;

&lt;p&gt;All we need is this: &lt;em&gt;Write a todo item.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Everything else is optional.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Date&lt;/li&gt;
  &lt;li&gt;Tag for search&lt;/li&gt;
  &lt;li&gt;More context&lt;/li&gt;
  &lt;li&gt;Priority&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My requirements:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;TODOs available everywhere. No API access. No logins. No single-sign-ons.&lt;/li&gt;
  &lt;li&gt;Edit my todo.txt in plain text — on mobile, on desktop, anywhere.&lt;/li&gt;
  &lt;li&gt;My agent should understand it without special parsing logic.&lt;/li&gt;
  &lt;li&gt;No tooling restrictions. No Todoist. No app lock-in.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here’s the thing about mobile. When humans type on a phone, friction kills you. Switching keyboard layouts. Tapping through menus. Hitting the (i) icon to add metadata. Every extra tap is a reason to not capture the thought.&lt;/p&gt;

&lt;p&gt;Simple. Low friction. Fewer keys to mark. Fewer taps to add metadata.&lt;/p&gt;

&lt;p&gt;That needs a thoughtful structure.&lt;/p&gt;

&lt;p&gt;After some brainstorming, this is what I settled on:&lt;/p&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;? 2024-02-15 Call the accountant about Q4 taxes #finance
! 2024-02-10 Submit expense report
x Buy groceries
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;That’s it. Just text.&lt;/p&gt;

&lt;p&gt;Want to mark state? Add &lt;code class="language-plaintext highlighter-rouge"&gt;?&lt;/code&gt; for open, &lt;code class="language-plaintext highlighter-rouge"&gt;x&lt;/code&gt; for done.&lt;/p&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;? 2024-02-15 Call the accountant about Q4 taxes #finance
x 2024-02-10 Submit expense report
? Buy groceries
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Want priority? Add &lt;code class="language-plaintext highlighter-rouge"&gt;!&lt;/code&gt; — more exclamation marks, higher urgency.&lt;/p&gt;

&lt;p&gt;Want tags use &lt;code class="language-plaintext highlighter-rouge"&gt;#&lt;/code&gt;. Or you the same &lt;code class="language-plaintext highlighter-rouge"&gt;#&lt;/code&gt; to define a section if you prefer&lt;/p&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;? 2024-02-15 Call the accountant about Q4 taxes #finance
Send the 1099, property tax document
Bank statements

Investments document

x 2024-02-10 Submit expense report
For the cupertino travel

? Buy groceries
Milk
Eggs
Bread

! Pay rent 02/01/2026
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Date is optional. Tags are optional. Context is whatever you write.&lt;/p&gt;

&lt;p&gt;You can read it. You can edit it in any text editor. An agent can parse it in seconds.&lt;/p&gt;

&lt;p&gt;The file syncs via whatever cloud storage you already use. iCloud, Google Drive, Dropbox — doesn’t matter. No new account. No new subscription. No new app to learn.&lt;/p&gt;

&lt;p&gt;Your data stays yours.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Tightened the flow, added progressive examples showing the format building up, and kept your voice. Want me to add a summary table of the syntax or leave it minimal?&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id="why-this-matters"&gt;Why This Matters&lt;/h2&gt;

&lt;p&gt;This isn’t really about todos. It’s about a principle.&lt;/p&gt;

&lt;p&gt;The agentic future means our tools need to be &lt;em&gt;composable&lt;/em&gt;. Your calendar, your notes, your todos, your files — agents will interact with all of them. If your data is locked behind proprietary APIs and formats, you’re dependent on those companies to build integrations.&lt;/p&gt;

&lt;p&gt;Plain text is the universal interface. Every agent can read it. Every editor can open it. Every sync service can move it.&lt;/p&gt;

&lt;p&gt;It’s not fancy. It’s not feature-rich. It’s resilient.&lt;/p&gt;

&lt;p&gt;When the tool you use today shuts down — and it will, eventually — your text files will still be there. Readable. Usable. Yours.&lt;/p&gt;

&lt;h2 id="todofreedom-specification"&gt;todo.freedom Specification&lt;/h2&gt;

&lt;p&gt;Goal: Any &lt;em&gt;human/machine can read,write,update,delete in most simplest form and understand TODOs without API or special tools&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;File type: &lt;code class="language-plaintext highlighter-rouge"&gt;.txt&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Encoding: &lt;code class="language-plaintext highlighter-rouge"&gt;UTF-8&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;One file contains tasks and project headers.&lt;/p&gt;

&lt;h4 id="open-close-task"&gt;Open, Close task&lt;/h4&gt;
&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;? - open
! - priority
x - done
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id="additional-metadata-symbol"&gt;Additional metadata symbol&lt;/h4&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;# - tag or section
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id="task-states-column-0-only"&gt;Task States (column 0 only)&lt;/h4&gt;

&lt;p&gt;Each task must begin with exactly one of:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;?  Open task&lt;/li&gt;
  &lt;li&gt;!  Priority task&lt;/li&gt;
  &lt;li&gt;x  Completed task&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rules:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Prefix must be at column 0.&lt;/li&gt;
  &lt;li&gt;Prefix must be followed by a single space.&lt;/li&gt;
  &lt;li&gt;Only these prefixes create a new task.&lt;/li&gt;
  &lt;li&gt;Everything until the next project header or task prefix belongs to the current task (context).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;? Review contract 2026-03-01
! File annual report 2026-04-15
x Renew domain 2025-02-16
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id="multiline-context-optional"&gt;Multiline Context (Optional)&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;No indentation required.&lt;/li&gt;
  &lt;li&gt;Context may contain any text.&lt;/li&gt;
  &lt;li&gt;Context ends when a new project header (# ) or task prefix (? , ! , x ) appears at column 0.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If a context line must begin with # , ? , ! , or x , prefix it with &lt;code class="language-plaintext highlighter-rouge"&gt;&amp;lt;space&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;? Write email to school
 #About the test Wiley submmited
 xmas is coming
 !Also email his teacher
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id="date-optional"&gt;Date (Optional)&lt;/h4&gt;
&lt;p&gt;Each task may contain zero or one date: &lt;code class="language-plaintext highlighter-rouge"&gt;MM/DD/YYYY (US)&lt;/code&gt; or &lt;code class="language-plaintext highlighter-rouge"&gt;YYYY-MM-DD (ISO)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Rules:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Date represents the primary time anchor for the task.&lt;/li&gt;
  &lt;li&gt;Interpretation depends on state:
    &lt;ul&gt;
      &lt;li&gt;Open + future date → upcoming&lt;/li&gt;
      &lt;li&gt;Open + past date → overdue&lt;/li&gt;
      &lt;li&gt;Completed + date → completion date&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Always use ISO format for correct lexical sorting.&lt;/li&gt;
  &lt;li&gt;Recommended placement: end of the first line.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;? File taxes 2026-04-15
x Renew domain 02/01/2026
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id="tags-optional"&gt;Tags (Optional)&lt;/h4&gt;

&lt;p&gt;Tags are tokens in the form: &lt;code class="language-plaintext highlighter-rouge"&gt;#tag&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Rules:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Tags may appear anywhere inside a task block.&lt;/li&gt;
  &lt;li&gt;Tags must not start at column 0.&lt;/li&gt;
  &lt;li&gt;Tags contain no spaces.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;? File taxes #finance #annual 2026-04-15
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id="project-sections-optional"&gt;Project Sections (optional)&lt;/h4&gt;

&lt;p&gt;A project section is defined by: &lt;code class="language-plaintext highlighter-rouge"&gt;# Project Name&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Rules:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Must start at column 0.&lt;/li&gt;
  &lt;li&gt;Must be followed by a single space.&lt;/li&gt;
  &lt;li&gt;All tasks below belong to that project until the next # header.&lt;/li&gt;
  &lt;li&gt;Flat structure only (no nesting).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;# Summer Trip 2026

? pack clothes
! book flights
? book hotels 

# 2026 Plan
? Finish todo.freedom
? open source todo.freedom
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id="structural-constraints"&gt;Structural Constraints&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;Only these column-0 prefixes are meaningful:
    &lt;ul&gt;
      &lt;li&gt;#&lt;/li&gt;
      &lt;li&gt;?&lt;/li&gt;
      &lt;li&gt;!&lt;/li&gt;
      &lt;li&gt;x&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;Everything else is context.&lt;/li&gt;
  &lt;li&gt;No indentation required.&lt;/li&gt;
  &lt;li&gt;No nested hierarchy.&lt;/li&gt;
  &lt;li&gt;One project level only.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id="cli-filtering-examples"&gt;CLI Filtering Examples&lt;/h4&gt;

&lt;ul&gt;
  &lt;li&gt;Open tasks: &lt;code class="language-plaintext highlighter-rouge"&gt;grep '^[?!] ' todo.txt&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Priority tasks: &lt;code class="language-plaintext highlighter-rouge"&gt;grep '^! ' todo.txt&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Completed tasks: &lt;code class="language-plaintext highlighter-rouge"&gt;grep '^x ' archive-2026.txt&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;By project: &lt;code class="language-plaintext highlighter-rouge"&gt;awk '/^# Legal/{flag=1;next}/^# /{flag=0}flag' todo.txt&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;By tag: &lt;code class="language-plaintext highlighter-rouge"&gt;grep '#finance' todo.txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5 id="full-spec-example"&gt;Full spec example&lt;/h5&gt;

&lt;div class="language-plaintext highlighter-rouge"&gt;&lt;div class="highlight"&gt;&lt;pre class="highlight"&gt;&lt;code&gt;# TODO

? Review contract 2026-03-01
! File annual report 2026-04-15
x Renew domain 2025-02-16


? File taxes #finance #annual 2026-04-15
x Renew domain 02/01/2026

? This todo has context starting with reserved prefix. This is offset with &amp;lt;space&amp;gt;
 #About the test Wiley submmited
 xmas is coming
 !Also email his teacher


# Summer Trip 2026

? pack clothes
! book flights
? book hotels 

# 2026 Plan
? Finish todo.freedom
? open source todo.freedom
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
					<pubDate>Sat, 10 Jan 2026 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/todo.txt.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/todo.txt.html</guid>
				</item>
			
		
			
				<item>
					<title>US Dollar (USD) as Reserve currency and its future - Part 2</title>
					<description>&lt;script src="https://cdn.jsdelivr.net/npm/chart.js"&gt;&lt;/script&gt;

&lt;p&gt;In &lt;a href="/article/usd-as-reserve-currency.html"&gt;Part 1&lt;/a&gt;, we traced how the dollar became dominant through three strategic moves — Bretton Woods, the Nixon Shock, and the petrodollar arrangement. Each time the old foundation crumbled, America engineered a new one.&lt;/p&gt;

&lt;p&gt;Now the question: is a fourth move coming? And who’s trying to make sure it fails?&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="replace-the-dollar-or-get-around-it"&gt;Replace the dollar or get around it?&lt;/h3&gt;

&lt;p&gt;My guess here is - de-dollarization commentary gets wrong: the challengers aren’t trying to &lt;em&gt;replace&lt;/em&gt; the dollar with something else. They’re trying to &lt;em&gt;route around&lt;/em&gt; it.&lt;/p&gt;

&lt;p&gt;No one is building a new global reserve currency. They’re building escape routes — bilateral agreements, regional settlement systems, sanctions-proof alternatives. The goal isn’t a new monetary hegemon. The goal is optionality.&lt;/p&gt;

&lt;p&gt;This distinction matters. A frontal assault on dollar dominance would fail. The network effects are too strong, the infrastructure too deep. But a gradual erosion? A world where the dollar is still #1 but no longer the &lt;em&gt;only&lt;/em&gt; option? That’s already happening.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="the-challengers-where-theyll-win-and-where-theyll-lose"&gt;The Challengers: Where They’ll Win and Where They’ll Lose&lt;/h3&gt;

&lt;h4 id="china-and-the-yuan"&gt;China and the Yuan&lt;/h4&gt;

&lt;p&gt;China has been methodical. Since 2015, they’ve built an alternative payments infrastructure piece by piece.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What they’ve built:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;CIPS (Cross-Border Interbank Payment System) — their SWIFT alternative, now connected to 1,400+ institutions in 100+ countries&lt;/li&gt;
  &lt;li&gt;Bilateral currency swap lines with 40+ central banks&lt;/li&gt;
  &lt;li&gt;Petroyuan agreements — buying Russian oil, Iranian oil, some Saudi oil in yuan&lt;/li&gt;
  &lt;li&gt;Digital yuan (e-CNY) — the most advanced major-economy CBDC&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where they’ll win:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;China will dominate &lt;em&gt;regional&lt;/em&gt; settlement. ASEAN countries increasingly settle trade with China in yuan — it’s simply easier when China is your largest trading partner. Belt and Road projects are yuan-denominated. African infrastructure loans are repaid in yuan. Central Asian energy deals bypass the dollar entirely.&lt;/p&gt;

&lt;p&gt;For &lt;em&gt;sanctioned nations&lt;/em&gt;, the yuan is already the primary alternative. Russia now holds more yuan than euros. Iran and Venezuela have no choice. This is a growing club.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where they’ll lose:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Capital controls kill the yuan’s reserve currency ambitions. No treasury manager wants to hold large yuan reserves when Beijing can restrict outflows at any moment. You can’t be a reserve currency if people can’t &lt;em&gt;freely leave&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;There’s also no deep, liquid bond market. US Treasuries are the world’s safe asset because you can buy or sell $50 billion without moving the price. Chinese government bonds don’t offer that liquidity.&lt;/p&gt;

&lt;p&gt;And there’s political risk. Xi can freeze your assets too — just ask Jack Ma. The dollar’s issuer is unpredictable; the yuan’s issuer is unpredictable &lt;em&gt;and&lt;/em&gt; opaque.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verdict:&lt;/strong&gt; Regional winner, global also-ran. The yuan will capture 5-8% of reserves by 2035. It won’t capture 20%.&lt;/p&gt;

&lt;hr /&gt;

&lt;h4 id="brics-and-the-fantasy-of-a-common-currency"&gt;BRICS+ and the Fantasy of a Common Currency&lt;/h4&gt;

&lt;p&gt;Every BRICS summit produces headlines about a new currency to challenge the dollar. Every headline is premature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What they’re doing:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;New Development Bank (alternative to World Bank/IMF)&lt;/li&gt;
  &lt;li&gt;Talk of a common settlement unit (maybe gold-backed, maybe basket-weighted)&lt;/li&gt;
  &lt;li&gt;Bilateral trade in local currencies (India-Russia in rupees, China-Brazil in yuan)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where they’ll win:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bilateral settlement between members is genuinely growing. India paid for Russian oil in rupees and dirhams throughout 2023-2024. China and Brazil now settle some trade in yuan. These are real flows, real infrastructure.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;symbolism&lt;/em&gt; also matters. BRICS+ represents the global majority frustrated with dollar hegemony. That political momentum creates pressure, even if the financial architecture lags.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where they’ll lose:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A currency needs trust. BRICS is a bloc of convenience, not shared interests.&lt;/p&gt;

&lt;p&gt;India and China are strategic rivals — they had a border war in 2020. Brazil’s economy is a fraction of China’s. Russia is a sanctions-crippled petro-state. South Africa is economically marginal. The new members (Iran, UAE, Ethiopia, Egypt) add political diversity, not financial depth.&lt;/p&gt;

&lt;p&gt;There’s no shared fiscal policy, no common central bank, no integrated bond market. The euro took decades to build with far more aligned economies — and it still nearly collapsed in 2012.&lt;/p&gt;

&lt;p&gt;A BRICS currency is a talking point, not a project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verdict:&lt;/strong&gt; Useful for bilateral workarounds. Irrelevant as a dollar replacement.&lt;/p&gt;

&lt;hr /&gt;

&lt;h4 id="the-euro-permanent-runner-up"&gt;The Euro: Permanent Runner-Up&lt;/h4&gt;

&lt;p&gt;The euro is the only currency with the &lt;em&gt;scale&lt;/em&gt; to rival the dollar. It hasn’t, and probably won’t.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it has:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;20% of global reserves (stable for two decades)&lt;/li&gt;
  &lt;li&gt;Deep, liquid bond markets (though fragmented by country)&lt;/li&gt;
  &lt;li&gt;Rule of law, property rights, no capital controls&lt;/li&gt;
  &lt;li&gt;Already the #2 invoicing currency for global trade&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where it’ll win:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The euro is the safe alternative for those who want to diversify from dollars but don’t trust Beijing. European companies increasingly invoice in euros. Some commodity contracts (especially gas) have shifted to euro pricing.&lt;/p&gt;

&lt;p&gt;For Russia sanctions, the euro was frozen alongside the dollar — but that’s made some countries see the euro as “just as bad” while others see it as “the next best option.” It’s complicated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where it’ll lose:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;No fiscal union means no Eurobond — no single safe asset equivalent to Treasuries. German bunds are safe but small. Italian bonds are large but risky. The market is fragmented.&lt;/p&gt;

&lt;p&gt;Political fragmentation is worse. Hungary blocks sanctions. Italy flirts with euroskepticism. France and Germany can’t agree on anything. The ECB isn’t the Fed — it can’t act as global lender of last resort because it’s politically constrained by 20 different governments.&lt;/p&gt;

&lt;p&gt;The euro is structurally capped. It’s the best alternative, but it can’t become the primary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verdict:&lt;/strong&gt; Stable at 20-22%. The euro is a complement to dollar dominance, not a threat to it.&lt;/p&gt;

&lt;hr /&gt;

&lt;h4 id="gold-the-ancient-hedge-returns"&gt;Gold: The Ancient Hedge Returns&lt;/h4&gt;

&lt;p&gt;Central banks bought more gold in 2022-2023 than in any year since 1950. This isn’t nostalgia. It’s strategy.&lt;/p&gt;

&lt;div style="background:#fff; padding:25px; border-radius:8px; margin:35px 0; box-shadow:0 2px 8px rgba(0,0,0,0.08);"&gt;
  &lt;h4 style="color:#b8860b; margin:0 0 5px;"&gt;Central Bank Gold Purchases (2015-2024)&lt;/h4&gt;
  &lt;p style="font-size:0.85rem; color:#666; margin:0 0 20px;"&gt;Net purchases in metric tonnes — note the post-2022 surge after Russia sanctions&lt;/p&gt;
  &lt;canvas id="goldBuyingChart" height="80"&gt;&lt;/canvas&gt;
  &lt;div style="margin-top:20px; padding:15px; background:#fef9e7; border-radius:6px; font-size:0.9rem;"&gt;
    &lt;strong&gt;Key insight:&lt;/strong&gt; After the US froze Russia's dollar reserves in 2022, central banks globally accelerated gold purchases. Gold can't be frozen, sanctioned, or debased by a foreign power.
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;What’s happening:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;China added 300+ tonnes in 2023 alone (officially — likely more unreported)&lt;/li&gt;
  &lt;li&gt;Russia, Turkey, India, Poland, Singapore all major buyers&lt;/li&gt;
  &lt;li&gt;Gold’s share of reserves has doubled from ~10% (2015) to ~20%+ (2024)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where gold wins:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gold is the ultimate sanctions hedge. You can’t freeze a gold bar sitting in your own vault. You can’t debase it through money printing. You can’t cut it off from SWIFT.&lt;/p&gt;

&lt;p&gt;For countries worried about dollar weaponization, gold is insurance. Not a transaction currency — but a store of value that doesn’t depend on American goodwill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where gold loses:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can’t pay for LNG imports with gold bars. Settlement is slow, physical, and expensive. There’s no yield. It’s illiquid at scale.&lt;/p&gt;

&lt;p&gt;Gold is a hedge, not an infrastructure. Countries are buying it to &lt;em&gt;reduce exposure&lt;/em&gt; to the dollar, not to &lt;em&gt;replace&lt;/em&gt; the dollar in daily commerce.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verdict:&lt;/strong&gt; Reserve diversification continues. Gold goes from 20% to maybe 25-30% of reserves. But it’s savings account, not checking account.&lt;/p&gt;

&lt;hr /&gt;

&lt;h4 id="stablecoins-dollar-dominance-by-accident"&gt;Stablecoins: Dollar Dominance by Accident&lt;/h4&gt;

&lt;p&gt;Here’s the irony: the biggest “threat” to the dollar might actually strengthen it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What’s happening:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Tether (USDT) processes more transaction volume than Visa&lt;/li&gt;
  &lt;li&gt;Circle’s USDC is used for remittances across Latin America, Africa, Southeast Asia&lt;/li&gt;
  &lt;li&gt;Dollar-backed stablecoins are the de facto currency of crypto markets&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where they’ll win:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Stablecoins are dollarizing the world &lt;em&gt;faster&lt;/em&gt; than the Fed ever could. A farmer in Nigeria holding USDT on his phone has dollar exposure without a bank account. A Venezuelan family receiving remittances in USDC bypasses both their broken banking system and their worthless bolivar.&lt;/p&gt;

&lt;p&gt;This is dollarization from below — not through government policy, but through individual choice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where they’ll lose:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Regulatory crackdowns could crush the sector. No lender of last resort means a Tether collapse would be catastrophic. And stablecoins don’t help countries that &lt;em&gt;want&lt;/em&gt; to escape dollar dependence — they deepen it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verdict:&lt;/strong&gt; Stablecoins strengthen dollar hegemony, not weaken it. The US should embrace them strategically.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="the-scoreboard-where-the-dollar-is-vulnerable"&gt;The Scoreboard: Where the Dollar Is Vulnerable&lt;/h3&gt;

&lt;p&gt;Not all arenas are equal. The dollar’s grip varies dramatically depending on what you’re measuring.&lt;/p&gt;

&lt;div style="background:#fff; padding:25px; border-radius:8px; margin:35px 0; box-shadow:0 2px 8px rgba(0,0,0,0.08);"&gt;
  &lt;h4 style="color:#1a365d; margin:0 0 5px;"&gt;Dollar Dominance by Arena — Threat Assessment&lt;/h4&gt;
  &lt;p style="font-size:0.85rem; color:#666; margin:0 0 20px;"&gt;Where USD is vulnerable vs. where it remains entrenched (scale: 0 = no threat, 10 = high threat)&lt;/p&gt;
  &lt;canvas id="threatChart" height="80"&gt;&lt;/canvas&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Reading the chart:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;High threat areas&lt;/em&gt; — Sanctioned countries have already left. Bilateral commodity trade is increasingly non-dollar. These trains have departed.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Medium threat areas&lt;/em&gt; — Oil trade and reserves are slowly diversifying. Not collapsing, but eroding at 1-2% per year.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Low threat areas&lt;/em&gt; — Debt issuance, trade finance, and the core plumbing of global finance remain dollar-dominated. Network effects here are strongest.&lt;/p&gt;

&lt;p&gt;The dollar won’t lose everywhere at once. It’s losing at the margins first.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="the-de-dollarization-spectrum"&gt;The De-Dollarization Spectrum&lt;/h3&gt;

&lt;p&gt;Countries aren’t binary — “dollarized” or “de-dollarized.” They exist on a spectrum based on their political alignment, sanctions exposure, and economic ties.&lt;/p&gt;

&lt;div style="background:#fff; padding:25px; border-radius:8px; margin:35px 0; box-shadow:0 2px 8px rgba(0,0,0,0.08);"&gt;
  &lt;h4 style="color:#5c3d6e; margin:0 0 5px;"&gt;De-Dollarization Spectrum by Country Positioning&lt;/h4&gt;
  &lt;p style="font-size:0.85rem; color:#666; margin:0 0 20px;"&gt;Where major economies sit on dollar dependence (left) vs. active de-dollarization (right)&lt;/p&gt;
  &lt;canvas id="spectrumChart" height="80"&gt;&lt;/canvas&gt;
  &lt;div style="margin-top:20px; padding:15px; background:#f5f3ff; border-radius:6px; font-size:0.9rem;"&gt;
    &lt;strong&gt;Reading this chart:&lt;/strong&gt; Higher score = more actively reducing dollar exposure. Sanctioned nations lead; US allies trail. The middle band — India, Brazil, Saudi, UAE — is where the action is. They're hedging, not choosing sides.
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;The three tiers:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 1: Fully committed to de-dollarization (score 7-10)&lt;/strong&gt;
Russia, Iran, Venezuela — they have no choice. Sanctions forced them out. China is here by strategy, not necessity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 2: Hedging actively (score 4-7)&lt;/strong&gt;
India, Brazil, Saudi Arabia, UAE, Indonesia, South Africa — these are the swing states. They’re not anti-American, but they’re building alternatives. India buys Russian oil in rupees. Saudi discusses yuan pricing with China. Brazil settles with China directly. They want &lt;em&gt;optionality&lt;/em&gt;, not revolution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tier 3: Dollar-aligned (score 0-4)&lt;/strong&gt;
Japan, UK, EU, Australia, Canada, South Korea — US allies with deep financial integration. They may grumble about dollar hegemony, but they’re not building exits. Their banks, their reserves, their trade finance are all dollar-native.&lt;/p&gt;

&lt;p&gt;The real story is Tier 2. That’s where the dollar’s future will be decided.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="the-real-threat-fragmentation-not-replacement"&gt;The Real Threat: Fragmentation, Not Replacement&lt;/h3&gt;

&lt;p&gt;Let me be direct: &lt;strong&gt;no currency will replace the dollar as global hegemon.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not the yuan — capital controls and political risk disqualify it.
Not the euro — structural fragmentation caps its ceiling.
Not gold — you can’t run a payments system on metal.
Not crypto — too volatile, too unregulated, too weird for central banks.&lt;/p&gt;

&lt;p&gt;But that’s not the threat.&lt;/p&gt;

&lt;p&gt;The threat is &lt;em&gt;fragmentation&lt;/em&gt; — a world where:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Regional blocs settle in local currencies (ASEAN in yuan, Mercosur in reals, Africa in mixed)&lt;/li&gt;
  &lt;li&gt;Commodity trade partially shifts to seller’s currency (oil in yuan for China, gas in rubles for Europe, gold for sanctions targets)&lt;/li&gt;
  &lt;li&gt;Every major economy holds 20-30% non-dollar reserves as insurance&lt;/li&gt;
  &lt;li&gt;SWIFT alternatives handle growing share of non-Western flows&lt;/li&gt;
  &lt;li&gt;The dollar is still #1, but at 45% of reserves instead of 58%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is &lt;strong&gt;multipolar money&lt;/strong&gt;. Not dollar collapse — dollar &lt;em&gt;dilution&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;The US would still have enormous privilege. But less than today. And shrinking.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="what-the-us-could-do-the-fourth-move"&gt;What the US Could Do: The Fourth Move&lt;/h3&gt;

&lt;p&gt;History suggests America doesn’t accept decline passively. When Bretton Woods crumbled, Nixon pivoted to fiat. When fiat needed an anchor, Kissinger created the petrodollar.&lt;/p&gt;

&lt;p&gt;What’s the fourth move?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 1: Embrace stablecoins as dollar distribution&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Private stablecoins are already spreading dollar usage faster than any government program. USDT and USDC have dollarized more people in five years than the IMF did in fifty.&lt;/p&gt;

&lt;p&gt;The US could lean into this. Regulate stablecoins enough to ensure backing and compliance. Let them run on global rails. Accept that Tether operating from the Bahamas is still &lt;em&gt;dollar hegemony&lt;/em&gt; — just privatized.&lt;/p&gt;

&lt;p&gt;Risk: Regulatory turf wars (SEC vs. CFTC vs. Fed) could strangle the sector instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 2: Launch a wholesale digital dollar&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not a retail CBDC — Americans don’t need digital cash. But a &lt;em&gt;wholesale&lt;/em&gt; digital dollar for interbank settlement could modernize the plumbing.&lt;/p&gt;

&lt;p&gt;The mBridge project (China, UAE, Thailand, Hong Kong) is already piloting multi-CBDC settlement. If cross-border payments become faster and cheaper through non-dollar rails, the US needs a competitive offering.&lt;/p&gt;

&lt;p&gt;Risk: The Fed moves slowly. China is five years ahead on CBDC infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 3: Weaponize less, co-opt more&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every new sanctions regime pushes marginal countries toward alternatives. The Russia sanctions were necessary — but they also showed every neutral country what &lt;em&gt;could&lt;/em&gt; happen to them.&lt;/p&gt;

&lt;p&gt;A smarter approach: expand swap lines, increase IMF flexibility, offer dollar access as a carrot instead of only using exclusion as a stick.&lt;/p&gt;

&lt;p&gt;Risk: Domestic politics make this nearly impossible. “Soft on adversaries” is an attack ad.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 4: Tie new strategic sectors to dollar settlement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The petrodollar worked because everyone needed oil. What does everyone need now?&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Semiconductors (TSMC, ASML, Nvidia)&lt;/li&gt;
  &lt;li&gt;Cloud infrastructure (AWS, Azure, GCP)&lt;/li&gt;
  &lt;li&gt;AI models and compute&lt;/li&gt;
  &lt;li&gt;Pharmaceutical supply chains&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If access to advanced chips or AI compute requires dollar settlement, you’ve created new structural demand. This is industrial policy meets monetary strategy.&lt;/p&gt;

&lt;p&gt;Risk: Could accelerate China’s push for self-sufficiency. Creates new geopolitical flashpoints.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="the-strategic-takeaway"&gt;The Strategic Takeaway&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;For countries:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;De-dollarization isn’t ideology — it’s risk management. Every treasury should be asking:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;What percentage of our reserves are in dollars?&lt;/li&gt;
  &lt;li&gt;What happens if we’re sanctioned (even secondarily)?&lt;/li&gt;
  &lt;li&gt;Do we have bilateral settlement options with major trading partners?&lt;/li&gt;
  &lt;li&gt;Should we be holding more gold?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The answer isn’t to dump dollars. It’s to build optionality while dollar infrastructure still works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For payment leaders:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The future is multi-rail, multi-currency. The corridors that matter in 2030:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;China-ASEAN (yuan-dominated)&lt;/li&gt;
  &lt;li&gt;India-Middle East (rupee/dirham mix)&lt;/li&gt;
  &lt;li&gt;Africa (yuan for infrastructure, dollar for trade, mobile money for retail)&lt;/li&gt;
  &lt;li&gt;Latin America (dollar + real + yuan depending on partner)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Winners will be those who can settle in &lt;em&gt;any&lt;/em&gt; currency the counterparty wants. Single-currency dependency is a vulnerability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For the US:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The dollar’s dominance was never automatic. It was engineered, defended, and re-engineered when necessary.&lt;/p&gt;

&lt;p&gt;The current complacency is dangerous. While Washington debates stablecoin regulation and the Fed studies CBDCs, China is deploying infrastructure. BRICS is signing agreements. Central banks are buying gold.&lt;/p&gt;

&lt;p&gt;The window for a fourth strategic move is open. It won’t stay open forever.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id="conclusion-the-dollar-isnt-dying-but-its-no-longer-alone"&gt;Conclusion: The Dollar Isn’t Dying. But It’s No Longer Alone.&lt;/h3&gt;

&lt;p&gt;Eighty years ago, the dollar replaced the pound through strategic positioning at a moment of crisis.&lt;/p&gt;

&lt;p&gt;Fifty years ago, the dollar survived the end of gold backing by becoming indispensable infrastructure.&lt;/p&gt;

&lt;p&gt;The next fifty years will be different. Not a single challenger rising to replace the dollar, but a slow fragmentation — regional blocs, bilateral deals, digital alternatives, sanctions hedges.&lt;/p&gt;

&lt;p&gt;The dollar will still be #1 in 2050. But #1 with 45% share in a fragmented system is very different from #1 with 70% share in a unipolar one.&lt;/p&gt;

&lt;p&gt;The question isn’t whether the dollar will fall. It’s whether America will adapt — again — or let entropy do its work.&lt;/p&gt;

&lt;p&gt;History suggests adaptation. But history isn’t destiny.&lt;/p&gt;

&lt;p&gt;The fourth move is waiting to be made.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;#USD #Geopolitics #Finance #Payments #DeDollarization #BRICS #China #Yuan&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Data sources: IMF COFER, World Gold Council, BIS, SWIFT, PBoC&lt;/em&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;script&gt;
document.addEventListener('DOMContentLoaded', function() {
  
  // Helper function
  function createChartIfPresent(id, config) {
    var canvas = document.getElementById(id);
    if (!canvas) return;
    new Chart(canvas, config);
  }

  // 1. Central Bank Gold Buying Chart
  createChartIfPresent('goldBuyingChart', {
    type: 'bar',
    data: {
      labels: ['2015', '2016', '2017', '2018', '2019', '2020', '2021', '2022', '2023', '2024'],
      datasets: [{
        label: 'Net Gold Purchases (tonnes)',
        data: [566, 383, 375, 656, 668, 255, 463, 1082, 1037, 890],
        backgroundColor: [
          'rgba(184, 134, 11, 0.6)',
          'rgba(184, 134, 11, 0.6)',
          'rgba(184, 134, 11, 0.6)',
          'rgba(184, 134, 11, 0.6)',
          'rgba(184, 134, 11, 0.6)',
          'rgba(184, 134, 11, 0.6)',
          'rgba(184, 134, 11, 0.6)',
          'rgba(184, 134, 11, 1)',
          'rgba(184, 134, 11, 1)',
          'rgba(184, 134, 11, 0.8)'
        ],
        borderColor: '#b8860b',
        borderWidth: 1
      }]
    },
    options: {
      responsive: true,
      plugins: {
        legend: { display: false },
        tooltip: {
          callbacks: {
            label: function(context) {
              return context.parsed.y + ' tonnes';
            }
          }
        }
      },
      scales: {
        y: {
          beginAtZero: true,
          max: 1200,
          ticks: {
            callback: function(value) { return value + 't'; }
          }
        }
      }
    }
  });

  // 2. Threat Assessment Horizontal Bar Chart
  createChartIfPresent('threatChart', {
    type: 'bar',
    data: {
      labels: [
        'Sanctioned country flows',
        'Bilateral commodity trade',
        'Central bank reserves',
        'Oil trade settlement',
        'Cross-border payments',
        'Trade finance',
        'International debt issuance'
      ],
      datasets: [{
        label: 'Threat to USD Dominance',
        data: [9, 7, 5, 5, 4, 2, 2],
        backgroundColor: [
          'rgba(139, 44, 44, 0.9)',
          'rgba(139, 44, 44, 0.75)',
          'rgba(217, 119, 6, 0.7)',
          'rgba(217, 119, 6, 0.7)',
          'rgba(217, 119, 6, 0.5)',
          'rgba(45, 90, 39, 0.6)',
          'rgba(45, 90, 39, 0.6)'
        ],
        borderColor: [
          '#8b2c2c',
          '#8b2c2c',
          '#d97706',
          '#d97706',
          '#d97706',
          '#2d5a27',
          '#2d5a27'
        ],
        borderWidth: 1
      }]
    },
    options: {
      indexAxis: 'y',
      responsive: true,
      plugins: {
        legend: { display: false },
        tooltip: {
          callbacks: {
            label: function(context) {
              var level = context.parsed.x;
              var desc = level &gt;= 7 ? 'High threat' : level &gt;= 4 ? 'Medium threat' : 'Low threat';
              return desc + ' (' + level + '/10)';
            }
          }
        }
      },
      scales: {
        x: {
          beginAtZero: true,
          max: 10,
          ticks: {
            callback: function(value) { return value; }
          },
          title: {
            display: true,
            text: 'Threat Level (0 = entrenched, 10 = vulnerable)'
          }
        }
      }
    }
  });

  // 3. De-Dollarization Spectrum Chart
  createChartIfPresent('spectrumChart', {
    type: 'bar',
    data: {
      labels: [
        'Russia',
        'Iran', 
        'China',
        'Venezuela',
        'India',
        'Brazil',
        'Saudi Arabia',
        'UAE',
        'Indonesia',
        'South Africa',
        'Turkey',
        'EU',
        'Japan',
        'UK',
        'South Korea',
        'Australia',
        'Canada'
      ],
      datasets: [{
        label: 'De-dollarization score',
        data: [10, 9, 8, 8, 6, 5, 5, 5, 4, 4, 6, 2, 1, 1, 2, 1, 1],
        backgroundColor: function(context) {
          var value = context.parsed.y;
          if (value &gt;= 7) return 'rgba(139, 44, 44, 0.8)';
          if (value &gt;= 4) return 'rgba(217, 119, 6, 0.7)';
          return 'rgba(26, 54, 93, 0.7)';
        },
        borderColor: function(context) {
          var value = context.parsed.y;
          if (value &gt;= 7) return '#8b2c2c';
          if (value &gt;= 4) return '#d97706';
          return '#1a365d';
        },
        borderWidth: 1
      }]
    },
    options: {
      indexAxis: 'y',
      responsive: true,
      plugins: {
        legend: { display: false },
        tooltip: {
          callbacks: {
            label: function(context) {
              var score = context.parsed.x;
              var tier = score &gt;= 7 ? 'Tier 1: Active de-dollarization' : 
                         score &gt;= 4 ? 'Tier 2: Hedging / building options' : 
                         'Tier 3: Dollar-aligned';
              return tier + ' (score: ' + score + '/10)';
            }
          }
        }
      },
      scales: {
        x: {
          beginAtZero: true,
          max: 10,
          ticks: {
            callback: function(value) { return value; }
          },
          title: {
            display: true,
            text: '← Dollar-aligned    |    Active de-dollarization →'
          }
        }
      }
    }
  });

});
&lt;/script&gt;

</description>
					<pubDate>Thu, 14 Aug 2025 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/usd-as-reserve-currency-2.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/usd-as-reserve-currency-2.html</guid>
				</item>
			
		
			
				<item>
					<title>Cross-Border Payments in 2025 - Where the Rails Are Actually Improving</title>
					<description>&lt;p&gt;Moving money across borders has always been friction wrapped in fees. You initiate a wire transfer. It hops through three or four banks. Each one takes a cut. Two to five days later, it arrives — minus a chunk you didn’t fully anticipate.&lt;/p&gt;

&lt;p&gt;We’ve lived with this for decades. But something is shifting.&lt;/p&gt;

&lt;p&gt;Not the fintech marketing — the actual plumbing.&lt;/p&gt;

&lt;h2 id="where-is-real-progress-happening"&gt;Where is real progress happening?&lt;/h2&gt;

&lt;p&gt;A few places are genuinely interesting.&lt;/p&gt;

&lt;p&gt;First, instant payment networks are starting to talk to each other. Singapore’s PayNow now connects to India’s UPI and Thailand’s PromptPay. Money moves in minutes. Not through correspondent banks. Through direct rails. The ASEAN region is building something called Project Nexus to link five countries’ domestic instant payment systems. Europe’s SEPA Instant now reaches virtually every eurozone bank account.&lt;/p&gt;

&lt;p&gt;This is real infrastructure. Not a wrapper on the old system.&lt;/p&gt;

&lt;p&gt;Second, SWIFT — the network everyone loves to criticize — has actually improved. Their gpi system brought tracking (finally) and speed commitments. The average gpi payment now settles in under 30 minutes. Still uses correspondent banks. Still has fees. But measurably better than the black hole it used to be.&lt;/p&gt;

&lt;p&gt;Third, central banks are experimenting with shared digital currency ledgers. Project mBridge connects China, Hong Kong, Thailand, and UAE on a common platform. Real transactions have happened. Settlement that used to take days now takes seconds. This is still early. But it’s not theory anymore.&lt;/p&gt;

&lt;p&gt;Fourth, stablecoins are quietly solving specific corridors. Remittances to the Philippines. B2B payments between subsidiaries in different countries. Treasury movements avoiding FX desks. Not mainstream. But working.&lt;/p&gt;

&lt;h2 id="what-hasnt-changed"&gt;What hasn’t changed?&lt;/h2&gt;

&lt;p&gt;For most B2B payments between major economies — US to China, US to Germany — you’re still on legacy rails. Faster, more transparent legacy rails. But legacy nonetheless.&lt;/p&gt;

&lt;p&gt;And here’s the thing about solving problems.&lt;/p&gt;

&lt;p&gt;You fix one issue, you create another.&lt;/p&gt;

&lt;p&gt;Real-time settlement sounds great until your treasury team realizes they can no longer predict cash positions the way they used to. Connecting to multiple rail systems means managing multiple compliance frameworks. Decentralized payment infrastructure means more endpoints to secure.&lt;/p&gt;

&lt;p&gt;This is the nature of progress. The problem transforms.&lt;/p&gt;

&lt;h2 id="what-should-you-watch"&gt;What should you watch?&lt;/h2&gt;

&lt;p&gt;The corridor matters more than the technology. US-Europe is improving. Intra-ASEAN is excellent. Africa is building its own system (PAPSS) to reduce dependency on the dollar for intra-continental trade. US-China? Still stuck.&lt;/p&gt;

&lt;p&gt;If you’re a payment leader, the strategic move is building optionality. Don’t bet on one rail. Build the architecture to shift volume as new infrastructure matures.&lt;/p&gt;

&lt;p&gt;The rails are improving. Just not uniformly.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;#CrossBorderPayments #Payments #Fintech&lt;/p&gt;
</description>
					<pubDate>Fri, 21 Mar 2025 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/cross-border-payment.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/cross-border-payment.html</guid>
				</item>
			
		
			
				<item>
					<title>US Dollar (USD) as Reserve currency and its future - Part 1</title>
					<description>&lt;script src="https://cdn.jsdelivr.net/npm/chart.js"&gt;&lt;/script&gt;

&lt;p&gt;&lt;img src="../../images/usd-regime-change-1.png" /&gt;&lt;/p&gt;

&lt;p&gt;Money is just paper. Until it isn’t.&lt;/p&gt;

&lt;p&gt;The US dollar didn’t become the world’s reserve currency by accident. It took three deliberate, strategic moves — each one transforming the rules of global finance while everyone else was still playing by the old ones.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Move one - Replace british pound&lt;/li&gt;
  &lt;li&gt;Move two - Break the gold promise&lt;/li&gt;
  &lt;li&gt;Move three - Oil for dollar&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How a wartime agreement, a broken promise, and a desert handshake built a monetary empire. This is the story of how the United States engineered monetary dominance — not just through world war military strategies, but through a series of calculated institutional maneuvers that most people have never heard of. And more importantly, what it means for the future of money.&lt;/p&gt;

&lt;hr /&gt;

&lt;h4 id="move-one-replace-the-british-pound-1944"&gt;Move One: Replace the British Pound (1944)&lt;/h4&gt;

&lt;p&gt;Before World War II, the &lt;a href="https://www.youtube.com/watch?v=xguam0TKMw8"&gt;British pound sterling ruled international trade&lt;/a&gt;. Britain was the center of global commerce. The pound was as good as gold — literally backed by it. London was where the world’s money flowed.&lt;/p&gt;

&lt;p&gt;Then came the war.&lt;/p&gt;

&lt;p&gt;Britain went massively into debt. The country sacrificed more than a quarter of its national wealth to fight Germany. Factories were bombed. The treasury was emptied. The empire that once controlled a quarter of the world’s landmass was suddenly a debtor nation, dependent on American loans to survive.&lt;/p&gt;

&lt;p&gt;Meanwhile, America emerged unscathed. No bombs fell on Detroit or Pittsburgh. Its factories were running at full capacity, producing tanks, planes, and ships. Its gold reserves were swelling as European nations paid for American weapons and supplies. By 1944, the United States held roughly &lt;strong&gt;three-quarters of the world’s monetary gold&lt;/strong&gt;.&lt;/p&gt;

&lt;h5 id="us-gold-reserves-1930-2024"&gt;US Gold Reserves 1930-2024&lt;/h5&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Year&lt;/th&gt;
      &lt;th&gt;Gold Reserves (metric tonnes)&lt;/th&gt;
      &lt;th&gt;Key Event&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1930&lt;/td&gt;
      &lt;td&gt;6,358&lt;/td&gt;
      &lt;td&gt;Pre-Depression baseline&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1935&lt;/td&gt;
      &lt;td&gt;8,998&lt;/td&gt;
      &lt;td&gt;After Gold Reserve Act&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1940&lt;/td&gt;
      &lt;td&gt;19,543&lt;/td&gt;
      &lt;td&gt;WWII capital flight to US&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1944&lt;/td&gt;
      &lt;td&gt;21,800&lt;/td&gt;
      &lt;td&gt;Bretton Woods Conference&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1950&lt;/td&gt;
      &lt;td&gt;20,279&lt;/td&gt;
      &lt;td&gt;Post-war peak&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1960&lt;/td&gt;
      &lt;td&gt;15,822&lt;/td&gt;
      &lt;td&gt;European recovery begins&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1970&lt;/td&gt;
      &lt;td&gt;9,839&lt;/td&gt;
      &lt;td&gt;Nixon Shock looms&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1971&lt;/td&gt;
      &lt;td&gt;9,070&lt;/td&gt;
      &lt;td&gt;Gold window closes&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2024&lt;/td&gt;
      &lt;td&gt;8,133&lt;/td&gt;
      &lt;td&gt;Present day (stable since 1980)&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;div style="background:#fff; padding:25px; border-radius:8px; margin:35px 0; box-shadow:0 2px 8px rgba(0,0,0,0.08);"&gt;
  &lt;h4 style="color:#8b2c2c; margin:0 0 5px;"&gt;Gold Price: From $35 Fixed to Free Float&lt;/h4&gt;
  &lt;p style="font-size:0.85rem; color:#666; margin:0 0 20px;"&gt;USD per troy ounce, key events marked&lt;/p&gt;
  &lt;canvas id="goldPriceChart" height="50"&gt;&lt;/canvas&gt;
&lt;/div&gt;

&lt;div style="background:#fff; padding:25px; border-radius:8px; margin:35px 0; box-shadow:0 2px 8px rgba(0,0,0,0.08);"&gt;
  &lt;h4 style="color:#b8860b; margin:0 0 5px;"&gt;US Gold Reserves: The Foundation of Dollar Power&lt;/h4&gt;
  &lt;p style="font-size:0.85rem; color:#666; margin:0 0 20px;"&gt;Metric tonnes held by US Treasury, 1930-2024&lt;/p&gt;
  &lt;canvas id="goldChart" height="80"&gt;&lt;/canvas&gt;
&lt;/div&gt;

&lt;p&gt;In July 1944, as Allied troops were racing across Normandy, 730 delegates from 44 nations gathered at the Mount Washington Hotel in Bretton Woods, New Hampshire. Their mission: design the post-war financial order.&lt;/p&gt;

&lt;p&gt;The British delegation was led by John Maynard Keynes, the most famous economist in the world. Keynes proposed a new international currency called the “bancor” — a neutral unit of exchange managed by a world central bank. It was elegant, fair, and would have prevented any single nation from dominating global finance.&lt;/p&gt;

&lt;p&gt;The Americans had a different idea.&lt;/p&gt;

&lt;p&gt;Harry Dexter White, the US Treasury official leading the American delegation, proposed a system where all currencies would be fixed to the dollar, and the dollar would be fixed to gold at $35 per ounce. The US would be the anchor. The US would be the center.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“The American dollar thus obtains international recognition, on paper as in fact, as the world currency.”&lt;/p&gt;

  &lt;p&gt;— New York Times, July 23, 1944&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Keynes lost. The Americans won. As Benn Steil wrote in &lt;em&gt;The Battle of Bretton Woods&lt;/em&gt;, Keynes had only “his own brilliance and a fast-fading appeal to Anglo-American wartime solidarity.” The Americans had leverage — they had the gold.&lt;/p&gt;

&lt;p&gt;The outcome: every country would keep their currency fixed to the dollar, within a 1% band. The dollar was fixed to gold. Central banks could exchange their dollars for gold at any time. The British pound was out. The US dollar was in.&lt;/p&gt;

&lt;p&gt;This wasn’t charity. This was strategy.&lt;/p&gt;

&lt;hr /&gt;

&lt;h4 id="move-two-break-the-gold-promise-1971"&gt;Move Two: Break the Gold Promise (1971)&lt;/h4&gt;

&lt;p&gt;The &lt;abbr title="The 1944 international monetary framework where currencies were pegged to the US dollar, and the dollar was convertible to gold at $35/oz." style="text-decoration: underline dotted; cursor: help;"&gt;Bretton Woods system&lt;/abbr&gt; worked beautifully — until it didn’t.&lt;/p&gt;

&lt;p&gt;The design had a fatal flaw, identified by economist Robert Triffin as early as 1960. To &lt;em&gt;supply enough dollars for global trade, America had to run deficits&lt;/em&gt; — spending more abroad than it earned. But running persistent deficits would eventually erode confidence in the dollar’s gold backing. The system contained its own contradiction.&lt;/p&gt;

&lt;h5 id="the-triffin-dilemma"&gt;The Triffin Dilemma&lt;/h5&gt;

&lt;div style="background:rgba(175, 192, 187, 0.2); padding:22px; border-radius:10px; margin:30px 0; max-width:700px; border:1px solid rgba(0, 0, 0, 0.15); border-left:4px solid #2547cf;"&gt;
  
  &lt;h4 style="margin:0 0 8px; font-size:1.2rem; color:inherit;"&gt;The Triffin Dilemma: A System at War with Itself&lt;/h4&gt;
  &lt;p style="font-size:0.95rem; color:rgba(0,0,0,0.8); margin:0 0 18px; line-height:1.4;"&gt;The paradox that forced the world off the Gold Standard in 1971.&lt;/p&gt;

  &lt;div style="display: flex; flex-wrap: wrap; gap: 16px;"&gt;
    
    &lt;div style="flex: 1; min-width: 280px; background:rgba(248, 245, 215, 0.7); padding:18px; border-radius:8px; border:1px solid rgba(0, 0, 0, 0.12);"&gt;
      &lt;h5 style="margin:0 0 12px; font-size:1rem; color:inherit; display:flex; align-items:center; font-weight:700;"&gt;
        &lt;span style="background:#2547cf; color:#fff; width:22px; height:22px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; margin-right:10px; font-size:0.75rem;"&gt;1&lt;/span&gt;
        To Maintain Confidence
      &lt;/h5&gt;
      &lt;p style="margin:0; font-size:0.95rem; line-height:1.5; color:rgba(0,0,0,0.85);"&gt;
        The US must limit dollar supply to keep it strictly backed by gold. 
        &lt;br /&gt;&lt;span style="display:block; margin-top:8px;"&gt;&lt;strong style="color:#2547cf;"&gt;The Crisis:&lt;/strong&gt; Global trade collapses due to a lack of liquidity (cash).&lt;/span&gt;
      &lt;/p&gt;
    &lt;/div&gt;

    &lt;div style="flex: 1; min-width: 280px; background:rgba(248, 245, 215, 0.7); padding:18px; border-radius:8px; border:1px solid rgba(0, 0, 0, 0.12);"&gt;
      &lt;h5 style="margin:0 0 12px; font-size:1rem; color:inherit; display:flex; align-items:center; font-weight:700;"&gt;
        &lt;span style="background:#2547cf; color:#fff; width:22px; height:22px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; margin-right:10px; font-size:0.75rem;"&gt;2&lt;/span&gt;
        To Fuel Global Trade
      &lt;/h5&gt;
      &lt;p style="margin:0; font-size:0.95rem; line-height:1.5; color:rgba(0,0,0,0.85);"&gt;
        The US must run huge deficits to flood the world with dollars. 
        &lt;br /&gt;&lt;span style="display:block; margin-top:8px;"&gt;&lt;strong style="color:#2547cf;"&gt;The Crisis:&lt;/strong&gt; Gold backing becomes a mathematical impossibility.&lt;/span&gt;
      &lt;/p&gt;
    &lt;/div&gt;

  &lt;/div&gt;

  &lt;div style="text-align:left; margin-top:20px; padding-top:12px; border-top:1px dashed rgba(0, 0, 0, 0.2);"&gt;
    &lt;p style="margin:0; font-size:0.9rem; font-weight:700; color:#2547cf; text-transform: uppercase; letter-spacing:0.06em; display:flex; align-items:center; gap:8px;"&gt;
      ⚠️ Result: Inevitable Systemic Collapse
    &lt;/p&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;By the late 1960s, the contradiction was becoming reality.&lt;/p&gt;

&lt;p&gt;Europe and Japan had rebuilt from the war. Their exports became competitive with American goods. The US trade balance deteriorated. Military spending in Vietnam added to the outflow. Dollars piled up in foreign central banks.&lt;/p&gt;

&lt;p&gt;Meanwhile, US gold reserves were shrinking. In 1944, America held 21,800 metric tonnes of gold. By 1970, that had fallen to 9,839 tonnes — a decline of 55%. Foreign governments were quietly exchanging their dollars for gold, depleting America’s reserves month by month.&lt;/p&gt;

&lt;p&gt;The country was vulnerable to a bank run — except the bank was the entire United States, and the depositors were foreign governments.&lt;/p&gt;

&lt;p&gt;In early August 1971, the British ambassador formally requested that the US guarantee the gold value of $3 billion in British dollar reserves. France had already been aggressively converting dollars to gold for years under De Gaulle’s direction. A run was coming.&lt;/p&gt;

&lt;p&gt;From August 13 to 15, 1971, President Nixon and fifteen advisers — including Federal Reserve Chairman Arthur Burns and future Fed Chairman Paul Volcker — gathered secretly at Camp David. They created what they called the “New Economic Policy.”&lt;/p&gt;

&lt;p&gt;On Sunday evening, August 15, Nixon went on television:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“I have directed Secretary Connally to suspend temporarily the convertibility of the dollar into gold.”&lt;/p&gt;

  &lt;p&gt;— President Richard Nixon, August 15, 1971&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;“Temporarily” turned out to be permanently. The gold window never reopened. The foundation of the entire international monetary system — the promise that made Bretton Woods work — was unilaterally withdrawn.&lt;/p&gt;

&lt;p&gt;The technical term is the “Nixon Shock.”&lt;/p&gt;

&lt;p&gt;But here’s what’s remarkable: &lt;strong&gt;the dollar didn’t collapse. It strengthened.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Why? Because by 1971, the dollar was already so embedded in global trade that countries had no practical alternative. Contracts were denominated in dollars. Reserves were held in dollars. The infrastructure of international commerce — banking relationships, settlement systems, pricing conventions — all ran on dollars.&lt;/p&gt;

&lt;p&gt;Switching would have been catastrophically expensive. The network effects were more powerful than the gold.&lt;/p&gt;

&lt;p&gt;Nixon didn’t just break a promise. He revealed that the promise was never the source of the dollar’s power.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id="move-three-oil-for-dollars-1973-1975"&gt;Move Three: Oil for Dollars (1973-1975)&lt;/h2&gt;

&lt;p&gt;After leaving the gold standard, America needed a new anchor. It found one in the desert.&lt;/p&gt;

&lt;p&gt;The 1973 oil crisis gave the US an opening. Arab oil producers had just demonstrated their leverage by imposing an embargo on the United States in retaliation for American support of Israel in the Yom Kippur War. Oil prices quadrupled from $3 to $12 per barrel. Gas stations ran dry. The world learned that energy was the ultimate commodity.&lt;/p&gt;

&lt;p&gt;In June 1974, Secretary of State Henry Kissinger and Treasury Secretary William Simon traveled to Saudi Arabia. Prince Fahd bin Abdulaziz, the Second Deputy Prime Minister, met with them and President Nixon in Washington around the same time.&lt;/p&gt;

&lt;p&gt;The exact terms of what was negotiated remain debated. There was no single document titled “The Petrodollar Agreement.” But the outcome was clear.&lt;/p&gt;

&lt;p&gt;Saudi Arabia would price its oil in dollars. In exchange, the US would provide military protection and access to American weapons. The Saudis would also invest their oil revenues — hundreds of billions of dollars — in US Treasury bonds. This recycling of petrodollars back into American financial markets would support the dollar and keep interest rates low.&lt;/p&gt;

&lt;p&gt;By 1975, all OPEC nations were trading oil in dollars.&lt;/p&gt;

&lt;h4 id="the-petrodollar-flywheel"&gt;The Petrodollar Flywheel&lt;/h4&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Every country needs oil&lt;/strong&gt; to run their economy&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Oil is priced and traded exclusively&lt;/strong&gt; in US dollars&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Countries must hold dollar reserves&lt;/strong&gt; to buy oil&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Oil exporters receive dollars&lt;/strong&gt;, invest them in US Treasuries&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;This demand keeps the dollar strong&lt;/strong&gt; and US borrowing costs low&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Strong dollar reinforces&lt;/strong&gt; oil pricing convention&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Cycle repeats&lt;/strong&gt; — creating persistent global demand for dollars&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Think about what this meant. Gold was physical and limited — there was only so much of it in the ground. But oil demand was growing and insatiable. Every new factory in China, every car on the road in India, every airplane crossing the Pacific — all required oil. And all required dollars to pay for it.&lt;/p&gt;

&lt;p&gt;The petrodollar system achieved what gold could not: it created &lt;em&gt;growing&lt;/em&gt; demand for dollars, linked to global economic expansion itself.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id="the-larger-pattern"&gt;The Larger Pattern&lt;/h2&gt;

&lt;p&gt;Step back and look at the sequence.&lt;/p&gt;

&lt;p&gt;In 1944, the dollar’s strength came from American gold reserves. In 1971, Nixon revealed that the gold was never essential — the network effects were. In 1974, a new foundation was built on oil demand.&lt;/p&gt;

&lt;p&gt;Each transition followed a similar pattern:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Crisis emerges&lt;/strong&gt; in the existing arrangement&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;Unilateral action&lt;/strong&gt; by the United States changes the rules&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;New foundation&lt;/strong&gt; is established that preserves dollar dominance&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;World adapts&lt;/strong&gt; because switching costs are prohibitive&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What’s consistent across all three moves is the strategic insight: the dollar’s power doesn’t come from any single backing, but from its &lt;em&gt;embeddedness&lt;/em&gt; in global commerce. Once the dollar became the infrastructure — the plumbing of international trade — it became very hard to displace.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id="where-we-are-now"&gt;Where We Are Now&lt;/h2&gt;

&lt;p&gt;The dollar remains dominant, but the landscape is shifting.&lt;/p&gt;

&lt;h4 id="global-reserve-currency-composition-1995-2024"&gt;Global Reserve Currency Composition 1995-2024&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Year&lt;/th&gt;
      &lt;th&gt;USD&lt;/th&gt;
      &lt;th&gt;EUR&lt;/th&gt;
      &lt;th&gt;JPY&lt;/th&gt;
      &lt;th&gt;GBP&lt;/th&gt;
      &lt;th&gt;CNY&lt;/th&gt;
      &lt;th&gt;Other&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1995&lt;/td&gt;
      &lt;td&gt;59%&lt;/td&gt;
      &lt;td&gt;—&lt;/td&gt;
      &lt;td&gt;6.8%&lt;/td&gt;
      &lt;td&gt;2.1%&lt;/td&gt;
      &lt;td&gt;—&lt;/td&gt;
      &lt;td&gt;32%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1999&lt;/td&gt;
      &lt;td&gt;71%&lt;/td&gt;
      &lt;td&gt;17.9%&lt;/td&gt;
      &lt;td&gt;6.4%&lt;/td&gt;
      &lt;td&gt;2.9%&lt;/td&gt;
      &lt;td&gt;—&lt;/td&gt;
      &lt;td&gt;1.8%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2001&lt;/td&gt;
      &lt;td&gt;72%&lt;/td&gt;
      &lt;td&gt;19.2%&lt;/td&gt;
      &lt;td&gt;5.0%&lt;/td&gt;
      &lt;td&gt;2.7%&lt;/td&gt;
      &lt;td&gt;—&lt;/td&gt;
      &lt;td&gt;1.1%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2010&lt;/td&gt;
      &lt;td&gt;62%&lt;/td&gt;
      &lt;td&gt;26.0%&lt;/td&gt;
      &lt;td&gt;3.7%&lt;/td&gt;
      &lt;td&gt;3.9%&lt;/td&gt;
      &lt;td&gt;—&lt;/td&gt;
      &lt;td&gt;4.4%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2020&lt;/td&gt;
      &lt;td&gt;59%&lt;/td&gt;
      &lt;td&gt;21.2%&lt;/td&gt;
      &lt;td&gt;5.9%&lt;/td&gt;
      &lt;td&gt;4.7%&lt;/td&gt;
      &lt;td&gt;2.1%&lt;/td&gt;
      &lt;td&gt;7.1%&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2024&lt;/td&gt;
      &lt;td&gt;58%&lt;/td&gt;
      &lt;td&gt;20%&lt;/td&gt;
      &lt;td&gt;6%&lt;/td&gt;
      &lt;td&gt;5%&lt;/td&gt;
      &lt;td&gt;2%&lt;/td&gt;
      &lt;td&gt;9%&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;!-- PASTE THIS WHERE YOU WANT THE RESERVE CURRENCY PIE CHART --&gt;
&lt;div style="background:#fff; padding:25px; border-radius:8px; margin:35px 0; box-shadow:0 2px 8px rgba(0,0,0,0.08);"&gt;
  &lt;h4 style="color:#5c3d6e; margin:0 0 5px;"&gt;Global Foreign Exchange Reserves by Currency (2024)&lt;/h4&gt;
  &lt;p style="font-size:0.85rem; color:#666; margin:0 0 20px;"&gt;IMF COFER data — USD share declined from 72% peak (2001) but remains dominant&lt;/p&gt;
  &lt;div style="display:flex; gap:30px; align-items:center; flex-wrap:wrap;"&gt;
    &lt;div style="flex:1; min-width:220px;"&gt;
      &lt;canvas id="reserveChart" height="250"&gt;&lt;/canvas&gt;
    &lt;/div&gt;
    &lt;div style="flex:1; min-width:200px;"&gt;
      &lt;div style="display:flex; align-items:center; margin-bottom:10px;"&gt;&lt;span style="width:14px;height:14px;border-radius:3px;background:#1a365d;margin-right:10px;"&gt;&lt;/span&gt;&lt;span style="flex:1;"&gt;US Dollar&lt;/span&gt;&lt;strong&gt;58%&lt;/strong&gt;&lt;/div&gt;
      &lt;div style="display:flex; align-items:center; margin-bottom:10px;"&gt;&lt;span style="width:14px;height:14px;border-radius:3px;background:#2d5a27;margin-right:10px;"&gt;&lt;/span&gt;&lt;span style="flex:1;"&gt;Euro&lt;/span&gt;&lt;strong&gt;20%&lt;/strong&gt;&lt;/div&gt;
      &lt;div style="display:flex; align-items:center; margin-bottom:10px;"&gt;&lt;span style="width:14px;height:14px;border-radius:3px;background:#8b2c2c;margin-right:10px;"&gt;&lt;/span&gt;&lt;span style="flex:1;"&gt;Japanese Yen&lt;/span&gt;&lt;strong&gt;6%&lt;/strong&gt;&lt;/div&gt;
      &lt;div style="display:flex; align-items:center; margin-bottom:10px;"&gt;&lt;span style="width:14px;height:14px;border-radius:3px;background:#5c3d6e;margin-right:10px;"&gt;&lt;/span&gt;&lt;span style="flex:1;"&gt;British Pound&lt;/span&gt;&lt;strong&gt;5%&lt;/strong&gt;&lt;/div&gt;
      &lt;div style="display:flex; align-items:center; margin-bottom:10px;"&gt;&lt;span style="width:14px;height:14px;border-radius:3px;background:#8b4513;margin-right:10px;"&gt;&lt;/span&gt;&lt;span style="flex:1;"&gt;Chinese Yuan&lt;/span&gt;&lt;strong&gt;2%&lt;/strong&gt;&lt;/div&gt;
      &lt;div style="display:flex; align-items:center; margin-bottom:10px;"&gt;&lt;span style="width:14px;height:14px;border-radius:3px;background:#4a5568;margin-right:10px;"&gt;&lt;/span&gt;&lt;span style="flex:1;"&gt;Other&lt;/span&gt;&lt;strong&gt;9%&lt;/strong&gt;&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;div style="margin-top:20px; padding:15px; background:#f5f3ff; border-radius:6px; font-size:0.9rem;"&gt;
    &lt;strong&gt;Key insight:&lt;/strong&gt; The dollar's share dropped from 72% (2001) to 58% (2024), but it still dwarfs all competitors combined. The euro has been stuck at ~20% for two decades.
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Source: IMF COFER data&lt;/em&gt;&lt;/p&gt;

&lt;!-- PASTE THIS WHERE YOU WANT THE RESERVE SHARE OVER TIME CHART --&gt;
&lt;div style="background:#fff; padding:25px; border-radius:8px; margin:35px 0; box-shadow:0 2px 8px rgba(0,0,0,0.08);"&gt;
  &lt;h4 style="color:#1a365d; margin:0 0 5px;"&gt;Reserve Currency Share Over Time (1999-2024)&lt;/h4&gt;
  &lt;p style="font-size:0.85rem; color:#666; margin:0 0 20px;"&gt;Percentage of global foreign exchange reserves by currency&lt;/p&gt;
  &lt;canvas id="reserveTimeChart" height="280"&gt;&lt;/canvas&gt;
&lt;/div&gt;

&lt;p&gt;As of late 2024, about 58% of global foreign exchange reserves are held in dollars. The euro holds roughly 20%. The Chinese yuan — despite China being the world’s largest exporter — holds just 2%.&lt;/p&gt;

&lt;p&gt;Oil is still overwhelmingly priced in dollars. International debt is still largely denominated in dollars. SWIFT, the messaging network for cross-border payments, still processes most transactions in dollars. The dollar remains the plumbing.&lt;/p&gt;

&lt;p&gt;But pressures are building:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sanctions and weaponization:&lt;/strong&gt; After Russia’s invasion of Ukraine, the US froze Russian central bank assets. This demonstrated the dollar’s power — but also its risk. Countries are now asking: could this happen to us?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;China’s rise:&lt;/strong&gt; China and Saudi Arabia have discussed oil trades in yuan. BRICS nations are exploring payment alternatives. The mBridge project connects multiple central bank digital currencies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;US fiscal trajectory:&lt;/strong&gt; American debt has surpassed $34 trillion. If confidence in US fiscal management erodes, dollar holdings become less attractive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Central bank gold buying:&lt;/strong&gt; Central banks added more gold to reserves in 2022-2023 than in any period since 1950. Gold’s share of reserve assets has more than doubled since 2015.&lt;/p&gt;

&lt;hr /&gt;

&lt;h4 id="timeline-eight-decades-of-dollar-dominance"&gt;Timeline: Eight Decades of Dollar Dominance&lt;/h4&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Year&lt;/th&gt;
      &lt;th&gt;Event&lt;/th&gt;
      &lt;th&gt;Significance&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;1944&lt;/td&gt;
      &lt;td&gt;Bretton Woods&lt;/td&gt;
      &lt;td&gt;USD becomes anchor of global monetary system&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1958&lt;/td&gt;
      &lt;td&gt;System Goes Live&lt;/td&gt;
      &lt;td&gt;Currencies become fully convertible&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1960&lt;/td&gt;
      &lt;td&gt;Triffin Warning&lt;/td&gt;
      &lt;td&gt;Economist predicts dollar crisis&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1968&lt;/td&gt;
      &lt;td&gt;Gold Pool Collapse&lt;/td&gt;
      &lt;td&gt;Seven nations stop defending $35/oz&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1971&lt;/td&gt;
      &lt;td&gt;Nixon Shock&lt;/td&gt;
      &lt;td&gt;Gold window closes permanently&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1974&lt;/td&gt;
      &lt;td&gt;Petrodollar&lt;/td&gt;
      &lt;td&gt;Saudi Arabia prices oil in USD&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1975&lt;/td&gt;
      &lt;td&gt;OPEC Follows&lt;/td&gt;
      &lt;td&gt;All OPEC nations trade in dollars&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1999&lt;/td&gt;
      &lt;td&gt;Euro Launches&lt;/td&gt;
      &lt;td&gt;First potential challenger emerges&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2016&lt;/td&gt;
      &lt;td&gt;Yuan in SDR&lt;/td&gt;
      &lt;td&gt;Chinese currency joins IMF basket&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2022&lt;/td&gt;
      &lt;td&gt;Russia Sanctions&lt;/td&gt;
      &lt;td&gt;Dollar weaponization debate intensifies&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;hr /&gt;

&lt;h2 id="what-comes-next"&gt;What Comes Next?&lt;/h2&gt;

&lt;p&gt;History suggests America will find a fourth move.&lt;/p&gt;

&lt;p&gt;The pattern has been consistent: when the current arrangement becomes untenable, someone in Washington engineers a new arrangement that preserves dollar dominance while transforming its foundation. Gold gave way to network effects. Network effects were reinforced by oil. What comes after oil?&lt;/p&gt;

&lt;p&gt;Some possibilities:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Digital infrastructure:&lt;/strong&gt; If the US can position itself at the center of digital payments infrastructure — whether through a digital dollar, stablecoin regulation, or dominance in cross-border payment rails — this could become the next foundation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Technology standards:&lt;/strong&gt; Just as oil required dollars, AI, semiconductors, and cloud computing could require American standards and settlement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security guarantees:&lt;/strong&gt; The petrodollar was partly a security arrangement. New security dependencies — cyber defense, space access, supply chain resilience — could create new dollar dependencies.&lt;/p&gt;

&lt;p&gt;Or perhaps the fourth move never comes. Perhaps the dollar slowly fades as reserve managers diversify, as regional blocs emerge, as technology enables alternatives. Perhaps we’re watching the end of an era.&lt;/p&gt;

&lt;p&gt;But I wouldn’t bet on it.&lt;/p&gt;

&lt;p&gt;The dollar hasn’t survived eighty years because of gold, or oil, or any single backing. It has survived because of strategic adaptability — the willingness to remake the rules when the old rules stop working, combined with the leverage to make others accept the new ones.&lt;/p&gt;

&lt;p&gt;Paper is just paper. Until someone makes it indispensable.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;#USD #Geopolitics #Finance #Payments #History #Economics&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Data sources: IMF COFER, Federal Reserve, World Gold Council, St. Louis Fed&lt;/em&gt;&lt;/p&gt;

&lt;!-- PASTE THIS AT THE VERY END OF YOUR MARKDOWN FILE --&gt;
&lt;script&gt;
document.addEventListener('DOMContentLoaded', function() {
  function createChartIfPresent(id, config) {
    var canvas = document.getElementById(id);
    if (!canvas) return;
    new Chart(canvas, config);
  }
  
  // 1. Gold Reserves Chart
  createChartIfPresent('goldChart', {
    type: 'line',
    data: {
      labels: ['1930', '1935', '1940', '1944', '1950', '1955', '1960', '1965', '1970', '1971', '1980', '2024'],
      datasets: [{
        label: 'Gold Reserves (tonnes)',
        data: [6358, 8998, 19543, 21800, 20279, 19331, 15822, 12499, 9839, 9070, 8221, 8133],
        borderColor: '#b8860b',
        backgroundColor: 'rgba(184, 134, 11, 0.15)',
        fill: true,
        tension: 0.3,
        pointRadius: 5,
        pointBackgroundColor: '#b8860b'
      }]
    },
    options: {
      responsive: true,
      plugins: {
        legend: { display: false },
        tooltip: {
          callbacks: {
            label: function(context) {
              return context.parsed.y.toLocaleString() + ' tonnes';
            }
          }
        }
      },
      scales: {
        y: {
          beginAtZero: true,
          max: 25000,
          ticks: {
            callback: function(value) { return (value / 1000) + 'k'; }
          }
        }
      }
    }
  }); // Fixed missing closing brackets here

  // 2. Reserve Currency Pie Chart
  createChartIfPresent('reserveChart', {
    type: 'doughnut',
    data: {
      labels: ['US Dollar', 'Euro', 'Japanese Yen', 'British Pound', 'Chinese Yuan', 'Other'],
      datasets: [{
        data: [58, 20, 6, 5, 2, 9],
        backgroundColor: ['#1a365d', '#2d5a27', '#8b2c2c', '#5c3d6e', '#8b4513', '#4a5568'],
        borderWidth: 2,
        borderColor: '#fff'
      }]
    },
    options: {
      responsive: true,
      plugins: {
        legend: { display: false },
        tooltip: {
          callbacks: {
            label: function(context) {
              return context.label + ': ' + context.parsed + '%';
            }
          }
        }
      }
    }
  });

  // 3. Reserve Share Over Time Chart
  createChartIfPresent('reserveTimeChart', {
    type: 'line',
    data: {
      labels: ['1999', '2001', '2005', '2010', '2015', '2020', '2024'],
      datasets: [
        {
          label: 'USD',
          data: [71, 72, 66.5, 62.1, 65.7, 59.0, 58],
          borderColor: '#1a365d',
          backgroundColor: 'rgba(26, 54, 93, 0.1)',
          fill: true,
          tension: 0.3
        },
        {
          label: 'Euro',
          data: [17.9, 19.2, 24.1, 26.0, 19.1, 21.2, 20],
          borderColor: '#2d5a27',
          backgroundColor: 'rgba(45, 90, 39, 0.1)',
          fill: true,
          tension: 0.3
        },
        {
          label: 'Other',
          data: [11.1, 8.8, 9.4, 11.9, 15.2, 19.8, 22],
          borderColor: '#4a5568',
          backgroundColor: 'rgba(74, 85, 104, 0.1)',
          fill: true,
          tension: 0.3
        }
      ]
    },
    options: {
      responsive: true,
      plugins: {
        legend: { position: 'bottom' },
        tooltip: {
          callbacks: {
            label: function(context) {
              return context.dataset.label + ': ' + context.parsed.y + '%';
            }
          }
        }
      },
      scales: {
        y: {
          beginAtZero: true,
          max: 80,
          ticks: {
            callback: function(value) { return value + '%'; }
          }
        }
      }
    }
  });

  // 4. Gold Price Chart
  createChartIfPresent('goldPriceChart', {
    type: 'line',
    data: {
      labels: ['1934', '1944', '1968', '1971', '1973', '1974', '1980', '2000', '2011', '2024'],
      datasets: [{
        label: 'Gold Price ($/oz)',
        data: [35, 35, 35, 38, 42, 183, 850, 279, 1895, 2400],
        borderColor: '#8b2c2c',
        backgroundColor: 'rgba(139, 44, 44, 0.1)',
        fill: true,
        tension: 0.3,
        pointRadius: 6,
        pointBackgroundColor: '#8b2c2c'
      }]
    },
    options: {
      responsive: true,
      plugins: {
        legend: { display: false },
        tooltip: {
          callbacks: {
            label: function(context) {
              return '$' + context.parsed.y.toLocaleString() + ' per ounce';
            }
          }
        }
      },
      scales: {
        y: {
          beginAtZero: true,
          ticks: {
            callback: function(value) { return '$' + value; }
          }
        }
      }
    }
  });
});
&lt;/script&gt;

</description>
					<pubDate>Tue, 23 Jul 2024 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/usd-as-reserve-currency.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/usd-as-reserve-currency.html</guid>
				</item>
			
		
			
				<item>
					<title>Problems never solved but transformed - Revisit the statement</title>
					<description>&lt;p&gt;&lt;img src="../../images/m6943_cartoon_is_in_an_apartment-msubra.png" style="" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="problems-never-solved.html"&gt;Back in 2019, I jotted down a fleeting reflection on a question&lt;/a&gt; that may seem trivial at first glance. It’s the kind of question that feels almost too obvious, woven as it is into the fabric of our daily existence, which is perhaps why it can feel trivial to contemplate. Yet, take a moment to consider it:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Why does it seem as if there’s an unending cascade of issues needs our attention?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Asking these questions lead to inspect &lt;em&gt;“What events create new problems once it is solved?”&lt;/em&gt;. I am revisiting that thought to see if anything has changed in my perception and try to avoid confirmation bias. This time, I leveraged AI technology to debate that with me.&lt;/p&gt;

&lt;p&gt;I asked AI to debate my hypothesis:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Debate this statement with me - “We do not solve the problem, but transform it to an another state?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;AI an I debated for about 15 minutes and  Here is a summary of the debate on the idea that AI and I had.&lt;/p&gt;

&lt;div class="two-col-parent"&gt;
  &lt;div class="two-col-column"&gt;

    &lt;p&gt;&lt;strong&gt;Arguments “for”&lt;/strong&gt;&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;&lt;strong&gt;Cyclical Nature of Problems&lt;/strong&gt; - problems, by their nature, are cyclical and evolutionary. When we solve one problem, we often do so within a specific context and set of parameters that can give rise to new challenges.
Example: the invention of automobiles solved the problem of long-distance travel but introduced new problems like pollution and traffic congestion&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Perspective and Perception&lt;/strong&gt; - From a philosophical standpoint, the way we perceive problems and solutions is deeply subjective. What constitutes a solution for one individual or society might not hold the same value for another?
In Buddhism it is notion of impermanence (lasts only for a limited period) and the Vedantic emphasis on transcending limited perceptions. 
Example: Buy a vacuum machine to easy the cleaning. But prepare to spend effort to maintain, clean and take care of the machine. You got a new problem to handle.&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Complex Systems Theory&lt;/strong&gt; In complex systems, such as ecosystems, economies, or societies, interventions often have unforeseen consequences due to the interconnectedness of components.Solving a problem in one part of the system can cause ripple effects that transform it or create new problems in other parts. This suggests that solutions are part of a dynamic process of transformation rather than definitive endpoints.
Example: You want a connected society. Introduce the social platforms. Solves connectivity, but opens up array of complex issues right from Mis-information, Creating bias, impacts reading abilities in children and many more&lt;/li&gt;
    &lt;/ol&gt;

  &lt;/div&gt;

  &lt;div class="two-col-column"&gt;

    &lt;p&gt;&lt;strong&gt;Arguments “against”&lt;/strong&gt;&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;&lt;strong&gt;Definitive Solutions Exist&lt;/strong&gt; - There are numerous instances where problems have been solved without merely transforming them into other issues. Example: the eradication of a disease like smallpox through vaccination - Humanity solved, eliminating a major cause of suffering without transforming it into a different problem&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Incremental Progress&lt;/strong&gt; - Progress is achieved through the incremental solving of problems, building towards a better state of affairs. Each solution contributes to a foundation of knowledge and capability that enables humanity to tackle more significant challenges&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;Clear Objectives and Goals&lt;/strong&gt; - In the fields of science and engineering, problems are defined with specific, measurable objectives. When these objectives are met, the problem is considered solved. Example: landing a spacecraft on Mars is a problem with clear goals. Upon achieving these goals, the problem is solved&lt;/li&gt;
    &lt;/ol&gt;

  &lt;/div&gt;

&lt;/div&gt;

&lt;p&gt;In a nutshell, this revist has made my thoughts bit wider, yet more affirm on that we “always” never solve a problem. By solving all the manual tasks with Automated (Software and Machines), we transform that issue into another form or shape.&lt;/p&gt;

&lt;embed src="../../images/post-1.svg" style="width:100vw;background-color:white;" /&gt;

</description>
					<pubDate>Thu, 14 Mar 2024 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/Revisit-Problems-never-solved-but-transformed/html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/Revisit-Problems-never-solved-but-transformed/html</guid>
				</item>
			
		
			
				<item>
					<title>Why does the price of the product once increases never decrease?</title>
					<description>&lt;p&gt;A product you bought ten years ago costs more today. We all know inflation causes price increases.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Why does drop in inflation not decrease the price?
&lt;br /&gt; Answer: &lt;strong&gt;Inflation is compounding.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p class="img-caption"&gt;&lt;img src="../Screenshot 2024-01-15 at 6.48.33 PM.png" alt="US Inflation graph" title="US Inflation graph" /&gt;
calculator: &lt;a href="https://smartasset.com/investing/inflation-calculator"&gt;https://smartasset.com/investing/inflation-calculator&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Yes. If the price of a product is $100 and inflation is at 4% at the beginning of, say, 2020, this is how the price grows each year.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;End of Year&lt;/th&gt;
      &lt;th&gt;Rate&lt;/th&gt;
      &lt;th&gt;Price&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;2020&lt;/td&gt;
      &lt;td&gt;..%&lt;/td&gt;
      &lt;td&gt;$100&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2021&lt;/td&gt;
      &lt;td&gt;5%&lt;/td&gt;
      &lt;td&gt;$105&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2022&lt;/td&gt;
      &lt;td&gt;5%&lt;/td&gt;
      &lt;td&gt;$110.25&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2023&lt;/td&gt;
      &lt;td&gt;4%&lt;/td&gt;
      &lt;td&gt;$114.66&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2024&lt;/td&gt;
      &lt;td&gt;3%&lt;/td&gt;
      &lt;td&gt;$118.10&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2025&lt;/td&gt;
      &lt;td&gt;2%&lt;/td&gt;
      &lt;td&gt;$120.5&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;So, as illustrated in the table, 2021 inflation increased to 5%; it stayed the same in 2022 and started to drop 1% every year, hitting the Fed’s dream target of 2%. Now, the exact product would cost $120.50.&lt;/p&gt;

&lt;p&gt;Invest in assets that give you little over the inflation rate to maintain the same purchasing power. The more, the merrier, but you should aim to achieve a little over the inflation rate.&lt;/p&gt;

&lt;p&gt;So, if anyone says inflation is dropping, keep in mind that the rate at which the price of a product grows is slower than before; it does not undo the growth.&lt;/p&gt;

&lt;h3 id="can-the-price-go-down"&gt;Can the price go down?&lt;/h3&gt;

&lt;p&gt;Yes.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;What is required to reverse the price?
&lt;br /&gt; &lt;strong&gt;Deflation&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Deflation is having a negative inflation rate. During the great depression, many countries faced this.&lt;/p&gt;

&lt;p class="img-caption"&gt;&lt;img src="https://www.dineshbakshi.com/images/stories/economics_diagrams/disinflation_graph.png" alt="inflation and disinflation diagram" /&gt;
credit: &lt;a href="https://www.dineshbakshi.com"&gt;https://www.dineshbakshi.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://ycharts.com/indicators/japan_inflation_rate#:~:text=Japan%20Inflation%20Rate%20is%20at,long%20term%20average%20of%202.42%25."&gt;Recently, in 2021, Japan had a brief disinflation period.&lt;/a&gt;&lt;/p&gt;

&lt;p class="img-caption"&gt;&lt;img src="../Screenshot 2024-01-15 at 7.04.42 PM.png" alt="Japan Disflation period" title="Japan Disflation period" /&gt;&lt;/p&gt;

&lt;p&gt;#inflation #finance #economy&lt;/p&gt;
</description>
					<pubDate>Sun, 14 Jan 2024 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/inflation-price-effect.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/inflation-price-effect.html</guid>
				</item>
			
		
			
				<item>
					<title>Edge AI</title>
					<description>&lt;p&gt;&lt;img src="../images/edge-ai-cars.png" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.technologyreview.com/2023/02/08/1068068/chatgpt-is-everywhere-heres-where-it-came-from/"&gt;In 2023, we find ourselves at a pivotal moment in the evolution of AI, particularly with the launch of groundbreaking GPT models&lt;/a&gt;. This isn’t just a fleeting trend; it’s a substantial shift in the landscape of technology. We’ve seen enthusiasts and professionals alike experimenting with these models, producing content that spans the spectrum from highly practical to purely creative. But the real buzz is about something even more transformative: the rise of Edge AI.&lt;/p&gt;

&lt;p&gt;Think about this: You hop into your car, and like a trusted friend, it knows your destination. As you drive, it gently reminds you to pick up a package, even noting that you have time for a quick coffee with a friend. This isn’t science fiction; it’s the practical magic of Edge AI. Here, the need for instant decision-making trumps the traditional reliance on distant cloud services. This represents a new frontier in computing, one that’s rapidly gaining momentum.&lt;/p&gt;

&lt;p&gt;Edge AI is particularly crucial when time is of the essence, and you can’t afford the luxury of waiting for data to bounce back from a remote server. It’s about embedding intelligence in everyday devices, enabling them to process information on the spot. This innovation is not just about convenience; it’s about bringing sophisticated AI capabilities to where they’re most needed, whether that’s in moving vehicles, remote areas without reliable internet, or even in developing countries where tech infrastructure is limited.&lt;/p&gt;

&lt;p&gt;The technology landscape is abuzz with activity, as major players like &lt;a href="https://cloud.google.com/blog/products/ai-machine-learning/how-to-build-and-execute-ai-use-cases-at-the-edge"&gt;Google&lt;/a&gt;,  &lt;a href="https://blogs.nvidia.com/blog/what-is-edge-ai/"&gt;Nvidia&lt;/a&gt;, &lt;a href="https://www.ibm.com/topics/edge-ai"&gt;IBM&lt;/a&gt;, &lt;a href="https://www.hpe.com/us/en/what-is/edge-ai.html"&gt;HPE&lt;/a&gt; forge ahead in the realm of Edge AI. &lt;a href="https://www.msn.com/en-us/lifestyle/other/apple-s-new-ai-research-could-totally-transform-your-iphone/ar-AA1lUIV4"&gt;Apple’s recent announcement about integrating AI directly into iPhones&lt;/a&gt; – using a technique called &lt;a href="https://www.macrumors.com/2023/12/21/apple-ai-researchers-run-llms-iphones/"&gt;“LLM in a flash”&lt;/a&gt; – marks a significant leap forward. This approach allows complex AI models to function efficiently on devices with limited memory.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.maheshsubramaniya.com/article/problems-never-solved.html"&gt;Well, in reality, if you have a new solution to solve existing problem, you get a new set of problems to tackle&lt;/a&gt;. For developers, this new era presents a challenge: designing AI models that are both lightweight and powerful. Operationally, the shift to Edge AI introduces a new layer of complexity. It demands a transition from centralized to distributed systems, affecting everything from technical strategies to team management. Leaders in this field need to stay attuned to these changes, ensuring their teams are well-equipped for this new paradigm.&lt;/p&gt;

&lt;p&gt;However, Edge AI comes with its own set of challenges. As AI becomes more dispersed, security and privacy concerns escalate. Each device running AI could potentially be a security risk, necessitating a rethink of traditional security protocols to safeguard endpoints and user data. Moreover, data governance becomes more intricate in a decentralized setup, requiring nuanced and robust policies.&lt;/p&gt;

&lt;p&gt;In summary, the advent of Edge AI isn’t just a technological advancement; it represents a paradigm shift in our interaction with artificial intelligence. It challenges our traditional notions of computing and necessitates a comprehensive approach that spans technical expertise, strategic management, and security awareness. As this field evolves, professionals must remain informed and adaptable, ensuring their skills and strategies align with the ever-changing landscape of AI.&lt;/p&gt;

&lt;p&gt;#EdgeAI #AI #ArtificialIntelligence&lt;/p&gt;
</description>
					<pubDate>Sat, 30 Dec 2023 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/Edge-AI.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/Edge-AI.html</guid>
				</item>
			
		
			
				<item>
					<title>Problems never solved, they transform</title>
					<description>&lt;p&gt;&lt;img src="../images/problem.jpg" style="width:30%;" /&gt;&lt;/p&gt;

&lt;p&gt;In the world full of problems, solving a problem doesn’t erase the problem, rather transforms into another problem, more like the conservation of energy. Let me give you a simple example.&lt;/p&gt;

&lt;p&gt;Say, you are looking to shield your car from blazing hot sun and not turn your interior into an oven. You buy a windshield reflector, some side shields to attach to the windows. Now you have effectively reduced the heat in the interior of the car but never got the desired result. But for the sake of argument let us assume that you have solved your problem.&lt;/p&gt;

&lt;p&gt;Yes?&lt;/p&gt;

&lt;p&gt;Probably, that specific problem, but you have introduced a new set of problems to tackle.&lt;/p&gt;

&lt;p&gt;What is that?&lt;/p&gt;

&lt;p&gt;Now, you have effectively added a new set of problems to your list of problems,&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Storage of the windshield protector&lt;/li&gt;
  &lt;li&gt;Every time you get into the car, remember to fold it&lt;/li&gt;
  &lt;li&gt;Every time you get out of the car, remember to put it back on.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now you have successfully hooked up-to a new set of problem while solving another. Life is full of problems to solve, which never gets vanished, but just transforms from one form to another.&lt;/p&gt;

&lt;p&gt;In our current world, we tried to find solution for&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Connecting people, Created Social networking, created priacy issues.&lt;/li&gt;
  &lt;li&gt;Faster payment, leads to data hacking&lt;/li&gt;
  &lt;li&gt;Finding information, use search engine, they can manipulate what you see &amp;amp; learn.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Many more you could think of. Our mind always lets us choose lesser of two evils.&lt;/p&gt;
</description>
					<pubDate>Fri, 09 Aug 2019 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/problems-never-solved.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/problems-never-solved.html</guid>
				</item>
			
		
			
				<item>
					<title>Is Gold buying outside India worth?</title>
					<description>&lt;style&gt;
input{
  font-size: 100%;
}

div.row{
  margin-bottom: 10px;
}

div.row span{
  font-weight: bold;
}

&lt;/style&gt;

&lt;div ng-controller="gController as gctrl" ng-init="gctrl.computeProfitOrLossForCoin()"&gt;
    &lt;h3 class="post-title"&gt;Is Gold buying outside India worth?&lt;a href="http://www.maheshsubramaniya.com/" title="Back to home"&gt;⮐&lt;/a&gt;&lt;/h3&gt;

    &lt;div class="left"&gt;
      &lt;div class="row"&gt;
        &lt;span&gt;1 unit of Forex in &amp;#x20B9; (INR) (Eg: &lt;a href="https://www.google.com/#q=1+USD+%3D+INR"&gt;1 USD&lt;/a&gt;)&lt;/span&gt;
        &lt;div&gt;
          &lt;input type="number" ng-model="usdToInr" ng-change="gctrl.computeProfitOrLossForCoin()" min="1" /&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
        &lt;span&gt;Outside India - 24ct&lt;/span&gt;
        &lt;div&gt;
          &lt;span&gt;$&lt;/span&gt;&lt;input type="number" ng-model="goldPriceOutsideIndiaPerOunceInUSD" ng-change="gctrl.computeProfitOrLossForCoin()" /&gt;&lt;span&gt;/gm&lt;/span&gt;
          &lt;span&gt;( {[{goldPriceOutsideIndiaPerOunceInUSD*usdToInr | rupees}]} / gram) &lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
        &lt;span&gt;India - 24ct (in &amp;#x20B9;)&lt;/span&gt;
        &lt;div&gt;
          &lt;input type="number" ng-model="goldPriceIndia24ctPerGramInINR" ng-change="gctrl.computeProfitOrLossForCoin()" /&gt;
          &lt;span&gt;/gm&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
        &lt;span&gt;India - 22ct (in &amp;#x20B9;)&lt;/span&gt;
        &lt;div&gt;
          &lt;input type="number" ng-model="goldPriceIndia22ctPerGramInINR" ng-change="gctrl.computeProfitOrLossForCoin();" /&gt;
          &lt;span&gt;/gm&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
        &lt;span&gt;Customs duty (in &amp;#x20B9;) (Usually &amp;#x20B9; 750/10grams)&lt;/span&gt;
        &lt;div&gt;
          &lt;input type="number" ng-model="customsDutyPer10Grams" ng-change="gctrl.computeProfitOrLossForCoin()" /&gt;
          &lt;span&gt;/10 gm&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
        &lt;span&gt;Wastage, Making Charges (usually 10% for Jewels )&lt;/span&gt;
        &lt;div&gt;
          &lt;input type="number" ng-model="valueAddition" ng-change="gctrl.computeProfitOrLossForCoin()" /&gt;
          &lt;span&gt;%&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="row"&gt;
        &lt;span&gt;VAT (usually 1%)&lt;/span&gt;
        &lt;div&gt;
          &lt;input type="number" maxlength="3" ng-model="valueAddedTax" ng-change="gctrl.computeProfitOrLossForCoin()" /&gt;
          &lt;span&gt;%&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;

    &lt;div class="right"&gt;
      &lt;div&gt;
        &lt;h3&gt;If you hold as Coin &lt;small&gt;(after exchange rates &amp;amp; duties)&lt;/small&gt;&lt;/h3&gt;
        &lt;div&gt;
            {[{gctrl.computeProfitOrLossForCoin()}]}
        &lt;/div&gt;


        &lt;div&gt;
          &lt;span&gt;1 gm of 24ct purchased &lt;b&gt;outside India&lt;/b&gt; will buy you &lt;/span&gt;&lt;span&gt;{[{gctrl.getIndianEquivalentof22CtInGrams()  | number : 2 }]} gms of 22ct&lt;/span&gt;  in India        &lt;/div&gt;


        &lt;div&gt;
          &lt;span&gt;8 gm  ( 1 sov ) of 24ct &lt;b&gt;purchased outside&lt;/b&gt; India will buy you &lt;/span&gt;&lt;span&gt;{[{gctrl.getIndianEquivalentof22CtInGrams() * 8 | number : 2 }]} gms ( ~ {[{gctrl.getIndianEquivalentof22CtInGrams()  * 8 |soverign }]} ) of 22ct&lt;/span&gt;
        &lt;/div&gt;

      &lt;/div&gt;
      &lt;div&gt;

        &lt;h3&gt;If you hold as Jewellery&lt;small&gt;( after exchange rates,duties, making charges etc.,)&lt;/small&gt;&lt;/h3&gt;


        &lt;div&gt;
          &lt;span&gt;1 gm of 24ct purchased &lt;b&gt;outside India&lt;/b&gt; will buy you &lt;/span&gt;&lt;span&gt;{[{gctrl.getIndianEquivalentof22CtPerGramAsJewels()  | number : 2 }]} grams of 22ct&lt;/span&gt;  in India
        &lt;/div&gt;

       &lt;div&gt;
          &lt;span&gt;8 gm  ( 1 sov ) of 24ct purchased &lt;b&gt;outside India&lt;/b&gt; will buy you &lt;/span&gt;&lt;span&gt;{[{gctrl.getIndianEquivalentof22CtPerGramAsJewels() * 8 | number : 2 }]} gms ( ~ {[{gctrl.getIndianEquivalentof22CtPerGramAsJewels()  * 8 |soverign }]} ) of 22ct&lt;/span&gt;
        &lt;/div&gt;

       &lt;div&gt;
          &lt;span&gt;8 gm  ( 1 sov ) of 22ct purchased &lt;b&gt;in India&lt;/b&gt; will be equivalent to &lt;/span&gt;&lt;span&gt;{[{gctrl.getIndianEquivalentof22CtPerGramAsJewelsPurchasedInIndia() * 8 | number : 2 }]} gms ( ~ {[{gctrl.getIndianEquivalentof22CtPerGramAsJewelsPurchasedInIndia()  * 8 |soverign }]} ) of 22ct&lt;/span&gt;
        &lt;/div&gt;

      &lt;/div&gt;
    &lt;/div&gt;

&lt;/div&gt;

&lt;div&gt;
  &lt;h5&gt;
    Found any issues with the calculator - &lt;a href="/contact.html"&gt;write to me&lt;/a&gt;
  &lt;/h5&gt;


  &lt;div&gt;
    &lt;h3&gt;References&lt;/h3&gt;
    &lt;ol&gt;
      &lt;li&gt;&lt;div&gt;&lt;a href="http://www.apmex.com/product/11950/1-oz-gold-bar-credit-suisse-in-assay"&gt;Gold Price - 1oz&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
    &lt;li&gt;&lt;div&gt;&lt;a href="https://www.google.com/webhp?sourceid=chrome-instant&amp;amp;ion=1&amp;amp;espv=2&amp;amp;ie=UTF-8#q=USD+to+INR"&gt;USD to INR&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
      &lt;li&gt;&lt;div&gt;&lt;a href="http://www.livechennai.com/gold_silverrate.asp"&gt;Gold Price - Chennai&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
      &lt;li&gt;&lt;div&gt;&lt;a href="http://www.livechennai.com/gold_silverrate.asp"&gt;Gold Price - Chennai&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
      &lt;li&gt;&lt;div&gt;&lt;a href="https://www.google.com/search?q=1+troy+oz+%3D+%3F+grams"&gt;1 oz (troy) = 31.1 grams&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
      &lt;li&gt;&lt;div&gt;&lt;a href="https://en.wikipedia.org/wiki/Fineness#Gold"&gt;24 ct = 99.99% purity&lt;/a&gt;&lt;/div&gt; &lt;/li&gt;
      &lt;li&gt;&lt;div&gt;&lt;a href="https://en.wikipedia.org/wiki/Fineness#Gold"&gt;22 ct = 91.6% purity&lt;/a&gt;&lt;/div&gt; &lt;/li&gt;
      &lt;li&gt;&lt;div&gt;&lt;a href="http://ajithprasad.com/gold-jewellery-buying-tips-wastage-charges-making-charges-va-karat-916-bis-hallmark/"&gt;Value Addition - Wastage, Making Charges ( Most commonly 10% for Jewels )&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
      &lt;li&gt;&lt;div&gt;&lt;a href="http://www.tnvat.gov.in/english/VATSCHE_ALPHA_270312.pdf#page=7"&gt;VAT - Value Added Tax ( Generally 1% )&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
    &lt;/ol&gt;
  &lt;/div&gt;
&lt;/div&gt;
</description>
					<pubDate>Sun, 19 Jul 2015 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//calc/goldbuy.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//calc/goldbuy.html</guid>
				</item>
			
		
			
				<item>
					<title>Understanding how jars are loaded into JVM from a directory in Linux</title>
					<description>&lt;p&gt;&lt;strong&gt;Question&lt;/strong&gt;: If the &lt;code class="language-plaintext highlighter-rouge"&gt;lib/&lt;/code&gt; folder has &lt;code class="language-plaintext highlighter-rouge"&gt;jar1.jar&lt;/code&gt; and &lt;code class="language-plaintext highlighter-rouge"&gt;jar2.jar&lt;/code&gt;, what is the order of the jar loading into the JVM if you use Linux(EXT3 file system)?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Short Answer&lt;/strong&gt;: One cannot say or technically, &lt;strong&gt;Random&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The order in which Jar files are loaded into JVM are &lt;strong&gt;influenced by how the file system orders its file in the directory&lt;/strong&gt;. Since the &lt;code class="language-plaintext highlighter-rouge"&gt;java.io.File&lt;/code&gt; API depends on the native API, different platforms lists file in different order.&lt;/p&gt;

&lt;h3 id="ext3-file-system"&gt;EXT3 file system&lt;/h3&gt;

&lt;p&gt;EXT3 file system is &lt;a href="https://www.kernel.org/doc/Documentation/filesystems/ext3.txt"&gt;defacto file system in Linux kernel &lt;/a&gt; for over 15 years. There are &lt;a href="https://en.wikipedia.org/wiki/Ext3#References"&gt;some extensive documentation &lt;/a&gt; on what it is and how it works.&lt;/p&gt;

&lt;p&gt;Lets see how the files are created and fetched in the ext3 file system.&lt;/p&gt;

&lt;p&gt;Create 5 files&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nb"&gt;seq &lt;/span&gt;1 5&lt;span class="sb"&gt;`&lt;/span&gt; | xargs &lt;span class="nb"&gt;touch&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;List the file in alphabetical order. The &lt;code class="language-plaintext highlighter-rouge"&gt;ls&lt;/code&gt; command &lt;a href="http://www.freebsd.org/cgi/man.cgi?ls"&gt;without any argumentt&lt;/a&gt; will list files in lexicographical order.&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls
&lt;/span&gt;1   2   3   4   5&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;List the files in the list order. Again these files are sorted by lexicographical order.&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
total 0
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 1
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 2
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 3
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 4
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 5&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;List the files in &lt;strong&gt;directory order&lt;/strong&gt; &lt;code class="language-plaintext highlighter-rouge"&gt;-U&lt;/code&gt; switch will list the file in &lt;strong&gt;unordered&lt;/strong&gt; and which is the way files are arranged the file in the file system&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-U&lt;/span&gt;
2  1  5  3  4&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;For more clarity, let us list the file in list order&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-Ul&lt;/span&gt;
total 0
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 2
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 1
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 5
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 3
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 4&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;If you think the files are ordered by &lt;strong&gt;inode&lt;/strong&gt; number, then you may be wrong again. Here is the listing of files with &lt;code class="language-plaintext highlighter-rouge"&gt;inode&lt;/code&gt; number in 1st column.&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-Uli&lt;/span&gt;
total 0
671786 &lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 2
671780 &lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 1
671789 &lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 5
671787 &lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 3
671788 &lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt; 1 training training 0 Jul 10 02:04 4
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;To add more interesting discussion, let us look across different machines with same Operating system and EXT3 file system.&lt;/p&gt;

&lt;p&gt;EXT3 file system &lt;a href="https://www.kernel.org/doc/ols/2005/ols2005v1-pages-77-104.pdf"&gt;hash the filenames&lt;/a&gt; and places the entry in the directory level inode table.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;readdir() returning filenames in a hash-sorted order, so that reads from the inode table would be done in a random order.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So now you got an understanding of what directory ordering will look like.&lt;/p&gt;

&lt;p&gt;So if your one machine load jars as &lt;code class="language-plaintext highlighter-rouge"&gt;jar1.jar, jar2.jar&lt;/code&gt;, another Linux machine with same OS release may load as &lt;code class="language-plaintext highlighter-rouge"&gt;jar2.jar,jar1.jar&lt;/code&gt; or may be same order as the other machine. &lt;strong&gt;Random&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Since it is &lt;strong&gt;random&lt;/strong&gt;, you cannot expect the same ordering in another machine with EXT3 file system.&lt;/p&gt;

&lt;h3 id="why-is-this-important-to-understand"&gt;Why is this important to understand?&lt;/h3&gt;

&lt;p&gt;With the usage of Maven, developers tend to miss to verify the list of jars gets packaged into a web application. When maven pulls the dependencies and the dependencies uses two different versions same component, say &lt;code class="language-plaintext highlighter-rouge"&gt;javax.mail 1.3,1.4&lt;/code&gt; then EXT3 file system doesn’t guarantee the order of jar loaded.&lt;/p&gt;

&lt;p&gt;So always exercise caution and do review your &lt;code class="language-plaintext highlighter-rouge"&gt;lib/&lt;/code&gt; folder to see what jars are pulled and packaged by your maven or any other packaging tool you use.&lt;/p&gt;

&lt;p&gt;If you have tools like IDEs like &lt;a href="http://www.jetbrains.com/idea/"&gt;IntelliJ &lt;/a&gt;, try to generate the POM diagram and review the jars and its transitive dependencies.&lt;/p&gt;
</description>
					<pubDate>Thu, 10 Jul 2014 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/understanding-how-jars-are-loaded-into-jvm-from-a-directory.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/understanding-how-jars-are-loaded-into-jvm-from-a-directory.html</guid>
				</item>
			
		
			
				<item>
					<title>When to re-factor your code</title>
					<description>&lt;p&gt;Refactoring is a must needed exercise in every software module, but everything has its cost.&lt;/p&gt;

&lt;h4 id="do-not-do-refactoring-if-it-is-absolutely-not-required"&gt;Do not do refactoring if it is absolutely not required.&lt;/h4&gt;
&lt;p&gt;I do not question your intention. If you are tempted to re-factor a large code, ask yourself if it is &lt;strong&gt;absolutely&lt;/strong&gt; necessary. If your refactoring is not going to yield any &lt;strong&gt;absolute&lt;/strong&gt; benefit, then stop it.&lt;/p&gt;

&lt;h4 id="many-incremental-changes-are-better"&gt;Many Incremental changes are better&lt;/h4&gt;
&lt;p&gt;If the code you are going to re-factor leads to refactoring other code and it chains reaction. You should stop. Turn your focus on to the other modules and re-factor incrementally.&lt;/p&gt;

&lt;h4 id="make-sure-to-pass-existing-tests"&gt;Make sure to pass existing tests.&lt;/h4&gt;
&lt;p&gt;No questions asked.&lt;/p&gt;

&lt;h4 id="follow-coding-standards-of-your-company"&gt;Follow coding standards of your company&lt;/h4&gt;
&lt;p&gt;This is like talking same language to anyone reading your code. If you break the coding standards, then you break the grammar and people have difficulty in understanding and if someone doesnt understand what you have done, then it voids your work.&lt;/p&gt;

&lt;h4 id="no-ego-in-personal-preference"&gt;No ego in personal preference&lt;/h4&gt;
&lt;p&gt;And don’t get your personal preference into the code. If you think that what you are doing is awesome, then take it to the standards group and then get it done. Don’t sneak it.&lt;/p&gt;

&lt;h4 id="language-gets-a-new-api"&gt;Language gets a new API&lt;/h4&gt;
&lt;p&gt;Good thing to know, but still doesn’t make a solid case to re-factor your code. It is probably the best candidate for new code.&lt;/p&gt;
</description>
					<pubDate>Fri, 13 Jun 2014 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/when-to-refactor-the-code.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/when-to-refactor-the-code.html</guid>
				</item>
			
		
			
				<item>
					<title>IE Heisenbug</title>
					<description>&lt;p&gt;Circa 2009, when I was testing the mobile webapp in cross platform, Internet Explorer is especially a &lt;a href="http://www.maheshsubramaniya.com/article/ie-6-and-ie-7-radio-buttons-doesnt-select.html"&gt;pain in the neck&lt;/a&gt;. One such pain is a &lt;a href="http://www.catb.org/jargon/html/H/heisenbug.html"&gt;Heisenbug&lt;/a&gt; that I came across.&lt;/p&gt;

&lt;pre&gt;
console.log('heisenbug');
alert('if you see this, then no heisenbug');
&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://jsfiddle.net/maheshexp/SJV2j/"&gt;Fiddle here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This bug was so irritating that I couldnt figure out easily why this code is breaking. And screw the IE developer tool.&lt;/p&gt;

&lt;p&gt;Easy fix? Just redefine the &lt;code&gt;console&lt;/code&gt; object to use alert, as 1st line of the code.&lt;/p&gt;

&lt;pre&gt;
console.log = function(o){ alert(o); }
&lt;/pre&gt;
</description>
					<pubDate>Thu, 01 May 2014 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/IE-heisenbug.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/IE-heisenbug.html</guid>
				</item>
			
		
			
				<item>
					<title>Go lang - how to install packages</title>
					<description>&lt;h4 id="set-gopath-environment-variable"&gt;Set GOPATH environment variable&lt;/h4&gt;

&lt;p&gt;Set the GOPATH variable which &lt;code class="language-plaintext highlighter-rouge"&gt;go&lt;/code&gt; compiler uses to search for packages along with &lt;code class="language-plaintext highlighter-rouge"&gt;GOROOT&lt;/code&gt; environment variable, which is generally the installation of &lt;code class="language-plaintext highlighter-rouge"&gt;go&lt;/code&gt;&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GOROOT&lt;/span&gt;
&lt;span class="go"&gt;/usr/local/go/

&lt;/span&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$GOPATH&lt;/span&gt;
&lt;span class="go"&gt;/development/go/youtube&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id="install-mercurial-client"&gt;Install Mercurial client&lt;/h4&gt;

&lt;p&gt;&lt;a href="http://mercurial.selenic.com/wiki/Download"&gt;Download and install&lt;/a&gt; the mercurial client in your machine and set the environment variables for PATH.&lt;/p&gt;

&lt;p&gt;If you are running Mac, you can use &lt;a href="http://brew.sh/"&gt;homebrew&lt;/a&gt; to install mercurial in seconds.&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;hg&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h4 id="run-the-go-get-command"&gt;Run the &lt;code class="language-plaintext highlighter-rouge"&gt;go get&lt;/code&gt; command&lt;/h4&gt;

&lt;p&gt;Lets install a package&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;go get &lt;span class="s2"&gt;"code.google.com/p/google-api-go-client/youtube/v3"&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;This will create two packages&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;src - contains the source files of the dependencies&lt;/li&gt;
  &lt;li&gt;pkg - contains the compiled binary of the dependencies&lt;/li&gt;
&lt;/ul&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="gp"&gt;$&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;tree &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;span class="c"&gt;.
&lt;/span&gt;&lt;span class="go"&gt;├── pkg
│   └── darwin_amd64
│       └── code.google.com
│           └── p
│               └── google-api-go-client
│                   └── googleapi
└── src
    └── code.google.com
        └── p
            └── google-api-go-client
                ├── adexchangebuyer
                │   ├── v1
                │   ├── v1.1
                │   ├── v1.2
                │   └── v1.3
                │   ...
                │   ...
                ├── youtube
                │   ├── v3
                │   └── v3alpha
                └── youtubeanalytics
                    ├── v1
                    └── v1beta1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now the dependencies are installed in the folder and you can continue to build the program by &lt;code class="language-plaintext highlighter-rouge"&gt;go build&lt;/code&gt;&lt;/p&gt;
</description>
					<pubDate>Thu, 17 Apr 2014 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/go-how-to-install-packages.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/go-how-to-install-packages.html</guid>
				</item>
			
		
			
				<item>
					<title>New parents should read Freakonomics, than watching it.</title>
					<description>&lt;figure&gt;
    &lt;img src="http://www.ethos3.com/wp-content/uploads/2012/07/freakonomics.jpeg" alt="Freakonomics" /&gt;
    &lt;figcaption&gt;Source: &lt;a href="http://www.ethos3.com"&gt;www.ethos3.com&lt;/a&gt;&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: &lt;em&gt;This is not a &lt;a href="http://www.amazon.com/Freakonomics-Economist-Explores-Hidden-Everything/dp/0060731338#customerReviews"&gt;book review&lt;/a&gt;, but sharing what I think is interesting for young parents like me.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update [02-18-2014]&lt;/strong&gt;: I’ve modified the title from “&lt;em&gt;Young parents should read Freakonomics, than watching it&lt;/em&gt;”, as I see that “&lt;em&gt;New Parents&lt;/em&gt;” fits better than “&lt;em&gt;Young Parents&lt;/em&gt;”.&lt;/p&gt;

&lt;p&gt;I was introduced to &lt;a href="http://amzn.to/1cOAdyL"&gt;Freakonomics&lt;/a&gt; through the movie in Netflix in 2011 and I watched it again in 2014 in &lt;a href="http://amzn.to/1bDyl1b"&gt;Amazon Prime&lt;/a&gt;. What difference did it make? Well, it made a huge difference. I’m now lending my ears to any information regarding Parenting, Child Behavior and their education. And Freakonomics has exactly these things which did matter to me in 2014 than in 2010. Contrary to my initial perception, the movie didn’t talk about economy, fiscal or monetary stuffs. I believed book would be the same too.&lt;/p&gt;

&lt;p&gt;After watching the movie, I thought reading the book will supplement the information and also I’ve kind of had an idea that mostly movies are just 20% of what says( with my experience from &lt;a href="http://amzn.to/1dBBoWo"&gt;Da Vinci Code&lt;/a&gt; and &lt;a href="http://amzn.to/1fs98lq"&gt;Angels &amp;amp; Demons&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;So, I gladly picked up a book from Austin Milwood library. And gave a glance on Table of contents. Starting from “Hidden side of everything” to “Parenting”, every title had a brief overview of what the topic is going to teach about.&lt;/p&gt;

&lt;p&gt;And once I started reading, I completed in two sittings. It is not just the book is small ( 200 pages - for me, anything beyond 20 page is a lot), but the facts, questions and conclusions are astounding and interesting. Well again this book defeated my initial assumption(&lt;em&gt;supplementing the movie&lt;/em&gt;), it was nothing close to it. The movie is more like an tip of the iceberg.&lt;/p&gt;

&lt;p&gt;Though the book explores various aspects of society such as Crime, Names, Lying, Groups and Business etc., the reason for me to pick up the book is knowing the observations and conclusions of this one of the celebrated, &lt;a href="https://en.wikipedia.org/wiki/Steven_Levitt"&gt;Harvard educated Scholar&lt;/a&gt; on Parenting. So let me jump straight there.&lt;/p&gt;

&lt;p&gt;What did his analysis say? A Child tend to do well in school, when the child have&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Well educated parents&lt;/li&gt;
  &lt;li&gt;Lots of books at home&lt;/li&gt;
  &lt;li&gt;Parents with High socio-economic status&lt;/li&gt;
  &lt;li&gt;Mother, who is 30+ years during the birth&lt;/li&gt;
  &lt;li&gt;Parents speak English&lt;/li&gt;
  &lt;li&gt;Parents involved in PTA&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and these facts or behavior which may not guarantee that child will do good at school (&lt;em&gt;note he doesn’t say &lt;strong&gt;BAD&lt;/strong&gt;, just says may not help to large extend or sometimes may cause damage&lt;/em&gt;)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Family is intact&lt;/li&gt;
  &lt;li&gt;Parents moved to a better neighborhood&lt;/li&gt;
  &lt;li&gt;Mother didn’t work between birth and kindergarten&lt;/li&gt;
  &lt;li&gt;Child attended Head stat&lt;/li&gt;
  &lt;li&gt;Parents take Child regularly to a museum&lt;/li&gt;
  &lt;li&gt;Parent read to child nearly every day&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are certain facts falls in either of the category based on what the child observes or perceives&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Child frequently watches television&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also he also mentioned, Asian kids does better than American kids. And I assume the term &lt;em&gt;Asian&lt;/em&gt; in a broad range to include Indians, even thought most of the time it mentions Chinese and &lt;a href="https://en.wikipedia.org/wiki/Far_East"&gt;Far eastern&lt;/a&gt; countries.&lt;/p&gt;

&lt;p&gt;Though Levitt’s conclusions certainly triggers some thought about some conventional parenting, but doesn’t mean his conclusions are absolute truth. You should have your own discretion on deciding what is good and correct for your kid.&lt;/p&gt;
</description>
					<pubDate>Sun, 16 Feb 2014 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/young-parents-should-read-freakonomics.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/young-parents-should-read-freakonomics.html</guid>
				</item>
			
		
			
				<item>
					<title>Kelvi - StackOverflow Questions Monitor</title>
					<description>
</description>
					<pubDate>Sun, 05 Jan 2014 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/kelvi-stackoverflow-dashboard-app.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/kelvi-stackoverflow-dashboard-app.html</guid>
				</item>
			
		
			
				<item>
					<title>jaadi - simple storage API for javascript applications</title>
					<description>
</description>
					<pubDate>Sun, 05 Jan 2014 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/jaadi-javascript-simple-storage-api.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/jaadi-javascript-simple-storage-api.html</guid>
				</item>
			
		
			
				<item>
					<title>How to build symbolic  differential &amp; integral calculus engine in Prolog</title>
					<description>&lt;figure&gt;
	&lt;img src="/images/2013/prolog-math-banner.svg" alt="\int e^{x} = d(e^{x}) = e^{x}" /&gt; 
&lt;/figure&gt;

&lt;p&gt;Math is all about symbolic calculation and there are only &lt;a href="https://en.wikipedia.org/wiki/List_of_computer_algebra_systems"&gt;handful of programming languages&lt;/a&gt; to do the symbolic math. But when need arises, you can write your own symbolic math processing engine easily and I will show you how you can use Prolog to do it and integrate into any java application.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://en.wikipedia.org/wiki/Prolog"&gt;Prolog&lt;/a&gt; a well known language in the academia areas of computer science such as Artificial Intelligence and related studies. Prolog is a logic programming and  pattern matching language. It is a first-order programming model and helps you to build code in a mathematical or inference based approach. Prolog is a simple language to learn and yet powerful to use ( just for fun, try to convert the rules listed in here into Java code ). It is pretty easy to get start with it in matter of hours.&lt;/p&gt;

&lt;p&gt;This article shows you how to use Prolog to write Differential and Integral calculus rules. I’ve coded few modules for some of my bachelors projects such as &lt;a href="https://github.com/mymindleaks/Mint"&gt;MinT&lt;/a&gt; and &lt;a href="https://github.com/mymindleaks/jLogics"&gt;jLogics&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you are new to prolog, I would recommend to get some &lt;a href="https://en.wikibooks.org/wiki/Prolog"&gt;basics of Prolog&lt;/a&gt; before diving in here. Do not worry you are not learning anything &lt;a href="http://net.tutsplus.com/articles/roundups-articles/top-10-most-bizarre-programming-languages/"&gt;weird like this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In nutshell, just understand that&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;It can be used a Compiled or Interpreted language and works based on the pattern matching.&lt;/li&gt;
  &lt;li&gt;You start with simple facts &amp;amp; relations and extend those as rules.&lt;/li&gt;
  &lt;li&gt;Expressions are separated by COMMA(,) and the function is terminated by a DOT(.)&lt;/li&gt;
  &lt;li&gt;Just build the foundations correct and rest everything would fit ( just like the axioms in Math )&lt;/li&gt;
  &lt;li&gt;Prolog is good at &lt;a href="http://ww2.cs.mu.oz.au/482/lectures/Prolog_How_Works.pdf"&gt;backtracking&lt;/a&gt;. i.e if one of the input couldn’t derive to a ‘Truth’ value, it would try with nex set of values until it finds ‘Truth’.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is an example of backtracking. Prolog, will match for truth always and until it matches, it will backtrack and keep looking.&lt;/p&gt;

&lt;p&gt;In this program, when you ask for &lt;code class="language-plaintext highlighter-rouge"&gt;good_menu_in(thai)&lt;/code&gt;, it will find two matches &lt;code class="language-plaintext highlighter-rouge"&gt;restaurant4&lt;/code&gt; and &lt;code class="language-plaintext highlighter-rouge"&gt;restaurant1&lt;/code&gt; and then for each match, it will try to find the matching &lt;code class="language-plaintext highlighter-rouge"&gt;good()&lt;/code&gt; menu item. When it checks for &lt;code class="language-plaintext highlighter-rouge"&gt;restaurant4&lt;/code&gt;, it doesn’t match any &lt;code class="language-plaintext highlighter-rouge"&gt;good()&lt;/code&gt; item. So it will backtrack to &lt;code class="language-plaintext highlighter-rouge"&gt;restaurant1&lt;/code&gt;.&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-prolog" data-lang="prolog"&gt;&lt;span class="ss"&gt;good&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;restaurant1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;ginger_chicken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;good&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;restaurant1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;fried_noodles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;good&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;restaurant2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;chicken_curry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;good&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;restaurant2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;kung_pao_chicken&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="ss"&gt;restaurant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;thai&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;restaurant4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;restaurant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;thai&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;restaurant1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;restaurant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;chinese&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;restaurant2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="ss"&gt;restaurant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;indian&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;restaurant3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="ss"&gt;good_menu_in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="ss"&gt;restaurant&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="ss"&gt;good&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;M&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="ss"&gt;good_menu_in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;thai&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;when &lt;code class="language-plaintext highlighter-rouge"&gt;restaurant1()&lt;/code&gt; rule is executed, it would fetch &lt;code class="language-plaintext highlighter-rouge"&gt;restaurant4&lt;/code&gt; and &lt;code class="language-plaintext highlighter-rouge"&gt;restaurant1&lt;/code&gt;. When it tries to match &lt;code class="language-plaintext highlighter-rouge"&gt;good(restaurant4)&lt;/code&gt;, it wont find any, hence it will backtrack to &lt;code class="language-plaintext highlighter-rouge"&gt;good(restaurant1)&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Result:
&lt;code class="language-plaintext highlighter-rouge"&gt;ginger_chicken&lt;/code&gt;, &lt;code class="language-plaintext highlighter-rouge"&gt;fried_noodles&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Here is another &lt;a href="http://en.wikipedia.org/wiki/Prolog#Evaluation"&gt;example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, let us get started.&lt;/p&gt;

&lt;h2 id="differential-rules"&gt;Differential rules&lt;/h2&gt;

&lt;h3 id="define-the-basic-axioms"&gt;Define the basic axioms&lt;/h3&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-prolog" data-lang="prolog"&gt;&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(X) w.r.t. X is 1      &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;          &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; If C is a constant then &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
                                   &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(C)/dX is 0            &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;                 &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(U+V)/dX = A+B where   &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;                   &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; A = d(U)/dX and         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; constant multiplied to variable d(C&lt;/span&gt;&lt;span class="cm"&gt;*X)&lt;/span&gt;&lt;span class="err"&gt;/d(x) &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt; 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;
   &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="p"&gt;!.&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;           &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(U&lt;/span&gt;&lt;span class="cm"&gt;*V)&lt;/span&gt;&lt;span class="err"&gt;/dX = B&lt;/span&gt;&lt;span class="cm"&gt;*U+A*V where */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;                 &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; A = d(U)/dX and           &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt; &lt;span class="p"&gt;).&lt;/span&gt;                 &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; B = d(V)/dX               &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(U/V)/dX = (A&lt;/span&gt;&lt;span class="cm"&gt;*V-B*U)&lt;/span&gt;&lt;span class="err"&gt;/(V&lt;/span&gt;&lt;span class="cm"&gt;*V) */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;                &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where A = d(U)/dX and       &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt;       B = d(V)/dX           &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;       &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(U^C)/dX = C&lt;/span&gt;&lt;span class="cm"&gt;*A*U^(C-1)   */&lt;/span&gt;
   &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;                    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where C is a number or    &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
   &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;).&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id="now-little-complex-pattern"&gt;Now little complex pattern.&lt;/h3&gt;

&lt;p&gt;As prolog is good at pattern matching, you can define rules with complex inputs. When you invoke &lt;code class="language-plaintext highlighter-rouge"&gt;d(sin(X))&lt;/code&gt; or &lt;code class="language-plaintext highlighter-rouge"&gt;d(sin(sin(X)))&lt;/code&gt;,it will match the rule. And then it will still track for &lt;code class="language-plaintext highlighter-rouge"&gt;d(X)&lt;/code&gt;. In the first case it is just &lt;code class="language-plaintext highlighter-rouge"&gt;X&lt;/code&gt; and in 2nd case it is &lt;code class="language-plaintext highlighter-rouge"&gt;sin(X)&lt;/code&gt; and see if anything matches up.&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-prolog" data-lang="prolog"&gt;&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;       &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(sin(W))/dX = Z&lt;/span&gt;&lt;span class="cm"&gt;*cos(W)   */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id="list-of-basic-trigonometric-rules"&gt;List of basic trigonometric rules&lt;/h3&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-prolog" data-lang="prolog"&gt;&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;       &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(sin(W))/dX = Z&lt;/span&gt;&lt;span class="cm"&gt;*cos(W)   */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;       &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(exp(W))/dX = Z&lt;/span&gt;&lt;span class="cm"&gt;*exp(W)   */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;            &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(log(W))/dX = Z/W        &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(cos(W))/dX = Z&lt;/span&gt;&lt;span class="cm"&gt;*sin(W)   */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;tan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;sec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(tan(W))/dX = Z&lt;/span&gt;&lt;span class="cm"&gt;*sec(W)^2   */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;cosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(cot(W))/dX = -Z&lt;/span&gt;&lt;span class="cm"&gt;*cosec(W)^2   */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;sec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;tan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(sec(W))/dX = sec(W)&lt;/span&gt;&lt;span class="cm"&gt;*tan(W)  */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;cosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;cot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(cosec(W))/dX = -cosec(W)&lt;/span&gt;&lt;span class="cm"&gt;*cot(W)  */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;arcsin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(arcsin(W))/dX = Z/sqrt(1-W^2) &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;arccos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(arccos(W))/dX = -(Z/sqrt(1-W^2) )&lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;arctan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(arctan(W))/dX = Z/(1+W^2) &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;arccot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(arccot(W))/dX = -(Z/(1+W^2)) &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;arcsec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(arcsec(W))/dX = (Z/(W&lt;/span&gt;&lt;span class="cm"&gt;*sqrt(W^2-1))) */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 
&lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;arccosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;    &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; d(arccosec(W))/dX = -(Z/(W&lt;/span&gt;&lt;span class="cm"&gt;*sqrt(W^2-1))) */&lt;/span&gt;
   &lt;span class="ss"&gt;d&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;                  &lt;span class="cm"&gt;/*&lt;/span&gt;&lt;span class="err"&gt; where Z = d(W)/dX         &lt;/span&gt;&lt;span class="cm"&gt;*/&lt;/span&gt;
 &lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/mymindleaks/8126309"&gt;Full Gist&lt;/a&gt;&lt;/p&gt;

&lt;h2 id="integral-rules"&gt;Integral rules&lt;/h2&gt;

&lt;p&gt;Similar to Differential, Integral rules are defined. Start with the basic axioms and expand.&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-prolog" data-lang="prolog"&gt;&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;C&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt; &lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt; &lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;V&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;U&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;U&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nv"&gt;U&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;V&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="nv"&gt;N&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;W1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;numeric&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;N&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nv"&gt;W&lt;/span&gt; &lt;span class="ss"&gt;is&lt;/span&gt; &lt;span class="nv"&gt;N&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="nv"&gt;W1&lt;/span&gt; &lt;span class="ss"&gt;is&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="nv"&gt;N&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;N&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;N&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;N&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;Z&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;atomic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;Z&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nv"&gt;Z&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;inf&lt;/span&gt; &lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="nv"&gt;N&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="nv"&gt;A1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;^&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;N&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nv"&gt;A2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;A&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;N&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;),&lt;/span&gt;
        &lt;span class="nv"&gt;R&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;A1&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nv"&gt;A2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="c1"&gt;% integration of functions&lt;/span&gt;
&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;tan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="ss"&gt;tan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="ss"&gt;cot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt;        &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;tan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ss"&gt;cot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;tan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;sec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;cosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;cot&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ss"&gt;cosec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;exp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;B&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;arcsin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;arctan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;arcsec&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="ss"&gt;arctan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;arcsin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;ln&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="ss"&gt;sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="nv"&gt;A&lt;/span&gt;&lt;span class="o"&gt;^&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;):-&lt;/span&gt; &lt;span class="p"&gt;!.&lt;/span&gt;

&lt;span class="c1"&gt;% integration of functions&lt;/span&gt;
&lt;span class="c1"&gt;% using substitutions&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="ss"&gt;cos&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nv"&gt;X&lt;/span&gt; &lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;):-&lt;/span&gt;
        &lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;sin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;R&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;

&lt;span class="c1"&gt;%if all fails&lt;/span&gt;

&lt;span class="ss"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nv"&gt;W&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a href="https://gist.github.com/mymindleaks/8126305"&gt;Full Gist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/mymindleaks/jCalculus/blob/master/lib/calculus.pl"&gt;Complete Source&lt;/a&gt;&lt;/p&gt;

&lt;h2 id="java-integration"&gt;Java Integration&lt;/h2&gt;
&lt;p&gt;You can use &lt;a href="http://www.gnu.org/software/gnuprologjava/manual/index.html"&gt;GnuProlog&lt;/a&gt; for java to integrate your prolog program into your java app. Build the basic prolog engine using the gnuprolog APIs and you should be set.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://raw.github.com/mymindleaks/jCalculus/master/src/calculus/PrologEngine.java"&gt;Source&lt;/a&gt;&lt;/p&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PrologEngine&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Serializable&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;HashMap&lt;/span&gt; &lt;span class="n"&gt;variableResult&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;StringReader&lt;/span&gt; &lt;span class="n"&gt;sr&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;TermReader&lt;/span&gt; &lt;span class="n"&gt;tr&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;ReadOptions&lt;/span&gt; &lt;span class="n"&gt;rd_ops&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Environment&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Interpreter&lt;/span&gt; &lt;span class="n"&gt;interpreter&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;WriteOptions&lt;/span&gt; &lt;span class="n"&gt;wr_ops&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Term&lt;/span&gt; &lt;span class="n"&gt;goalTerm&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Interpreter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Goal&lt;/span&gt; &lt;span class="n"&gt;goal&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;goalToExecute&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;TermWriter&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;PrologEngine&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;ParseException&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;fileName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="cm"&gt;/* initialize the prolog environment */&lt;/span&gt;
    &lt;span class="n"&gt;env&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Environment&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ensureLoaded&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;AtomTerm&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fileName&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;
    &lt;span class="n"&gt;interpreter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;createInterpreter&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;runIntialization&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;interpreter&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

    &lt;span class="cm"&gt;/* show any error occured */&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Iterator&lt;/span&gt; &lt;span class="n"&gt;iter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getLoadingErrors&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;iterator&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt; &lt;span class="n"&gt;iter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasNext&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt; &lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;PrologTextLoaderError&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;PrologTextLoaderError&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;iter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;next&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
      &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;err&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;rd_ops&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ReadOptions&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;rd_ops&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;operatorSet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getOperatorSet&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;wr_ops&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WriteOptions&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;wr_ops&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;operatorSet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getOperatorSet&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TermWriter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;StringWriter&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getResult&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;variable&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;variableResult&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;variable&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Exception&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"No Such Variable : "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;variable&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;Term&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Term&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="o"&gt;).&lt;/span&gt;&lt;span class="na"&gt;dereference&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
      &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;output&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;exec&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;goalToExecute&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;goalToExecute&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;goalToExecute&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
      &lt;span class="n"&gt;sr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;StringReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;goalToExecute&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;tr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TermReader&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sr&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

      &lt;span class="n"&gt;goalTerm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;readTermEof&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rd_ops&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
      &lt;span class="n"&gt;goal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;interpreter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;prepareGoal&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;goalTerm&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

      &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;flag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;interpreter&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;execute&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;goal&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

      &lt;span class="k"&gt;switch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flag&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;PrologCode&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;SUCCESS&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;PrologCode&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;SUCCESS_LAST&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
          &lt;span class="n"&gt;variableResult&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HashMap&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="n"&gt;rd_ops&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;variableNames&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
          &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nc"&gt;PrologCode&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;FAIL&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;
          &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Exception&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Cannot Execute for : "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;goalToExecute&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
      &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;err&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id="jcalculus---java-library"&gt;jCalculus - java library&lt;/h3&gt;

&lt;p&gt;I’ve built this as part of my final year project and it is available over &lt;a href="https://github.com/mymindleaks/jCalculus"&gt;github&lt;/a&gt; for anyone to use.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note&lt;/strong&gt;: I’m not maintaining this anymore&lt;/em&gt;&lt;/p&gt;

&lt;h3 id="usage"&gt;Usage&lt;/h3&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setProperty&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"jcalculus"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

&lt;span class="nc"&gt;Integral&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Integral&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eval&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expression&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="n"&gt;withRespectToVariable&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id="test-code"&gt;Test code&lt;/h3&gt;

&lt;figure class="highlight"&gt;&lt;pre&gt;&lt;code class="language-java" data-lang="java"&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.io.*&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;calculus.PrologEngine&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;javax.swing.*&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;calculus.*&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;


&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;test&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;dx&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;goalToRun&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Derivative&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Derivative&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eval&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;goalToRun&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"x"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Differential of "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;goalToRun&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" : "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;in&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;goalToRun&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Integral&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Integral&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;eval&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;goalToRun&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="s"&gt;"x"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Integral of "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;goalToRun&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;" : "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;[])&lt;/span&gt; &lt;span class="kd"&gt;throws&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"path/to/script"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setProperty&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"jcalculus"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;goalToRun&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"sin(x^3)"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;dx&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;goalToRun&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;in&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;goalToRun&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;&lt;a href="https://github.com/mymindleaks/jCalculus/blob/master/test/test.java~1~"&gt;Source&lt;/a&gt;&lt;/p&gt;
</description>
					<pubDate>Sat, 21 Dec 2013 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/building-differential-integral-calculus-engine-in-prolog.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/building-differential-integral-calculus-engine-in-prolog.html</guid>
				</item>
			
		
			
				<item>
					<title>Macbook Air - Back in 2008 I hated it and now I'm loving it</title>
					<description>&lt;figure&gt;
	&lt;img src="/images/2013/macbook-air-2013-1.jpg" alt="Macbook Air 13 2013" /&gt; 
&lt;/figure&gt;

&lt;p&gt;&lt;a href="/article/why-you-wont-love-macbook-air.html"&gt;Back in 2008&lt;/a&gt; I hated it so much and so sarcastic on it. The basic version had only 80 GB harddisk and it was a complete strip down version of then fully loaded laptop (with DVD drives, 4 gig RAM, fast processor, wide screen etc.,). That was the time when the world was ruled by HP, Dell and Lenovo laptops.&lt;/p&gt;

&lt;p&gt;Now fast forward to 2013 and well I’m owning a &lt;a href="http://anandtech.com/show/7085/the-2013-macbook-air-review-13inch/3"&gt;Macbook Air 13” with 8GB RAM and i7 processor&lt;/a&gt;. Which is way superior than any Notebook today in market. I bought the new Macbook Air from Adorama on &lt;time&gt;Sep 2013&lt;/time&gt; and now it is &lt;time&gt;Dec 2013&lt;/time&gt; for the past 4 months, I have pushed my notebook to some exteme level  (&lt;a href="http://cnettv.cnet.com/new-macbook-air-torture-test-always/9742-1_53-50128386.html"&gt;ofcourse not like this&lt;/a&gt;) of processing and it has survived well and I’m impressed.&lt;/p&gt;

&lt;h3 id="comparision-of-specs"&gt;Comparision of Specs:&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Macbook Air 13”&lt;/th&gt;
&lt;th&gt;Early 2008&lt;/th&gt;
&lt;th&gt;Mid 2013&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Harddisk&lt;/td&gt;
&lt;td&gt;80 GB PATA SSD or 64 GB SSD&lt;/td&gt;
&lt;td&gt;256 GB SSD&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory&lt;/td&gt;
&lt;td&gt;2 GB DD2 SDRAM&lt;/td&gt;
&lt;td&gt;8 GB DDR3 SDRAM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Processor&lt;/td&gt;
&lt;td&gt;1.8 GHz Intel Core 2 Duo&lt;/td&gt;
&lt;td&gt;1.7 GHz Intel Core i7 scales upto 3.4 GHz&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extras&lt;/td&gt;
&lt;td&gt;Weight: 1.3 kg&lt;br /&gt;
Web cam: Low res 640x480&lt;br /&gt;
Battery: Well, kind of ok
&lt;/td&gt;
&lt;td&gt;
Weigh: 1.0+ Kg&lt;br /&gt;
Web cam: Facetime 720p HD cam &lt;br /&gt;
Battery Life: 4 to 5 hours solid with heavy usage
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;In today’s world neither I do not miss Optical Drives because I handle files or documents through flash drives, online or in worst case I can buy a External USB optical drive for $20+ nor I’m not worried about sealed batteries anymore. But may be about ethernet port ( &lt;a href="http://store.apple.com/us/product/MD463ZM/A/thunderbolt-to-gigabit-ethernet-adapter"&gt;apple has an adapter now&lt;/a&gt; ) if I’m at India as you Wifi is just improving for better up in our homes. And definately more on 1 USB port 3.0 is good, along with Intel’s Thunderbolt technology, impressive again. &lt;a href="http://macs.about.com/od/faq1/f/What-Is-Thunderbolt-High-Speed-I-O.htm"&gt;Two heavy weight data-transfer technologies in my air&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;table&gt;

&lt;tr&gt;&lt;td&gt;USB 2.0: 480 Mbps&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;USB 3.0: 4.8 Gbps&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;FireWire 800: 786 Mbps&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;FireWire 1600 (not yet available): 1.6 Gbps&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;FireWire 3200 (not yet available): 3.2 Gbps&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SATA II: 3 Gbps&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SATA III: 6 Gbps&lt;/td&gt;&lt;/tr&gt;
&lt;tr style="background-color:gold;"&gt;&lt;td&gt;Thunderbolt: 10 Gbps per channel&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;/blockquote&gt;

&lt;p&gt;What more reasons do I need to love it?  I do not need a Pro laptops anymore let it be retina or whatever.&lt;/p&gt;
</description>
					<pubDate>Sun, 01 Dec 2013 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/2008-i-hated-macbookair-now-loving-it.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/2008-i-hated-macbookair-now-loving-it.html</guid>
				</item>
			
		
			
				<item>
					<title>Your privacy invasion - Is your life at stake?</title>
					<description>&lt;p&gt;The title may sound bit exaggerating, but would be the truth eventually, if this is let to grow out of control.&lt;/p&gt;

&lt;p&gt;Recently the world is worried and talking about the NSA’s some of the evil works.  When I was talking about this to my friend, the first question was “So, whats up with that?”.&lt;/p&gt;

&lt;p&gt;And If you had tried to speak about this to your friend, chances that you would have come across these or similar questions.&lt;/p&gt;

&lt;p&gt;“Isn’t it whatever government does it in the name of security and safety is really mean to do good for people of the country?”&lt;/p&gt;

&lt;p&gt;“What does it really bother you when government eavesdrops on your  communication network?”&lt;/p&gt;

&lt;p&gt;“Why should I care if government get details from google, facebook, my mobile service providers?”&lt;/p&gt;

&lt;p&gt;“And I’m from country XXXXXXX and all these fuzz are for USA, only the american has to worry about”.&lt;/p&gt;

&lt;p&gt;Well, the reaction from my friend isn’t surprising for me. If you are not following the privacy and freedom of speech and information related issues in the past, then you are not supposed to get alerted by this. Not just tracking complete data, even tracking the metadata ( i.e information about what you did rather than the details about it ) of your communication will turn dangerous to you.&lt;/p&gt;

&lt;p&gt;Here are some of the facts and some of my thoughts what could a government can do holding your data.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;If you have shared something about terrorism, say LTTE and atrocities happened in Sri Lanka in the name of War on LTTE in facebook or in any social media sites , government knows that this particular individual is now LTTE supporter and may need to watched&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;If you have watched movies, downloaded softwares (illegal, porn, pirated), chances that government knows about you and may stop at your doorstep when something related goes wrong in a big way.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;If you have written some hate comment or text about government, this may fire back to you and may either lose job or stop you from getting jobs. What worse could happen to one not getting a job?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You are running a very competitive business and your phone calls are wired and taped. Someone watches what you speak about your business and could potentially share it.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You are a military personal and spoke over phone with another military colleague which may / maynot be a harmful information, so now you can be targeted when something in national security is compromised or can frame you easily.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You communicate to your doctor via email / phone about some disease that you or your family member has, now government knows about it and when some breakout happens, then you can be targeted.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You are dealing with your bank related to your financials and everything is getting recorded in some database where government monitors what your transactions are all about. Your details can be shared to Income tax department on what are you doing.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And with the BigData and other related technologies, it is comparatively easier to link all the transcripts of a particular individual and build the history.&lt;/p&gt;

&lt;p&gt;Whatever I described here is just a tip of the iceberg. There may be much more consequences as well.&lt;/p&gt;

&lt;p&gt;All these are new generation of threats that government has put its hands on. This is new generation of armed power to suppress an individual or a group of individuals to protest and express their thought in a democratic country.  This new generation of suppression leads to much more powerful and worst attack on humankind by some group of people called government, whom we have elected to do good for us.&lt;/p&gt;

&lt;p&gt;And there is another set of risks involved. When we say government, it is not just mere computers collects and digests the information. There are human analysts who are looking at your data. And that analyst could be anyone, he could be your neighbour, your kin or even your life’s worst rival.&lt;/p&gt;

&lt;p&gt;If the current active protest of the Online Privacy violation isnt supported to large extent, then this would set as a valid mechanism to exercise in any country by its government. So, show your protest for this online spying and make an effort not to spread to other countries as well.&lt;/p&gt;

&lt;p&gt;I hope you are are little worried about the issue and taking precautions on you not getting tracked as much as possible. There are even worst hidden in the NSA’s PRISM program. It is really an irony that one who speaks about privacy is invading yours.&lt;/p&gt;
</description>
					<pubDate>Mon, 17 Jun 2013 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/your-privacy-invasion-prism-is-your-life-at-stake.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/your-privacy-invasion-prism-is-your-life-at-stake.html</guid>
				</item>
			
		
			
				<item>
					<title>Why personal projects may need version control system?</title>
					<description>&lt;p&gt;To be real, you do not. Unless some crazy thoughts running in your mind about your personal projects. You are going to read such a feeling happened to me recently.&lt;/p&gt;

&lt;p&gt;I never used to version my code, for my personal projects. And I do not have to, because I know pretty well what stuff I code and I always maintain one version and it is &lt;strong&gt;version 1.0&lt;/strong&gt;, also the need for backup is solved with the backup at the external hard drive, if I want to revert back, it is just a copy-paste from the backup. And there are plethora of source repos online for free, like &lt;strong&gt;Sourceforge&lt;/strong&gt;. I’ve used Sourceforge for a long time, much like a hard-drive, &lt;em&gt;a web hard-drive&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;One of the tool I built for myself, I’m using it for a while and keep improving it. So, I start to work on a bug, and all of sudden I see that I should add a feature and after a while, adding a feature I feel that I should re-factor the entire code to be more modular and makes it less work to add more features. For all these days I work mostly in a serial fashion in my personal projects.  Now something is making me to work in parallel. So, I started getting the strange mixed feelings about my code, personal project etc.,&lt;/p&gt;

&lt;p&gt;I drew the following choices, clone my entire project folder manually into a new folder and start working or use a version control system like &lt;a href="http://betterexplained.com/articles/a-visual-guide-to-version-control/"&gt;Subversion or CVS&lt;/a&gt;. But this leaves me a situation of re-configuring the IDE and that sort of work. Luckily most of the IDEs have features that helps you to Export - Import your settings file. But still it is all a lot of time spent on doing something you shouldn’t be doing and instead working on the fix you need to make. &lt;a href="http://www.youtube.com/watch?v=4XpnKHJAok8"&gt;Like Linus&lt;/a&gt;, I started to realize how CVS based system sucks and wanted someting I want to do. I read few articles on various takes of &lt;a href="https://news.ycombinator.com/item?id=1271888"&gt;CVS&lt;/a&gt;, &lt;a href="http://stackoverflow.com/questions/802573/difference-between-git-and-cvs"&gt;Git&lt;/a&gt;, &lt;a href="http://blog.cedarsoft.com/2010/01/top-10-why-subversion-is-better-than-git/"&gt;love&lt;/a&gt; and &lt;a href="http://stackoverflow.com/questions/871/why-is-git-better-than-subversion"&gt;hates&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So anything that makes me to deal with folders, I hated it. I do not want the traditional folder-copy-setup-ide-thingy. Or which ever system made me to do it, I reject it first place.&lt;/p&gt;

&lt;p&gt;I remembered that few years ago, when GitHub was getting popular, I registered myself in GitHub and pushed my code as a place to rest and not get lost, yet another web hard-drive for me. But the problem with GitHub is, I cannot have a &lt;strong&gt;&lt;em&gt;free&lt;/em&gt;&lt;/strong&gt; private repo. By the time, I was also ware of the fact that GitHub is run based on Git, and Git can also be run in local with minimal setup. This stuff wooed me. I gave a try. &lt;a href="http://git-scm.com/book/en/Getting-Started-A-Short-History-of-Git"&gt;As promised by Linus&lt;/a&gt;,  the setup was simple and quick. One or two config files and all set to go.&lt;/p&gt;

&lt;p&gt;The most striking feature I loved and which also fitted my need is the easy way of &lt;a href="http://git-scm.com/book/en/Git-Branching"&gt;creating and managing branches&lt;/a&gt; in git. Though most of the VCS systems has branches and merges, they are surely tedious. This concept exactly allows me to create multiple replica of the same codebase, work on it and merge to the main branch, without switching IDE.&lt;/p&gt;

&lt;p&gt;Also, at the same time I figured out &lt;a href="http://www.bitbucket.org"&gt;BitBucket&lt;/a&gt; offered private repos, which is what I want. Now all my code public code is at &lt;a href="https://github.com/mymindleaks"&gt;GitHub&lt;/a&gt; and private code in BitBucket. And Thanks to Git being a common bridge as I have little hassle in doing separate setup, IDEs or understanding two different service provider on how they maintain the code in their system.&lt;/p&gt;

&lt;figure class="image"&gt;
&lt;img src="http://i.qkme.me/3u48x0.jpg" alt="Git meme" /&gt;
&lt;/figure&gt;
</description>
					<pubDate>Fri, 26 Apr 2013 00:00:00 +0000</pubDate>
					<author>Mahesh Subramaniya</author>
					<link>http://www.maheshsubramaniya.com//article/why-personal-projects-need-version-control-systems.html</link>
					<guid isPermaLink="true">http://www.maheshsubramaniya.com//article/why-personal-projects-need-version-control-systems.html</guid>
				</item>
			
		
	</channel>
</rss>